jQuery(document).ready(function(){
			
						// Body font
			
				var bodyfontStatus = readCookie('bodyfontStatus');
				if(bodyfontStatus){
					jQuery('p,body,html').css("fontFamily", bodyfontStatus);
					jQuery('#bodyfont').val(bodyfontStatus);
				}
				else{
					jQuery('p,body,html').css("fontFamily", "Arial");
					jQuery('#bodyfont').val("Arial");
				}
				jQuery("#bodyfont").change(function () {
							var selectedbodyfont = jQuery('#bodyfont option:selected').val();
							createCookie('bodyfontStatus', selectedbodyfont,365);
							jQuery('p,body,html').css("fontFamily", selectedbodyfont);
					});
										  
										  
			
				
			// H1 font
			
				var h1fontStatus = readCookie('h1fontStatus');
				if(h1fontStatus){
					jQuery('h1, h1 a').css("fontFamily", h1fontStatus);
					jQuery('#h1font').val(h1fontStatus);
				}
				else{
					jQuery('h1, h1 a').css("fontFamily", "Georgia, Times New Roman, Times, serif");
					jQuery('#h1font').val("Georgia, Times New Roman, Times, serif");
				}
				jQuery("#h1font").change(function () {
							var selectedfont = jQuery('#h1font option:selected').val();
							createCookie('h1fontStatus', selectedfont,365);
							jQuery('h1, h1 a').css("fontFamily", selectedfont);
					});	
				
				// H2 font
			
				var h2fontStatus = readCookie('h2fontStatus');
				if(h2fontStatus){
					jQuery('h2, h2 a').css("fontFamily", h2fontStatus);
					jQuery('#h2font').val(h2fontStatus);
				}
				else{
					jQuery('h2, h2 a').css("fontFamily", "Georgia, Times New Roman, Times, serif");
					jQuery('#h2font').val("Georgia, Times New Roman, Times, serif");
				}
				jQuery("#h2font").change(function () {
							var selectedfont = jQuery('#h2font option:selected').val();
							createCookie('h2fontStatus', selectedfont,365);
							jQuery('h2, h2 a').css("fontFamily", selectedfont);
					});	
				
				
				// H3 font
			
				var h3fontStatus = readCookie('h3fontStatus');
				if(h3fontStatus){
					jQuery('h3, h3 a').css("fontFamily", h3fontStatus);
					jQuery('#h3font').val(h3fontStatus);
				}
				else{
					jQuery('h3, h3 a').css("fontFamily", "Georgia, Times New Roman, Times, serif");
					jQuery('#h3font').val("Georgia, Times New Roman, Times, serif");
				}
				jQuery("#h3font").change(function () {
							var selectedfont = jQuery('#h3font option:selected').val();
							createCookie('h3fontStatus', selectedfont,365);
							jQuery('h3, h3 a').css("fontFamily", selectedfont);
					});
				
				// H4 font
			
				var h4fontStatus = readCookie('h4fontStatus');
				if(h4fontStatus){
					jQuery('h4, h4 a').css("fontFamily", h4fontStatus);
					jQuery('#h4font').val(h4fontStatus);
				}
				else{
					jQuery('h4, h4 a').css("fontFamily", "Georgia, Times New Roman, Times, serif");
					jQuery('#h4font').val("Georgia, Times New Roman, Times, serif");
				}
				jQuery("#h4font").change(function () {
							var selectedfont = jQuery('#h4font option:selected').val();
							createCookie('h4fontStatus', selectedfont,365);
							jQuery('h4, h4 a').css("fontFamily", selectedfont);
					});
				
				
				
				
			// Menu font
			
				var menufontStatus = readCookie('menufontStatus');
				if(menufontStatus){
					jQuery('#primary-menu li a').css("fontFamily", menufontStatus);
					jQuery('#menufont').val(menufontStatus);
				}
				else{
					jQuery('#primary-menu li a').css("fontFamily", "Arial");
					jQuery('#menufont').val("Arial");
				}
				jQuery("#menufont").change(function () {
							var selectedmenufont = jQuery('#menufont option:selected').val();
							createCookie('menufontStatus', selectedmenufont,365);
							jQuery('#primary-menu li a').css("fontFamily", selectedmenufont);
					});
				
			
			// Menu DESCRIPTION font
			
				var menudescfontStatus = readCookie('menudescfontStatus');
				if(menudescfontStatus){
					jQuery(' #primary-menu li a span').css("fontFamily", menudescfontStatus);
					jQuery('#menudescfont').val(menudescfontStatus);
				}
				else{
					jQuery('#primary-menu li a span').css("fontFamily", "Arial");
					jQuery('#menudescfont').val("Arial");
				}
				jQuery("#menudescfont").change(function () {
							var selectedmenufont = jQuery('#menudescfont option:selected').val();
							createCookie('menudescfontStatus', selectedmenufont,365);
							jQuery('#primary-menu li a span').css("fontFamily", selectedmenufont);
					});
			

				
				
			//var panel = readCookie('panelOpen');
			
								
			jQuery("#open_options").click(function(){
					jQuery("#options_panel").fadeIn();
					
					});
			
			jQuery("#close").click(function(){
					
					jQuery("#options_panel").stop().fadeOut(); 
						
					});
			
				var currentpath = window.location.pathname;
			
				if(window.location == 'http://themes.no/powerplay/'){
									jQuery("#slideshow_0").attr('checked',true);	
							};
							
				if(window.location == 'http://themes.no/powerplay/accordion/'){
									jQuery("#slideshow_1").attr('checked',true);	
							};
				if(window.location == 'http://themes.no/powerplay/nivo/'){
									jQuery("#slideshow_2").attr('checked',true);	
							};
				
				
				jQuery("#slideshow_0").click(function() {
                	window.location =  'http://themes.no/powerplay/';						
            		});
		  
				jQuery("#slideshow_1").click(function() {
						window.location = 'http://themes.no/powerplay/accordion//';
						});
				
				jQuery("#slideshow_2").click(function() {
							window.location = 'http://themes.no/powerplay/nivo/';
						});
				
				
				
				
				// Tabpanel on/off
				//jQuery("#showtabpanel").attr('checked',false);
				
				var tabStatus = readCookie('tabStatus');
				
				if(tabStatus){
					jQuery("#hometabs").hide();
					jQuery("#showtabpanel").attr('checked',false);
				}
				else{
					jQuery("#hometabs").show();
					jQuery("#showtabpanel").attr('checked',true);
				}
				
		
				jQuery("#showtabpanel").change(function () {
					
					if (jQuery("#showtabpanel").attr('checked')) {
						  jQuery("#hometabs").fadeIn();
						  eraseCookie('tabStatus');
					}
					else{
						jQuery("#hometabs").fadeOut();
						var tabDisplay = 'showing';
						  createCookie('tabStatus', tabDisplay,365);
						
					}
				});
				
				
			
				
				
				
				
				
				// Articles on/off (Default ON)
				
			
				 	
				var articlesStatus = readCookie('articlesStatus');
				

					if(articlesStatus){
						jQuery("#welcome_article").hide();
						jQuery("#showarticles").attr('checked',false);
					}
					else{
						jQuery("#welcome_article").show();
						jQuery("#showarticles").attr('checked',true);
					}
				
				
				jQuery('#showarticles').change(function () {
					
					if (jQuery("#showarticles").attr('checked')) {
						  jQuery("#welcome_article").fadeIn('fast');
						  eraseCookie('articlesStatus');
						  
					}
					else{
						jQuery("#welcome_article").fadeOut('fast');
						 var articleDisplay = 'showing';
						 createCookie('articlesStatus', articleDisplay,365);
						
					}
				});
				
				
				// FEATURED PAGES ON/OFF
				
				var featuredStatus = readCookie('featuredStatus');
				
				if(featuredStatus){
					jQuery("#featuredpages").hide();
					jQuery("#showfeatured").attr('checked',false);
				}
				else{
					jQuery("#featuredpages").show();
					jQuery("#showfeatured").attr('checked',true);
				}
				
				
				jQuery("#showfeatured").change(function () {
					
					if (jQuery("#showfeatured").attr('checked')) {
						  jQuery("#featuredpages").fadeIn();
						 eraseCookie('featuredStatus');
					}
					else{
						jQuery("#featuredpages").fadeOut();
						 var featuredDisplay = 'showing';
						  createCookie('featuredStatus', featuredDisplay,365);
					}
				});
				
				
				// Blog posts  on/off
				var blogStatus = readCookie('blogStatus');
				
				if(blogStatus){
					jQuery("#home_blog").show();
					jQuery("#showblog").attr('checked',true);
				}
				else{
					jQuery("#home_blog").hide();
					jQuery("#showblog").attr('checked',false);
				}
				
				
				
				jQuery("#showblog").change(function () {
					
					if (jQuery("#showblog").attr('checked')) {
						  jQuery("#home_blog").fadeIn();
						    var blogDisplay = 'showing';
						  createCookie('blogStatus', blogDisplay,365);
					}
					else{
						jQuery("#home_blog").fadeOut();
						eraseCookie('blogStatus');
					}
				});
				
				
				// Widgets posts  on/off
				
				var w1Status = readCookie('w1Status');
				
				if(w1Status){
					jQuery(".homewidget1").hide();
					jQuery("#showwidget1").attr('checked',false);
				}
				else{
					jQuery(".homewidget1").show();
					jQuery("#showwidget1").attr('checked',true);
				}
				
				jQuery('#showwidget1').change(function () {
					
					if (jQuery("#showwidget1").attr('checked')) {
						  jQuery(".homewidget1").fadeIn();
						  eraseCookie('w1Status');
					}
					else {
						jQuery(".homewidget1").fadeOut()
						 var w1Display = 'showing';
						  createCookie('w1Status', w1Display,365);
					};
				});
				
				
				
				
				// Widget 2
			
				

				
			var w2Status = readCookie('w2Status');
				
				if(w2Status){
					jQuery(".homewidget2").hide();
					jQuery("#showwidget2").attr('checked',false);
				}
				else{
					jQuery(".homewidget2").show();
					jQuery("#showwidget2").attr('checked',true);
				}
				
				jQuery('#showwidget2').change(function () {
					
					if (jQuery("#showwidget2").attr('checked')) {
						  jQuery(".homewidget2").fadeIn();
						  eraseCookie('w2Status');
					}
					else {
						jQuery(".homewidget2").fadeOut()
						 var w1Display = 'showing';
						  createCookie('w2Status', w2Display,365);
					};
				});
				
				// Widget 3
								
				var widget3Status = readCookie('w3Status');
				
				if(widget3Status){
					jQuery(".homewidget3").show();
					jQuery("#showwidget3").attr('checked',true);
				}
				else{
					jQuery(".homewidget3").hide();
					jQuery("#showwidget3").attr('checked',false);
				}
				
				
				jQuery("#showwidget3").change(function () {
					
					if (jQuery("#showwidget3").attr('checked')) {
						  jQuery(".homewidget3").fadeIn();
						  var w3Display = 'showing';
						  createCookie('w3Status', w3Display,365);
					}
					else{
						jQuery(".homewidget3").fadeOut();
						eraseCookie('w3Status');
					}
				});
				
				
				// Widget 4
				
				var widget4Status = readCookie('w4Status');
				
				if(widget4Status){
					jQuery(".homewidget4").show();
					jQuery("#showwidget4").attr('checked',true);
				}
				else{
					jQuery(".homewidget4").hide();
					jQuery("#showwidget4").attr('checked',false);
				}
				
				
				jQuery("#showwidget4").change(function () {
					
					if (jQuery("#showwidget4").attr('checked')) {
						  jQuery(".homewidget4").fadeIn();
						  var w4Display = 'showing';
						  createCookie('w4Status', w4Display,365);
					}
					else{
						jQuery(".homewidget4").fadeOut();
						eraseCookie('w4Status');
					}
				});


			// Widget 5
				
				var widget5Status = readCookie('w5Status');
				
				if(widget5Status){
					jQuery(".homewidget5").show();
					jQuery("#showwidget5").attr('checked',true);
				}
				else{
					jQuery(".homewidget5").hide();
					jQuery("#showwidget5").attr('checked',false);
				}
				
				
				jQuery("#showwidget5").change(function () {
					
					if (jQuery("#showwidget5").attr('checked')) {
						  jQuery(".homewidget5").fadeIn();
						  var w4Display = 'showing';
						  createCookie('w5Status', w5Display,365);
					}
					else{
						jQuery(".homewidget5").fadeOut();
						eraseCookie('w5Status');
					}
				});
				
				
				// Widget 6
				
				var widget6Status = readCookie('w6Status');
				
				if(widget6Status){
					jQuery(".homewidget6").show();
					jQuery("#showwidget6").attr('checked',true);
				}
				else{
					jQuery(".homewidget6").hide();
					jQuery("#showwidget6").attr('checked',false);
				}
				
				
				jQuery("#showwidget6").change(function () {
					
					if (jQuery("#showwidget6").attr('checked')) {
						  jQuery(".homewidget6").fadeIn();
						  var w6Display = 'showing';
						  createCookie('w6Status', w6Display,365);
					}
					else{
						jQuery(".homewidget6").fadeOut();
						eraseCookie('w6Status');
					}
				});
				
			// Toggle on off cookie
			
		
			
			// Background color
			
			var bc = readCookie('bCol');
			
			if (bc) {
			jQuery('#colorSelector div').css('background', bc);
			jQuery('body, html').css('background',  bc);					  
			}
			
			jQuery('#colorSelector').ColorPicker({
				color: '#555',
				onShow: function (colpkr) {
					jQuery(colpkr).fadeIn(500);
					return false;
				},
				onHide: function (colpkr) {
					var bgc = jQuery('body').css('background');
					//	alert(bgc);
					jQuery(colpkr).fadeOut(500);
					
					createCookie('bCol', bgc,365);
					
					return false;
				},
				onChange: function (hsb, hex, rgb) {
					
					
					jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
					jQuery('body, html').css('backgroundColor', '#' + hex);

				}
		
			 });
			
	
			
			
			
			
			
			
			
			// Menu color
			
			var mc = readCookie('mCol');
			
			
			if (mc) {
			jQuery('#colorSelector3 div').css('backgroundColor', mc);
			jQuery('#primary').css('backgroundColor', mc);					  
			}
			
			
			jQuery('#colorSelector3').ColorPicker({
				color: '#555',
				onShow: function (colpkr) {
					jQuery(colpkr).fadeIn(500);
					return false;
				},
				onHide: function (colpkr) {
					var mc = jQuery('#primary').css('backgroundColor');
					//	alert(bgc);
					jQuery(colpkr).fadeOut(500);
					
					createCookie('mCol', mc,365);
					
					return false;
				},
				onChange: function (hsb, hex, rgb) {
					
					jQuery('#colorSelector3 div').css('backgroundColor', '#' + hex);
					jQuery('#primary').css('backgroundColor', '#' + hex);
					
					
					}
 				});
			
			
				// Reset cookies
				jQuery('#resetColor').click(function(){
															 
						eraseCookie('bCol');	
						eraseCookie('lCol');	
						eraseCookie('mCol');	
						eraseCookie('menuStatus');
						eraseCookie('tabStatus');
						eraseCookie('articlesStatus');
						eraseCookie('featuredStatus');
						eraseCookie('blogStatus');
						eraseCookie('w1Status');
						eraseCookie('w2Status');
						eraseCookie('w3Status');
						eraseCookie('w4Status');
						eraseCookie('menufontStatus');
						eraseCookie('menudescfontStatus');
						eraseCookie('bodyfontStatus');
						eraseCookie('h1fontStatus');
						eraseCookie('h2fontStatus');
						eraseCookie('h3fontStatus');
						eraseCookie('h4fontStatus');
						eraseCookie('h5fontStatus');
				});
});


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);
}

