var globalVars = {}
globalVars.bgLayer = 0;
globalVars.bgIndex = 0;
globalVars.bgInterval = 5000;

$(function(){
	$(".tog").click(function(){				 
		if(this.href.indexOf("#")>-1){
			var elem = $("#"+this.href.split("#")[1])[0];
			if(elem.className.match("show")){
				$(elem).removeClass("show");	
				$(this).removeClass('active');	
			}else{
				$(elem).addClass("show");	
				$(this).addClass('active');
			}
			return false;
		}else{
			return true;	
		}
	});
	showBox();
	//var container = [".filterOne",".filterTwo",".filterThree"];
	//styleForm(container);
	
	/* Call the function using this:*/
	cgCreate("#srchResults","li",16,".imgB_Nav");
	
	HFS();
	var int = setInterval("ChangeBG()",globalVars.bgInterval);
	NavEffects();
});



function ChangeBG(){
	var array = new Array();
	array[0] = {'background-color':'#ffffff','background-repeat':'no-repeat','background-image':'url('+sDir+'/images/backgrounds/shapesBg.jpg)','background-position':'center -100px'};
	array[1] = {'background-color':'#ffffff','background-repeat':'no-repeat','background-image':'url('+sDir+'/images/backgrounds/J-S_water.jpg)','background-position':'center 0px'};
	array[2] = {'background-color':'#f1ed0f','background-repeat':'no-repeat','background-image':'url('+sDir+'/images/backgrounds/sunnyBg.jpg)','background-position':'center -100px'};
	array[3] = {'background-color':'#ffffff','background-repeat':'no-repeat','background-image':'url('+sDir+'/images/backgrounds/J_art_extended.jpg)','background-position':'center 0px'};
	
	globalVars.bgIndex+=1;
	if(globalVars.bgIndex>(array.length-1)){
		globalVars.bgIndex = 0;
	}
	
	if(globalVars.bgLayer==0){
		$("#Layer2").css({'opacity':'0'});
		$("#Layer2").css(array[globalVars.bgIndex]);
		//$("#Layer1")[0].innerHTML += globalVars.bgIndex+"<br/>";
		$("#Layer2").animate({'opacity':1},400);
		globalVars.bgLayer=1;
	}else{
		$("body,html").css(array[globalVars.bgIndex]);
		//$("#Layer1")[0].innerHTML += globalVars.bgIndex+"<br/>";
		$("#Layer2").animate({'opacity':0},400);
		globalVars.bgLayer=0;
	}
}

function NavEffects(){
	$("#primary").addClass("navFx");
	$("#primary a").each(function(){
		if(this.className.match("active")){
			$(this).children("span").css({"opacity":"1"});
		}
	});
	$("#primary a").bind("mouseenter",function(){
		$(this).children("span").animate({"opacity":"1"},250);										   
	});
	$("#primary a").bind("mouseleave",function(){
		if(!$(this)[0].className.match("active")){							   
			$(this).children("span").animate({"opacity":"0"},250);
		}
	});
	//Readability Edit:
	$(".entry-content").bind("mouseenter",function(){
		if(!$("#wrap #transBody")[0].className.match("full")){
			$("#wrap #transBody").animate({"opacity":".95"},500,function(){ $("#wrap #transBody").addClass("full"); });	
		}
	});
	$(".entry-content").bind("mouseleave",function(){
		if($("#wrap #transBody")[0].className.match("full")){
			$("#wrap #transBody").animate({"opacity":".75"},500,function(){ $("#wrap #transBody").removeClass("full"); });	
		}
	});
}
