function message()
{
mess = "";
if (document.form1.Name1.value =="")
	{
		mess = mess + "Name is required\n";
	}
if (document.form1.Address.value =="")
	{
		mess = mess + "Address is required\n";
	}
if (document.form1.City.value =="")
	{
		mess = mess + "City Name is required\n";
	}
if (document.form1.State.value =="")
	{
		mess = mess + "State Name is required\n";
	}
if (document.form1.Zip.value =="")
	{
		mess = mess + "Zip is required\n";
	}
if (document.form1.Country.value =="")
	{
		mess = mess + "Country Name is required\n";
	}
if (document.form1.Phone.value =="")
	{
		mess = mess + "Phone is required\n";
	}
if (document.form1.email.value=="")
	{
		mess = mess + "E-mail is required\n";
	}
else
	{
	var emailpat = /^(\".*\"|[A-Za-z0-9]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9]\w*(\.[A-Za-z0-9]\w*)+)$/;
	var matcharray = window.document.form1.email.value.match(emailpat);
	if (matcharray == null)
	{
		mess = mess + "Invalid email\n";
	}
	}
if (mess!="")
	{
		alert(mess);
		return false;
	}
else
	{
		return true;
	}
}
function display1()
{
var id2 = window.document.form1.seldescr1.options[window.document.form1.seldescr1.selectedIndex].value;
var item
f1 = id2.indexOf("*");
item=id2.substring(0,f1);
window.document.form1.item1.value = item

f2 = id2.lastIndexOf("*")
price=id2.substring(f1+1,f2);
window.document.form1.price1.value = price

window.document.form1.tit1.value=id2.substring(f2+4,id2.length)

if (price=="" | price==0)
{
price1=id2.substring(f2+1,id2.length);
window.document.form1.price1.value = price1
}
}

function display2()
{
var id2 = window.document.form1.seldescr2.options[window.document.form1.seldescr2.selectedIndex].value;
var item2
f1 = id2.indexOf("*");
item2=id2.substring(0,f1);
window.document.form1.item2.value = item2

f2 = id2.lastIndexOf("*")
price2=id2.substring(f1+1,f2);
window.document.form1.price2.value = price2

window.document.form1.tit2.value=id2.substring(f2+4,id2.length)
if (price2=="" | price2==0)
{
price2=id2.substring(f2+1,id2.length);
window.document.form1.price2.value = price2
}
}

function display3()
{
var id2 = window.document.form1.seldescr.options[window.document.form1.seldescr.selectedIndex].value;
var item3
f1 = id2.indexOf("*");
item3=id2.substring(0,f1);
window.document.form1.item3.value = item3

f2 = id2.lastIndexOf("*")
price2=id2.substring(f1+1,f2);
window.document.form1.price3.value = price2

window.document.form1.tit3.value=id2.substring(f2+4,id2.length)

if (price2=="" | price2==0)
{
price2=id2.substring(f2+1,id2.length);
window.document.form1.price3.value = price2
}
}

function Cal1()
{
   Tot1 = window.document.form1.qty1.value * window.document.form1.price1.value 
    var str1 = new String(Tot1)
	var i = str1.indexOf(".")
	if (i == -1 )
	 {	   
	   var tot_new = str1 + ".00"
	 }
	else
	 {
	   var lindex = (str1.length - 1)   
	   if ((i + 1) == lindex)
	    {
	      var tot_new = str1 + "0"
	    }
	   if ((i + 2) == lindex)
	    {
	      var tot_new = str1 
	    }
	   if ((i + 2) < lindex)
	    {     
	      if (parseInt(str1.charAt(i+3)) > 5 ) 
	       {     
	         var tot_new = str1.substring(0,i+3)
	       }
	      else
	       {         
	         var temp1 = Stot + 0.01
	         var temp2 = new String(temp1)
	         var tot_new = temp2.substring(0,i+3)
	       }       
	    }  
	 } 
	
   window.document.form1.total1.value = tot_new
}

function Cal2()
{
Tot2 = window.document.form1.qty2.value * window.document.form1.price2.value 
 var str1 = new String(Tot2)
	var i = str1.indexOf(".")
	if (i == -1 )
	 {	   
	   var tot_new = str1 + ".00"
	 }
	else
	 {
	   var lindex = (str1.length - 1)   
	   if ((i + 1) == lindex)
	    {
	      var tot_new = str1 + "0"
	    }
	   if ((i + 2) == lindex)
	    {
	      var tot_new = str1 
	    }
	   if ((i + 2) < lindex)
	    {     
	      if (parseInt(str1.charAt(i+3)) > 5 ) 
	       {     
	         var tot_new = str1.substring(0,i+3)
	       }
	      else
	       {         
	         var temp1 = Stot + 0.01
	         var temp2 = new String(temp1)
	         var tot_new = temp2.substring(0,i+3)
	       }       
	    }  
	 } 
	
window.document.form1.total2.value = tot_new
}

function Cal3()
{
Tot3 = window.document.form1.qty3.value * window.document.form1.price3.value
var str1 = new String(Tot3)
	var i = str1.indexOf(".")
	if (i == -1 )
	 {	   
	   var tot_new = str1 + ".00"
	 }
	else
	 {
	   var lindex = (str1.length - 1)   
	   if ((i + 1) == lindex)
	    {
	      var tot_new = str1 + "0"
	    }
	   if ((i + 2) == lindex)
	    {
	      var tot_new = str1 
	    }
	   if ((i + 2) < lindex)
	    {     
	      if (parseInt(str1.charAt(i+3)) > 5 ) 
	       {     
	         var tot_new = str1.substring(0,i+3)
	       }
	      else
	       {         
	         var temp1 = Stot + 0.01
	         var temp2 = new String(temp1)
	         var tot_new = temp2.substring(0,i+3)
	       }       
	    }  
	 } 
	
window.document.form1.total3.value = tot_new
}

function Cal4()
{
   Stot = 0
   var x1 = parseFloat(window.document.form1.total3.value)
   var x2 = parseFloat(window.document.form1.total1.value)
   var x3 = parseFloat(window.document.form1.total2.value)
   
   if (!isNaN(x1))
   {
     Stot = Stot + x1
   }
   if (!isNaN(x2))
   {     
     Stot = Stot + x2
   }
   if (!isNaN(x3))
   {
     Stot = Stot + x3
   }
   
   //Stot = parseFloat(window.document.form1.total3.value) + parseFloat(window.document.form1.total1.value) + parseFloat(window.document.form1.total2.value)

	// -------------------------------------- Adjust decimal
   	
	var str1 = new String(Stot)
	var i = str1.indexOf(".")
	if (i == -1 )
	 {	   
	   var tot_new = str1 + ".00"
	 }
	else
	 {
	   var lindex = (str1.length - 1)   
	   if ((i + 1) == lindex)
	    {
	      var tot_new = str1 + "0"
	    }
	   if ((i + 2) == lindex)
	    {
	      var tot_new = str1 
	    }
	   if ((i + 2) < lindex)
	    {     
	      if (parseInt(str1.charAt(i+3)) > 5 ) 
	       {     
	         var tot_new = str1.substring(0,i+3)
	       }
	      else
	       {         
	         var temp1 = Stot + 0.01
	         var temp2 = new String(temp1)
	         var tot_new = temp2.substring(0,i+3)
	       }       
	    }  
	 } 
	  window.document.form1.stotal.value = tot_new
}