//js function
function popUp(URL,w,h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + w + ",height=" + h +",left = 100,top = 100');");
}
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 showPrice(form) {
	var oForm = form;
	if(oForm) {
		var oList1 = oForm.elements["id[1]"];	//size option
		var oList2 = oForm.elements["id[2]"];	//stretch or not option
		if(oList1&&oList2) {
			var sizeValue = parseInt(oList1.options[oList1.selectedIndex].value);
			if(sizeValue > 4) {
				for (var i=oList2.length-1;i>=0;i--) {
					var stretchValue = parseInt(oList2.options[i].value);
					if(stretchValue == 1000) {
						oList2.options[i].selected = true;
					}
				}
				oList2.disabled = true;
			} else if(sizeValue >=1 && sizeValue <=4) {
				oList2.disabled = false;
			}
		}
	}
		
    var myTotalPrice = 0;
    var showUP = 0;
    var myMathProblem = "";
    myItemPrice = parseFloat(form.nuPrice.value);
	 
    for (var i = 0; i < form.elements.length; i++)
    {
      var e = form.elements[i];
      if ( e.type == 'select-one' && e.disabled == false)
      {
        showUP = 1;
        Item = e.selectedIndex;
        myPrice = e.options[Item].text;
        myDollarSign = myPrice.indexOf("$",0)
        if ( myDollarSign != "-1" )
        {
          myParSign = myPrice.indexOf(")", myDollarSign);
          myAttributeString = myPrice.substring(myDollarSign+1, myParSign);
          myAttributeString = myAttributeString.replace(/,/,"");
          myAttributePrice = parseFloat(myAttributeString);
          myMathProblem = myPrice.charAt(myDollarSign - 1);
        } else { myAttributePrice = 0; }
          if (myMathProblem == "-")
          {
            myTotalPrice = myTotalPrice - myAttributePrice;
          } else {
            myTotalPrice = myTotalPrice + myAttributePrice;
          }
      }
    }
    if ( showUP )
    {
        myTotalPrice = FormatNumber(myTotalPrice + myItemPrice);
        document.getElementById("price_now").innerHTML = "$" + myTotalPrice;
    } else {
    	document.getElementById("price_now").innerHTML = "$" + myItemPrice;
    }
}

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

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