function IsNumber(sText,Label)
{

   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   if(sText=="") {alert(Label+ " Should not be Empty");return false}
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   if(!IsNumber)
   	alert(Label+ " Must Be numeric")
   return IsNumber;
}
function IsonBlurNumber(sText,Label,element)
{
   var ValidChars = "0123456789";
   var IsDigit=true;
   var Char;
   sText=trim(sText);
   if(sText!="")
   {
   for (i = 0; i < sText.length && IsDigit == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsDigit = false;
      }
   }
   if(!IsDigit)
   {   
   	alert(Label+ " must be numeric!");
	element.focus();
	element.select();
   }
  }
  return IsDigit;
}

function IsAlphaNumeric(sText,Label)
{

   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '.,'!@$-+&-_/";
   var IsAlphaNumeric=true;
   var Char;
   if(sText=="") {alert(Label+ " Should not be Empty");return false}
   for (i = 0; i < sText.length && IsAlphaNumeric == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsAlphaNumeric = false;
      }
   }
   if(!IsAlphaNumeric)
	   	alert(Label+ " Must Be Alphaumeric")
   return IsAlphaNumeric;
}
function IsFullyAlphaNumeric(sText,Label)
{

   var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
   var IsAlphaNumeric=true;
   var Char;
   if(sText=="") {alert(Label+ " Should not be Empty");return false}
   for (i = 0; i < sText.length && IsAlphaNumeric == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsAlphaNumeric = false;
      }
   }
   if(!IsAlphaNumeric)
	   	alert(Label+ " Must Be Alphaumeric")
   return IsAlphaNumeric;
}

function IsFax(sText,Label)
{
   var ValidChars = "0123456789-() ";
   var IsNumber=true;
   var Char;
   if(sText=="") {alert(Label+ " Should not be Empty");return false}
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   if(!IsNumber)
   	alert(Label+ " Must Be in Format eg:229-230-4443 or (229)-230-4443")
   return IsNumber;
}

function IsAmount(sText)
{
   var ValidChars = "0123456789.";
   var IsAmount=true;
   var Char;
   if(sText=="") return false
   for (i = 0; i < sText.length && IsAmount == true; i++) 	
   { 
		 Char = sText.charAt(i); 
		 if (ValidChars.indexOf(Char) == -1) 
         {
    	     IsAmount = false;
         }
   }
   return IsAmount;
}

function IsValidAmount(sText,Label)
{
	if(!IsAmount(sText))
	{
		alert("Invalid "+Label+".. "+Label+" Must Have Numeric Values")
		return false;
	}
	AmtArray = sText.split(".")
	if(AmtArray.length>2)
	{
		alert("Invalid "+Label+".. "+Label+" Must have single Period for Float")
		return false;
	}
	if(AmtArray.length>1)
	{
		FloatAmt = AmtArray[1];
		if(FloatAmt.length>2)
		{
			alert("Invalid "+Label+"..  Float Value must have two Digits")
			return false;
		}
	}
	return true
}


function IsFloat(sText,Label)
{
	if(!IsAmount(sText))
	{
		alert("Invalid "+Label+".. "+Label+" Must Have Numeric Values")
		return false;
	}
	AmtArray = sText.split(".")
	if(AmtArray.length>2)
	{
		alert("Invalid "+Label+".. "+Label+" Must have single Period for Float")
		return false;
	}
	return true
}

function isEmailAddr(email,Label) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (true)
}
alert("Invalid "+Label+" Address! Please re-enter.")
return (false)
}

function IsEmail(sText,Label,element)
{
  var isEmail=false;
  sText=trim(sText);
  if(sText!="")
  {
  var email = new String(sText);
  var index = email.indexOf("@");
  if (index > 0)
  {
    var pindex = email.indexOf(".",index);
    if ((pindex > index+1) && (email.length > pindex+1))
	isEmail= true;
  }
 if(!isEmail)
 {
   alert("Invalid "+Label+": Must be in format name@site.domain");
   element.focus();
   element.select();
 } 
 }
}

function trim(Val)
{
	while(''+Val.charAt(0)==' ')
	Val=Val.substring(1,Val.length);
	return Val
}

function IsValid(Val,Label)
{
	if(trim(Val)=="")
	{
		alert(Label+" Should Not be Empty")
		return false
	}
	return true
}

function splitText(theNotes)
{
		theString = theNotes.split("\n")
		NewString = ""
		for(i=0;i<theString.length;i++)
		{
			NewString+=theString[i]+"|"
		}
		return NewString
}
function floatRound(number,X) {
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,Label){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy for "+Label)
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+" for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
return true
}
function isValidDate(dtStr,Label){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy for "+Label)
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+" for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date for "+Label+"\nDate Format is mm/dd/yyyy")
		return false
	}
return true
}
function WatchDelete(frm)
{
	frm=eval("document."+frm);
				isSelected = false;
				for(i=0; i<frm.elements.length; i++)
				{
					if(frm.elements[i].name == "chkSite[]" && frm.elements[i].checked)	
					{
						isSelected = true;
						break;
					}
				}
				if(isSelected)
				{
					if( confirm("Are you sure to Remove the Selected Items from the list"))
					{
						frm.w_Action.value=1;
						frm.submit();
					}
				}	
				else
				{
					alert("Please select the Items to be Removed");
				}

}
function CheckExt(value,label)
	{
		var ext = value.split(".")
		ext[1]=ext[1].toUpperCase();
		if(label.indexOf(ext[1]) == -1)
			return false;
		else
			return true;
	}
	
	function getPopupX(popupx){
		PopupLeft    = (screen.width-popupx)/2;
		return PopupLeft;
	}
	function getPopupY(popupy){
		PopupTop     = (screen.height-popupy)/2;
		return PopupTop;
	}
	
	function IsValidURL(strURL,n)
	{
		strURL 		= strURL.toUpperCase();
//		alert(strURL)		
		if(strURL==""||strURL=="HTTP://") return false	
		thePrefix 	= strURL.substr(0,7).toUpperCase();
		var Prefix2 = strURL.substr(0,8).toUpperCase();
		if( thePrefix!="HTTP://" )
		{ 
			siteFlag = 0;
			return false;
		}
		else
		siteFlag = 1;	
		if ( Prefix2!="HTTPS://" && siteFlag == 0 ) return false;
		if(n!=-1) if(strURL.split("/").length>n) return false;
		
		return true
	}
	
