function select_deSelectAll()
{
	docForm = document.purchase;
	
	index = docForm.strIndx.value;
	
	index = index.split("~");

	str ="";
	flag= 0;
	
	if(docForm.selectAll.checked==true)
	{
		for(i=0;i<(index.length-1);i++)
		{
			//alert("chbo"+index[i])
			docForm["chbo"+index[i]].checked = true;
		}
	}
	else
	{
		for(i=0;i<(index.length-1);i++)
		{
			//alert("chbo"+index[i])
			docForm["chbo"+index[i]].checked = false;
		}	
	}



	if(str)
	{
		alert(str)
		return false
	}
	else 
	{
	
		return true;
	}		

}


/*
function validate()
{
	docForm = document.purchase;
	
	cnt= docForm["frmQty[]"].value;
	//cnt= docForm,frmQty[].value;
	
	alert(cnt);

	
	str ="";

	for(i=0;i<(index.length-1);i++)
	{
		nbr = docForm["frmQty"+index[i]].value;
		
		if(isNaN(nbr) || nbr < -1)
		{
			str += "Row "+i +" Please enter a positive no. in quantity field.\n";
			//break;
		}

	}

	if(str)
	{
		alert(str);
		return false;
	}
	else 
	{	
		return true;
	}	
	
}
*/



function validate(doc)
{
	re2 = /\w*@\w*\.\w+/;
	re3 = /\d+/;
	ref = /\w+/;

       function blank(doc)
       {
	    if((doc.MC_name.value == "") || (doc.MC_address.value == "") || (doc.MC_email.value == "") || (doc.MC_tell.value == "") || (doc.MC_zip.value == "") ||(doc.MC_country.value == "")  )
	    {
		alert("Some Fields are Vacant");
		return false;
	    }
	    else
	    {
		return true;
	    }
       }

       function checkdd(doc)
       {

	   if((doc.MC_country.value != "1") && (doc.t.value == "1") )
	   {
		alert("Demand Draft facility is only for India, please use Credit Card facility.");
		return false;
	   }
	   else
	   {
		return true;
	   }
       }
       function check_country(doc)
       {
	   cnt = doc.MC_country.selectedIndex;  
	   cnt1 = doc.t.selectedIndex;  
	   cval = doc.MC_country.options[cnt].value
	   cval1 = doc.t.options[cnt1].value
	   if((cval == 1) && (cval1 == 1))
	   {
		alert("Credit Card Facility is available only for International Buyer. Buyers from India  please select Demand Draft,  alternatively you can deposit cash/cheque with branches of HDFC bank in your city for more information send an email at ionline@vsnl.com");
		return false;
	   }
	   else
	   {
		return true;
	   }
       }    		       
       function check_email(doc)
       {
	   if(doc.value != "")
	   {
	       fsign = doc.value.indexOf("@");             
	       ssign = doc.value.indexOf(".");

	       if(fsign <= 0 || ssign <= 0)
	       {

		     alert("You should enter proper email ID");
		     return false;
	       }
	       else
	       {
		     return true;
	       }
	   }
	   else
	   {
		    return true;
	   }
      } 

      function check_num(doc)
      {
	   if(!((re3.test(doc.MC_zip.value)) &&  (re3.test(doc.MC_tell.value))))
	   {
		alert("You should enter only numeric values for the fields ISD No.,STD No.,PHONE No., QUANTITY and Zip");
		return false;
	   }
	   else
	   {
		return true;
	   }
      }
      if(!check_country(doc))
      {
	    return false;
      } 		
      if(!blank(doc))
      {
	   return false;
      }

      if(!check_email(doc.MC_email))
      {
	    return false;
      }

      if(!check_num(doc))
      {
	    return false;
      }
}
