function add_qty(txtid)
{
	if(document.getElementById(txtid).value != "")
	{
		if(isNaN(document.getElementById(txtid).value))
		{
			alert("Please Enter The Value In Number");
			return false;
		}
	}
		prevval=document.getElementById(txtid).value;
		prevval++;
		document.getElementById(txtid).value=prevval;
		//CalculateTotal(document.frm);
}
function less_qty(txtid)
{
	if(document.getElementById(txtid).value != "")
	{
		if(isNaN(document.getElementById(txtid).value))
		{
			alert("Please Enter The Value In Number");
			return false;
		}
	}
		prevval=document.getElementById(txtid).value;
		prevval--;
		if(parseInt(prevval) <= 0)
		{
			document.getElementById(txtid).value=0;
		}
		else
		{
			document.getElementById(txtid).value=prevval;
		}
	//CalculateTotal(document.frm);
}

function calculate_price(packid,fieldid)
{
	add_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var packid=packid;
	var qty=document.getElementById(fieldid).value;
	if (document.getElementById("paf"+packid).checked==false)
	{
	document.getElementById("pa"+packid).checked=true;
	}
	//alert(qty);
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_calculate.php";
  	url=url+"?packid="+packid+"&qty="+qty;
  	if (document.getElementById("pa"+packid).checked==true)
  	{
  	url="price_calculate.php?packid="+packid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("paf"+packid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			//alert(str);
			document.frm.TOTAL.value=str;
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
function calculate_lessprice(packid,fieldid)
{
	less_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var packid=packid;
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	
	if (qty==0 || qty=="")
	{
		document.getElementById("pa"+packid).checked=false;
		document.getElementById("paf"+packid).checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_calculate.php";
	url=url+"?packid="+packid+"&qty="+qty;
	if (document.getElementById("pa"+packid).checked==true)
  	{
  	url="price_calculate.php?packid="+packid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("paf"+packid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			if (str==0)
			{
				document.frm.express.checked=false;
			}
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
function calculate_packprice(packid,fieldid)
{
	//alert(packid);
	//alert(fieldid);
	var packid=packid;
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	
	if (qty==0 || qty=="")
	{
		document.getElementById("pa"+packid).checked=false;
		document.getElementById("paf"+packid).checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_calculate.php";
	url=url+"?packid="+packid+"&qty="+qty;
	if (document.getElementById("pa"+packid).checked==true)
  	{
  	url="price_calculate.php?packid="+packid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("paf"+packid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
function calculate_indprice(bannid,fieldid)
{
	add_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var bannid=bannid;
	var qty=document.getElementById(fieldid).value;
	if (document.getElementById("ani"+bannid).checked==false)
	{
	document.getElementById("C"+bannid).checked=true
	}
	//alert(qty);
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_bannercalculate.php";
	url=url+"?bannid="+bannid+"&qty="+qty;
	if (document.getElementById("C"+bannid).checked==true)
  	{
  	url="price_bannercalculate.php?bannid="+bannid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("ani"+bannid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
  	else
  	{
  	url=url+"&flash=delete";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
function calculate_indprice2(bannid,fieldid)
{
	//alert(packid);
	//alert(fieldid);
	var bannid=bannid;
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	
	if (qty==0 || qty=="")
	{
		document.getElementById("C"+bannid).checked=false;
		document.getElementById("ani"+bannid).checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_bannercalculate.php";
	url=url+"?bannid="+bannid+"&qty="+qty;
	if (document.getElementById("C"+bannid).checked==true)
  	{
  	url="price_bannercalculate.php?bannid="+bannid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("ani"+bannid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}

function calculate_lessindprice(bannid,fieldid)
{
	less_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var bannid=bannid;
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	if (qty==0 || qty=="")
	{
		document.getElementById("C"+bannid).checked=false;
		document.getElementById("ani"+bannid).checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_bannercalculate.php";
	url=url+"?bannid="+bannid+"&qty="+qty;
	if (document.getElementById("C"+bannid).checked==true)
  	{
  	url="price_bannercalculate.php?bannid="+bannid+"&qty="+qty+"&animate=add";
  	}
  	if (document.getElementById("ani"+bannid).checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			if (str==0)
			{
				document.frm.express.checked=false;
			}
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}

function calculate_animate(bannid,fieldid,textfieldid)
{
	var bannid=bannid;
	//alert(fieldid);
	var qty=document.getElementById(textfieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_animatecalculate.php";
  	if (document.getElementById(fieldid).checked==true)
  	{
  	document.getElementById("ani"+bannid).checked=false;
	url=url+"?bannid="+bannid+"&animate=add";
		if (qty=="" || qty==0)
		{
		add_qty(textfieldid);
		}
	}
	else
	{
	url=url+"?bannid="+bannid+"&animate=delete";
	}
	if (document.getElementById("ani"+bannid).checked==true)
  	{
	url=url+"&flash=add";
	}
	else
	{
	url=url+"&flash=delete";
	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			//alert(str);
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}

//************************ Individual Banner Flash ***************************

function calculate_flash(bannid,fieldid,textfieldid)
{
	var bannid=bannid;
	//alert(fieldid);
	var qty=document.getElementById(textfieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_flashcalculate.php";
  	if (document.getElementById(fieldid).checked==true)
  	{
		if (qty=="" || qty==0)
		{
		add_qty(textfieldid);
		}
	}
  	if (document.getElementById(fieldid).checked==true)
  	{
	document.getElementById("C"+bannid).checked=false;
	url=url+"?bannid="+bannid+"&flash=add";
	}
	else
	{
	url=url+"?bannid="+bannid+"&flash=delete";
	}
	if (document.getElementById("C"+bannid).checked==true)
  	{
	url=url+"&animate=add";
	}
	else
	{
	url=url+"&animate=delete";
	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			//alert(str);
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}

//****************************************************************************

function calculate_express()
{
	var total=document.frm.TOTAL.value.replace(",","");
	if (total > 0)
	{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_expresscalculate.php";
  	if (document.frm.express.checked==true)
  	{
	url=url+"?express=add";
	}
	else
	{
	url=url+"?express=delete";
	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			document.frm.TOTAL.value=str;
			document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
else
{
	alert("Please Select a Package or Banner.");
	document.frm.express.checked=false;
}
}

function calculate_packageanimate(packid,fieldid,textfieldid)
{
	var packid=packid;
	//alert(fieldid);
	var qty=document.getElementById(textfieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_packageanimatecalculate.php";
  	if (document.getElementById(fieldid).checked==true)
  	{
		if (qty=="" || qty==0)
		{
		alert("Please mention a Quantity for the Package and then click Animate");
		document.getElementById(fieldid).checked=false;
		}
		else
		{
		document.getElementById("paf"+packid).checked=false;
		var qty=document.getElementById(textfieldid).value;
		url=url+"?packid="+packid+"&qty="+qty+"&animate=add";
		if (document.getElementById("paf"+packid).checked==true)
		{
		url=url+"&flash=add";
		}
		url=url+"&sid="+Math.random();
		//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4)
				{
					if ( xmlHttp.responseText.length > 0)
					{
					var str=xmlHttp.responseText;
					//alert(str);
					document.frm.TOTAL.value=str;
					document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
					}
				}	
			}
			xmlHttp.send(null);
		}
	}
	else
	{
	url=url+"?packid="+packid+"&qty="+qty+"&animate=delete";
	url=url+"&sid="+Math.random();
		//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4)
				{
					if ( xmlHttp.responseText.length > 0)
					{
					var str=xmlHttp.responseText;
					//alert(str);
					document.frm.TOTAL.value=str;
					document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
					}
				}	
			}
			xmlHttp.send(null);
	}
	
}

//***********************Package Flash**********************************

function calculate_packageflash(packid,fieldid,textfieldid)
{
	var packid=packid;
	//alert(fieldid);
	var qty=document.getElementById(textfieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_packageflashcalculate.php";
  	if (document.getElementById(fieldid).checked==true)
  	{
		if (qty=="" || qty==0)
		{
		alert("Please mention a Quantity for the Package and then click Flash");
		document.getElementById(fieldid).checked=false;
		}
		else
		{
		document.getElementById("pa"+packid).checked=false;
		var qty=document.getElementById(textfieldid).value;
		url=url+"?packid="+packid+"&qty="+qty+"&flash=add";
		url=url+"&sid="+Math.random();
		//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4)
				{
					if ( xmlHttp.responseText.length > 0)
					{
					var str=xmlHttp.responseText;
					//alert(str);
					document.frm.TOTAL.value=str;
					document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
					}
				}	
			}
			xmlHttp.send(null);
		}
	}
	else
	{
	url=url+"?packid="+packid+"&qty="+qty+"&flash=delete";
	url=url+"&sid="+Math.random();
		//alert(url);
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4)
				{
					if ( xmlHttp.responseText.length > 0)
					{
					var str=xmlHttp.responseText;
					//alert(str);
					document.frm.TOTAL.value=str;
					document.getElementById("totalsum").innerHTML="<b>$"+str+"</b>";
					}
				}	
			}
			xmlHttp.send(null);
	}
	
}

//********************For Custom Banner Size ********************************

function calculate_custom_price(fieldid)
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value=="")
	{
		alert("Please enter banner size Width x Height.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please Write Custom Banner Width.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value!="" && document.frm.customheight.value=="")
	{
		alert("Please Write Custom Banner Height.");
		document.frm.customheight.focus();
	}
	else
	{
	add_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_customcalculate.php";
	url=url+"?qty="+qty;
	if (document.frm.custombannid.value!="")
	{
	url=url+"&bannid="+document.frm.custombannid.value+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	else
	{
	url=url+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	if (document.getElementById("customanimate").checked==true)
  	{
  	url=url+"&animate=add";
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			str=str.split(",");
			document.frm.TOTAL.value=str[0];
			document.frm.custombannid.value=str[1];
			document.getElementById("totalsum").innerHTML="<b>$"+str[0]+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
}
function calculate_custom_price2(fieldid)
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value=="")
	{
		alert("Please enter banner size Width x Height.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please Write Custom Banner Width.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value!="" && document.frm.customheight.value=="")
	{
		alert("Please Write Custom Banner Height.");
		document.frm.customheight.focus();
	}
	else
	{
	//alert(fieldid);
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	
	if (qty==0 || qty=="")
	{
		document.getElementById("customanimate").checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_customcalculate.php";
	url=url+"?qty="+qty;
	if (document.frm.custombannid.value!="")
	{
	url=url+"&bannid="+document.frm.custombannid.value+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	else
	{
	url=url+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	if (document.getElementById("customanimate").checked==true)
  	{
  	url=url+"&animate=add";
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			str=str.split(",");
			document.frm.TOTAL.value=str[0];
			document.frm.custombannid.value=str[1];
			document.getElementById("totalsum").innerHTML="<b>$"+str[0]+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
}

function calculate_custom_lessprice(fieldid)
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value=="")
	{
		alert("Please enter banner size Width x Height.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please Write Custom Banner Width.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value!="" && document.frm.customheight.value=="")
	{
		alert("Please Write Custom Banner Height.");
		document.frm.customheight.focus();
	}
	else
	{
	less_qty(fieldid);
	//alert(packid);
	//alert(fieldid);
	var qty=document.getElementById(fieldid).value;
	//alert(qty);
	if (qty==0 || qty=="")
	{
		document.getElementById("customanimate").checked=false;
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_customcalculate.php";
  	url=url+"?qty="+qty;
	if (document.frm.custombannid.value!="")
	{
	url=url+"&bannid="+document.frm.custombannid.value+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	else
	{
	url=url+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	if (document.getElementById("customanimate").checked==true)
  	{
  	url=url+"&animate=add";
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			str=str.split(",");
			document.frm.TOTAL.value=str[0];
			document.frm.custombannid.value=str[1];
			if (str[0]==0)
			{
				document.frm.express.checked=false;
			}
			document.getElementById("totalsum").innerHTML="<b>$"+str[0]+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
}

function calculate_custom_animate(fieldid)
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value=="")
	{
		alert("Please enter banner size Width x Height.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please Write Custom Banner Width.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value!="" && document.frm.customheight.value=="")
	{
		alert("Please Write Custom Banner Height.");
		document.frm.customheight.focus();
	}
	else
	{
	//alert(fieldid);
	if (document.getElementById("customanimate").checked==true && (document.getElementById(fieldid).value=="" || document.getElementById(fieldid).value==0))
  	{
  			document.getElementById(fieldid).value=1;
  	}
  	if (document.getElementById("customflash").checked==true && (document.getElementById(fieldid).value=="" || document.getElementById(fieldid).value==0))
  	{
  			document.getElementById(fieldid).value=1;
  	}
  	if (document.getElementById("customanimate").checked==true)
  	{
  		document.getElementById("customflash").checked=false;
  	}
  	var qty=document.getElementById(fieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_customcalculate.php";
  	url=url+"?qty="+qty;
	if (document.frm.custombannid.value!="")
	{
	url=url+"&bannid="+document.frm.custombannid.value+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	else
	{
	url=url+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	if (document.getElementById("customanimate").checked==true)
  	{
  	url=url+"&animate=add";
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			str=str.split(",");
			document.frm.TOTAL.value=str[0];
			document.frm.custombannid.value=str[1];
			//alert(str);
			document.getElementById("totalsum").innerHTML="<b>$"+str[0]+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
}
// **************************************************************************

function calculate_custom_flash(fieldid)
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value=="")
	{
		alert("Please enter banner size Width x Height.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please Write Custom Banner Width.");
		document.frm.customwidth.focus();
	}
	else if (document.frm.customwidth.value!="" && document.frm.customheight.value=="")
	{
		alert("Please Write Custom Banner Height.");
		document.frm.customheight.focus();
	}
	else
	{
	//alert(fieldid);
	if (document.getElementById("customanimate").checked==true && (document.getElementById(fieldid).value=="" || document.getElementById(fieldid).value==0))
  	{
  			document.getElementById(fieldid).value=1;
  	}
  	if (document.getElementById("customflash").checked==true && (document.getElementById(fieldid).value=="" || document.getElementById(fieldid).value==0))
  	{
  			document.getElementById(fieldid).value=1;
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  		document.getElementById("customanimate").checked=false;
  	}
	var qty=document.getElementById(fieldid).value;
				
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	var url="price_customcalculate.php";
  	url=url+"?qty="+qty;
	if (document.frm.custombannid.value!="")
	{
	url=url+"&bannid="+document.frm.custombannid.value+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	else
	{
	url=url+"&customsize="+document.frm.customwidth.value+"x"+document.frm.customheight.value;
	}
	if (document.getElementById("customanimate").checked==true)
  	{
  	url=url+"&animate=add";
  	}
  	if (document.getElementById("customflash").checked==true)
  	{
  	url=url+"&flash=add";
  	}
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if ( xmlHttp.responseText.length > 0)
			{
			var str=xmlHttp.responseText;
			str=str.split(",");
			document.frm.TOTAL.value=str[0];
			document.frm.custombannid.value=str[1];
			//alert(str);
			document.getElementById("totalsum").innerHTML="<b>$"+str[0]+"</b>";
			}
		}	
	}
xmlHttp.send(null);
}
}

// **************************************************************************
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function validate()
{
	if (document.frm.customwidth.value=="" && document.frm.customheight.value!="")
	{
		alert("Please enter custom banner width.");
		document.frm.customwidth.focus();
		return false;
	}
	if (document.frm.customheight.value=="" && document.frm.customwidth.value!="")
	{
		alert("Please enter custom banner height.");
		document.frm.customheight.focus();
		return false;
	}
	if (document.frm.bannertext.value=="")
	{
		alert("Please enter banner text.");
		document.frm.bannertext.focus();
		return false;
	}
	if (document.frm.instruction.value=="")
	{
		alert("Please enter instructions / special notes.");
		document.frm.instruction.focus();
		return false;
	}
	/*if(document.frm.F1.value != "")
	{
		if(!/(\.gif|\.jpg|\.jpeg|\.swf)$/i.test(document.frm.F1.value)) 
		{
			alert("THAT IS NOT A VALID Image File\nPlease load a image file with an extention of one of the following :\n\nGIF, JPG, JPEG");
			//document.frm.F1.focous();
			return false;
		}
	}*/
	if (Math.round(document.frm.TOTAL.value)==0)
	{
		alert("Please Choose any One Package or Any One Individual Banner");
		return false;
	}
}

function showbanner(banner)
{
	if (document.getElementById("bannernm").innerHTML != "")
	{
		id=document.getElementById("bannernm").innerHTML;
		document.getElementById(id).style.display="none";
	}
	document.getElementById(banner).style.display="";
	document.getElementById("bannernm").innerHTML=banner;
}
function hidebanner(banner)
{
	document.getElementById(banner).style.display="none";
}
function banner_instruction(banner)
{
	document.getElementById(banner).style.display="";
}	


/* This script is Copyright (c) Paul McFedries and 
Logophilia Limited (http://www.mcfedries.com/).
Permission is granted to use this script as long as 
this Copyright notice remains in place.*/

function CalculateTotal(frm) 
{
    var order_total = 0
    // Run through all the form fields
    for (var i=0; i < frm.elements.length; ++i) 
    {

        // Get the current field
        form_field = frm.elements[i]

        // Get the field's name
        form_name = form_field.name

        // Is it a "product" field?
        if (form_name.substring(0,1) == "Q") {

            // If so, extract the price from the name
            item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))
            // Get the quantity
            item_quantity = parseInt(form_field.value)
            // Update the order total
            if (item_quantity >= 0) {
                order_total += item_quantity * item_price
            }
        }
    }
	
    // Display the total rounded to two decimal places
    frm.TOTAL.value = round_decimals(order_total, 2)
}

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
}