function IsaCardno(fld)
{ 
	var result=true
	var st=fld.value

	if(!isNaN(st) && st.length>12 && st.length<17)
	{
	
		var adig=parseInt(st.charAt(0))
		var twodig=parseInt(st.substring(0,2))
		var fourdig=parseInt(st.substring(0,4)) 
		
		if(st.length==13) {if(adig==4){result=false}}
		else if(st.length==15)
		{
			if(!(twodig==34 || twodig==37)){result=false}
		}
		else if(st.length==16)
		{
		if(!(adig==4 || fourdig==6011 || twodig==16 || (twodig>50 && twodig<55)))
			{result=false}
		}
		else 
		{
			result=false
			alert("Incorrect number of digits")    
		}
		if(!result){alert("Incorrect prefix")}
		else
		{
			var sum=0
			var v=0
			for(var i=1; i<st.length+1; i++)
			{
				v=parseInt(st.charAt(st.length-i))
				if(i % 2 ==0)
					{sum=sum+(v*2) % 10 + Math.floor((v*2)/10)}
				else
				{sum=sum+v}
			}//for i
			if(sum % 10)
			{
				result=false
				alert("fails LUHN check")
			}
		}//luhn check
	}//if correct length
	else
	{
		result=false
		alert("Incorrect number of digits")
	}

	if(!result)
	{
		fld.select()
	}
	return result
}	
function setAdminCatPage(pno)
{ 
// page no process
	document.frmCategory.pageno.value=pno;
	document.frmCategory.submit();
}

function setAdminProdPage(pno)
{ 
// page no process
	document.frmProduct.pageno.value=pno;
	document.frmProduct.submit();
}
function setAdminAuctPage(pno)
{ 
// page no process
	document.frmAuction.pageno.value=pno;
	document.frmAuction.submit();
}

function setUserPage(pno,frm)
{ 
// page no process
	frm.pageno.value=pno;
	frm.submit();
}

function isEmpty(value,lable,a,frm)
{
		if(!IsValid(value,lable))
		{
			frm[a].focus();
			return true;
		}
}
//Function Used to go to Admin View Program from View all program
function AdminView(frm,obj,val,dest)
{
	obj=eval("document."+frm+"."+obj);
	frm=eval("document."+frm);
	obj.value=val;
	frm.action=dest;
	frm.submit();
}

//Function Used to go to Admin Edit  Program from View all program
function AdminEdit(frm,obj,val,dest)
{
	obj=eval("document."+frm+"."+obj);
	frm=eval("document."+frm);
	obj.value=val;
	
	frm.action=dest;
	frm.submit();
}
function AdminBid(frm,obj,val,dest)
{
	obj=eval("document."+frm+"."+obj);
	frm=eval("document."+frm);
	obj.value=val;
	frm.action=dest;
	frm.submit();
}

