function popupWindow(url) {

 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}


function popupXL(i) {

var xlContStyle = document.getElementById("xlCont0").style;
xlContStyle.display='none';

var xlContStyle = document.getElementById("xlCont1").style;
xlContStyle.display='none';

var xlContStyle = document.getElementById("xlCont2").style;
xlContStyle.display='none';

var xlContStyle = document.getElementById("xlCont3").style;
xlContStyle.display='none';

var xlContStyle = document.getElementById("xlCont"+i).style;
xlContStyle.display='block';


}

function doNothing() {};


function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
 
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}
//Retorna: 1 = NIF ok, 2 = CIF ok, 3 = NIE ok, -1 = NIF error, -2 = CIF error, -3 = NIE error, 0 = ??? error
function valida_nif_cif_nie(a) 
{
	var temp=a.toUpperCase();
	var cadenadni="TRWAGMYFPDXBNJZSQVHLCKE";
 
	if (temp!==''){
		//si no tiene un formato valido devuelve error
		if ((!/^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$/.test(temp) && !/^[T]{1}[A-Z0-9]{8}$/.test(temp)) && !/^[0-9]{8}[A-Z]{1}$/.test(temp))
		{
			return 0;
		}
 
		//comprobacion de NIFs estandar
		if (/^[0-9]{8}[A-Z]{1}$/.test(temp))
		{
			posicion = a.substring(8,0) % 23;
			letra = cadenadni.charAt(posicion);
			var letradni=temp.charAt(8);
			if (letra == letradni)
			{
			   	return 1;
			}
			else
			{
				return -1;
			}
		}
 
		//algoritmo para comprobacion de codigos tipo CIF
		suma = parseInt(a[2])+parseInt(a[4])+parseInt(a[6]);
		for (i = 1; i < 8; i += 2)
		{
			temp1 = 2 * parseInt(a[i]);
			temp1 += '';
			temp1 = temp1.substring(0,1);
			temp2 = 2 * parseInt(a[i]);
			temp2 += '';
			temp2 = temp2.substring(1,2);
			if (temp2 == '')
			{
				temp2 = '0';
			}
 
			suma += (parseInt(temp1) + parseInt(temp2));
		}
		suma += '';
		n = 10 - parseInt(suma.substring(suma.length-1, suma.length));
 
		//comprobacion de NIFs especiales (se calculan como CIFs)
		if (/^[KLM]{1}/.test(temp))
		{
			if (a[8] == String.fromCharCode(64 + n))
			{
				return 1;
			}
			else
			{
				return -1;
			}
		}
 
		//comprobacion de CIFs
		if (/^[ABCDEFGHJNPQRSUVW]{1}/.test(temp))
		{
			temp = n + '';
			if (a[8] == String.fromCharCode(64 + n) || a[8] == parseInt(temp.substring(temp.length-1, temp.length)))
			{
				return 2;
			}
			else
			{
				return -2;
			}
		}
 
		//comprobacion de NIEs
		//T
		if (/^[T]{1}/.test(temp))
		{
			if (a[8] == /^[T]{1}[A-Z0-9]{8}$/.test(temp))
			{
				return 3;
			}
			else
			{
				return -3;
			}
		}
 
		//XYZ
		if (/^[XYZ]{1}/.test(temp))
		{
			pos = str_replace(['X', 'Y', 'Z'], ['0','1','2'], temp).substring(0, 8) % 23;
			if (a[8] == cadenadni.substring(pos, pos + 1))
			{
				return 3;
			}
			else
			{
				return -3;
			}
		}
	}
 
	return 0;
}

function FormatNumber(num)



   {



     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 + '.' + cents);



   }







     function FormatNumber1(num)



  {



    if(isNaN(num)) { num = "0"; }



    sign = (num == (num = Math.abs(num)));



    num = Math.floor(num*1+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 + ',' + cents);



  }







  function showPrice(form,oldprice)



  {



   var currencysymbol1 = "";



    var currencysymbol2 = "";



    var myTotalPrice = 0;



    var showUP = 0;



    var myMathProblem = "";



    myItemPrice = parseFloat(form.nuPrice.value);







   myDollarSign2 = form.nuPrice.value.indexOf("EUR",0)



   if ( myDollarSign2 != "-1" )



   {



      currencysymbol1 = "";



     currencysymbol2 = "€";



   } else {



     currencysymbol1 = "";



     currencysymbol2 = "€";



   }







   for (var i = 0; i < form.elements.length; i++)



    {



      var e = form.elements[i];



      if ( e.type == 'select-one' )



      {



        showUP = 1;



        Item = e.selectedIndex;



        myPrice = e.options[Item].text;



        myDollarSign = myPrice.indexOf("$",0)



        if ( myDollarSign != "-1" )



        {



        currencysymbol1 = "$";



        currencysymbol2 = "";



          myParSign = myPrice.indexOf(")", myDollarSign);



          myAttributeString = myPrice.substring(myDollarSign+1, myParSign);



          myAttributeString = myAttributeString.replace(/,/,"");



          myAttributePrice = parseFloat(myAttributeString);



          myMathProblem = myPrice.charAt(myDollarSign - 1);



        } else {



         myDollarSign1 = myPrice.indexOf("(",0)



         if ( myDollarSign1 != "-1" )



         {



         currencysymbol1 = "";



          currencysymbol2 = "€";



         myParSign = myPrice.indexOf(")", myDollarSign1);



         myAttributeString = myPrice.substring(myDollarSign1+1, myParSign);



         myAttributeString = myAttributeString.replace(/,/,"");



         myAttributePrice = parseFloat(myAttributeString);



         myMathProblem = myPrice.charAt(myDollarSign1 - 1);



         } else {



         myAttributePrice = 0;



         }



     



      }



          if (myMathProblem == "-")



          {



            myTotalPrice = myTotalPrice - myAttributePrice;



          } else {



            myTotalPrice = myTotalPrice + myAttributePrice;



          }



      }



    }



    if ( showUP )



    {



      myDollarSign3 = form.nuPrice.value.indexOf(".",0)



      if ( myDollarSign3 != "-1" )



      {



        myTotalPrice = FormatNumber(myTotalPrice + myItemPrice);



      } else {



        myTotalPrice = FormatNumber1(myTotalPrice + myItemPrice);



      }
			
			oldprice_ant ="";
      oldprice_pos ="";
       
			if (oldprice!="") {
			 	oldprice_ant = '<s>' + oldprice + '</s>&nbsp;<span class="productSpecialPrice">';
       	oldprice_pos = '</span>';
			}


        document.getElementById("productNEWprice").innerHTML = oldprice_ant + currencysymbol1 + myTotalPrice + currencysymbol2 + oldprice_pos;



    }



  }



