var themePath = "/wp-content/themes/fotonz_clean/";
var themeNumber = 7;

function themeToggle(num, linkid, cookiename) {
	
	this.num = num; // number of themes
	this.n = 0;	// current theme property
	// Set a new cookie and switch themes.  
	this.toggle = function(n) {
		jQuery.cookie(cookiename, n, { expires: 999, path: '/'});
			
		document.getElementById(linkid).href = themePath + "theme.php?n=" + n;
	

		this.n = n; // set current theme property
		this.hilite();
	}	
	this.hilite = function() {
		jQuery("#themelinks > a").removeClass("themeon");
		jQuery("#thlnk"+this.n).addClass("themeon");
	}
	
	
		// Called once DOM is loaded
		this.init = function() {
		
			
			// Add links to DOM
			jQuery("#nzmainnav").after(themelinks);
			// Highlight current theme
			this.hilite();
		}
		
}

var fotonzTheme = new themeToggle(themeNumber,"csslink","themecookie");	

var randLinkTitle = (jQuery("html").attr("lang") == "ru-RU") ? "Случайная картинка в шапке" : "Random header image";

var themelinks  = "";
for (i=0;i<=themeNumber+1;i++)
{
	var thindex = i;
	var	thlnktext = i;
	var thlnktitle = i + ":-)";
	// last link is a random theme
	if (i > themeNumber) {
		thlnktext = "?";
		thindex = "99";
		thlnktitle = randLinkTitle;
	}
	themelinks += '<a href="" onclick="fotonzTheme.toggle(' + thindex +');return false;" id="thlnk' + thindex + '" title="' + thlnktitle + '">' + thlnktext + '</a>';
}

themelinks = '<div id="themelinks">' + themelinks + '</div>';


jQuery(document).ready(function() {
		if (isgoodbrowser) fotonzTheme.init();
});