//Function Used to go to Admin Edit  Program from View all program
function AdminSite(frm,obj,val,dest)
{
	obj=eval("document."+frm+"."+obj);
	frm=eval("document."+frm);
	obj.value=val;
	frm.hfFrom.value	= 1;
	frm.action=dest;
	frm.submit();
}
//Function Used to go delete selected Record
function AdminDelete(frm,obj,val,msg)
{
	if(confirm("Do You Really want to Delete "+msg+"?"))
	{
		objDel=eval("document."+frm+".hfDelCatId");
		obj=eval("document."+frm+"."+obj);
		frm=eval("document."+frm);
		objDel.value = 1;
		obj.value=val;
		frm.submit();
	}
}
function AdminAuctionSearch()
{
document.frmAuctionSearch.action="auctions_view.php";
document.frmAuctionSearch.submit();
}
function ShowAuctionProducts(obj,frm)
{
	if (document.all)
    	    var xMax = (screen.width-650)/2, yMax = (screen.height-450)/2;
	 else if (!document.all && document.getElementById)
	       var xMax = (window.innerWidth-650)/2, yMax = (window.innerHeight-450)/2;
obj=eval("document."+frm+"."+obj);
if( obj.selectedIndex != 0 )
{
	var id = obj.value;
	window.open("category_products_view.php?catid="+id,"CategoryProductList","location=no,status=no,scrollbars=yes,resize=no,width=650,height=450,left="+xMax+",top="+yMax)
}
else
{
	alert("Please Select a Category to View its Products.");
	obj.focus();
}	
	
//window.open("category_products_view.php","","location=no,status=yes,resize=no");
}
function AdminSelect(frm,obj,val,ctrl,Strcode,Strname)
{
	obj			= eval("window.opener.document."+frm+"."+obj);
	obj1		= eval("window.opener.document."+frm+"."+ctrl);
	obj1.value	= Strcode +" - "+ Strname;
	obj.value	= val;
	window.close();
}
function ValidateAdminAuctionInput(frm)
{
	if(frm.selCategory.selectedIndex == 0 )
	{
		alert("Please Select a Category");
		frm.selCategory.focus();
		return false;
	}
	if(!IsAlphaNumeric(frm.txtProductCode.value,"Product Code"))
	{
		frm.txtProductCode.focus();
		return false;
	}
	if(!IsAlphaNumeric(frm.txtProductName.value,"Product Name"))
	{
		frm.txtProductName.focus();
		return false;
	}
	if(frm.txtGalleryImage.value=="")
	{
		alert("Please Enter the Gallery Image");
		return false;
	}

	if(frm.txtGalleryImage.value!="")
	{
		MyFile = frm.txtGalleryImage.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtGalleryImage.focus()
			return false
		}
	}
	if(frm.txtImage.value=="")
	{
		alert("Please Enter the Product Image");
		return false;
	}

	if(frm.txtImage.value!="")
	{
		MyFile = frm.txtImage.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtImage.focus()
			return false
		}
	}
		if(frm.txtLogoImage.value=="")
	{
		alert("Please Enter the Logo Image");
		return false;
	}

		
	if(frm.txtLogoImage.value!="")
	{
		MyFile = frm.txtLogoImage.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtLogoImage.focus()
			return false
		}
	}
	if(frm.txtAuctionType[1].checked)
	{
		if(!IsNumber(frm.txtQuantity.value,"Quantity"))
		{
			frm.txtQuantity.focus();
			return false;		
		}
	
	}
	if(!IsValidAmount(frm.txtPrice.value,"Price"))
	{
		frm.txtPrice.focus();
		return false;
	}
	
	if(frm.txtStartDate.value=="")
	{
		alert("Please Enter Valid Auction Start Date");
		frm.txtStartDate.focus();
		return false;
	}
		var dd = new Date();
		var CDate  = dd.getDate();
		var CDat = String(CDate).length;
		if(CDat == 1)	{
			var CDate="0"+CDate;
		}
		var CMonth = dd.getMonth();
		var CMonth = CMonth+1;	
		var CMonthl = String(CMonth).length;
		if(CMonthl == 1)	{
			var CMonth="0"+CMonth;
		}
		var CYear = dd.getFullYear();
		var Today=(CMonth+"/"+CDate+"/"+CYear);
		if(frm.txtStartDate.value < Today)	{
		alert("Auction Start Date should be greater than Todays Date");
		return false;
	}
	if(frm.txtEndDate.value=="")
	{
		alert("Please Enter Valid Auction End Date");
		frm.txtEndDate.focus();
		return false;
	}
		var dd = new Date();
		var CDate  = dd.getDate();
		var CDat = String(CDate).length;
		if(CDat == 1)	{
			var CDate="0"+CDate;
		}
		var CMonth = dd.getMonth();
		var CMonth = CMonth+1;	
		var CMonthl = String(CMonth).length;
		if(CMonthl == 1)	{
			var CMonth="0"+CMonth;
		}
		var CYear = dd.getFullYear();
		var Today=(CMonth+"/"+CDate+"/"+CYear);
		if(frm.txtEndDate.value < Today)	{
		alert("Auction End Date should be greater than Todays Date");
		return false;
	}

	
	var startdt=frm.txtStartDate.value;
	var mon=startdt.substr(0,2);
	var dt=startdt.substr(3,2);
	var yr=startdt.substr(6,4);
	var TempStart = yr+mon+dt;
	var resstr=mon+"/"+dt+"/"+yr;
	
	var StartDate =new Date(resstr);

	var StartDateNum = parseInt(TempStart);
	var enddt=frm.txtEndDate.value;

	var mon1=enddt.substr(0,2);
	var dt1=enddt.substr(3,2);
	var yr1=enddt.substr(6,4);
	var TempEnd = yr1+mon1+dt1;		
	var resstr1=mon1+"/"+dt1+"/"+yr1;
	
	
	var EndDate =new Date(resstr1);

	var EndDateNum = parseInt(TempEnd);	
	if(StartDateNum > EndDateNum)
	{
		alert("Start Date Should be less than End Date");
		return false;
	}
	if(!IsValidAmount(frm.txtStartBid.value,"Starting Bid Amount"))
	{
		frm.txtStartBid.focus();
		return false;
	}
	if(!IsValidAmount(frm.txtShipCost.value,"Shipping Cost"))
	{
		frm.txtShipCost.focus();
		return false;
	}
	if( frm.selFeatureAuction.selectedIndex == 0 )	
	{
		alert("Please Select Option of Auction Feature");
		frm.selFeatureAuction.focus();
		return false;
	}
}
function ValidateAdminAuctionInputEdit(frm)
{
	
	if(frm.selCategory.selectedIndex == 0 )
	{
		alert("Please Select a Category");
		frm.selCategory.focus();
		return false;
	}
	if(!IsAlphaNumeric(frm.txtProductCode.value,"Product Code"))
	{
		frm.txtProductCode.focus();
		return false;
	}
	if(!IsAlphaNumeric(frm.txtProductName.value,"Product Name"))
	{
		frm.txtProductName.focus();
		return false;
	}
	/*if(!IsValid(frm.txtDescription.value,"Product Description"))
	{
		frm.txtDescription.focus();
		return false;
	}*/
	if(frm.txtGallery.value!="")
	{
		MyFile = frm.txtGallery.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtGallery.focus()
			return false
		}
	}
	if(frm.txtImage.value!="")
	{
	//	alert(frm.txtImage.value);
		
		MyFile = frm.txtImage.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtImage.focus()
			return false
		}
	}
	if(frm.txtLogoImage.value!="")
	{
		//alert(frm.txtLogoImage.value);
		
		MyFile = frm.txtLogoImage.value
		FileArray = MyFile.split("\\")
		FileName = FileArray[FileArray.length-1]
		ExtArray = FileName.split(".")
		Ext = ExtArray[ExtArray.length-1]
		Ext = Ext.toUpperCase(Ext)
		if(!(Ext=="JPG"||Ext=="JPE"))
		{
			alert("Invalid Upload File! Upload jpeg or jpg File Only")
			frm.txtLogoImage.focus()
			return false
		}
	}
	
	if(frm.selAuctionStatus.value == "Added")
	{
		if(frm.txtAuctionType[1].checked)
		{
			if(!IsNumber(frm.txtQuantity.value,"Quantity"))
			{
				frm.txtQuantity.focus();
				return false;		
			}
		
		}
		else	{
			frm.txtQuantity.value	= 0;
		}
	}

	 
	if(frm.selAuctionStatus.value == "Added")
	{
		if(!IsValidAmount(frm.txtPrice.value,"Price"))
		{
			frm.txtPrice.focus();
			return false;
		}
	}
	/*
	if(frm.selNewProduct.selectedIndex==0)
	{
		alert("Please Select an Option of New Product");
		frm.selNewProduct.focus();
		return false;
	}
	if(frm.selFeatureProduct.selectedIndex==0)
	{
		alert("Please Select an Option of Featured Product");
		frm.selFeatureProduct.focus();
		return false;
	}
	if(frm.selProductStatus.selectedIndex==0)
	{
		alert("Please Select an Option of Product Status");
		frm.selProductStatus.focus();
		return false;
	}
	*/
	if(frm.selAuctionStatus.value == "Added")
	{
		if(frm.txtStartDate.value=="")
		{
			alert("Please Enter Valid Auction Start Date");
			return false;
		}
	}
	if(frm.selAuctionStatus.value == "Added" || frm.selAuctionStatus.value == "Opened")
	{
		if(frm.txtEndDate.value=="")
		{
			alert("Please Enter Valid Auction End Date");
			return false;
		}
	}
	if(frm.selAuctionStatus.value == "Added")
	{	
	var startdt=frm.txtStartDate.value;
	
	var mon=startdt.substr(0,2);
	var dt=startdt.substr(3,2);
	var yr=startdt.substr(6,4);
	var TempStart = yr+mon+dt;
	var resstr=mon+"/"+dt+"/"+yr;
	
	var StartDate =new Date(resstr);
	
	var StartDateNum = parseInt(TempStart);
	var enddt=frm.txtEndDate.value;

	var mon1=enddt.substr(0,2);
	var dt1=enddt.substr(3,2);
	var yr1=enddt.substr(6,4);
	var TempEnd = yr1+mon1+dt1;		
	var resstr1=mon1+"/"+dt1+"/"+yr1;
	}
	if(frm.selAuctionStatus.value == "Added" || frm.selAuctionStatus.value == "Opened")
	{	

	var EndDate =new Date(resstr1);
	var dd = new Date();
	var CDate = dd.getDate();
	var CMonth = dd.getMonth();
	var CYear = dd.getFullYear();
	var todate=(CYear+"/"+CMonth+"/"+CDate);
	var EndDateNum = parseInt(TempEnd);
	if(EndDateNum < todate)
	{
		alert("End Date Should be less than Today Date");
		return false;
	}
	if(StartDateNum > EndDateNum)
	{
		alert("Start Date Should be less than End Date");
		return false;
	}}

	if(frm.selAuctionStatus.value == "Added" )	{	
	if(!IsValidAmount(frm.txtStartBid.value,"Starting Bid Amount"))
	{
		frm.txtStartBid.focus();
		return false;
	}
	}	

	/*
	if(!IsValidAmount(frm.txtNextBidInc.value,"Next Bid Increment"))
	{
		frm.txtNextBidInc.focus();
		return false;
	}
	*/
	if(frm.selAuctionStatus.value == "Added" || frm.selAuctionStatus.value == "Opened" || frm.selAuctionStatus.value == "Closed")	{	
	if(!IsValidAmount(frm.txtShipCost.value,"Shipping Cost"))
	{
		frm.txtShipCost.focus();
		return false;
	}
	if( frm.selFeatureAuction.selectedIndex == 0 )	
	{
		alert("Please Select Option of Auction Feature");
		frm.selFeatureAuction.focus();
		return false;
	}
	}
	/*
	if( frm.selAuctionStatus.selectedIndex == 0 )	
	{
		alert("Please Select Option of Auction Status");
		frm.selAuctionStatus.focus();
		return false;
	}
	*/
}

