function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
if(document.getElementById){//all the modern browsers
nav = "all";
}
else if(document.all){//this is IE4 only
nav = "ie4";
}
else if(document.layers){//this is NS4
nav = "ns4";
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function send(id)
{
 var elem;
 if (document.all) elem = document.all(id);
 else if (document.getElementById) elem = document.getElementById(id);
 elem.submit();
}

function openBrWindow(theURL,winName,features,isCenter) { //preparada per centrar popups

	if(window.screen)if(isCenter)if(isCenter=="true"){
	var myLeft = (screen.width-450)-(screen.width/5);
	var myTop = 100;
	features+=(features!='')?',':'';
	features+=',left='+myLeft+',top='+myTop;
	}
	//alert(features);
  	window.open(theURL,winName,features);
}


function change_value(formulari,nom_camp,value_camp){

 		var camp_accio = formulari + "." + nom_camp;
		var accio = formulari + "." + nom_camp + ".value='" + value_camp + "'";
				
		var elemform;
		var elemaccio;
 			if (document.all){
			 elemform = document.all(camp_accio);
 			}else if (document.getElementById){
			 elemform = document.getElementById(camp_accio);
			 }
		
		if(elemform){
			var accio = formulari + "." + nom_camp + ".value='" + value_camp + "'";
			eval(accio);
		}
	
}

function remote_url(url){
window.opener.location=url
window.close();
}

function on_enter_submit(e,formul,num) {

	var keynum
	var keychar
	var numcheck
	
	if(window.event) // IE
	{
	keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera	
	{
	keynum = e.which
	}
	
	keychar = String.fromCharCode(keynum)
	
	//alert("Número:  "+ keynum + "\nReal:  " + keychar)
	
	//numcheck = /\d/
	//return !numcheck.test(keychar)

	
		if(keynum==13){
			if(num==1){
			MM_validateFormIndex('firstname','','R','lastname','','R','email1','','RisEmail','email1C','','RisEmail','phone','','R','day','','selected','month','','selected','year','','selected','sexH','','checked','iagree','','checked');
			}else if(num==2){
			MM_validateFormIndex('fusername','','RisEmail','fpassword','','R');
			}else if(num==3){
			MM_validateFormIndex('fusername','','RisEmail','fpassword','','R')
			}else if(num==4){
			MM_validateFormIndex('email','','RisEmail')
			}else if(num==5){
			MM_validateFormIndex('firstname','','R','street_address','','R','postalcode','','R','city','','R','state','','R')
			}else if(num==6){
			MM_validateFormIndex('password_current','','R','password_new','','R','password_confirmation','','R')
			}else if(num==7){
			MM_validateFormIndex('firstname','','R','email1','','RisEmail','consulta','','R')
			}else if(num==8){
			MM_validateFormIndex('firstname','','R','email1','','RisEmail','suggeriment','','R')
			}else if(num==9){
			MM_validateFormIndex('emailR','','RisEmail')
			}else if(num==10){
			MM_validateFormIndex('yourname','','R','yourmail','','RisEmail','friendname','','R','friendmail','','RisEmail')			
			}else if(num==11){
			MM_validateFormIndex('firstname','','R','years_old','','R','phone','','R','city','','R','email1','','RisEmail','consulta','','R')		
			}else if(num==12){
			MM_validateFormIndex('firstname','','R','phone','','RisNum','city','','R','email1','','RisEmail','day_tupper','','R','city_tupper','','R','how_many','','R','years_old','','R')
			}else if(num==13){
			MM_validateFormIndex('firstname','','R','phone','','RisNum','city','','R','email1','','RisEmail','day','','selected','month','','selected','year','','selected')
			}else if(num==14){
			MM_validateFormIndex('fusername1','','RisEmail','fpassword1','','R')}
		
			
			
			
			
			
			
			if(document.MM_returnValue == true){
			send(formul);
			return true;
			}
			else{
			return false;
			}
		}
		 
	
}

function gotovariant(domain,strpoductes,familylinkname){

	location.href="http://"+domain+"/"+strpoductes+"/"+familylinkname+"/"+document.form1.variante.value;
}

function deleteitemfromshoppingcart(idproduct,page){
	document.shoppingcartform.optionshoppingcart.value='delete';
	document.shoppingcartform.idproducttodelete.value=idproduct;
	document.shoppingcartform.target="";
	document.shoppingcartform.action=page;	
	document.shoppingcartform.submit();
}

function oNumero(numero)
{
//Propiedades 
this.valor = numero || 0
this.dec = -1;
//Métodos 
this.formato = numFormat;
this.ponValor = ponValor;
//Definición de los métodos 
function ponValor(cad)
{
if (cad =='-' || cad=='+') return
if (cad.length ==0) return
if (cad.indexOf('.') >=0)
	this.valor = parseFloat(cad);
else 
	this.valor = parseInt(cad);
} 
function numFormat(dec, miles)
{
var num = this.valor, signo=3, expr;
var cad = ""+this.valor;
var ceros = "", pos, pdec, i;
for (i=0; i < dec; i++)
ceros += '0';
pos = cad.indexOf('.')
if (pos < 0)
	cad = cad+"."+ceros;
else
	{
	pdec = cad.length - pos -1;
	if (pdec <= dec)
		{
		for (i=0; i< (dec-pdec); i++)
			cad += '0';
		}
	else
		{
		num = num*Math.pow(10, dec);
		num = Math.round(num);
		num = num/Math.pow(10, dec);
		cad = new String(num);
		}
	}
pos = cad.indexOf('.')
if (pos < 0) pos = cad.lentgh
if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
	   signo = 4;
if (miles && pos > signo)
	do{
		expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
		cad.match(expr)
		cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
		}
while (cad.indexOf(',') > signo)
	if (dec<0) cad = cad.replace(/\./,'')
	cad = cad.replace(".","c")
	cad = cad.replace(",",".")
	cad = cad.replace("c",",")
	return cad;
}
}


function refreshshoppingcart(numitems,domain){
	var total = 0;
	for (count = numitems; count >= 0; count--) {
		var1 = eval("document.shoppingcartform.qtt"+count+".value");
		var2 = eval("document.shoppingcartform.price_unit"+count+".value");
		var3 = eval("document.shoppingcartform.price_total"+count+".value");
		var4 = var1 * var2;
		total = total + var4;
		var5 = new oNumero(parseInt(Math.round(var1 * var2 * 100))/100);
		var6 = var5.formato(2, true);
		var6 =  var6 + " €";

		func = "price"+count+"('"+var6+"')";

		eval(func);
	}
	total = new oNumero(parseInt(Math.round(total * 100))/100);
	totalf = total.formato(2, true);
	totalf =  totalf + " €";
	document.shoppingcartform.totalshoppingcart.value=totalf;
	
	document.shoppingcartform.action="http://"+domain+"/refreshshoppingcart.php";
	document.shoppingcartform.target="actualitza";
	document.shoppingcartform.optionshoppingcart.value='update';
	document.shoppingcartform.submit();	

}


///////////////////////////
function capturekeys(e,area) {
	var keynum
	var keychar
	var numcheck
	
	if(window.event) // IE
	{
	keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera	
	{
	keynum = e.which
	}
	
	keychar = String.fromCharCode(keynum)
	
	//alert("Número:  "+ keynum + "\nReal:  " + keychar)
	
	//numcheck = /\d/
	//return !numcheck.test(keychar)

	if(area.value.length >= 300){ 

		if(keynum==8){
		}else if(keynum==46){
		}else if(keynum==37){
		}else if(keynum==39){
		}else{
		return false; 
		}
	}
}


function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_changeProp2(objName,theProp) {
	d = document.getElementById(objName);
	d.innerHTML=theProp;
}




function marca_otra1(){

var j
j=0

for (i=0;i<document.form_order1.direction.length;i++){
	if (document.form_order1.direction[i].id=='otra'){
    	j = 1;
		document.form_order1.direction[i].checked=true;
	}
}
if (j == 0){
    alert("Please select radio button ...")
}

//document.form_order1.otra.checked=true;
}

function marca_otra2(){

var j
j=0
for (i=0;i<document.form_order1.direction2.length;i++){
	if (document.form_order1.direction2[i].id=='otra'){
    	j = 1;
		document.form_order1.direction2[i].checked=true;
	}
}
if (j == 0){
    alert("Please select radio button ...")
}

//document.form_order1.otra.checked=true;
}

function MM_openBrWindow4(theURL,winName,features,w,h) { //v2.0

   var availHeight = screen.availHeight;
   var availWidth = screen.availWidth;

   var x = 0, y = 0; 
   if (document.all) {
        x = window.screenTop; 
        y = window.screenLeft;
   }
   else if (document.layers) {  
        x = window.screenX;
        y = window.screenY;
   }
   

   availWidth = (availWidth - w)/2;
   availHeight = (availHeight - h)/2;


   var arguments = features + ',top='+availHeight+',left='+availWidth+',width=' + w + ',height=' + h;;
   var newWindow = window.open(theURL,winName,arguments);
   newWindow.focus();

}

			  
function MM_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	    obj.visibility=v; }
}

function payment(){
		if ((document.tpvvirtual.pressedButton.value) == "c"){
			MM_showHideLayers('LayerC','','show','Layer2','','hide');
			MM_openBrWindow4('','tpvvirtual','scrollbars=yes',770,560);
			setTimeout('', 2000);
		}
		else{
			if ((document.tpvvirtual.pressedButton.value) == "p"){
				MM_showHideLayers('LayerP','','show','Layer2','','hide');
				MM_openBrWindow4('','tpvvirtual','scrollbars=yes',770,560);
				setTimeout('', 2000);
			}
			else{
				document.tpvvirtual.target = '';
			}
		}

		document.tpvvirtual.submit();
}			  

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function processhopingcart(domain){
	document.location = "http://" + domain + "/order1.php";
}

function lon(target)
{
	try {
		if (parent.visibilityToolbar)
			parent.visibilityToolbar.set_display("standbyDisplayNoControls");
	} catch (e) {}

	try {
		if (!target)
			target = this;

		if (!target._lon_disabled_arr)
			target._lon_disabled_arr = new Array();
		else if (target._lon_disabled_arr.length > 0)
			return true;

		target.document.getElementById("loaderContainer").style.display = "";
		var select_arr = target.document.getElementsByTagName("select");

		for (var i = 0; i < select_arr.length; i++) {
			if (select_arr[i].disabled)
				continue;

			select_arr[i].disabled = true;
			_lon_disabled_arr.pop(select_arr[i]);
			var clone = target.document.createElement("input");
			clone.type = "hidden";
			clone.name = select_arr[i].name;
			var values = new Array();
			for (var n = 0; n < select_arr[i].length; n++) {
				if (select_arr[i][n].selected) {
					values[values.length] = select_arr[i][n].value;
				}
			}
			clone.value = values.join(",");
			select_arr[i].parentNode.insertBefore(clone, select_arr[i]);
		}
	} catch (e) {
		return false;
	}
	return true;
}

function loff(target)
{
	try {
		if (parent.visibilityToolbar) {
			parent.visibilityToolbar.set_display(visibilityCount
												 ? "standbyDisplay"
												 : "standbyDisplayNoControls");
		}
	} catch (e) {}

	try {
		if (!target)
			target = this;

		target.document.getElementById("loaderContainer").style.display = "none";

		if (target._lon_disabled_arr) {
			while(_lon_disabled_arr.length > 0) {
				var select = _lon_disabled_arr.push();
				select.disabled = false;

				var clones_arr = target.document.getElementsByName(select.name);
				for (var n = 0; n < clones_arr.length; n++) {
					if ("hidden" == clones_arr[n].type)
						clones_arr[n].parent.removeChild(clones_arr[n]);
				}
			}
		}
	} catch (e) {
		return false;
	}
	return true;
}

function _body_onload()
{
	loff();
}


function _body_onunload()
{
	lon();
}

