/*-------------------------------------------------------------------------------------
	*
	*	@copyright:_________2008, Siegelwerk
	*	@link:______________http://www.siegelwerk.de
	*	@author:____________Oliver Hook
	*	@function:__________custom js scripts + dom loading
	*
	*	@version:___________1.0
	*
-------------------------------------------------------------------------------------*/
/*------------------------------------------------
	*	hide elements before site is loaded
--------------------------------------------------*/
document.documentElement.className += " swJsLoad";
/*------------------------------------------------
	*	fire functions if dom is ready
--------------------------------------------------*/
jQuery.noConflict();
     
// Put all your code in your document ready area
jQuery(document).ready(function($){
	// prepend a-tag for keyboard navigation
	$(".wpSrd").prepend("<a href='#' class='sizeS'></a>");
	
	// makes hand cursor in every browser
	$(".wpSrd").css({cursor:'pointer'});
	
	// adds title attribute for surrounding element
	$(".wpSrd").attr({title: "Klicken um Details einzublenden"});
	
	// adds/removes 2px border to image on hover the surrounding element (by case studies)
	$(".pgCs").bind("mouseover", function(){
		$(this).prev().find(".sizeM").addClass("jQuery");
	}).bind("mouseout", function(){
		$(this).prev().find(".sizeM").removeClass("jQuery");
	});
	
	// adds/removes 2px border to image on hover the surrounding element (by other works)
	$(".wpSrd").bind("mouseover", function(){
		$(this).find(".sizeS").addClass("jQuery");
	}).bind("mouseout", function(){
		$(this).find(".sizeS").removeClass("jQuery");
	});
	
	// fading slied/toggle effect
	jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
		return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback); 
	};
	
	// open/close additional information by other works
	$(".wpSrd").bind("click", function(){
		var wpId = $(this);
		
		// get/set dynamic el height
		var elHeight = 190;
		var flyOutHeight = wpId.next(".wpFlyOut").height();
		
		if(flyOutHeight <= elHeight){
			wpId.next(".wpFlyOut").height(elHeight-5);
		}
		else if (flyOutHeight <= elHeight*2 && flyOutHeight > elHeight){
			wpId.next(".wpFlyOut").height(elHeight*2-5);
		}
		else if (flyOutHeight <= elHeight*3 && flyOutHeight > elHeight*2){
			wpId.next(".wpFlyOut").height(elHeight*3-5);
		}
		else {
			wpId.next(".wpFlyOut").css({height: "auto"});
		}
		
		
		//wpId.next(".wpFlyOut").slideToggle('normal');
		wpId.next(".wpFlyOut").slideToggle({ duration: 1000, easing: 'easeOutQuint'});
		//wpId.next(".wpFlyOut").slideFadeToggle("normal");
		var getTxtState = wpId.find(".more").text();
		wpId.find(".more").empty();
		
		if(getTxtState == "+") {
			wpId.find(".sizeS").addClass("jQueryActive");
			wpId.next(".wpFlyOut").fadeIn("normal");
			wpId.find(".more").append("-");
			wpId.attr({title: "Klicken um Details auszublenden"})
		} else {
			wpId.find(".sizeS").removeClass("jQueryActive");
			wpId.find(".more").append("+");
			wpId.attr({title: "Klicken um Details einzublenden"})
		}

		return false;
	});
	
	// E-Mail Spam Protection info(AT)siegelwerk.com
	$("a.lnMail").attr("href","mailto:%69%6e%66%6f@%73%69%65%67%65%6c%77%65%72%6b%2e%63%6f%6d");
	// E-Mail Spam Protection bewerbung(AT)siegelwerk.com
	$("a.lnMailBewerbung").attr("href","mailto:%62%65%77%65%72%62%75%6e%67@%73%69%65%67%65%6c%77%65%72%6b%2e%63%6f%6d");
	
	// IE fix for breaking words with "-" in front of the word
	if ($.browser.msie || $.browser.safari) {
		$(".noWrap").wrap("<nobr></nobr>");
	}
	
})