function AdminImageView(ImgWidth,ImgHeight,ProdImgId)
{
	if (document.all)
    	    var xMax = (screen.width-ImgWidth)/2, yMax = (screen.height-ImgHeight)/2;
	 else if (!document.all && document.getElementById)
	       var xMax = (window.innerWidth-ImgWidth)/2, yMax = (window.innerHeight-ImgHeight)/2;

	var newwidth	= ImgWidth+20;
	var newheight	= ImgHeight+30;
	window.open("product_actual_image.php?ImgId="+ProdImgId,"AdminProductImageView","location=no,status=no,scrollbars=yes,resize=no,width="+newwidth+",height="+newheight+",left="+xMax+",top="+yMax)
}
function FrontImageView(ImgWidth,ImgHeight,ProdImgId)
{
	if (document.all)
    	    var xMax = (screen.width-ImgWidth)/2, yMax = (screen.height-ImgHeight)/2;
	 else if (!document.all && document.getElementById)
	       var xMax = (window.innerWidth-ImgWidth)/2, yMax = (window.innerHeight-ImgHeight)/2;

	var newwidth	= ImgWidth+25;
	var newheight	= ImgHeight+57;
	window.open("product_actual_image.php?ImgId="+ProdImgId,"ProductImageView","location=no,status=no,scrollbars=yes,resize=no,width="+newwidth+",height="+newheight+",left="+xMax+",top="+yMax)
}

function IsPasswordLength(sPass1,sPass2)
{
	if(trim(sPass1)=="")
	{
		alert("Password Should Not be Empty")
		return false
	}
	
	if(sPass1!=sPass2)
	{
		alert("Password Mismatch")
		return false
	}
/*	IsFound = false
	for(i=0;i<objBlock.length && !IsFound ;i++)
	{
		reg = new RegExp(objBlock[i])
		if(sPass1.match(reg))
		{
			IsFound = true
		}
	}
	if(IsFound)
	{
		alert("Password should not have "+strLabel)
		return false
	}*/
	return true;
}
function IsonBlurPassword(sText,Label,element)
{
	if(!IsValid(sText,"Password"))
		{
			element.focus();
			return false;
		}	
	else
		if(sText.length<6)
		{
			alert("Password should be minimum 6 Characters");
			element.focus();
			return false;
		}
}
function IsonConfirmPassword(Pass1,Pass2,element)
{
	if(!IsValid(Pass2,"Retype Password"))
		{
			element.focus();
			return false;
		}	
	else
		if(Pass1!= Pass2)
		{
			alert("Password Mismatch");
			element.focus();
			return false;
		}
}

function IsEmailLength(sPass1,sPass2)
{
	if(trim(sPass1)=="")
	{
		alert("Email Should Not be Empty")
		return false
	}
	
	if(sPass1!=sPass2)
	{
		alert("Email Mismatch")
		return false
	}
/*	IsFound = false
	for(i=0;i<objBlock.length && !IsFound ;i++)
	{
		reg = new RegExp(objBlock[i])
		if(sPass1.match(reg))
		{
			IsFound = true
		}
	}
	if(IsFound)
	{
		alert("Password should not have "+strLabel)
		return false
	}*/
	return true;
}

//function which validates admin details
function ValidateAdminData(frm)
{
	if(!IsValid(frm.txtFirstName.value,"First Name"))
	{
		frm.txtFirstName.focus();
		return false;
	}
	if(!IsValid(frm.txtLastName.value,"Last Name"))
	{
		frm.txtLastName.focus();
		return false;
	}
	if(!isEmailAddr(frm.txtEmail.value))
	{
		alert("Please Enter Valid Email Address.");
		frm.txtEmail.focus();
		return false;
	}
	/*
	if(!IsValid(frm.txtWebTitle.value,"Website Title"))
	{
		frm.txtWebTitle.focus();
		return false;
	}
	if(!IsValid(frm.txtSite.value,"Website Address"))
	{
		frm.txtSite.focus();
		return false;
	}
	*/
	if(frm.selSite.selectedIndex == 0)
	{
		alert("Please Select One Website");
		frm.selSite.focus();
		return false;
	}
	if(!IsValid(frm.txtLoginName.value,"Login Name"))
	{
		frm.txtLoginName.focus();
		return false;
	}
	if(!IsValid(frm.txtPassword.value,"Password"))
	{
		frm.txtPassword.focus();
		return false;
	}
	if(!IsValid(frm.txtCPassword.value,"Retype Password"))
	{
		frm.txtCPassword.focus();
		return false;
	}
	if(!IsPasswordLength(frm.txtPassword.value,frm.txtCPassword.value))
	{
		frm.txtPassword.focus();
		return false;
	}
	if(frm.selAdminStatus.selectedIndex == 0)
	{
		alert("Please Select one option of Status");
		frm.selAdminStatus.focus();
		return false;
	}
}//End of Function

