function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

function overlayclose(c){
	document.getElementById(c).style.display = "none";
}

function ContentDisplay(d) {
	for (var j=1;j<=3;j++)
	{
		var st=document.getElementById("subcontent"+j);
		if(st.style.display=="block") 
		{st.style.display="none";} 
	} 
	document.getElementById(d).style.display = "block";
}

function showhide(pagename) {
document.getElementById("viewdisplay").style.display="block";
if(document.getElementById('viewinput')){
document.getElementById('viewinput').style.display = "none";
}
window.location="wdadminbanner.php?pagename="+pagename;
}

/*function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}*/

// This is to check search options whether category and city are chosen
function checkSearch() {
	catid = document.getElementById("categoryopt").value;
	cityid = document.getElementById("cityopt").value;
	if(catid < 1) {
		alert("Please select category");
		document.getElementById("categoryopt").focus();
		return false;
	}
	if(cityid < 1) {
		alert("Please select city");
		document.getElementById("cityopt").focus();
		return false;
	}
	return true;
}

function checkResellerForm() {
	
	if(!CheckName(document.resellerfrm.nametxt.value, "Center Name")) {
		document.resellerfrm.nametxt.focus();
		return false;
	}
	if(trim(document.resellerfrm.addresstxt.value) == "") {
		alert("Address should not be empty");
		document.resellerfrm.addresstxt.focus();
		return false;
	}
	if(document.resellerfrm.cityopt.value == 0) {
		alert("Please select city");
		document.resellerfrm.cityopt.focus();
		return false;
	}
	if(!CheckNumber(document.resellerfrm.pintxt.value, "Pincode")) {
		document.resellerfrm.pintxt.focus();
		return false;
	}
	if(!CheckPhone(document.resellerfrm.telephonetxt.value, "Telephone")) {
		document.resellerfrm.telephonetxt.focus()
		return false;
	}
	if(document.resellerfrm.emailtxt.value != "") {
		if(!CheckEmailAddr(document.resellerfrm.emailtxt.value,"Email")) {
			document.resellerfrm.emailtxt.focus();
			return false;
		}
	}
	return true;
}

function checkResellerSearch() {
	if((trim(document.resellersearchfrm.nametxt.value) == "") && (document.resellersearchfrm.cityopt.value == 0)) {
		alert("Center Name or City should not be empty");
		document.resellersearchfrm.nametxt.focus();
		return false;
	}
	return true;
}

function showResellerPaging(pageno) {
	
	document.resellersearchfrm.action = "wdadminviewreseller.php?page=" + pageno;
	document.resellersearchfrm.submit();
}

