function MM_openBrWindow(site,target,para)
{
	window.open(site,target,para);
}
function popup()
{
	window.open ("newpad.php", "Popup", "HEIGHT=300, WIDTH=700, screenX=20, screenY=5, status=yes, scrollbars=yes, toolbar=no, directories=no, menubar=no, location=no");
}
function checkselect1()
{	
	
	
	if (document.Form.roundID.selectedIndex<=0)
	{
		alert ("Please choose the model!");
		document.Form.roundID.focus();
		return false;
	}
	
	/* this validation is added by Minhaj */
	if(document.getElementById('nn_Fabric').value==''){
		alert('Please select mat fabric.');
		return false;
	}
	if(document.getElementById('nn_UVProtection').value==''){
		alert('Please select UV Protection Options.');
		return false;
	}
	/* this validation is added by Minhaj */

	
	if (document.Form.pquantity.value == "")
	{
		alert("Please enter the quantity.")
		document.Form.pquantity.focus()
		return false;
	}
	if (!(document.Form.pquantity.value <= 99999 && document.Form.pquantity.value > 0))
	{
		alert("Please enter a numeric value for quantity");
		document.Form.pquantity.value = '';
		document.Form.pquantity.focus();		
		return false;
	}

	if(document.Form.pquantity.value.indexOf(".") != -1)
	{
		//alert("Invalid Quantity");
		alert("Please enter quantity in whole numbers"); 
		document.Form.pquantity.value = '';
		document.Form.pquantity.focus();		
		return false;
	}
	
    document.Form.submit();		return true;
}
function round_decimals(original_number, decimals) 
{
	var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}