(function (jQuery) {
  styleSelect = {
    init: function () {
      jQuery('.select-wrap').each(function () {
        jQuery(this).prepend('<span>' + jQuery(this).find('.select option:selected').text() + '</span>');
      });
      jQuery('.select').live('change', function () {
       jQuery(this).prev('span').replaceWith('<span>' + jQuery(this).find('option:selected').text() + '</span>');
      });
	
		
      jQuery('.select').bind(jQuery.browser.msie ? 'click' : 'change', function(event) {
        jQuery(this).prev('span').replaceWith('<span>' + jQuery(this).find('option:selected').text() + '</span>');
      }); 
    }
  };
  jQuery(document).ready(function () {
    styleSelect.init()
  })
})(jQuery);


jQuery(function()
	{
		// Call stylesheet init so that all stylesheet changing functions 
		// will work.
		jQuery.stylesheetInit();
		
		// This code loops through the stylesheets when you click the link with 
		// an ID of "toggler" below.
		jQuery('#toggler').bind(
			'click',
			function(e)
			{
				jQuery.stylesheetToggle();
				return false;
			}
		);
		
		// When one of the styleswitch links is clicked then switch the stylesheet to
		// the one matching the value of that links rel attribute.

				jQuery("#skins").change(function() {
							var selectedstyle = jQuery('#skins option:selected').val();
							jQuery.stylesheetSwitch(selectedstyle);
							
				return false;
					});
				
				
							
		
		
		
		
	}
);

