﻿var options = { path: '/', expires: 14 };

$(document).ready(function() {						   

switch ($.cookie('homepanel')) {
	case 'one': 
		goSecond();
		break;
	case 'two':
		goThird();
		break;
	case 'three':
		goFirst();
		break;
	default:
		goFirst();
		break;
}

$("div#bg-switcher a").click(swap);

});

function swap(event){
     
	 $("div#bg-switcher a").removeClass("on");
	 $(this).addClass("on");
	 
	 if ($(this).hasClass('first')) {
		 goFirst();
	 }
	 
	 if ($(this).hasClass('second')) {
		 goSecond();
	 }

	 if ($(this).hasClass('third')) {
		 goThird();
	 }
	 
     event.preventDefault();
   }
   
function goFirst() {
	$("div#bg-switcher a").removeClass("on");
	$("div#bg-switcher a.first").addClass("on");
	$('html').css('background-image', 'url(/images/bg1.jpg)');
	$('p.btns-learn-more a img').attr('src','/images/btn-learn-green.png');
	$('div#message img').attr('src','/images/title-sustainable.gif');
	$.cookie('homepanel', 'one', options);
}

function goSecond() {
	$("div#bg-switcher a").removeClass("on");
	$("div#bg-switcher a.second").addClass("on");
	$('html').css('background-image', 'url(/images/bg2.jpg)');
	$('p.btns-learn-more a img').attr('src','/images/btn-learn-orange.png');
	$('div#message img').attr('src','/images/title-measurable.gif');
	$.cookie('homepanel', 'two', options);
}

function goThird() {
	$("div#bg-switcher a").removeClass("on");
	$("div#bg-switcher a.third").addClass("on");
	$('html').css('background-image', 'url(/images/bg3.jpg)');
	$('p.btns-learn-more a img').attr('src','/images/btn-learn-blue.png');
	$('div#message img').attr('src','/images/title-doable.gif');
	$.cookie('homepanel', 'three', options);		
}
 