function pad_with_zeros(rounded_value, decimal_places) 
{
    // Convert the number to a string
	var value_string = rounded_value.toString()
// Locate the decimal point
    var decimal_location = value_string.indexOf(".")
    // Is there a decimal point?
    if (decimal_location == -1) 
	{
	// If no, then all decimal places will be padded with 0s
    decimal_part_length = 0
    // If decimal_places is greater than zero, tack on a decimal point
	value_string += decimal_places > 0 ? "." : ""
    }
    else 
	{
// If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    if (pad_total > 0) 
	{
        // Pad the string with 0s
		for (var counter = 1; counter <= pad_total; counter++)
			value_string += "0"
	}
    return value_string
}

function calPrice_new(pPrice, currency, cur_sign, cur_charges)
{
	//alert(pPrice+"   "+currency+"      "+cur_sign+"      "+cur_charges);
	cur_charges = cur_charges/100;
	optProd = new Array(5)	
	optProd["solidBlack"]=0
	optProd["blue"]=9.95
	optProd["green"]=9.95
	optProd["purple"]=9.95
	optProd["half_half"]=19.95
	optProd["targeted"]=29.95
	optProd["4-check"]=29.95
	optProd["sunShield"]=29.95
	optProd["white"] = 29.95
	optProd["taupe"] = 29.95
	optProd["irishgreen"]=29.95
	optProd["duraClip"]=49.95
	optProd["none"]=0
	var totPrice = pPrice;
	document.Form.txtPrice.value=totPrice;
	document.Form.txtPricebottom.value=totPrice;

if (document.getElementById('price_Fabric')){
	if (document.getElementById('price_Fabric').value!='')
	{	
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_Fabric').value + document.getElementById('price_Fabric').value * currency*cur_charges));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}
if (document.getElementById('price_UVProtection')){
	if (document.getElementById('price_UVProtection').value!='')
	{
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_UVProtection').value + document.getElementById('price_UVProtection').value*currency*cur_charges));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}



	
	var MID = document.Form.MID.value;
	//var form = document.Form;

	qObj = document.Form.pquantity;
	var pqty = qObj.value;

	//qObj = document.all("quantity["+MID+"]");
	//var pqty = qObj.value;	
	
	if(pqty == '')
	{
		pqty = 1;
	}
	//alert('aaa===>'+document.Form.txtPrice.value * currency+document.Form.txtPrice.value * currency*cur_charges)	
	//	document.Form.txtPrice.value = round_decimals(document.Form.txtPrice.value, 2);
	//document.Form.txtPrice.value = cur_sign+""+round_decimals((document.Form.txtPrice.value * currency), 2);
	//document.Form.txtPrice.value = cur_sign+""+round_decimals((document.Form.txtPrice.value * currency * pqty), 2);
	document.Form.txtPrice.value = cur_sign+" "+round_decimals((document.Form.txtPrice.value * pqty), 2);
	document.Form.txtPricebottom.value = cur_sign+" "+round_decimals((document.Form.txtPricebottom.value * pqty), 2);
	if(isNaN(pqty))
	{
	   document.Form.txtPrice.value = '';
	   document.Form.txtPricebottom.value = '';
	   qObj.value = '';
	   alert('Please enter the numeric quantity.')
	}
	if(pqty==0)
	{
	   document.Form.txtPrice.value = '';
	   document.Form.txtPricebottom.value = '';
	   qObj.value = '';
	   alert('Please enter the quantity > 0.')
	}
}


function calPrice(pPrice, currency, cur_sign)
{
	optProd = new Array(11)
	optProd["solidBlack"]=0
	optProd["blue"]=9.95
	optProd["green"]=9.95
	optProd["purple"]=9.95
	optProd["half_half"]=19.95
	optProd["targeted"]=29.95
	optProd["4-check"]=29.95
	optProd["sunShield"]=29.95
	optProd["white"] = 29.95
	optProd["taupe"] = 29.95
	optProd["irishgreen"]=29.95
	optProd["duraClip"]=49.95
	optProd["none"]=0
	var totPrice = pPrice;
	
	document.Form.txtPrice.value=totPrice;
	document.Form.txtPricebottom.value=totPrice;

	
	
if (document.getElementById('price_Fabric')){
	if (document.getElementById('price_Fabric').value!='')
	{	
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_Fabric').value));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}
if (document.getElementById('price_UVProtection')){
	if (document.getElementById('price_UVProtection').value!='')
	{
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_UVProtection').value));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}

if (document.getElementById('price_1_Fabric')){
	if (document.getElementById('price_1_Fabric').value!='')
	{	
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_1_Fabric').value));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}
if (document.getElementById('price_1_UVProtection')){
	if (document.getElementById('price_1_UVProtection').value!='')
	{
		totPrice =(parseFloat(totPrice)+parseFloat(document.getElementById('price_1_UVProtection').value));
		document.Form.txtPrice.value=totPrice;
		document.Form.txtPricebottom.value=totPrice;
	}
}


	
	var MID = document.Form.MID.value;
	/* var form = document.Form;
	qObj = document.all("quantity["+MID+"]");
	var pqty = qObj.value;	*/
	qObj = document.Form.pquantity;
	var pqty = qObj.value;
	
	if(pqty == '')
	{
		pqty = 1;
	}
		
	//	document.Form.txtPrice.value = round_decimals(document.Form.txtPrice.value, 2);
	//document.Form.txtPrice.value = cur_sign+""+round_decimals((document.Form.txtPrice.value * currency), 2);
	document.Form.txtPrice.value = cur_sign+""+round_decimals((document.Form.txtPrice.value * currency * pqty), 2);
	document.Form.txtPricebottom.value = cur_sign+""+round_decimals((document.Form.txtPricebottom.value * currency * pqty), 2);
	if(isNaN(pqty))
	{
	   document.Form.txtPrice.value = '';
	   document.Form.txtPricebottom.value = '';
	   qObj.value = '';
	   alert('Please enter the numeric quantity.')
	}
	if(pqty==0)
	{
	   document.Form.txtPrice.value = '';
	   document.Form.txtPricebottom.value = '';
	   qObj.value = '';
	   alert('Please enter the quantity > 0.')
	}
}
function mat_options_PopUp(fabric, width, height)
{
    window.open("mat_options.php?type="+fabric+"", "Mat_Options", "toolbar=no, menubar=no, width="+width+", height="+height+", status=no, scrollbars=no", false)
}