/**
* Stylesheet toggle variation on styleswitch stylesheet switcher.
* Built on jQuery.
* Under an CC Attribution, Share Alike License.
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function(jQuery)
	{
		// Local vars for toggle
		var availableStylesheets = [];
		var activeStylesheetIndex = 0;
		
		// To loop through available stylesheets
		jQuery.stylesheetToggle = function()
		{
			activeStylesheetIndex ++;
			activeStylesheetIndex %= availableStylesheets.length;
			jQuery.stylesheetSwitch(availableStylesheets[activeStylesheetIndex]);
		};
		
		// To switch to a specific named stylesheet
		jQuery.stylesheetSwitch = function(styleName)
		{
			jQuery('link[@rel*=style][title]').each(
				function(i) 
				{
					this.disabled = true;
					if (this.getAttribute('title') == styleName) {
						this.disabled = false;
						activeStylesheetIndex = i;
					}
				}
			);
			createCookie('style', styleName, 365);
		};
		
		// To initialise the stylesheet with it's 
		jQuery.stylesheetInit = function()
		{
			jQuery('link[rel*=style][title]').each(
				function(i) 
				{
					availableStylesheets.push(this.getAttribute('title'));
				}
			);
			var c = readCookie('style');
			if (c) {
				jQuery.stylesheetSwitch(c);
			}
		};
	}
)(jQuery);

// 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