function openReseller(ResellerCode) {
	window.open('wdadminresellerdetails.php?ResellerID=' + ResellerCode,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function editReseller(ResellerCode) {
	window.location.href = "wdadmineditreseller.php?ResellerID=" + ResellerCode;
}

function deleteReseller(ResellerCode) {
	if(!confirm ("Are you sure want to delete")) return false;
	window.location.href = "wdadmindeletereseller.php?ResellerID=" + ResellerCode;
}

function closePopup() {
	window.close();
	opener.document.forms[0].action = opener.location.href;
	opener.document.forms[0].submit();
}

function checkaddlisting() {
	if(document.addlistingfrm.categoryopt.value ==0) {
		alert("Please select Category");
		document.addlistingfrm.categoryopt.focus();
		return false;
	}
	if(document.addlistingfrm.Adtypeopt.value ==0) {
		alert("Please select Ad Type");
		document.addlistingfrm.Adtypeopt.focus();
		return false;
	}
	if(!CheckName(document.addlistingfrm.nametxt.value, "Business Name")) {
		document.addlistingfrm.nametxt.focus();
		return false;
	}
	if(!CheckName(document.addlistingfrm.contacttxt.value, "Contact Person")) {
		document.addlistingfrm.contacttxt.focus();
		return false;
	}
	if(!CheckPhone(document.addlistingfrm.phonetxt.value, "Phone Number")) {
		document.addlistingfrm.phonetxt.focus();
		return false;
	}
	if(!CheckMobile(document.addlistingfrm.mobiletxt.value, "Mobile Number")) {
		document.addlistingfrm.mobiletxt.focus();
		return false;
	}
	if(trim(document.addlistingfrm.addresstxt.value) == "") {
		alert("Address should not be empty");
		document.addlistingfrm.addresstxt.focus();
		return false;
	}
	if(document.addlistingfrm.cityopt.value == 0) {
		alert("Please select city");
		document.addlistingfrm.cityopt.focus();
		return false;
	}
	if(document.addlistingfrm.emailtxt.value != "") {
		if(!CheckEmailAddr(document.addlistingfrm.emailtxt.value,"Email")) {
			document.addlistingfrm.emailtxt.focus();
			return false;
		}
	}
	if(trim(document.addlistingfrm.descriptiontxt.value) == "") {
		alert("Description should not be empty");
		document.addlistingfrm.descriptiontxt.focus();
		return false;
	}
	if(document.addlistingfrm.landingurltxt.value != "") {
		if(!isURL(document.addlistingfrm.landingurltxt.value)) {
			alert("Invalid Landing Page URL");
			document.addlistingfrm.landingurltxt.focus();
			return false;
		}
	}
	if(document.addlistingfrm.siteurltxt.value != "") {
		if(!isURL(document.addlistingfrm.siteurltxt.value)) {
			alert("Invalid Site URL");
			document.addlistingfrm.siteurltxt.focus();
			return false;
		}
	}
	if(document.addlistingfrm.productopt.value == 0) {
		alert("Please select Product Type ");
		document.addlistingfrm.productopt.focus();
		return false;
	}
	if(document.addlistingfrm.Adtypeopt.value == 2 && (document.addlistingfrm.productopt.value == 1 || document.addlistingfrm.productopt.value == 2 || document.addlistingfrm.productopt.value == 3)) {
	}
	else if(document.addlistingfrm.Adtypeopt.value == 3 && (document.addlistingfrm.productopt.value== 4 || document.addlistingfrm.productopt.value == 5 || document.addlistingfrm.productopt.value == 6)) {
	}
	else if(document.addlistingfrm.Adtypeopt.value == 4 && (document.addlistingfrm.productopt.value == 7 || document.addlistingfrm.productopt.value == 8 || document.addlistingfrm.productopt.value == 9)) {
	}
	else {
		alert("Ad Type and Product Type Mismatch");
		document.addlistingfrm.productopt.focus();
		return false;
	}
	if(document.addlistingfrm.paymentmodeopt.value == 0) {
		alert("Please select Pament Mode");
		document.addlistingfrm.paymentmodeopt.focus();
		return false;
	}
	if(trim(document.addlistingfrm.paymentdatetxt.value) == "") {
		alert("Payment Date should not be empty");
		document.addlistingfrm.paymentdatetxt.focus();
		return false;
	}
	if(!IsValidAmount(document.addlistingfrm.amounttxt.value, "Amount Paid")) {
		document.addlistingfrm.amounttxt.focus();
		return false;
	}
	if(!IsValidAmount(document.addlistingfrm.discounttxt.value, "Discount")) {
		document.addlistingfrm.discounttxt.focus();
		return false;
	}
	if(trim(document.addlistingfrm.resellercodetxt.value) == "") {
		alert("Reseller Code should not be empty");
		document.addlistingfrm.resellercodetxt.focus();
		return false;
	}
	/*var btn = valButton(document.addlistingfrm.TopCategory);
	if (btn == null) {
	alert('Please select Top Category Ads');
	return false;
	}*/
	return true;
}

/* start add top banner */
function checkaddtopbanner() {
/*	if(document.addtopbannerfrm.categoryopt.value ==0) {
		alert("Please select Category");
		document.addtopbannerfrm.categoryopt.focus();
		return false;
	}
	*/
	if(trim(document.addtopbannerfrm.bannertxt.value) == "") {
		alert("Banner should not be empty");
		document.addtopbannerfrm.bannertxt.focus();
		return false;
	}
	if(document.addtopbannerfrm.siteurltxt.value != "") {
		if(!isURL(document.addtopbannerfrm.siteurltxt.value)) {
			alert("Invalid Site URL");
			document.addtopbannerfrm.siteurltxt.focus();
			return false;
		}
	}
	if(trim(document.addtopbannerfrm.siteurltxt.value) == "") {
		alert("URL should not be empty");
		document.addtopbannerfrm.siteurltxt.focus();
		return false;
	}
	if(trim(document.addtopbannerfrm.fromdatetxt.value) == "") {
		alert("Please select From date");
		return false;
	}
	if(trim(document.addtopbannerfrm.todatetxt.value) == "") {
		alert("Please select To date");
		return false;
	}
/*	if(trim(document.addtopbannerfrm.descriptiontxt.value) == "") {
		alert("Description should not be empty");
		document.addtopbannerfrm.descriptiontxt.focus();
		return false;
	}
*/		
	return true;
}
/* end add top banner*/
/*start Edit top banner*/ 
function checkedittopbanner(){
if(document.addtopbannerfrm.siteurltxt.value != "") {
		if(!isURL(document.addtopbannerfrm.siteurltxt.value)) {
			alert("Invalid Site URL");
			document.addtopbannerfrm.siteurltxt.focus();
			return false;
		}
	}
	if(trim(document.addtopbannerfrm.siteurltxt.value) == "") {
		alert("URL should not be empty");
		document.addtopbannerfrm.siteurltxt.focus();
		return false;
	}
/*
	if(trim(document.addtopbannerfrm.descriptiontxt.value) == "") {
		alert("Description should not be empty");
		document.addtopbannerfrm.descriptiontxt.focus();
		return false;
	}*/
	return true;
}
/* end Edit top banner*/
function checkaddfreelisting() {
	if(document.addlistingfrm.categoryopt.value ==0) {
		alert("Please select Category");
		document.addlistingfrm.categoryopt.focus();
		return false;
	}
	if(!CheckName(document.addlistingfrm.nametxt.value, "Business Name")) {
		document.addlistingfrm.nametxt.focus();
		return false;
	}
	if(!CheckPhone(document.addlistingfrm.phonetxt.value, "Phone Number")) {
		document.addlistingfrm.phonetxt.focus();
		return false;
	}
	if(!CheckMobile(document.addlistingfrm.mobiletxt.value, "Mobile Number")) {
		document.addlistingfrm.mobiletxt.focus();
		return false;
	}
	if(trim(document.addlistingfrm.addresstxt.value) == "") {
		alert("Address should not be empty");
		document.addlistingfrm.addresstxt.focus();
		return false;
	}
	if(document.addlistingfrm.cityopt.value == 0) {
		alert("Please select city");
		document.addlistingfrm.cityopt.focus();
		return false;
	}
	return true;
}

function checkeditlisting() {
	if(document.editlistingfrm.categoryopt.value ==0) {
		alert("Please select Category");
		document.editlistingfrm.categoryopt.focus();
		return false;
	}
	if(document.editlistingfrm.Adtypeopt.value ==0) {
		alert("Please select Ad Type");
		document.editlistingfrm.Adtypeopt.focus();
		return false;
	}
	if(!CheckName(document.editlistingfrm.nametxt.value, "Business Name")) {
		document.editlistingfrm.nametxt.focus();
		return false;
	}
	if(!CheckName(document.editlistingfrm.contacttxt.value, "Contact Person")) {
		document.editlistingfrm.contacttxt.focus();
		return false;
	}
	if(!CheckPhone(document.editlistingfrm.phonetxt.value, "Phone Number")) {
		document.editlistingfrm.phonetxt.focus();
		return false;
	}
	if(!CheckMobile(document.editlistingfrm.mobiletxt.value, "Mobile Number")) {
		document.editlistingfrm.mobiletxt.focus();
		return false;
	}
	if(trim(document.editlistingfrm.addresstxt.value) == "") {
		alert("Address should not be empty");
		document.editlistingfrm.addresstxt.focus();
		return false;
	}
	if(document.editlistingfrm.cityopt.value == 0) {
		alert("Please select city");
		document.editlistingfrm.cityopt.focus();
		return false;
	}
	if(document.editlistingfrm.emailtxt.value != "") {
		if(!CheckEmailAddr(document.editlistingfrm.emailtxt.value,"Email")) {
			document.editlistingfrm.emailtxt.focus();
			return false;
		}
	}
	if(trim(document.editlistingfrm.descriptiontxt.value) == "") {
		alert("Description should not be empty");
		document.editlistingfrm.descriptiontxt.focus();
		return false;
	}
	if(document.editlistingfrm.landingurltxt.value != "") {
		if(!isURL(document.editlistingfrm.landingurltxt.value)) {
			alert("Invalid Landing Page URL");
			document.editlistingfrm.landingurltxt.focus();
			return false;
		}
	}
	if(document.editlistingfrm.siteurltxt.value != "") {
		if(!isURL(document.editlistingfrm.siteurltxt.value)) {
			alert("Invalid Site URL");
			document.editlistingfrm.siteurltxt.focus();
			return false;
		}
	}
	return true;
}

function checkeditfreelisting() {
	if(document.editlistingfrm.categoryopt.value ==0) {
		alert("Please select Category");
		document.editlistingfrm.categoryopt.focus();
		return false;
	}
	if(!CheckName(document.editlistingfrm.nametxt.value, "Business Name")) {
		document.editlistingfrm.nametxt.focus();
		return false;
	}
	if(!CheckPhone(document.editlistingfrm.phonetxt.value, "Phone Number")) {
		document.editlistingfrm.phonetxt.focus();
		return false;
	}
	if(trim(document.editlistingfrm.addresstxt.value) == "") {
		alert("Address should not be empty");
		document.editlistingfrm.addresstxt.focus();
		return false;
	}
	if(document.editlistingfrm.cityopt.value == 0) {
		alert("Please select city");
		document.editlistingfrm.cityopt.focus();
		return false;
	}
	return true;
}

function checkadvertise() {
	if(!CheckName(document.advertisefrm.nametxt.value, "Company Name")) {
		document.advertisefrm.nametxt.focus();
		return false;
	}
	if(document.advertisefrm.categoryopt.value ==0) {
		alert("Please select Product / Service Type");
		document.advertisefrm.categoryopt.focus();
		return false;
	}
	if(!CheckName(document.advertisefrm.cperson.value, "Contact Person")) {
		document.advertisefrm.cperson.focus();
		return false;
	}
	if(!CheckPhone(document.advertisefrm.phonetxt.value, "Contact Number")) {
		document.advertisefrm.phonetxt.focus();
		return false;
	}
	if(!CheckMobile(document.advertisefrm.mobiletxt.value, "Mobile Number")) {
		document.advertisefrm.mobiletxt.focus();
		return false;
	}
	if(trim(document.advertisefrm.addresstxt.value) == "") {
		alert("Contact Address should not be empty");
		document.advertisefrm.addresstxt.focus();
		return false;
	}
	if(!CheckEmailAddr(document.advertisefrm.emailtxt.value,"Email")) {
			document.advertisefrm.emailtxt.focus();
			return false;
	}
	if(document.advertisefrm.cityopt.value == 0) {
		alert("Please select city");
		document.advertisefrm.cityopt.focus();
		return false;
	}
	if(trim(document.advertisefrm.descriptiontxt.value) == "") {
		alert("Description should not be empty");
		document.advertisefrm.descriptiontxt.focus();
		return false;
	}
	return true;
}

function checkpaymentfrm() {
	if(document.paymentupgradefrm.productopt.value == 0) {
		alert("Please select Product Type ");
		document.paymentupgradefrm.productopt.focus();
		return false;
	}
	if(document.paymentupgradefrm.paymentmodeopt.value == 0) {
		alert("Please select Payment Mode");
		document.paymentupgradefrm.paymentmodeopt.focus();
		return false;
	}
	if(trim(document.paymentupgradefrm.paymentdatetxt.value) == "") {
		alert("Payment Date should not be empty");
		document.paymentupgradefrm.paymentdatetxt.focus();
		return false;
	}
	if(!IsValidAmount(document.paymentupgradefrm.amounttxt.value, "Amount Paid")) {
		document.paymentupgradefrm.amounttxt.focus();
		return false;
	}
	if(!IsValidAmount(document.paymentupgradefrm.discounttxt.value, "Discount")) {
		document.paymentupgradefrm.discounttxt.focus();
		return false;
	}
	if(trim(document.paymentupgradefrm.resellercodetxt.value) == "") {
		alert("Reseller Code should not be empty");
		document.paymentupgradefrm.resellercodetxt.focus();
		return false;
	}
	return true;
}

function openTopbanner(AdNo) {
	window.open('wdadmindtopbannerdetails.php?adID=' + AdNo,'','width=585,height=520,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}
function edittopbanner(AdNo,act) {
	//window.open('wdadmindtopbannerdetails.php?adID=' + AdNo+'&action='+act,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
bannerStatus=document.tpbannerlist.status.value;
document.tpbannerlist.action='wdadmindtopbannerdetails.php?adID=' + AdNo+'&action='+act+'&bs='+bannerStatus;
document.tpbannerlist.submit();
}
function openResellerCode() {
	window.open('wdadminresellercodelist.php','','width=300,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function selectResellerCode(val) {
	opener.document.forms[0].resellercodetxt.value = val;
	window.close();
}

function checkListingSearch() {
	if((document.searchlistfrm.categoryopt.value < 1) && (document.searchlistfrm.cityopt.value < 1)) {
		alert("Please select category and city");
		return false;
	}
	return true;
}

function openDirList(AdNo) {
	window.open('wdadmindirlistdetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function editdirlist(AdNo) {
	window.location.href = "wdadmineditlisting.php?adID=" + AdNo;
}

function deletedirlist(AdNo) {
	if(!confirm ("Are you sure want to delete")) return false;
	window.location.href = "wdadmindeletelisting.php?adID=" + AdNo;
}

function openDirFreeList(AdNo) {
	window.open('wdadmindirfreelistdetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function openReviewList(AdNo) {
	window.open('wdadminreviewdetails.php?adID=' + AdNo,'','width=650,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
}

function openTestimoniallist(Id) {
	window.open('wdadmintestmonialdetails.php?Id=' + Id,'','width=350,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
}

function openReviewEdit(RevId) {
	window.open('wdadminreviewedit.php?RevID=' + RevId,'','width=500,height=300,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
}
function openAdsReportList(AdNo) {
	window.open('wdadminadsreportdetails.php?adID=' + AdNo,'','width=650,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
}
function openAdSmsList(AdNo) {
	window.open('wdadminadssmsdetails.php?adID=' + AdNo,'','width=650,height=500,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
}

function editTestimoniallist(Id) {
	window.location.href = "wdadminedittestimonial.php?ID=" + Id;
}

function deleteTestimoniallist(Id) {
	if(!confirm ("Are you sure want to delete")) return false;
	window.location.href = "wdadmindeletetestimonial.php?ID=" + Id;
}

function editdirfreelist(AdNo) {
	window.location.href = "wdadmineditfreelisting.php?adID=" + AdNo;
}

function deletedirfreelist(AdNo) {
	if(!confirm ("Are you sure want to delete")) return false;
	window.location.href = "wdadmindeletefreelisting.php?adID=" + AdNo;
}

function openUploads(fname) {
	window.open(fname,'','width=200,height=200,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');	
}

function openBannerUploads(fname,width,height) {
	window.open(fname,'','width='+width+',height='+height+',menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');	
}

function closeListingPopup() {
	window.close();
	opener.document.forms[0].action = opener.location.href;
	opener.document.forms[0].submit();
}

function checkPeriodicalReport() {
	if(trim(document.reportfrm.fromdatetxt.value) == "") {
		alert("Please select From date");
		return false;
	}
	if(trim(document.reportfrm.todatetxt.value) == "") {
		alert("Please select To date");
		return false;
	}
	return true;
}

function openReportList(AdNo) {
	window.open('wdadminreportdetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function openDetailedReport(fromdate, todate) {
	window.open('wdadmindetailedreport.php?fromdate=' + fromdate + '&todate=' + todate,'','width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function getExpiryReport() {
	window.open('wdadminexpiryreport.php','','width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function getPaymentPendingReport() {
	window.open('wdadminpaymentpending.php','','width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function openPayPendingList(AdNo) {
	window.open('wdadminpaymentpendingdetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function paymentupgrate(AdNo) {
	window.location.href = "wdadminpaymentupgrade.php?AdNo=" + AdNo;
}

function openPayUpgradeList(AdNo) {
	window.open('wdadminpaymentupgradedetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}
/*
function editpaymentpending(AdNo) {
	window.location.href = "wdadmineditpaymentpending.php?adID=" + AdNo;
}
*/
function getOnlinePaymentReport() {
	window.open('wdadminonlinepayment.php','','width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function openOnlinePayList(AdNo) {
	window.open('wdadminonlinepaymentdetails.php?adID=' + AdNo,'','width=585,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}

function closePayPendingPopup() {
	window.close();
	opener.document.forms[0].action = opener.location.href;
	opener.document.forms[0].submit();
}

// Global functions

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(trim(sText) == "")
	{
		alert(Label+" should not be empty")
		return false;
	}
	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 CheckNumber(sText,Label)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   if(trim(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 isURL(argvalue) {

  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("http://") == -1)
    return false;
  else if (argvalue == "http://")
    return false;
  else if (argvalue.indexOf("http://") > 0)
    return false;

  argvalue = argvalue.substring(7, argvalue.length);
  if (argvalue.indexOf(".") == -1)
    return false;
  else if (argvalue.indexOf(".") == 0)
    return false;
  else if (argvalue.charAt(argvalue.length - 1) == ".")
    return false;

  if (argvalue.indexOf("/") != -1) {
    argvalue = argvalue.substring(0, argvalue.indexOf("/"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }

  if (argvalue.indexOf(":") != -1) {
    if (argvalue.indexOf(":") == (argvalue.length - 1))
      return false;
    else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
      return false;
    argvalue = argvalue.substring(0, argvalue.indexOf(":"));
    if (argvalue.charAt(argvalue.length - 1) == ".")
      return false;
  }

  return true;

}

function CheckEmailAddr(email,Label){
	var result = false;
	var theStr = new String(email);
	if(trim(theStr) == "") {alert(Label+ " Should not be Empty");return false}
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(theStr)) {
		result=true;
	}
	if(!result) alert("Invalid " + Label);
	return result;
}

function CheckPhone(sText,Label)
{
   var ValidChars = "0123456789(),/-+ ";
   var IsNumber=true;
   var Char;
   if(trim(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("Invalid " + Label)
   return IsNumber;
}

function CheckMobile(sText,Label)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   if(trim(sText)=="") {return true;}
   for (i = 0; i < sText.length && IsNumber == true;i++) 
   { 
      Char = sText.charAt(i); 
      if(ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   if(sText.length == 10) {
	   if(sText.charAt(0) != "9")
		   IsNumber = false;
   }
   else if(sText.length == 11) {
	   if(sText.charAt(0) != "0" || sText.charAt(1) != "9")
		   IsNumber = false;
   }
   else {
	   IsNumber = false;
   }
   if(!IsNumber)
   	alert("Invalid " + Label)
   return IsNumber;
}

function CheckName(sText,Label) {
var iChars = "!@#$%^*()~`=+|\}{][:;<>,?";
if(trim(sText)=="") {alert(Label+ " Should not be Empty");return false}
  for (var i = 0; i < sText.length; i++) {
  	if (iChars.indexOf(sText.charAt(i)) != -1) {
  	alert ("Invalid " + Label + ". Special Characters not allowed.");
  	return false;
  	}
  }
  return true;
}

function trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')){
	    s = s.substring(1,s.length);
    }
	return s;
}