// skin js START
////////////////////////////////////////////////////////////////////////////////////////////////

// functions
function resizeModuleGroupFunction() //function to resize the moduleGroups to the same hight
{
	jQuery('.moduleGroup').each(function(){
		resizeModuleGroup(this);
	});

	function resizeModuleGroup(moduleGroupElement) {
		var groupHeight = jQuery(moduleGroupElement).height();
		if (jQuery(moduleGroupElement).children('.module:not(.unframed)').size() > 1) {
			jQuery(moduleGroupElement).children('.module:not(.unframed)').each(function(){
//				var moduleHeaderHeight = jQuery(this).children('.moduleHeader').outerHeight(true);
//				var moduleFooterHeight = jQuery(this).children('.moduleFooter').outerHeight(true);
				var moduleBodyWrapHeight = groupHeight /*- moduleHeaderHeight - moduleFooterHeight;*/
				jQuery(this).children('.moduleBodyWrap').height(moduleBodyWrapHeight + 'px');
			});
		}
	}
}

function jQueryUniform(){ //function for nicer forms
	jQuery("input, textarea, select").uniform();
}

function iconSet(){
	jQuery('a[hrefjQuery=".pdf"]').addClass("pdf");
	jQuery('a[hrefjQuery=".doc"]').addClass("doc");
	jQuery('a[hrefjQuery=".docx"]').addClass("doc");
	jQuery('a[hrefjQuery=".xls"]').addClass("excel");
	jQuery('a[hrefjQuery=".ppt"]').addClass("powerpoint");
	jQuery('a[hrefjQuery=".txt"]').addClass("txt");
	jQuery('a[hrefjQuery=".rtf"]').addClass("txt");
	jQuery('a[hrefjQuery=".zip"]').addClass("zip");
	jQuery('a[hrefjQuery=".rar"]').addClass("zip");
	jQuery('a[hrefjQuery=".bin"]').addClass("zip");
	jQuery('a[hrefjQuery=".jpg"]').addClass("picture");
	jQuery('a[hrefjQuery=".jpeg"]').addClass("picture");
	jQuery('a[hrefjQuery=".png"]').addClass("picture");
	jQuery('a[hrefjQuery=".gif"]').addClass("picture");
	jQuery('a[href*="Mailto"]').addClass("mailto");
	/*jQuery('a').filter(function() {
	    return this.hostname && this.hostname !== location.hostname;
	}).addClass("external");*/

	jQuery('a:has(> img)').removeClass("pdf doc excel powermoint txt zip mailto picture");
	jQuery('a:has(> img)').addClass("hasNoBorder");
}

function fancyBoxes(){	
	// Image
	jQuery("a.lightbox").fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true
	});

	// iFrame Content
	jQuery('a.lightbox-page').fancybox({
		'zoomSpeedIn': 300,
		'zoomSpeedOut': 300,
		'overlayShow': true,
		'width': 650,
		'height': 280,
		'titleShow': false,
		'autoScale' : true,
		'type': 'iframe'
	});
}

function nivoSliderHeader(){
	jQuery('#sliderHeader').nivoSlider(
	{
		effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
		slices: 15, // For slice animations
		boxCols: 8, // For box animations
		boxRows: 4, // For box animations
		animSpeed: 2500, // Slide transition speed
		pauseTime: 8000, // How long each slide will show
		startSlide: 0, // Set starting Slide (0 index)
		directionNav: false, // Next & Prev navigation
		directionNavHide: true, // Only show on hover
		controlNav: true, // 1,2,3... navigation
		controlNavThumbs: false, // Use thumbnails for Control Nav
		controlNavThumbsFromRel: false, // Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', // Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
		keyboardNav: true, // Use left & right arrows
		pauseOnHover: true, // Stop animation while hovering
		manualAdvance: false, // Force manual transitions
		captionOpacity: 0.8, // Universal caption opacity
		prevText: 'Prev', // Prev directionNav text
		nextText: 'Next', // Next directionNav text
		beforeChange: function(){}, // Triggers before a slide transition
		afterChange: function(){}, // Triggers after a slide transition
		slideshowEnd: function(){}, // Triggers after all slides have been shown
		lastSlide: function(){}, // Triggers when last slide is shown
		afterLoad: function(){} // Triggers when slider has loaded
	});	
}

function clearFormInputText() // Clear default search text on click
{	
	jQuery('#siteSearchInput, .tx-indexedsearch-searchbox-sword').clearOnFocus();
}


// load all jQuery ready functions
jQuery(document).ready(function(){

	// load functions here
	resizeModuleGroupFunction();
	//iconSet();
	fancyBoxes();
	clearFormInputText();
	nivoSliderHeader();
	jQueryUniform();
});

jQuery(window).scroll(function()
{
	// load functions here
});


jQuery(function($){
	$.supersized({
		slides  :  	[ {image : 'http://zimbra.s1-abteilung.ch/base/fileadmin/Dokumente/hintergrundbilder/99.png'} ]
	});
});


// skin js END
////////////////////////////////////////////////////////////////////////////////////////////////

