/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

$(document).ready(function() {
	$('.styleswitch').click(function()
	{
		switchStylestyle(this.getAttribute("rel"));
		return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyle(c);
});

function switchStylestyle(styleName)
{
	//	alert(styleName);
	$('link[@rel*=style][@title]').each(function(i) 
	{
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	createCookie('style', styleName, 365);
}

// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions



// preload the images that change with the stylesheet selection
function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i < a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function applyStyleSheet()
{
    // preload the images

 
    MM_preloadImages('images/00.gif',
'images/01.gif',
'images/03.gif',
'images/04.gif',
'images/about.gif',
'images/about_b.gif',
'images/about_b.gif',
'images/b1rpt.gif',
'images/b1top.gif',
'images/bbtm.gif',
'images/brpt.gif',
'images/btn_black.gif',


'images/btn_black_selected.gif',
'images/btop.gif',
'images/contact.gif',
'images/contact_b.gif',
'images/about.gif',
'images/about_b.gif',
'images/Copy of topbg.gif',
'images/Copy of topbg_black.gif',
'images/gtop.gif',
'images/home.gif',
'images/home_b.gif',
'images/l_bullet.gif',


'images/lbbtm.gif',
'images/lbrpt.gif',
'images/leftnav_bullet.gif',
'images/login.gif',
'images/login_b.gif',
'images/logo.gif',
'images/logo_black.gif',


'images/lwork.gif',
'images/mainpic.jpg',
'images/mainpic_black.jpg',
'images/navbg1.gif',
'images/navbg.gif',
'images/navtoprpt.gif',
'images/q_bullet.gif',
 



'images/quotebg.gif',
'images/quotebg_black.gif',
'images/quotebg_black.gif',
'images/s_longbullet.gif',
'images/tick_b1.gif',
'images/tick_b.gif',
'images/tick_w1.gif',
 
 'images/tick_w.gif',
'images/topbg.gif',
'images/topbg.jpg',
'images/topbg_black.gif',
'images/w1btm.gif',
'images/w1rpt.gif',
'images/w1top.gif',
 
'images/wbtm.gif',
'images/wrpt.gif',
'images/wtop.gif' ,
'images/portfolio.gif',
'images/portfolio_b.gif')
    // apply style sheet
    /*var selectedtitle=getCookie("mysheet")    
    if (selectedtitle != "")
    {
        setImagePaths(selectedtitle);        
    }*/
    return false;
}