//function which validates admin details
function ValidateAdminDataEdit(frm)
{
	if(!IsValid(frm.txtLoginName.value,"Login Name"))
	{
		frm.txtLoginName.focus();
		return false;
	}
	if(!IsValid(frm.txtFirstName.value,"First Name"))
	{
		frm.txtFirstName.focus();
		return false;
	}
	if(!IsValid(frm.txtLastName.value,"Last Name"))
	{
		frm.txtLastName.focus();
		return false;
	}
	if(!isEmailAddr(frm.txtEmail.value))
	{
		alert("Please Enter Valid Email Address.");
		frm.txtEmail.focus();
		return false;
	}
	if(frm.selSite.selectedIndex == 0)
	{
		alert("Please Select One Website");
		frm.selSite.focus();
		return false;
	}
	/*
	if(!IsValid(frm.txtPassword.value,"Password"))
	{
		frm.txtPassword.focus();
		return false;
	}
	if(!IsValid(frm.txtCPassword.value,"Retype Password"))
	{
		frm.txtCPassword.focus();
		return false;
	}
	if(!IsPasswordLength(frm.txtPassword.value,frm.txtCPassword.value))
	{
		frm.txtPassword.focus();
		return false;
	}*/
	if(frm.selAdminStatus.selectedIndex == 0)
	{
		alert("Please Select one option of Status");
		frm.selAdminStatus.focus();
		return false;
	}
}//End of Function
function searchGoClicked()
{
	document.SearchForm.action="searc"
}
function ValidateSiteData(frm)
{
	if(!IsValid(frm.txtTitle.value,"Website Title"))
	{
		frm.txtTitle.focus();
		return false;
	}
	if(!IsValid(frm.txtSite.value,"Website Address"))
	{
		frm.txtSite.focus();
		return false;
	}
	if(!IsValid(frm.txtSite.value,"Website Address"))
	{
		frm.txtSite.focus();
		return false;
	}
	else if(!IsValidURL(frm.txtSite.value))
	{
		alert("Please Enter Valid Url. Url must contain Http://");
		frm.txtSite.focus();
		return false;
	}
	if(!IsValid(frm.txtDescription.value,"Description"))
	{
		frm.txtDescription.focus();
		return false;
	}
	if( frm.selSiteStatus.selectedIndex == 0 )
	{	
		alert("Please Select a Website Status");
		frm.selSiteStatus.focus();
		return false;
	}
}//End of Function
function ValidateCurrency(frm)
{
	if(!IsValid(frm.txtCode.value,"Code"))
	{
		frm.txtCode.focus();
		return false;
	}
	if(!IsValid(frm.txtName.value,"Name"))
	{
		frm.txtName.focus();
		return false;
	}
	if(!IsFloat(frm.txtValue.value,"USD Value"))
	{
		frm.txtValue.focus();
		return false;
	}
	if(!IsValid(frm.txtSymbol.value,"Symbol"))
	{
		frm.txtSymbol.focus();
		return false;
	}
	if( frm.selStatus.selectedIndex == 0 )
	{	
		alert("Please Select a Status Status");
		frm.selStatus.focus();
		return false;
	}
}//
function AdminSetChecked(val,frm,ctrlName)
{
	  ptr=eval("document."+frm);
	  len=ptr.elements.length;
	  var i=0;
	  for(i=0; i<len; i++){
			if (ptr.elements[i].name == ctrlName) 
			{
			   ptr.elements[i].checked=val;
			}
	   }
}//End of Function
function CheckAnyOneSelected(frm,ctrlName,str,itemname)
{
	  ptr=eval("document."+frm);
	  len=ptr.elements.length;
	  var i=0;
	  var y=0;
	  for(i=0; i<len; i++){
			if (ptr.elements[i].name==ctrlName) 
			{ 
				   if(ptr.elements[i].checked == 1)
				   {
						   y=1;
				   }
			}
		}
		if( y != 1)
		{
			 alert("You first need to select to "+str);
			 return false;
		}
		if(confirm("Are your sure to "+str+" ?"))
		{
			 ptr.hfAssignMultiple.value=1;
		}
		else
		{
			return false;
		}	
}//End of Function
function CheckBidData(frm)
{
	
//	alert(frm.hfBid[5].value);
//	alert(frm.hfBid.length);

	var totalCtrls		= frm.hfBid.length;
	totalCtrls			= totalCtrls - 1;
	var NewStartVal  = parseFloat(frm.txtStartRange1.value);
	var NewEndVal	 = parseFloat(frm.txtEndRange1.value);
	var NewIncVal	 = parseFloat(frm.txtIncrement1.value);
	var Newdiff		 = NewEndVal - NewStartVal;


	for(var i=0; i < totalCtrls; i++)
	{
		//First Check Each Row Has Valid values ie Start Value < End Value 
//		alert(frm.StartRange[i]);
		if(!IsValidAmount(frm.StartRange[i].value,"Bid Start Amount  "+i))
		{
			frm.StartRange[i].focus();
			return false;
		}
		if(!IsValidAmount(frm.EndRange[i].value,"Bid End Amount"))
		{
			frm.EndRange[i].focus();
			return false;
		}
		if(!IsValidAmount(frm.Increment[i].value,"Bid Increment Amount"))
		{
			frm.Increment[i].focus();
			return false;
		}
		
		var StartVal = parseFloat(frm.StartRange[i].value);
		var EndVal	 = parseFloat(frm.EndRange[i].value);
		var IncVal	 = parseFloat(frm.Increment[i].value);
		var diff	 = EndVal - StartVal;
//		alert("Start ="+StartVal+"===End ="+EndVal);
		if( StartVal >= EndVal )
		{
			alert("Bid Start Amount should be less than Bid End Amount.");
			frm.StartRange[i].focus();
			return false;
		}//End if
		if( IncVal > diff )
		{
			alert("Bid Increment Value should be less than or equal to \n Difference between Bid Start Amount and Bid End Amount.");
			frm.Increment[i].focus();
			return false;
		}//End if
		
//Checking Current End Bid Value is less than or equal to next Start Bid Value. if not raise an error msg
			var k = i + 1;
			if( k != totalCtrls)
			{
				if( !IsValidAmount(frm.StartRange[k].value," Bid Start Amount."))
				{
					frm.StartRange[k].focus();
					return false;
				}//End of if
				var NextStartVal = parseFloat(frm.StartRange[k].value);
				if( EndVal > NextStartVal)
				{
					alert("Current Bid Start Amount should be less than Previous Bid End Amount.");
					frm.StartRange[k].focus();
					return false;
				}
			}
//			alert( "K="+k+"==Ctrl:"+totalCtrls);
			if( k == totalCtrls )
			{
//				alert("Testing"+frm.txtStartRange1.value);
				if(frm.txtStartRange1.value !="" )
				{

					var KStart = parseFloat(frm.EndRange[i].value);
//					alert("In Test k="+KStart+" actual ="+NewStartVal)					
					if( NewStartVal < KStart )
					{
						alert("Current Bid Start Amount should be less than Previous Bid End Amount.");
						frm.txtStartRange1.focus();
						return false;
					}//End of Start Value  Equal Checking if
				}
			}
			
	}//End of For
		
	//Check For Duplicates except the current row
	if( frm.txtStartRange1.value != "" || frm.txtEndRange1.value != "" || frm.txtIncrement1.value !="" )
	{
		if(!IsValidAmount(frm.txtStartRange1.value,"New Bid Start Amount"))
		{
			frm.txtStartRange1.focus();
			return false;
		}
		if(!IsValidAmount(frm.txtEndRange1.value,"New Bid End Amount"))
		{
			frm.txtEndRange1.focus();
			return false;
		}
		if(NewStartVal >= NewEndVal)
		{
			alert("Bid Start Amount Should be Less than Bid End Amount");
			frm.txtStartRange1.focus();
			return false;
		}
		if(!IsValidAmount(frm.txtIncrement1.value,"New Bid Increment Amount"))
		{
			frm.txtIncrement1.focus();
			return false;
		}//End of if
		if( Newdiff < NewIncVal )
		{
			alert("Bid Increment Amount should be less than Difference between Bid Start Amount \n and Bid End Amount.")
			frm.txtIncrement1.focus();
			return false;
		}//End of if
	}//End of if
}//End of Function
function ValidateAuctionImages( frm )
{
//Product Main Image
	if(frm.txtImage.value!="")
	{
			MyFile = frm.txtImage.value;
			FileArray = MyFile.split("\\");
			FileName = FileArray[FileArray.length-1];
			ExtArray = FileName.split(".");
			Ext = ExtArray[ExtArray.length-1];
			Ext = Ext.toUpperCase(Ext);
			//if(!(Ext=="GIF"||Ext=="JPG"||Ext=="JPE"||Ext=="PNG"||Ext=="BMP"))
			if(!(Ext=="JPG"||Ext=="JPE"))
			{
				alert("Selected File is not an  JPG/JPEG Image File!... Please Upload  JPG/JPEG Image File Only for Product Main Image.");
				frm.txtImage.focus();
				return false;
			}//End of if		
	}//End of if

//Gallery Image
	if(frm.txtGalleryImage.value!="")
	{
			MyFile = frm.txtGalleryImage.value;
			FileArray = MyFile.split("\\");
			FileName = FileArray[FileArray.length-1];
			ExtArray = FileName.split(".");
			Ext = ExtArray[ExtArray.length-1];
			Ext = Ext.toUpperCase(Ext);
			//if(!(Ext=="GIF"||Ext=="JPG"||Ext=="JPE"||Ext=="PNG"||Ext=="BMP"))
			if(!(Ext=="JPG"||Ext=="JPE"))
			{
				alert("Selected File is not an  JPG/JPEG Image File!... Please Upload  JPG/JPEG Image File Only for Gallery Image.");
				frm.txtGalleryImage.focus();
				return false;
			}//End of if		
	}//End of if
//Company Logo Image
	if(frm.txtLogoImage.value!="")
	{
			MyFile = frm.txtLogoImage.value;
			FileArray = MyFile.split("\\");
			FileName = FileArray[FileArray.length-1];
			ExtArray = FileName.split(".");
			Ext = ExtArray[ExtArray.length-1];
			Ext = Ext.toUpperCase(Ext);
			//if(!(Ext=="GIF"||Ext=="JPG"||Ext=="JPE"||Ext=="PNG"||Ext=="BMP"))
			if(!(Ext=="JPG"||Ext=="JPE"))
			{
				alert("Selected File is not an  JPG/JPEG Image File!... Please Upload  JPG/JPEG Image File Only for Company Logo Image.");
				frm.txtLogoImage.focus();
				return false;
			}//End of if		
	}//End of if
	if(frm.txtImage.value == "" && frm.txtGalleryImage.value == "" && frm.txtLogoImage.value == "")
	{
		alert("Please Upload Atleast one image ");
		return false;
	}//End of if
}//End of Function
function ValidateTemplate(frm)
{
	if(!IsValid(frm.txtTemplateName.value,"Template Name"))
	{
		frm.txtTemplateName.focus();
		return false;
	}
	
	if(!IsValid(frm.txtFromName.value,"Template Name"))
	{
		frm.txtFromName.focus();
		return false;
	}
	if(!IsValid(frm.txtFromEmailAddress.value,"Template Name"))
	{
		frm.txtFromEmailAddress.focus();
		return false;
	}
	if(!IsValid(frm.txtSubject.value,"Template Name"))
	{
		frm.txtSubject.focus();
		return false;
	}	//end of if
	/*
	if(!IsValid(frm.TA.value,"Template Content"))
	{
//		frm.txtTemplateContent.focus();
		return false;
	}//end of if
	*/
	return false;
	
}//End of Function
//Function which is used in Auction Details Page of User Part and validates max bix amount
function ValidateMaxBid(frm,currVal,nextVal)
{
	if( !IsValidAmount(frm.txtMaxBid.value,"Maxmimum Bid Amount"))
	{
		frm.txtMaxBid.focus();
		return false;
	}//End of if
	var nextBidAmt	= currVal + nextVal ;
	var MaxAmt	= parseFloat( frm.txtMaxBid.value );

	if( MaxAmt < nextBidAmt )
	{
		alert("Your Maxmimum Bid Amount should be greater than or equal to " + nextBidAmt );
		frm.txtMaxBid.focus();
		return false;
	}//End of if
}//End of Function 
function ValidateRegn( frm )
{
	if( !IsValid( frm.txtFirstName.value,"First Name" ) )
	{
		frm.txtFirstName.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtLastName.value,"Last Name" ) )
	{
		frm.txtLastName.focus();
		return false;
	}//End of if
	if( frm.selDay.selectedIndex == 0 )
	{
		alert("Please Select Valid Day for Date of Birth");
		frm.selDay.focus();
		return false;
	}//End of if
	if( frm.selMonth.selectedIndex == 0 )
	{
		alert("Please Select Valid Month for Date of Birth");
		frm.selMonth.focus();
		return false;
	}//End of if
	if(!IsNumber(frm.txtYear.value,"Date of Birth - Year "))
	{
		frm.txtYear.focus();
		return false;
	}//End of if
	
	var yr = frm.txtYear.value;
	if( yr.length < 4 )
	{
		alert("Year Should Have 4 Digits. eg: 1970");
		frm.txtYear.focus();
		return false;
	}//End of If
	var intYr	= parseInt( frm.txtYear.value );
	if(intYr < 1900 )
	{
		alert("Please Enter Valid Year of Date of Birth");
		frm.txtYear.focus();
		return false;
	}//End of if
	

	var dt = frm.selMonth.value+"/"+frm.selDay.value+"/"+frm.txtYear.value;

	if(!isDate(dt,"Date of Birth"))
	{
		frm.selDay.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtAddressLine1.value,"Address Line 1" ) )
	{
		frm.txtAddressLine1.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtCity.value,"City" ) )
	{
		frm.txtCity.focus();
		return false;
	}//End of if
	
	if(frm.selState.selectedIndex == 0 && frm.txtState.value == "" )
	{
		alert("Please Select or Enter State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selState.selectedIndex == 1 )
	{
		if(!IsValid(frm.txtState.value,"State"))
		{
			frm.txtState.focus();
			return false;
		}
	}//End of if
	if(  frm.txtState.value != ""  &&   frm.selState.selectedIndex != 1 )
	{
		alert("Please Select Non - US option to enter Other State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selCountry.selectedIndex == 0 )
	{
		alert("Please Select a Country.");
		frm.selCountry.focus();
		return false;
	}//End of if
		
	if(!IsValid(frm.txtZip.value,"Zip / Postal Code"))
	{
		frm.txtZip.focus();
		return false;
	}//End of if
	if( !IsFax( frm.txtPrimaryPhone.value,"Primary Telephone" ) )
	{
		frm.txtPrimaryPhone.focus();
		return false;
	}//End of if
	if( frm.txtSecondaryPhone.value != "" )
	{
		if( !IsFax( frm.txtSecondaryPhone.value,"Secondary Telephone" ) )
		{
			frm.txtSecondaryPhone.focus();
			return false;
		}//End of if
	}//end of if
	if( !isEmailAddr(frm.txtEmail.value) )
	{
		alert("Please enter Valid Email Address");
		frm.txtEmail.focus();
		return false;
	}//End of if
	if( !IsValid(frm.txtCEmail.value,"Retype Email address" ))
	{
		frm.txtCEmail.focus();
		return false;
	}//End of if
	if( !IsEmailLength(frm.txtEmail.value,frm.txtCEmail.value ) )
	{
		frm.txtEmail.focus();
		return false;
	}
	if( frm.chkAgree.checked == false )
	{
		alert(" You Should check the User Agreement Checkbox to become a Registered Member");
		return false;
	}//End of if
}//End of Function

function ValidateUserLoginDet(frm)
{
	var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
	if( !IsValid(frm.txtUserName.value,"User Name") )
	{
		frm.txtUserName.focus();
		return false;
	}//End of if
	if( !IsFullyAlphaNumeric(frm.txtUserName.value,"UserName") )
	{
		frm.txtUserName.focus();
		return false;
	}//End of if
	var userNm	= frm.txtUserName.value;
	var nmLen	= userNm.length;
	if( nmLen < 6 )
	{
		alert("User Name Should have atleast 6 Characters");
		frm.txtUserName.focus();
		return false;
	}//end of if
	if( !IsValid(frm.txtPassword.value,"Password") )
	{
		frm.txtPassword.focus();
		return false;
	}//End of If
	
	var pwdVal		= frm.txtPassword.value;
	var pwdLen		= pwdVal.length;
	if( pwdLen < 6 )
	{
		alert("Password Should have atleast 6 Characters.");
		frm.txtPassword.focus();
		return false;
	}//End of if
	if( !IsValid(frm.txtCPassword.value,"Retype Password") )
	{
		frm.txtCPassword.focus();
		return false;
	}//End of If
	
	if( !IsPasswordLength(frm.txtPassword.value,frm.txtCPassword.value))
	{
		frm.txtPassword.focus();
		return false;
	}
	function Delete(frm,obj,val,msg)
{
	if(confirm("Do You Really want to Delete "+msg+"?"))
	{
		obj=eval("document."+frm+"."+obj);
		frm=eval("document."+frm);
		obj.value=val;
		frm.submit();
	}
}

	
}//End of Function


function ValidateEdit( frm )
{
	if( !IsValid( frm.txtFirstName.value,"First Name" ) )
	{
		frm.txtFirstName.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtLastName.value,"Last Name" ) )
	{
		frm.txtLastName.focus();
		return false;
	}//End of if
	if( frm.selDay.selectedIndex == 0 )
	{
		alert("Please Select Valid Day for Date of Birth");
		frm.selDay.focus();
		return false;
	}//End of if
	if( frm.selMonth.selectedIndex == 0 )
	{
		alert("Please Select Valid Month for Date of Birth");
		frm.selMonth.focus();
		return false;
	}//End of if
	if(!IsNumber(frm.txtYear.value,"Date of Birth - Year "))
	{
		frm.txtYear.focus();
		return false;
	}//End of if
	
	var yr = frm.txtYear.value;
	if( yr.length < 4 )
	{
		alert("Year Should Have 4 Digits. eg: 1970");
		frm.txtYear.focus();
		return false;
	}//End of If
	var intYr	= parseInt( frm.txtYear.value );
	if(intYr < 1900 )
	{
		alert("Please Enter Valid Year of Date of Birth");
		frm.txtYear.focus();
		return false;
	}//End of if
	

	var dt = frm.selMonth.value+"/"+frm.selDay.value+"/"+frm.txtYear.value;

	if(!isDate(dt,"Date of Birth"))
	{
		frm.selDay.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtAddressLine1.value,"Address Line 1" ) )
	{
		frm.txtAddressLine1.focus();
		return false;
	}//End of if
	if( !IsValid(frm.txtAddressLine2.value,"Address Line 2") )
	{
		frm.txtAddressLine2.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtCity.value,"City" ) )
	{
		frm.txtCity.focus();
		return false;
	}//End of if
	
	if(frm.selState.selectedIndex == 0 && frm.txtState.value == "" )
	{
		alert("Please Select or Enter State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selState.selectedIndex == 1 )
	{
		if(!IsValid(frm.txtState.value,"State"))
		{
			frm.txtState.focus();
			return false;
		}
	}//End of if
	if(  frm.txtState.value != ""  &&   frm.selState.selectedIndex != 1 )
	{
		alert("Please Select Non - US option to enter Other State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selCountry.selectedIndex == 0 )
	{
		alert("Please Select a Country.");
		frm.selCountry.focus();
		return false;
	}//End of if
		
	if(!IsValid(frm.txtZip.value,"Zip / Postal Code"))
	{
		frm.txtZip.focus();
		return false;
	}//End of if
	if( !IsFax( frm.txtPrimaryPhone.value,"Primary Telephone" ) )
	{
		frm.txtPrimaryPhone.focus();
		return false;
	}//End of if
	if( frm.txtSecondaryPhone.value != "" )
	{
		if( !IsFax( frm.txtSecondaryPhone.value,"Secondary Telephone" ) )
		{
			frm.txtSecondaryPhone.focus();
			return false;
		}//End of if
	}//end of if
}

function ValidateDetails( frm )
{
	if( !IsValid( frm.txtFirstName.value,"First Name" ) )
	{
		frm.txtFirstName.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtLastName.value,"Last Name" ) )
	{
		frm.txtLastName.focus();
		return false;
	}//End of if
	
	
	

	if( !IsValid( frm.txtAddressLine1.value,"Address Line 1" ) )
	{
		frm.txtAddressLine1.focus();
		return false;
	}//End of if
	
	if( !IsValid( frm.txtCity.value,"City" ) )
	{
		frm.txtCity.focus();
		return false;
	}//End of if
	
	if(frm.selState.selectedIndex == 0 && frm.txtState.value == "" )
	{
		alert("Please Select or Enter State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selState.selectedIndex == 1 )
	{
		if(!IsValid(frm.txtState.value,"State"))
		{
			frm.txtState.focus();
			return false;
		}
	}//End of if
	if(  frm.txtState.value != ""  &&   frm.selState.selectedIndex != 1 )
	{
		alert("Please Select Non - US option to enter Other State Name");
		 frm.selState.focus();
		return false;
	}//End of if
	if( frm.selCountry.selectedIndex == 0 )
	{
		alert("Please Select a Country.");
		frm.selCountry.focus();
		return false;
	}//End of if
		
	if(!IsValid(frm.txtZip.value,"Zip / Postal Code"))
	{
		frm.txtZip.focus();
		return false;
	}//End of if
	if( !IsFax( frm.txtPrimaryPhone.value,"Primary Telephone" ) )
	{
		frm.txtPrimaryPhone.focus();
		return false;
	}//End of if
	if( frm.txtSecondaryPhone.value != "" )
	{
		if( !IsFax( frm.txtSecondaryPhone.value,"Secondary Telephone" ) )
		{
			frm.txtSecondaryPhone.focus();
			return false;
		}//End of if
	}//end of if
	
	//Shipping details
	if( !IsValid( frm.txtSFirstName.value,"First Name for Shipping" ) )
	{
		frm.txtSFirstName.focus();
		return false;
	}//End of if
	if( !IsValid( frm.txtSLastName.value,"Last Name for Shipping" ) )
	{
		frm.txtSLastName.focus();
		return false;
	}//End of if
	
	
	

	if( !IsValid( frm.txtAddressLine1.value,"Address Line 1 for Shipping" ) )
	{
		frm.txtAddressLine1.focus();
		return false;
	}//End of if
	
	if( !IsValid( frm.txtSCity.value,"City for Shipping" ) )
	{
		frm.txtSCity.focus();
		return false;
	}//End of if
	
	if(frm.selSState.selectedIndex == 0 && frm.txtSState.value == "" )
	{
		alert("Please Select or Enter State Name");
		 frm.selSState.focus();
		return false;
	}//End of if
	if( frm.selSState.selectedIndex == 1 )
	{
		if(!IsValid(frm.txtSState.value,"State for Shipping"))
		{
			frm.txtSState.focus();
			return false;
		}
	}//End of if
	if(  frm.txtSState.value != ""  &&   frm.selSState.selectedIndex != 1 )
	{
		alert("Please Select Non - US option to enter Other State Name for Shipping");
		 frm.selSState.focus();
		return false;
	}//End of if
	if( frm.selSCountry.selectedIndex == 0 )
	{
		alert("Please Select a Country for Shipping.");
		frm.selSCountry.focus();
		return false;
	}//End of if
		
	if(!IsValid(frm.txtSZip.value,"Zip / Postal Code for Shipping"))
	{
		frm.txtZip.focus();
		return false;
	}//End of if
	if( !IsFax( frm.txtSPrimaryPhone.value,"Primary Telephone for Shipping" ) )
	{
		frm.txtSPrimaryPhone.focus();
		return false;
	}//End of if
	if( frm.txtSSecondaryPhone.value != "" )
	{
		if( !IsFax( frm.txtSSecondaryPhone.value,"Secondary Telephone for Shipping" ) )
		{
			frm.txtSSecondaryPhone.focus();
			return false;
		}//End of if
	}//end of if
}