document.write('<style type="text/css">img { -moz-opacity:.0; filter:alpha(opacity=0); opacity:.0; } body { overflow: hidden }</style>');

function selectorImagesLoaded($selector){ 
    $('img').animate({ 
	opacity: 1
	}, 200 );
} 

setTimeout("selectorImagesLoaded()",2000);


$(document).ready(function () {
	
	/*
	// ADD MAIN BODY SCROLLBAR
	var isResizing;
	
	// and the body scrollpane
	var setContainerHeight = function()
	{
		// IE triggers the onResize event internally when you do the stuff in this function
		// so make sure we don't enter an infinite loop and crash the browser
		if (!isResizing) { 
			isResizing = true;
			$w = $(window);
			$c = $('#scrollContainer');
			var p = (parseInt($c.css('paddingLeft')) || 0) + (parseInt($c.css('paddingRight')) || 0);
			$('body>.jScrollPaneContainer').css({'height': $w.height() + 'px', 'width': $w.width() + 'px'});
			$c.css({'height': ($w.height()-p) + 'px', 'width': ($w.width() - p) + 'px', 'overflow':'auto'});
			$c.jScrollPane({scrollbarWidth:12, animateTo:true, animateInterval:40});
			isResizing = false;	
		}
	}
	$(window).bind('resize', setContainerHeight);
	// reset scroll bar once images loaded
	$(window).bind('load', setContainerHeight);
	setContainerHeight();
	
	// it seems like you need to call this twice to get consistantly correct results cross browser...
	setContainerHeight();
	// END ADD MAIN BODY SCROLLBAR
	*/
	
	$('#love ul').jScrollPane();
	$('#learn ul.learnList').jScrollPane();
	$('#jobs ul').jScrollPane();
	
	//$("img").lazyload();
	
	// ADD MAIN BODY SCROLLBAR
	var isResizing;
	
	// and the body scrollpane
	var setContainerHeight = function()
	{
		// IE triggers the onResize event internally when you do the stuff in this function
		// so make sure we don't enter an infinite loop and crash the browser
		if (!isResizing) { 
			isResizing = true;
			$w = $(window);
			$c = $('#scrollContainer');
			var p = (parseInt($c.css('paddingLeft')) || 0) + (parseInt($c.css('paddingRight')) || 0);
			$('body>.flexcroll').css({'height': $w.height() + 'px', 'width': $w.width() + 'px'});
			$c.css({'height': ($w.height()-p) + 'px', 'width': ($w.width() - p) + 'px'});
			isResizing = false;	
			//CSBfleXcroll('scrollContainer');
		}
	}
	$(window).bind('resize', setContainerHeight);
	// reset scroll bar once images loaded
	$(window).bind('load', setContainerHeight);
	setContainerHeight();
	
	// it seems like you need to call this twice to get consistantly correct results cross browser...
	setContainerHeight();
	// END ADD MAIN BODY SCROLLBAR
	
	
	/////////////////////////// TAGS LIST ANIMATE
	
	$(".tagscol li").css({"display":"block"});
	
	//if($.cookie('tags_open') != 'true') {
		$(".tagscol").animate({ 
			width: "0px",
			opacity: 0
		}, 0 );
		
   		$(".tagscol ul").css({"display":"none"});
		var tagsHidden = true;
	/*} else {
   		$(".tagscol ul").css({"display":"block"});
		$(".tagscol").animate({ 
			width: "120px",
			opacity: 1
		}, 0 );
		$("#header").animate({ 
			marginLeft: "120px"
		}, 0 );
		var tagsHidden = false;	
	}*/
	
	
	$("#tagsTitle").click(function(){
		if(tagsHidden == true){
			tagsHidden = false;
   			$(".tagscol ul").css({"display":"block"});
			$(this).addClass('selected');
			$(".tagscol").animate({ 
				width: "120px",
				opacity: 1
			}, 500 );
			$("#header").animate({ 
				marginLeft: "120px"
			}, 500 );
			//$.cookie('tags_open', 'true');
		} else {
			tagsHidden = true;
			$(this).removeClass('selected');
			$(".tagscol").animate({ 
				width: "0px",
				opacity: 0
			}, 500, function(){
				
   				$(".tagscol ul").css({"display":"none"});	
			} );
			$("#header").animate({ 
				marginLeft: "0px"
			}, 500 );
			//$.cookie('tags_open', 'false');
			
		}
		return false;
	});
	
	
	
	/////////////////////////// BACK TO TOP ANIMATE	
	
	$('.backToTop').click(function(){
		 //$('#scrollContainer')[0].scrollTo(0);
		 $('body').scrollTo( { top:0 , left:0}, 1000, {easing:'easeInOutCubic'});
         return false;
	});
	
	
	/////////////////////////// FORM SHIZZLE	
	
	$('.textBox').focus(function(){
		thisTitle = $(this).attr('title');
		thisVal = $(this).attr('value');
		if(!thisTitle || thisTitle == thisVal) {
			thisVal = $(this).attr('value');
			$(this).attr('title',thisVal);
			this.value = '';
		}
	});
	$('.textBox').blur(function(){
		if(this.value == '' || this.value == ' '){
			thisVal = $(this).attr('title');
		 	this.value = thisVal;
		}
	});


	$("#commentform .submit").click(function(){	
		$("#commentform .textBox" ).each(function(){
			var thisVal = $(this).attr('title');
			if(this.value == thisVal){
			 	this.value = "";
			}
		});
		return true;
	});


	$("#contactForm .submit").click(function(){					   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		

		
		var emailFromVal = $("#contactEmail").val();
		if(emailFromVal == '') {
			$("#contactEmail").after('<span class="error">! REQUIRED</span>');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {	
			$("#contactEmail").after('<span class="error">! NOT AN EMAIL</span>');
			hasError = true;
		}
		
		var nameVal = $("#contactName").val();
		if(nameVal == '') {
			$("#contactName").after('<span class="error">! REQUIRED</span>');
			hasError = true;
		}
		
		var messageVal = $("#contactMessage").val();
		if(messageVal == '') {
			$("#contactMessage").after('<span class="error">! REQUIRED</span>');
			hasError = true;
		}
		
		var urlVal = $("#contactUrl").val();
		var subjectVal = $("#contactSubject").val();
		
		if(hasError == false) {
			$(this).hide();
			$("#contactForm").append('<img src="/wp-content/plugins/ajax-login-widget/alw_loading.gif" alt="Loading" id="loading" />');
			
			$.post("bin/sendemail.html",
   				{ emailFromVal: emailFromVal, nameVal: nameVal, messageVal: messageVal, urlVal: urlVal, subjectVal: subjectVal },
   					function(data){
						$("#contactForm").slideUp("normal", function() {				   
							$("#contactForm").after('<h3>Your email was sent!</h3>');											
						});
   					}
				 );
		}
		
		return false;
	});	
	



	/////////////////////////// TOP PANEL ANIMATE	
	
    $("#topPanel").animate({ 
    	height: "0px",
    	opacity: 0
    }, 0 );
    
    $(".topPanelContent").fadeOut();
    //$(".topPanelContent").css({"display":"block"});
	var topPanelHidden = true;
	var topPanelShowing;
	var hasClosed;

	
	$(".addLink.topPanelLink").click(function(){
		alert("You need to log in or register first buddy!");
		///$('#scrollContainer')[0].scrollTo(0);
		//$('#scrollContainer').scrollTo( { top:0 }, 1000, {easing:'easeInOutCubic'});
		
		 $('body').scrollTo( { top:0 , left:0}, 1000, {easing:'easeInOutCubic'});
	});

	$(".topPanelLink").click(function(){
		var targetPane = $(this).attr('href');
		
		
		
		if(topPanelHidden != true){
			$('.topPanelLink').removeClass('selected');
      		$("#topPanel").animate({ 
				height: "0px",
				opacity: 0
      		}, 500, function(){
      			setContainerHeight();	
      		});
      		$(".topPanelContent").fadeOut(500);
      		hasClosed = true;
		}
			
			
		if(topPanelShowing != targetPane || topPanelHidden == true) {
			topPanelShowing = targetPane;
			$(this).addClass('selected');
			
			//$('div' + targetPane).fadeIn(500);
			$('div' + targetPane).animate({ 
				opacity: 1
			}, 500, function(){	
				$('div' + targetPane).fadeIn(500);
      			setContainerHeight();	
			});

			
		 	$('body').scrollTo( { top:0 , left:0}, 1000, {easing:'easeInOutCubic'});
			$("#topPanel").animate({ 
				opacity: 1
			}, 0 );
      		$("#topPanel").animate({ 
				height: "300px",
				opacity: 1
      		}, 500, function(){
    			setContainerHeight();
      		});
      		hasClosed = false;
		}
		
		
		topPanelHidden = hasClosed;
		
		return false; 
    });
	
	

	/////////////////////////// BLOG PANEL ANIMATE	
	
	
	
	$(".blogItem").hover(
      function () {
         $(".infoOverlay",this).fadeIn("fast");
      }, 
      function () {
         $(".infoOverlay",this).fadeOut("fast");
      }
	);
	$("#recognitionCarousel li").hover(
      function () {
         $(".infoOverlay",this).fadeIn("fast");
      }, 
      function () {
         $(".infoOverlay",this).fadeOut("fast");
      }
	);
	
	

	/////////////////////////// TOOL TIPS ANIMATE	
	
	$('a').tooltip({ 
		track: true, 
		delay: 600, 
		showURL: false, 
		opacity: 0.85, 
		fixPNG: true,
		extraClass: "pretty fancy",
		top: -20, 
		left: 20 
	});
	
	

	/////////////////////////// CAROUSEL	
	
	
	$("#featuresCarousel .carousel.over").jCarouselLite({
		btnNext: "#featuresCarousel .next",
		btnPrev: "#featuresCarousel .prev",
		visible: 1,
		circular: true,
		easing: 'easeInOutCubic',
		speed: 800
	});
	
	$("#featuresCarousel .carousel.under").jCarouselLite({
		btnNext: "#featuresCarousel .next",
		btnPrev: "#featuresCarousel .prev",
		visible: 1,
		circular: true,
		easing: 'easeInOutCubic',
		speed: 800
	});
	

	$("#recognitionCarousel .carousel").jCarouselLite({
		btnNext: "#recognitionCarousel .next",
		btnPrev: "#recognitionCarousel .prev",
		visible: 1,
		easing: 'easeInOutCubic',
		circular: true,
		speed: 900,
		auto: 8000,
		afterEnd: function(a) {
			$("#recognitionCarousel li").hover(
			  function () {
				 $(".infoOverlay",this).fadeIn("fast");
			  }, 
			  function () {
				 $(".infoOverlay",this).fadeOut("fast");
			  }
			);
		}

	});
	

	/////////////////////////// TABS	
	
	$('#resources > ul').tabs({ fx: { opacity: 'toggle'} });
	//$('#resources > ul').tabs();
	
	/*var $tabs = $('#resources > ul').tabs(); // first tab selected

	//$('#resources > ul').tabs();

	$('#tabJobs').click(function() { // bind click event to link
	    $tabs.tabs('select', 0); // switch to third tab
	    return false;
	});
	$('#tabLearn').click(function() { // bind click event to link
	    $tabs.tabs('select', 1); // switch to third tab
	    return false;
	});
	$('#tabLove').click(function() { // bind click event to link
	    $tabs.tabs('select', 2); // switch to third tab
	    return false;
	});*/
		
	
	/////////////////////////// SMOOTHE IMAGE LOADING 
	// http://www.bennadel.com/blog/1007-jQuery-Attr-Function-Doesn-t-Work-With-IMAGE-complete.htm
	/*
	$("img").animate({ 
		opacity: 0
	}, 0 );
	
	$("img").load(function(evt){
		$(evt.target).animate({ 
			opacity: 1
		}, 200 );
	});

	if($("img")[0].complete){
		$("img").animate({ 
			opacity: 1
		}, 400 );
	}
	*/
	
	
	//attach directly to each image within each .imageSection 
    $('img').onImagesLoad({ 
        itemCallback: itemImagesLoaded,
        selectorCallback: selectorImagesLoaded
    }); 
    //itemImagesLoaded (the itemCallback) is invoked once for each individual image that loads 
    //i.e. the itemCallback will be invoked "$('.imageSection img').length" times 
    function itemImagesLoaded(domObject){ 
        $(domObject).animate({ 
			"opacity": "1"
		}, 400 );
    } 
	//selectorImagesLoaded (the selectorCallback) is invoked only once: when all images that 
    //$('.imageSection') encapsulates have loaded 

    
   // setTimeout("selectorImagesLoaded()",2000);


	/////////////////////////// SIDEBAR FADE OUT / IN	
	
	
	
	$(".pageSingle .sidebar").mouseenter(function(){
			$(this).animate({ 
				opacity: 1
			}, 200 );
	});
	$(".pageSingle .sidebar").mouseleave(function(){
			$(this).animate({ 
				opacity: 0.15
			}, 200 );
	});
	
	
	

	/////////////////////////// Add FFF theme to links	
	
	
	

		
	

	
});


