//sIFR

//<![CDATA[
/* Replacement calls. Please see documentation for more information. */

if(typeof sIFR == "function"){
			sIFR.replaceElement(".sIFR", named({sFlashSrc: "finkheavy.swf", sColor: "#000", sBgColor: "#FAF9F4", sWmode:"transparent"}));
		};

//]]>

// aleprosentit
function laskeale(vanhahinta,uusihinta) {
	vanhahinta = replace(vanhahinta,',','.');
	vanhahinta = replace(vanhahinta,'(','');
	vanhahinta = replace(vanhahinta,')','');
	vanhahinta = replace(vanhahinta,' €','');
	uusihinta = replace(uusihinta,',','.');
	uusihinta = replace(uusihinta,' €','');
	var prosentti = Math.round(((vanhahinta - uusihinta)/vanhahinta)*100);
	var aleprossa = '<div class="aletahti">-' + prosentti + '%</div>';
	var nothing = '';
	if (prosentti > 10) {
		return aleprossa;		
	} else {
		return nothing;
	}
}

// replace 
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


/*
 * General "add page onload event" function.
 */
function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
      window.onload = fnc;
  }
}

/*
 * Add the needed onload events.
 */
//addOnloadEvent(someFunction);

		
// login
function changeBox1() 
{
  document.getElementById('user_temp').style.display='none';
  document.getElementById('username').style.display='';
  document.getElementById('username').focus();
}
function restoreBox1() 
{
	if(document.getElementById('username').value=='')
	{
	  document.getElementById('user_temp').style.display='';
	  document.getElementById('username').style.display='none';
	}
}



function changeBox() 
{
  document.getElementById('temp').style.display='none';
  document.getElementById('password').style.display='';
  document.getElementById('password').focus();
}
function restoreBox() 
{
	if(document.getElementById('password').value=='')
	{
	  document.getElementById('temp').style.display='';
	  document.getElementById('password').style.display='none';
	}
}








function changeBox1Cart() 
{
  document.getElementById('user_temp_kori').style.display='none';
  document.getElementById('username_kori').style.display='';
  document.getElementById('username_kori').focus();
}
function restoreBox1Cart() 
{
	if(document.getElementById('username_kori').value=='')
	{
	  document.getElementById('user_temp_kori').style.display='';
	  document.getElementById('username_kori').style.display='none';
	}
}



function changeBoxCart() 
{
  document.getElementById('temp_kori').style.display='none';
  document.getElementById('password_kori').style.display='';
  document.getElementById('password_kori').focus();
}
function restoreBoxCart() 
{
	if(document.getElementById('password_kori').value=='')
	{
	  document.getElementById('temp_kori').style.display='';
	  document.getElementById('password_kori').style.display='none';
	}
}

/*
 * Tries to convert the value (String) to a floating point number. 
 * Commas (,) are replaced with dots (.) before parsing.
 */
function toFloat(value) {
	return parseFloat(value.replace(/,/,"."));
}