//Author of JS: Brandon L Welch (ClicksCrazy.com

//Function used to change site background color.
function changeSiteBg(color){
	//Set the color options.
	var blue   = "url('images/site_bg_1_blue.png')";
	var orange = "url('images/site_bg_1_orange.png')";
	var green  = "url('images/site_bg_1_green.png')";
	var black  = "url('images/site_bg_1.png')";
	//Set what we need to change color.
	var siteHeader     = document.getElementById('container');
	var colorContainer = document.getElementById('colorTheory');
	//Adjust the page.
	if(color == 'blue'){
		siteHeader.style.backgroundImage = blue;
		colorContainer.innerHTML = "Theory | Blue Symbolizes trust, stability, and wisdom.";
	}else if(color == 'orange'){
		siteHeader.style.backgroundImage = orange;
		colorContainer.innerHTML = "Theory | Orange Shows important elements, without causing stress.";
	}
	else if(color == 'green'){
		siteHeader.style.backgroundImage = green;
		colorContainer.innerHTML = "Theory | Green Color of nature, symbolizes growth and harmony.";
	}
	else if(color == 'black'){
		siteHeader.style.backgroundImage = black;
		colorContainer.innerHTML = "Theory | Black Carries feeling of perspective and depth.";
	}
}
//Function used as a global for showing and hiding.
function defaultShowHide(element){
	var element = document.getElementById(element);

	if(element.style.display == 'none'){
		$(element).fadeIn('slowest');
	}else{
		$(element).fadeOut('slowest');
	}
}

//Function used as a global for showing and hiding with a site shade.
function defaultShowHideShade(type, id, width, height,scroll){
	var shade   = document.getElementById('site_shade');
	
	if(shade.style.display == 'none'){
		//If True, browser will scroll to the top of the page.
		if(scroll=='1'){
			$('html').animate({scrollTop:0}, 'slow');
		}
		shade.style.display="block";
		$('#site_shade_container').fadeIn('slowest');
		$("#site_shade_container div").each(function(i){
			var value = 'site_shade_'+type+'_'+id;
	    	if(value == $(this).attr("id")){
	        	$(this).css("display","block")
				$('#site_shade_container').css("width",width+"px");
				$('#site_shade_container').css("height",height+"px");
	        }else{
		        $(this).css("display","none")
	    	}
	     });
	     
	     	
	}else{
		shade.style.display="none";
		$('#site_shade_container').fadeOut('slowest');	
	}
}

//Function used to Hide Site Shade. In cases needed as a one off.
function OverideHideSiteShade(){
	document.getElementById("site_shade").style.display="none";
	document.getElementById("site_shade_container").style.display="none";	
};
//Function used to send user email on Newsletter signup.
function sendNewsletter(){
	var email    = escape(document.getElementById("form_news_email").value);
	
	if(email == ''){
		document.getElementById("form_news_msg_container").innerHTML = 'Oops, you missed something!';
		if(email == '') {
			document.getElementById("form_news_email").style.borderColor = "#CC0000";
		}else{
			document.getElementById("form_news_email").style.borderColor = "#898989";	
		}
		return false;
	}		
	var dataString = 'email=' + email;  
	$.ajax({  
		type: "POST",  
		url: "server/server_newsletterForm.php",  
		data: dataString,  
		success: function() {
			$("#site_shade_news_submit").hide();
			$("#site_shade_news_inputs").hide();
			$("#site_shade_news_close").hide();
			$("#form_news_msg_container_l").show(0);
			setTimeout(function() { $('#form_news_msg_container_l').hide(0);}, 2000);
			setTimeout(function() {$("#form_news_msg_container_f").show(0);},2000);
			setTimeout(function() {defaultShowHideShade();},4000);
		}
	});
	return false; 
};