// Common JScript For ............ News Source Code
// Developed by:   Elham Esmaieli
// Date:           19 July 2009

/* This Function set a cookie in browser */
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

/* This Function get cookie value*/
function getCookie(c_name){
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

/* This Function check value if it is cookie set*/
function checkCookie(){
	color = getCookie('cssColor');		
	if (color!=null && color!="")		
		return color;
	else{
		var def = 'red';
		return def;
	}	
}	

/* This Function make color site select box visible*/
function showColorBox(){
	$("ColorBox").style.display="block"
}

/* This Function make color site select box hidden*/
function hideColorBox(){
	$("ColorBox").style.display="none"
}

/* This Function creat url base for site style sheet */
function setCssUrl(item){		
	var sr = $('colorStyle').href;
	var inx = sr.indexOf('CSS/');
	var baseURL = sr.substring(0,inx);		
	$('colorStyle').href= baseURL + "CSS/" + item + ".css";
	hideColorBox();
}

/* This Function make stie URL and set the color in cookie */
function getColor(col){
	setCssUrl(col);
	setCookie('cssColor',col,365);		
}