/* palvelukohtaisia */
if (document.all) {

window.onresize = function () {
	 location.reload(true)
}

}



 /* paaosat */
 function swzImg(a,src) {
   if (document.lastActive)
   {
       document.lastActive.className = "pic-maintence";
       document.lastActive = null;
   }
   a.parentNode.className = "pic-maintence";
   document.images['paaosa'].src = src;
   document.lastActive = a.parentNode;
}

 /* kuori */
 function swzImg01(a,src) {
   if (document.lastActive)
   {
       document.lastActive.className = "pic-maintence";
       document.lastActive = null;
   }
   a.parentNode.className = "pic-maintence";
   document.images['kuori'].src = src;
   document.lastActive = a.parentNode;
}

 /* kori */
 function swzImg02(a,src) {
   if (document.lastActive)
   {
       document.lastActive.className = "pic-maintence";
       document.lastActive = null;
   }
   a.parentNode.className = "pic-maintence";
   document.images['kori'].src = src;
   document.lastActive = a.parentNode;
}
 /* poltin */
 function swzImg03(a,src) {
   if (document.lastActive)
   {
       document.lastActive.className = "pic-maintence";
       document.lastActive = null;
   }
   a.parentNode.className = "pic-maintence";
   document.images['poltin'].src = src;
   document.lastActive = a.parentNode;
}

 /* polttoainejarjestelma */
 function swzImg04(a,src) {
   if (document.lastActive)
   {
       document.lastActive.className = "pic-maintence";
       document.lastActive = null;
   }
   a.parentNode.className = "pic-maintence";
   document.images['polttojarjestelma'].src = src;
   document.lastActive = a.parentNode;
}


/* popup skripti */
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=458,height=660');");
}

/* palaute alkp. kuva */
function movepic(img_name,img_src) {
document[img_name].src=img_src;
}

/**
	Tilauslomakkeen laskuri JavaScript
	Created by: Paul DeBrino
**/

function CheckChoice(whichbox)
	{
		with (whichbox.form)
		{
			//Handle differently, depending on type of input box.
			if (whichbox.type == "radio")
			{
				//First, back out the prior radio selection's price from the total:
				hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);
				//Then, save the current radio selection's price:
				hiddenpriorradio.value = eval(whichbox.price);
				//Now, apply the current radio selection's price to the total:
				hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
			}
			else
			{
				//If box was checked, accumulate the checkbox value as the form total,
				//Otherwise, reduce the form total by the checkbox value:
				if (whichbox.checked == false)
					{ hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
				else 	{ hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
			}

			//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
			if (hiddentotal.value < 0)
				{
				InitForm();
				}

			//Now, return with formatted total:
			return(formatCurrency(hiddentotal.value));
		}
	}

	//Define function to format a value as currency:
	function formatCurrency(num)
	{
	   // Courtesy of http://www7.brinkster.com/cyanide7/
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		   num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		    cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		    num = num.substring(0,num.length-(4*i+3))+','+
		          num.substring(num.length-(4*i+3));
  	    return (((sign)?'':'-') + num + ' euroa');
	}

	//Define function to init the form on reload:
	function InitForm()
		{
		//Reset the displayed total on form:
		document.tilauslomake.total.value='0';
		document.tilauslomake.hiddentotal.value=0;
		document.tilauslomake.hiddenpriorradio.value=0;
		document.tilauslomake.total.value='0';
		document.tilauslomake2.hiddentotal.value=0;
		document.tilauslomake2.hiddenpriorradio.value=0;
		document.tilauslomake2.hiddenpriorradio.value=0;

		//Set all checkboxes and radio buttons on form-1 to unchecked:
		for (xx=0; xx < document.myform.elements.length; xx++)
		{
		   if (document.tilauslomake.elements[xx].type == 'checkbox' | document.tilauslomake.elements[xx].type == 'radio')
			{
			document.tilauslomake.elements[xx].checked = false;
			}
		}
		//Set all checkboxes and radio buttons on form-2 to unchecked:
		for (xx=0; xx < document.tilauslomake2.elements.length; xx++)
		{
		   if (document.tilauslomake2.elements[xx].type == 'checkbox' | document.tilauslomake2.elements[xx].type == 'radio')
			{
			document.tilauslomake2.elements[xx].checked = false;
			}
		}

	}
