$JQ(document).ready(function(){
	
// fancybox and facebox
    $JQ("a.fancybox").fancybox();
	$JQ('a[rel*=facebox]').facebox()        

/*		
    adding clearBoth divs to the markup here = less code and mess in the markup		
*/
	
	$JQ(".column").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	$JQ("columnContainer").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	$JQ("columnContainer").after("<div class='clearBoth'></div>"); // adds clearBoth after the end of <div>
	
	$JQ("#contentBox").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	$JQ("#contentBox #content").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	$JQ("#contentBox #sidebar").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	$JQ("#slider .panel").append("<div class='clearBoth'></div>"); // adds clearBoth at the end of <div>
	
// button on the textpages
	$JQ("#slider .panel a.btnTextpage").before("<div class='clearBoth'></div><br />"); // adds clearBoth before <div>
	//$JQ("#slider .panel a.btnTextpage").after("<div class='clearBoth'></div>"); // adds clearBoth after the end of <div>

	$JQ(".headlineBlue").after("<div class='clearBoth'></div>"); // adds clearBoth after the end of <div>
	$JQ(".headlinePurple").after("<div class='clearBoth'></div>"); // adds clearBoth after the end of <div>
	$JQ(".headlineLight").after("<div class='clearBoth'></div>"); // adds clearBoth after the end of <div>
	
		
// contact buttons
	$JQ("#btnContact1").click(function(){
		$JQ(this).removeClass('notActive');
		$JQ('#btnContact2').addClass('notActive');
		$JQ("#textareaRow").slideUp();
	});		
	$JQ("#btnContact2").click(function(){
		$JQ(this).removeClass('notActive');
		$JQ('#btnContact1').addClass('notActive');
		$JQ("#textareaRow").slideDown();
	});		
	
	
// temp scripts showing error messages	
	/*
	$JQ("#btnSend").click(function(){
		$JQ("#errorDiv").slideDown();
		$JQ(".inputStyle").addClass('invalid');
	});
	*/
		


// set height of the first panel in textpage
	var panelHeight = $JQ(".panel").height();
	$JQ(".scroll").css('height',panelHeight);


// animate subSidebar elements
//var targetOnLeft = $JQ("#sidebarNav #el1").offset().left;

	$JQ("#sidebarNav #el2 a").click(function(){	
		$JQ("#sidebarNav li").animate ({ left: -71}, 500 );
	});	
	$JQ("#sidebarNav #el3 a").click(function(){	
		$JQ("#sidebarNav li").animate ({ left: -143}, 500 );
	});	
	$JQ("#sidebarNav #el4 a").click(function(){	
		$JQ("#sidebarNav li").animate ({ left: -213}, 500 );
	});	
	$JQ("#sidebarNav #el1 a").click(function(){	
		$JQ("#sidebarNav li").animate ({ left: 0}, 500 );
	});	
	

// smooth scrolling
	$JQ(".top a").click(function(){	
		var targetOffset = $JQ("#sitecontainer").offset().top;
      	$JQ('html,body').animate({scrollTop: targetOffset}, 1000);
	});				
	

// add some space in the bottom when employeeSwitcher is shown so the bar will never block any of the content
	if($JQ.trim($JQ("#employeeSwitcher").text()) != "") {
		$JQ("#footerNew").css("padding-bottom","200px");
	}
	
// change footer arrow to darker when the page is cases type
	if($JQ.trim($JQ("#footerArrowDark").text()) != "") {
		$JQ("#footerNew").addClass("footerNewDarkArrow");
	}	
	
	
	
	// script for tabs
	$JQ('.tabListNav a#tab1, #tabListNav a#tab1, #tabListNav a.tab1, .tabListNav a.tab1').addClass('selected');
		
	if (window.location.hash != "") {
		$JQ(".tab").hide();
		$JQ(".tabListNav a, #tabListNav a").removeClass("selected");	
		$JQ("div" + window.location.hash + "Panel").show();
		$JQ(".tabListNav a[href=" + window.location.hash + "], #tabListNav a[href=" + window.location.hash + "]").addClass("selected");	
	}	   
	
	$JQ(".tabListNav a, #tabListNav a").click(function() {
		$JQ('.tabListContainer div.tab').hide();
		var thisLink = $JQ(this).attr("href");
		$JQ('div' + thisLink + 'Panel').show();
		window.location.hash = thisLink;
		$JQ(".tabListNav a, #tabListNav a").removeClass("selected");	
		$JQ(this).addClass("selected");			
		return false;
	});	
		
		
		
	// case slideshow
	    $JQ('#caseSlideshow').after('<div id="nav">').cycle({
	        fx:     'fade',		       
	        pager:  '#nav',		
			timeout: 3000,		
	        before: function() { if (window.console) console.log(this.src); }
	    });	
		
    // case slideshow play/stop
	    $JQ("#slideshowStart").hide();
    		
	    $JQ('#slideshowStart').click(function() { 
	        $JQ('#caseSlideshow').cycle('resume', true); 
		    $JQ("#slideshowStart").hide();
		    $JQ("#slideshowPause").show();				
		    return false;
	    });	
	    $JQ('#slideshowPause').click(function() { 
	        $JQ('#caseSlideshow').cycle('pause'); 
		    $JQ("#slideshowPause").hide();
		    $JQ("#slideshowStart").show();
		    return false;
	    });		
	    
		// if number of images equal 1 on cases slideshow then disable slideshow navigation panel
		var items = 0;
		$JQ('#caseSlideshow li').each(function() { 
		    items++;		   				
		});		
		if(items == 1) $JQ("#slideshowNav").hide();	    
	    
	    
	    $JQ("#partOfRetouch #btnRetouch").click(function() {
		    if($JQ("#partOfRetouch ul").is(":hidden")) {
			     $JQ("#partOfRetouch ul").slideDown("fast"); 
			     $JQ(this).addClass("btnActive"); 
		    } else {
			    $JQ("#partOfRetouch ul").slideUp("fast"); 
			    $JQ(this).removeClass("btnActive");
		    }
		    return false;
	    });	    
	    	
});


function enterSubmit(buttonId, keyCode) {
    if (keyCode == 13) {
        eval($JQ('#'+buttonId).attr('href').split(':')[1]);
        return false;
    }
    return true;
}



