// JavaScript Document
var theImagesBig = new Array()
	theImagesBig[0] = 'url(' + imgRoot + 'shell/body_bg_black.jpg)';
	theImagesBig[1] = 'url(' + imgRoot + 'shell/body_bg_red.jpg)';
	theImagesBig[2] = 'url(' + imgRoot + 'shell/body_bg_orange.jpg)';
	theImagesBig[3] = 'url(' + imgRoot + 'shell/body_bg_yellow.jpg)';
	theImagesBig[4] = 'url(' + imgRoot + 'shell/body_bg_blue.jpg)';
	theImagesBig[5] = 'url(' + imgRoot + 'shell/body_bg_green.jpg)';

var theColors = new Array()
	theColors[0] = '#333333';
	theColors[1] = '#e02718';
	theColors[2] = '#df6a1b';
	theColors[3] = '#e8b115';
	theColors[4] = '#005A95';
	theColors[5] = '#6aa352';

//------ Retrieve Color Cookie ------

function getCookie(c_number)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_number + "=")
		if (c_start!=-1)
		{
			c_start=c_start + c_number.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 ""
}

//------ Set Color Cookie ------

function setCookie(c_number,value,expiredays,path,domain,secure)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_number+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

//------ Delete Color Cookie ------

function Delete_Cookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//------ Check Color Cookie, if exists run getCookie, if not then setCookie ------

function checkCookie()
{
	color=getCookie('color')
	if (color!=null && color!="") {
		//alert('Site color is '+color+'!')
		change(color);
	} else {
		//color=alert('Color not set',"2")
		if (color!=null && color!="") {
			setCookie('color', 2, 5, '/', '', '');
		}
	}
}

//------ Run site color change, setCookie ------

function change(colorid) {
	
	var newImageBig = theImagesBig[colorid];

	var newColor = theColors[colorid];
	
	//document.getElementById("body").style.backgroundImage = newImage;
	//document.getElementById("body").style.backgroundColor = newColor;
	
	//$('#wrapperInnerContainer2').css('backgroundImage',newImageBig);
	$('body').css({'background-color':newColor,'background-image': newImageBig});
	
	setCookie('color', colorid, 365, '/', '', '');
}

$(document).ready( function() {
	$('#moodChangerUL a').click( function() {
		change($(this).attr('rel'));
		return false;
	});
	
	checkCookie();
});

