﻿/*
* Rebuild Blog Title (no tables!)
*/
$('td.ms-PostTitle')
		.each(function(){
			var $title = $('<h3 class="blogtitle"></h3>').append( $(this).children() );
			$(this)
				.parents('table:first')
					.replaceWith( $title );
		});

/*
* Rebuild Webpart Header for Blog Navigation-Teaser
*/
var navheaderHtml = 
'<tr>\
	<td>\
		<table width="100%" cellspacing="0" cellpadding="0" border="0">\
			<tbody>\
				<tr class="ms-WPHeader">\
					<td style="width: 100%;" id="WebPartTitleWPQ5" title="Administratorhyperlinks - Blog-Administratorhyperlinks">\
						<h3 class="ms-standardheader ms-WPTitle">\
							<nobr>\
								<span>__webpartheader__</span>\
								<span id="WebPartCaptionWPQ5"/>\
							</nobr>\
						</h3>\
					</td>\
				</tr>\
			</tbody>\
		</table>\
	</td>\
</tr>';
$('div#column1 div.ms-navheader')
	.each(function(){
		var html = navheaderHtml.replace(/__webpartheader__/, $(this).html());
		//$webpartheader = $(this).children();
		$(this)
			.parents('div[id^=WebPartWPQ]:first')
				.parent('td')
					.parent('tr')
						.before( html );
						//.before( $webpartheader );
		$(this).remove();
	});
// nach dem Umbau der Header, die Teaserleiste einblenden
$('#column1.blogZone > div.sbicontent').show();


/*
* Listenansicht
*/
$('table.ms-listviewtable, #CalViewTable1').each(function(){
	$('#ctl00_MSO_ContentDiv div.pageTitle')
		.css({
			marginBottom: '7px',
			marginTop: '16px'
		});
});


/*
* Bearbeitungsmodus
*/
CRGHomepage.editmode = false;
if ( $('#MSOZone').length > 0 || $('div.ms-SPZone:first').length > 0 ) CRGHomepage.editmode = true;
/*if (CRGHomepage.editmode)
{
	$('.main, .bodyform, #links, #logo, #menu, #breadcrumb, #ctl00_MSO_ContentDiv, #CRGfooter')
		.css('width', 'auto');
		
	$('.main')
		.css('marginRight', '15px')
		.css('marginLeft', '15px')
		.css('backgroundImage', 'none');
		
	$('.bodyform')
		.css('marginLeft', '0px');
		
	$('body')
		.css('backgroundColor', '#DDDDDD');
};*/


/*
* If User has enough rights, show leftnavigation
*/
CRGHomepage.isAnonymousUser = true;
$('#siteactiontd div:first')
	.each(function(){
		/*
		$('#leftnavigation')
			.show();
		*/
		CRGHomepage.isAnonymousUser = false;
		$('div.mainContent')
			.find('.ms-menutoolbar, .ms-listdescription')
				.show();
	});
if (CRGHomepage.isAnonymousUser)
{
	$('#CalViewTable1')
		.find('th.ms-cal-workhour, th.ms-cal-workhourF, th.ms-cal-workhourhalfhour, th.ms-cal-workhourBhalfhour')
			.attr('onclick', '')
			.css('cursor', 'auto')
			.css('color', '#5A5A5A');
};

/*
* Blog: New Entry | Edit Entry
*/
if (JSRequest.QueryString === null) JSRequest.EnsureSetup();
if (JSRequest.PathName.indexOf('/blog/') != -1 && JSRequest.FileName == 'NewPost.aspx')
{
	$('td.ms-formlabel').css('width', '100%');
	$(':input.ms-long, iframe.ms-rtelong')
		.width( 483 );
};

// Anti Spam Links!
(function($){
	function decodeAntiSpamLink(txt){
		return txt.replace(/#1#/g, '.').replace(/#2#/, '@').split('').reverse().join('');
	};
	
	var antiSpamImages = [
		{name: 'kontaktadresse.jpg', encodedlink: 'ed#1#si-grc#2#tkatnok'}
	];

	$('img.antispam')
		.each(function(){
			for ( var i=0; i<antiSpamImages.length; i++ )
			{
				if ( this.src.indexOf(antiSpamImages[i].name) != -1 )
				{
					var m = decodeAntiSpamLink(antiSpamImages[i].encodedlink);
					$(this).replaceWith('<a href="mailto:' + m + '" title="' + m + '">' + m + '</a>');
				};
			};
		});
	
	$('a[rel*=#2#]')
		.each(function(){
			var m = decodeAntiSpamLink( $(this).attr('rel') );
			$(this)
				.attr('href', 'mailto:' + m)
				.attr('title', m)
				.removeAttr('rel')
				.text(m);
		});
})(jQuery);





