/*
 * Pure jQuery Style Switcher (http://www.userfirstinteractive.com/)
 * @author Scott D. Brooks 
 * @created by UserFirst Interactive (creations@userfirstinteractive.com)
 * 
 */

	function setStyle(myStyle) { 	
		if (myStyle == "red"){
		}
		else{  // blue
			/*$("body a").css("color", "#607e99");
			$("pre").css("border", "2px dashed #607e99");
			$("pre").css("border-left", "20px solid #607e99");*/
		}
	}
	
	function setCookUrl(){
		var cookurl = $("#cookurl").val();
		$.cookie('cookurl', null); 	
		if(cookurl!="--"){
			$.cookie('cookurl', cookurl,{ expires: 360 }); 	// set cookie	
			window.location = cookurl;
		}else{
			window.location = "index.php";
		}
	}
	function getCookUrl(){
		var url = window.location.pathname;
		var filename = url.substring(url.lastIndexOf('/')+1);
		var cookurl = $.cookie("cookurl");
		//alert(filename);
		if (cookurl != undefined && filename=="") {
			window.location = cookurl;	
		}
		
		if(cookurl=="--") window.location = "/";
	}

	function setCookie(choosenStyle) {  
		// javascript set
		$.cookie('style', null); 			// clear cookie
		$.cookie('style', choosenStyle,{ expires: 360 }); 	// set cookie		
	}		

	
	$(document).ready(function() {
		
	// stylesheet setup
	var headID = document.getElementsByTagName("head")[0];		   
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	
	var style_color = $.cookie("style");
	if (style_color != undefined) {
		cssNode.href = 'js/pure-jquery-style-switcher/css/' + style_color + '.css';		
	} else {
		cssNode.href = 'js/pure-jquery-style-switcher/css/blue.css';
		style_color = "blue";
		
	}			
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
	// set style for the image src.  Not required unless you are setting an image dynamically, like we do here.
	//setStyle(style_color);
	
	// click actions
	$("#switchToBlueAnchor").click(function()
	{
    	setCookie("blue");
		
	});
	$("#switchToOrangeAnchor").click(function()
	{
		setCookie("orange");
	});
	
		$("#switchToGreenAnchor").click(function()
	{
		setCookie("green");
	});	
		
		$("#switchToGreyAnchor").click(function()
	{
		setCookie("grey");
	});			
		$("#switchToBleoAnchor").click(function()
	{
		setCookie("bleo");
	});	
		
		$("#switchToRedAnchor").click(function()
	{
		setCookie("red");
	});	
	
		$("#switchToBrownAnchor").click(function()
	{
		setCookie("brown");
	});	
		
		$("#switchToPinkAnchor").click(function()
	{
		setCookie("pink");
	});	
		
		$("#switchToOlivyAnchor").click(function()
	{
		setCookie("olivy");
	});	
		
});
