
$(document).ready(function() {

$("#css-water").click(function() {
$("link[rel=stylesheet]").attr({href : "water.css"});
});

$("#css-ilma").click(function() {
$("link[rel=stylesheet]").attr({href : "ilma.css"});
});

$("#css-tuli").click(function() {
$("link[rel=stylesheet]").attr({href : "tuli.css"});
});

$("#css-tila").click(function() {
$("link[rel=stylesheet]").attr({href : "tila.css"});
});


});



var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;



function resetTest(){


var kysely = document.getElementById("doshatesti");

for (var loop = 0; loop < kysely.length; loop++ )
{

kysely[loop].checked = false;


}

document.getElementById("VataTulos").innerHTML="";

document.getElementById("PittaTulos").innerHTML="";

document.getElementById("KaphaTulos").innerHTML="";

document.getElementById("Kokonaistulos").innerHTML="";


}



function calculate_bodyType() {

var VataPisteet = 0;
var PittaPisteet = 0;
var KaphaPisteet = 0;

var kysely = document.getElementById("doshatesti");

for (var loop = 0; loop < kysely.length; loop++ )
{

if (kysely[loop].checked == true && kysely[loop].value == "Vata") {

VataPisteet++;

}

else  if (kysely[loop].checked == true && kysely[loop].value == "Pitta") {

PittaPisteet++;

}

else if  (kysely[loop].checked == true && kysely[loop].value == "Kapha") {

KaphaPisteet++;

}

} /*end of for loop*/


var VataTulos = "Vatapisteesi: " + VataPisteet;

var PittaTulos = "Pittapisteesi: " + PittaPisteet;

var KaphaTulos = "Kaphapisteesi: " + KaphaPisteet;


document.getElementById("VataTulos").innerHTML=VataTulos;

document.getElementById("PittaTulos").innerHTML=PittaTulos;

document.getElementById("KaphaTulos").innerHTML=KaphaTulos;

if(KaphaPisteet == PittaPisteet && KaphaPisteet == VataPisteet && PittaPisteet == VataPisteet) {

var KokonaisTulos = "Sinussa on yhtä paljon kaikkia tyyppejä!"; }


 else if (VataPisteet > PittaPisteet &&  VataPisteet > KaphaPisteet) {

var KokonaisTulos = "Sinussa on eniten <a href = 'Vata.html'>Vataa</a>!";
}

else if (PittaPisteet > VataPisteet && PittaPisteet > KaphaPisteet) {

var KokonaisTulos = "Sinussa on eniten <a href ='Pitta.html'>Pittaa!</a>";

}

else if(KaphaPisteet > VataPisteet && KaphaPisteet > PittaPisteet) {

var KokonaisTulos = "Sinussa on eniten <a href = 'Kapha.html'>Kaphaa!</a>";

}


else if(VataPisteet == PittaPisteet) {

var KokonaisTulos = "Sinussa on yhtä paljon <a href='Vata.html'>Vataa</a> ja <a href = 'Pitta.html'>Pittaa</a>";

}

else if(VataPisteet == KaphaPisteet) {

var KokonaisTulos = "Sinussa on yhtä paljon <a href='Vata.html'>Vataa</a> ja <a href = 'Kapha.html'>Kaphaa</a>";

}

else if(KaphaPisteet == PittaPisteet) {

var KokonaisTulos = "Sinussa on yhtä paljon  <a href = 'Kapha.html'>Kaphaa</a> ja <a href = 'Pitta.html'>Pittaa</a>";

}






else {

var KokonaisTulos = "Ole hyvä ja tee testi.";

}


document.getElementById("Kokonaistulos").innerHTML=KokonaisTulos;




}
 
function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
});

//email input validate

$(document).ready(function() { 
	      $("#conf").validate({ 
	        rules: { 
	         
		  email: {// compound rule 
	          required: true, 
	          email: true 
	        }, 
	        
	        
	        }, 
	        messages: { 
	         
		  email: "Ole hyvä ja anna sähköpostiosoite."	
	        } 
	      }); 
	    }); 