//Validation for Form
var xmlHttp
function checkPromotionCode(promotionCode,domain,accountno)
{ 
	
	if(document.getElementById("fedexcharge").value!="")
	{
		document.getElementById("bShippingMode1").style.display="block"
		document.getElementById("bShippingMode2").style.display="none"
	}
	
	if(document.f1.btnPromoVerify.value=='Cancel')
	{
		location.reload(true);	 
	}
	if(promotionCode=="")
	{
		alert("Enter Valid promotion code");
		document.f1.promoCode.focus();
		return false;
	}
//	if(document.f1.sameasbilling.sameasbilling)
//	{
//		if(document.f1.rdopShippingCountry.value=="")
//		{
//			alert("Select Shipping Country");
//			document.f1.opShippingCountry.focus();
//			return false;
//		}
//		if(document.f1.rdopShippingCountry.value!='216' && document.f1.rdopShippingCountry.value!='95' && document.f1.rdopShippingCountry.value!='218' && document.f1.rdopShippingCountry.value!='38')
//		{
//			alert("Invalid promotion Code");
//			document.f1.promoCode.value='';
//			return false;
//		}
//	}
//	else
//	{
//		//alert(document.f1.opShippingCountry.value);
//		if(document.f1.opShippingCountry.value=="")
//		{
//			alert("Select Shipping Country");
//			document.f1.opShippingCountry.focus();
//			return false;
//		}
//		if(document.f1.opShippingCountry.value!='216' && document.f1.opShippingCountry.value!='95' && document.f1.opShippingCountry.value!='218' && document.f1.opShippingCountry.value!='38')
//		{
//			//alert(document.f1.opShippingCountry.value)
//			alert("Invalid promotion Code");
//			document.f1.promoCode.value='';
//			return false;
//		}
//		
//	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	
	var url="tools/promotioncode.asp";
	url=url+"?promotionCode="+promotionCode;
	url=url+"&domain="+domain;
	url=url+"&accno="+accountno;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{	 
		var xmlText=xmlHttp.responseText
		//document.getElementById("xmlText").innerHTML=xmlHttp.responseText;
		if (window.ActiveXObject)
  		{
			var doc=new ActiveXObject("Microsoft.XMLDOM");
            doc.async="false";
  			doc.loadXML(xmlText);
  		}
			// code for Mozilla, Firefox, Opera, etc.
		else
  		{
			  var parser=new DOMParser();
			  var doc=parser.parseFromString(xmlText,"text/xml");
  		}


		var x=doc.documentElement;
		var msg=x.childNodes[0].childNodes[0].nodeValue;		
		var CartValue1=""		 
		var Country1=""
		var DiscountType1=""
		var DiscountField1=""
		var DiscountValue1=""
		var OldShipId1=""
		var NewShipId1=""
		var OldShipMode1=""
		var NewShipMode1=""
		var DiscountId1=""

		//var x=doc.documentElement;
		//var msg=x.childNodes[0].childNodes[0].nodeValue;
		if(msg=='Valid')
		{
				 var countmsg=x.childNodes[1].childNodes[0].nodeValue;
				
				 CartValue=x.getElementsByTagName("record")[0].childNodes[0].childNodes[0].nodeValue;
				 Country=x.getElementsByTagName("record")[0].childNodes[1].childNodes[0].nodeValue;
				 DiscountType=x.getElementsByTagName("record")[0].childNodes[2].childNodes[0].nodeValue;
				 DiscountField=x.getElementsByTagName("record")[0].childNodes[3].childNodes[0].nodeValue;
				 DiscountValue=x.getElementsByTagName("record")[0].childNodes[4].childNodes[0].nodeValue;
				 OldShipId=x.getElementsByTagName("record")[0].childNodes[5].childNodes[0].nodeValue;
				 NewShipId=x.getElementsByTagName("record")[0].childNodes[6].childNodes[0].nodeValue;
				 OldShipMode=x.getElementsByTagName("record")[0].childNodes[7].childNodes[0].nodeValue;
				 NewShipMode=x.getElementsByTagName("record")[0].childNodes[8].childNodes[0].nodeValue;
				 DiscountId=x.getElementsByTagName("record")[0].childNodes[9].childNodes[0].nodeValue;
				 
				 if(countmsg==1)
				 {
					 CartValue1=x.getElementsByTagName("record")[1].childNodes[0].childNodes[0].nodeValue;				 
					 Country1=x.getElementsByTagName("record")[1].childNodes[1].childNodes[0].nodeValue;
					 DiscountType1=x.getElementsByTagName("record")[1].childNodes[2].childNodes[0].nodeValue;
					 DiscountField1=x.getElementsByTagName("record")[1].childNodes[3].childNodes[0].nodeValue;
					 DiscountValue1=x.getElementsByTagName("record")[1].childNodes[4].childNodes[0].nodeValue;
					 OldShipId1=x.getElementsByTagName("record")[1].childNodes[5].childNodes[0].nodeValue;
					 NewShipId1=x.getElementsByTagName("record")[1].childNodes[6].childNodes[0].nodeValue;
					 OldShipMode1=x.getElementsByTagName("record")[1].childNodes[7].childNodes[0].nodeValue;
					 NewShipMode1=x.getElementsByTagName("record")[1].childNodes[8].childNodes[0].nodeValue;
					 DiscountId1=x.getElementsByTagName("record")[1].childNodes[9].childNodes[0].nodeValue;
				 }
			 var mgs1=""
			 var mgs2=""

			 if(parseInt(document.f1.bCartTotal.value)>=parseInt(CartValue))
			 {
				 shipcountry=document.getElementById("opShippingCountry").options[document.getElementById("opShippingCountry").selectedIndex].text.toLowerCase();
				 promocountry=Country.toLowerCase();
				if(shipcountry==promocountry)
				{
					if(DiscountType=='Percent' && DiscountField=='Net Amount' && DiscountType1=='Percent' && DiscountField1=='Shipping')
					{
					mgs2="You got discount of "+DiscountValue+"% "+ " on "+DiscountField + ' and ' + NewShipMode1;
					mgs1="true"
					}	
					// if(DiscountType=='Percent' && DiscountType1=='Percent' && DiscountField1=='Shipping')
					//			 {
					//				mgs2="You got " + NewShipMode1;
					//				mgs1="true"
					//			 }	
					if(DiscountType=='Percent' &&  DiscountField=='Shipping' && DiscountType1=='' && DiscountField1=='')
					{
					mgs2="You got " + NewShipMode;
					mgs1="true"
					}				
					
					if(DiscountType=='Percent' && DiscountField=='Net Amount') 
					{
					document.f1.bDiscount.value=numround(document.f1.bCartTotal.value*(DiscountValue/100),2);
					}
						
					if(DiscountType1=='Percent' && DiscountField1=='Net Amount')
					{
						document.f1.bDiscount.value=numround(document.f1.bCartTotal.value*(DiscountValue1/100),2);
					}
					
					if(DiscountType=='Percent' && DiscountField=='Net Amount' && DiscountType1=='' && DiscountField1=='') 
					{
						mgs2="You got " + DiscountValue+"% Discount";
					}
						
					if(DiscountType1=='Percent' && DiscountField1=='Net Amount' && DiscountType=='' && DiscountField=='')
					{
						mgs2="You got " + DiscountValue1 +"% Discount";
					}					
					
					document.getElementById("sendshipid").value=NewShipId;
					
					if(mgs1=="true")
					{
						if(document.f1.totqty.value<=6)
						{
							if(countmsg==1) 
							{
							objOptionShip=document.getElementById("bShippingMode");
							optVal = document.createElement("OPTION");
							optVal.value=NewShipId1+'|'+0+'|'+0+'|'+0;
							optVal.text =NewShipMode1+'($0.00)';
							objOptionShip.options.add(optVal);
							document.f1.btnPromoVerify.value='Cancel';
							}
							else
							{
								objOptionShip=document.getElementById("bShippingMode");
								optVal = document.createElement("OPTION");
								optVal.value=NewShipId+'|'+0+'|'+0+'|'+0;
								optVal.text =NewShipMode+' ($0.00)';
								objOptionShip.options.add(optVal);
								document.f1.btnPromoVerify.value='Cancel';
							}
						}
					}
				}
				else
				{
					mgs2="Invalid Country for this Promotion Code";		
				}

 			}
			else
			{
				mgs2="Your Cart Value should be more than $"+CartValue;		
			}
			alert(mgs2);			
		}
		else
		{
			alert('Invalid Promotion Code');
		}		
	}
}

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 chkAgreeJs(objForm)
{
	if(objForm.chkAgree.checked==false)
	{
		alert("Please check the Credit Card Authorization");
		objForm.chkAgree.focus();
	}
}
function validateform(objForm)
{	

	//alert( document.getElementById("tdAgree").style.display);
	var blExit=false;
	for(var intCounter=0;intCounter<objForm.length && blExit==false;intCounter++)
	{
		var strTemp=""
		//alert(objForm[intCounter].name + " " +objForm[intCounter].alt);
		//return false;
		
		if(!(document.all))
		{
			
			if(objForm[intCounter].type=="textarea" || objForm[intCounter].type=="select-one" || objForm[intCounter].type=="select-multiple")
			{
				Trim(objForm[intCounter]);
				if(objForm[intCounter].value=="" && objForm[intCounter].style.display!="none")
				{
					if(objForm[intCounter].dir!="ltr")
					{
						//alert("Please Give Value for This Field !");
						//objForm[intCounter].focus();
						//blExit=true;
						continue;

					}
					else
					{
						continue;
					}
					/*alert("Please Give Value for This Field !");
					objForm[intCounter].focus();
					blExit=true;*/
				}
				continue;
			}
			else 
			{
				strTemp=objForm[intCounter].alt.split("|");
			}
		}
		else
		{
			if(navigator.userAgent.toLowerCase().indexOf("opera")!=-1)
			{
				if(objForm[intCounter].type=="textarea" || objForm[intCounter].type=="select-one")
				{
					Trim(objForm[intCounter]);
					if(objForm[intCounter].value=="" && objForm[intCounter].style.display!="none")
					{
						if(objForm[intCounter].dir!="ltr")
						{
							alert("Please Give Value for This Field !");
							objForm[intCounter].focus();
							blExit=true;
						}
						else
						{
							continue;
						}
					}
					continue;
				}
				else
				{
					strTemp=objForm[intCounter].alt.split("|");
				}
			}
			else
			{
				strTemp=objForm[intCounter].alt.split("|");
			}
		}
		if(strTemp[0]=="REQ")
		{
			if(strTemp[1]=="TEXT")
			{
				Trim(objForm[intCounter])
				if(strTemp[2]=="")
				{
					if(objForm[intCounter].value=="")
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="NUMERIC")
				{
					if(IsNumeric(objForm[intCounter])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="STRING")
				{
					if(IsCharacter(objForm[intCounter])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="IP")
				{
					if(IsIP(objForm[intCounter])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="EMAIL")
				{
					if(IsEmail(objForm[intCounter])==false)
					{
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="PATH")
				{
					if(IsPath(objForm[intCounter])==false)
					{
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="NOSPL")
				{
					if(IsSpl(objForm[intCounter])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
				else if(strTemp[2]=="CC")
				{
					if(IsCreditCard(objForm[intCounter])==false)
					{
						alert(strTemp[3]);
						objForm[intCounter].focus();
						blExit=true;
					}
				}
			}
			else if(strTemp[1]=="CHECK")
			{
				if(objForm[intCounter].checked==false)
				{
					alert(strTemp[3]);
					objForm[intCounter].focus();
					blExit=true;
				}
			}
			else if(strTemp[1]=="SELECT")
			{
				if(document.getElementById("fedexcharge").value!="") 
				{
					if(document.getElementById("txtHint").innerHTML=="")
					{
						Trim(objForm[intCounter])
						if(strTemp[2]=="")
						{
							if(objForm[intCounter].value=="")
							{
								alert(strTemp[3]);
								objForm[intCounter].selectedIndex=0;
								objForm[intCounter].focus();
								blExit=true;
							}
						}
					}
				}
				else
				{
					Trim(objForm[intCounter])
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].selectedIndex=0;
							objForm[intCounter].focus();
							blExit=true;
						}
					}
				}
				
			}			
			else if(strTemp[1]=="SELECTfdx")
			{
				Trim(objForm[intCounter])
				if(strTemp[2]=="")
				{
					if(objForm[intCounter].value=="")
					{
						alert(strTemp[3]);
						objForm[intCounter].selectedIndex=0;
						objForm[intCounter].focus();
						blExit=true;
					}
				}
			}				
			
			else if(strTemp[1]=="HIDDEN")
			{
				Trim(objForm[intCounter])
				if(strTemp[2]=="")
				{
					if(objForm[intCounter].value=="")
					{
						alert(strTemp[3]);
						objForm[intCounter].selectedIndex=0;
						blExit=true;
					}
				}
			}
		}
		else if(strTemp[0]=="NOTREQ")
		{
			Trim(objForm[intCounter])
			if(objForm[intCounter].value!="")
			{
				if(strTemp[1]=="TEXT")
				{
					if(strTemp[2]=="")
					{
						if(objForm[intCounter].value=="")
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NUMERIC")
					{
						if(IsNumeric(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="STRING")
					{
						if(IsCharacter(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="IP")
					{
						if(IsIP(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="EMAIL")
					{
						if(IsEmail(objForm[intCounter])==false)
						{
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="PATH")
					{
						if(IsPath(objForm[intCounter])==false)
						{
							objForm[intCounter].focus();
							blExit=true;
						}
					}
					else if(strTemp[2]=="NOSPL")
					{
						if(IsSpl(objForm[intCounter])==false)
						{
							alert(strTemp[3]);
							objForm[intCounter].focus();
							blExit=true;
						}
					}
				}
			}
		}
	}

	if(document.getElementById("fedexcharge").value=="fdex")
	{
		getfedex=document.getElementById("bShippingMode2").options[document.getElementById("bShippingMode2").selectedIndex].text.indexOf("Choose Your Shipping Account")
	}
	else
	{
		getfedex=document.getElementById("bShippingMode").options[document.getElementById("bShippingMode").selectedIndex].text.indexOf("Choose Your Shipping Account")
	}
	
	if(getfedex==0)
	{
		if(document.getElementById("Ship_Mode").value == '')
		{
			alert("Select Mode");
			document.getElementById("Ship_Mode").focus();
			return false;
		}
		if(document.getElementById("otherparty").value == '')
		{
			alert("Enter Account Number");
			document.getElementById("otherparty").focus();
			return false;
		}
		if(document.getElementById("shpmode").value == '')
		{
			alert("Select Company");
			document.getElementById("shpmode").focus();
			return false;
		}
	}
	
	//if(document.getElementById("btnstatus").value!="" && document.getElementById("creditlimit").value!="") 
//	{
//		if(document.getElementById("creditlimit").checked==false)
//		{
//			alert("Select the Check Box");	
//			document.getElementById("creditlimit").focus();
//			return false;
//		}
//	}

	if(objForm.chkAgree)
	{
		if(objForm.chkAgree.checked==false && document.getElementById("tdAgree").style.display=="block")
		{
			alert("Please check the Credit Card Authorization");
			blExit=true;
		}
	}
			
	//alert(document.f1.bGrandTotal.value)
	//alert(document.getElementById("usedcreditlimit").value)
	//alert(document.getElementById("creditlimit").value)
	if((document.getElementById("creditlimit").value>0) && (document.getElementById("paytype").value!="CC" || document.getElementById("paytype").value!="PP"))
	{
		if(parseFloat(document.f1.bGrandTotal.value)+parseFloat(document.getElementById("usedcreditlimit").value)>parseFloat(document.getElementById("creditlimit").value))
		{
			remaningdays=document.getElementById("remaningdays").value;
			//alert("The Current Order Amount is more than Pending Credits. Due clear before "+remaningdays+" Days");
			alert("Thank You for ordering.  Your order amount is greater than available credit limit. This order will ship partially or please contact customer care to make payment of balance amount." );
			//document.getElementById("creditlimit").checked=false;
			//document.getElementById("creditlimit").focus();
			//return false;
		}		
	}		
				
	if(blExit==false)
	{
		return true;
	}
	else
	{
		return false;
	}
	
	
	
}

//function chkcreditlimit()
//{
//	if(document.getElementById("creditlimit").checked==true)
//	{
//		//alert(document.f1.bGrandTotal.value)
//		//alert(document.getElementById("creditlimit").value)
//		//alert(document.getElementById("usedcreditlimit").value)
//		
//		if(parseFloat(document.f1.bGrandTotal.value)+parseFloat(document.getElementById("usedcreditlimit").value)>parseFloat(document.getElementById("creditlimit").value))
//		{
//			remaningdays=document.getElementById("remaningdays").value;
//			alert("The Current Order Amount is more than Pending Credits. Due clear before "+remaningdays+" Days");	
//			//document.getElementById("creditlimit").checked=false;
//			//document.getElementById("creditlimit").focus();
//			//return false;
//		}
//	}
//}

//This function works as Trim function of VB
function Trim(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}

//  check for valid numeric strings	
function IsNumeric(oObject)
{
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function IsCreditCard(oObject)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0 || strString.length<13 || strString.length>17) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

//  check for valid strings	
function IsCharacter(oObject)
{
   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_. ,";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

//Validation for Proper Ip Address
function IsIP (oObject) {
var IPvalue=oObject.value;
errorString = "";
theName = "IPaddress";

var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var ipArray = IPvalue.match(ipPattern); 

if (IPvalue == "0.0.0.0")
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
else if (IPvalue == "255.255.255.255")
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
if (ipArray == null)
errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
else {
for (i = 0; i < 4; i++) {
thisSegment = ipArray[i];
if (thisSegment > 255) {
errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';
i = 4;
}
if ((i == 0) && (thisSegment > 255)) {
errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';
i = 4;
      }
   }
}
extensionLength = 3;
if (errorString == "")
return true;
else
return false;
}

//Validation for proper Email address
function IsEmail(oObject) {
var emailStr=oObject.value;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Email address seems incorrect (check @ and .'s)");
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];

if (user.match(userPat)==null) {
    alert("The username doesn't seem to be valid. Please check or register fresh");
    return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!");
		return false;
	    }
    }
    return true;
}

var domainArray=domain.match(domainPat);
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.");
    return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.");
   return false;
}


if (len<2) {
   var errStr="This address is missing a hostname!";
   alert(errStr);
   return false;
}
return true;
}

//Validation for proper directory path
function IsPath(oObject)
{
	strPath=oObject.value;
	var strValidChars = "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if(strPath=="")
	{
		alert("Enter proper path");
	}
	var strChar=strPath.charAt(0);
	if (strValidChars.indexOf(strChar) == -1)
	{
		alert("Drive letter is missing")
		return false;
	}
	strChar=strPath.charAt(1);
	if(strChar!=":")
	{
		alert(": missing after drive letter");
		return false;
	}
	strChar=strPath.charAt(2);
	if(strChar!="\\")
	{
		alert("\\ slash is missing after drive letter")
		return false;
	}
	strChar=strPath.charAt(strPath.length-1);
	if(strChar=="\\")
	{
		strChar="";
		for(var intI=0;intI<(strPath.length-1);intI++)
		{
			strChar=strChar + strPath.charAt(intI);
		}
		strPath=strChar;
		oObject.value=strPath;
	}
	return true;
}
//  check for valid strings	
function IsSpl(oObject)
{
   var strValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_. ,";
   var strChar;
   var blnResult = true;
   var strString=oObject.value;	
   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

//This function select all the values in SelectionList control
function SelectAllSelection(objList)
{
	objList.multiple=true;
	if (objList.options.length!=-1)
	{
    	if(objList.options.length>1)
    	{
			for(var intCounter=0;intCounter<objList.options.length;intCounter++)
       		{
				objList.options[intCounter].selected=true;
       		}
    	}
	}
  	else
  	{
      objList.options[0].selected=true;
   	}
}

//This function checks for the limit of Characters entered by the user
function LimitChar(objField,intLimit)
{
	if(objField.value.length>intLimit)
	{
		alert("You cannot enter more then " + intLimit + " characters in this field !");
		objField.value=objField.value.substring(0,intLimit);
		objField.focus();
	}
}

function datecheck(frmname)
{
	var d1=new Date();
	currmonth=d1.getMonth();
	curryear=d1.getYear();
	totcnt=0;
	var fn=eval(frmname);
	if(document.getElementById("opExpiryMonth"))
	{
		for(i=0;i<fn.elements.length;++i)
		{
			if(fn.elements[i].name=="opExpiryMonth")
			{
				++totcnt;
			}
		}
	}
	for(i=1;i<=totcnt;++i)
	{
		if(i==1)
		{
			blnvalid=true;
			if(fn.opExpiryYear[i-1].value==curryear)
			{
				if(fn.opExpiryMonth[i-1].value<=currmonth)
				{
					blnvalid=false;
				}
			}
			if(fn.opExpiryYear[i-1].value<curryear && blnvalid)
			{
				blnvalid=false;
			}
			if(!blnvalid)
			{
				alert("Please Select Valid Month and Year Combination");
				fn.opExpiryMonth[i-1].focus();
				return blnvalid;
			}
		}
		else
		{
			if(fn.opExpiryYear[i-1].value!="")
			{
				blnvalid=true;
				if(fn.opExpiryYear[i-1].value==curryear)
				{
					if(fn.opExpiryMonth[i-1].value<=currmonth)
					{
						blnvalid=false;
					}
				}
				if(fn.opExpiryYear[i-1].value<curryear && blnvalid)
				{
					blnvalid=false;
				}
				if(!blnvalid)
				{
					alert("Please Select Valid Month and Year Combination");
					fn.opExpiryMonth[i-1].focus();
					return blnvalid;
				}
			}
		}
	}
	return true;
}

