
function home_search(chk1) {
   if (chk1.busty.options[chk1.busty.selectedIndex].value == "0") {
      alert("Select a Business Category");
      chk1.busty.focus();
	  return false;
   }
   if (chktrim(chk1.term.value).length <=1 || (chktrim(chk1.term.value).length >=1 && chk1.term.value=="Enter Keywords here . . .")) {
      alert("Enter Product / Services Keyword(s)");
      chk1.term.focus();
	  return false;
   }
}
function catg_search(chk1) {
   if ( chktrim(chk1.term.value).length <=1 || ( chktrim(chk1.term.value).length >=1 && chk1.term.value=="Enter Keywords here . . .")) {
      alert("Enter Product / Services Keyword(s)");
      chk1.term.focus();
	  return false;
   }
}

function chktrim(inputString) {
         if (typeof inputString != "string") { return inputString; }
         var retValue = inputString;
         var ch = retValue.substring(0, 1);
         while (ch == " ") { 
           retValue = retValue.substring(1, retValue.length);
           ch = retValue.substring(0, 1);
         } 
         ch = retValue.substring(retValue.length-1, retValue.length);
         while (ch == " ") { 
            retValue = retValue.substring(0, retValue.length-1);
            ch = retValue.substring(retValue.length-1, retValue.length);
         }
         while (retValue.indexOf("  ") != -1) { 
            retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
         }
         return retValue; 
} 

function chk_login(chk2) {
   if (chk2.user_name.value.length == 0) {
      alert("E-mail ID can't be left blank");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('@') == -1) {
      alert("Error in Email ID");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('.') == -1) {
      alert("Error in Email ID");
      chk2.user_name.focus();
      return false;
   }
   if (chk2.user_name.value.indexOf('@') !=  chk2.user_name.value.lastIndexOf('@')) {
      alert("Please Specify One Email ID only");
      chk2.user_name.focus();
      return false;
   }  
   if (chk2.pass_word.value.length==0) {
      alert("Enter Your Password ");
      chk2.pass_word.focus();
      return false; 
   }
}

function search_valid(chk2) {
   if (chk2.busty.options[document.search.busty.selectedIndex].value == "0") {
      alert("Select a Business Category");
      chk2.busty.focus();
	  return false;
   }
   if (chktrim(chk2.term.value).length <=1 && chk2.term.value!="Enter Keywords here . . .") {
      alert("Enter Product Keyword");
      chk2.term.focus();
	  return false;
   }
}

function openwin(file,Iwidth,Iheight) {
   var newWin1=window.open(file,'nWin1','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width=400,height=300,screenX=0,screenY=0,left=20,top=20');
}
function openwin1(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin2','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
function openwin2(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin3','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width=650,height=500,screenX=0,screenY=0,left=20,top=20');
}
function openwin4(file,Iwidth,Iheight) {
      var newWin1=window.open(file,'nWin3','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left=20,top=20');
}
   
function newBizValid(id1,chk1) {
	if (chk1=="chk") {
   		len=id1.elements.length;
   		var i=0;
 		var pp=1;
   		for (i=0; i<len; i++) {
	   		 if (id1.elements[i].type == "checkbox" && id1.elements[i].checked==true) {
				pp=2;
			}
		}
  		if (pp==1) {
	  		alert("Please select your Product checkbox");
	  		return false;
  		} 
   	}
   	if (chktrim(id1.your_name.value).length==0) {
      	alert("Enter your name");
	  	id1.your_name.focus();
      	return false;
   	}
   	if (chktrim(id1.comp_name.value).length==0) {
      	alert("Enter your company name");
	  	id1.comp_name.focus();
      	return false;
   	}
   	if (chktrim(id1.address.value).length ==0) {
      	alert("Enter your Postal Address");
      	id1.address.focus();
      	return false;
   	}
   	if (id1.country.options[id1.country.selectedIndex].value=="")  {
      	alert("Select your Country");
      	id1.country.focus();
      	return false;
   	}
   	if (chktrim(id1.username.value).length == 0) {
      	alert("E-mail address can't be left blank");
      	id1.username.focus();
      	return false;
   	}
   	if (id1.username.value.indexOf('@') == -1) {
      	alert("Error in e-mail address");
      	id1.username.focus();
      	return false;
   	}
   	if (id1.username.value.indexOf('.') == -1) {
      	alert("Error in e-mail address");
      	id1.username.focus();
      	return false;
   	}
   if (id1.username.value.indexOf('@') != id1.username.value.lastIndexOf('@')) {
      alert("Please Specify One E-mail address only");
      id1.username.focus();
      return false;
   }
   if (chktrim(id1.your_requirement.value).length==0)  {
      alert("Enter Your Requirement");
      id1.your_requirement.focus();
      return false;
   }		
}

function chk_form1(id1,tlType) {
	if (tlType=="exist") {
     	len=id1.elements.length;
	 	var i=0;
 	 	var pp=1;
   	 	for (i=0; i<len; i++) {
        	if (id1.elements[i].type == "radio" && id1.elements[i].checked==true && id1.elements[i].name=="tradeleadID") {
           		pp=2;
	    	}
	 	}
     	if (pp==1) {
	    	alert("Select one of the existing Trade Lead");
	    	return false;
    	}
	}
	else {
		if (id1.tradelead_type.options[id1.tradelead_type.selectedIndex].value == "x") {
	       	alert("Select Trade Lead Type"); 
	        id1.tradelead_type.focus();
	        return false;  
	    }
	    if (id1.quantity.value.length == 0) {
	        alert("Do not leave Quantity field blank");
	        id1.quantity.focus();
	        return false; 
	    }
	    if (id1.subject.value.length == 0) {
	        alert("Do not leave Subject field blank");
	        id1.subject.focus();
	        return false; 
	    }
	    if (id1.keywords.value.length == 0) {
	        alert("Do not leave Keyword field blank");
	        id1.keywords.focus();
	        return false; 
	    }
	    if (id1.details.value.length>200) {
	        alert("Your Details limit upto 200 characters");
	        id1.details.focus();
	        return false; 
	    }
	    if ((!id1.details.value.indexOf('.com')) || (!id1.details.value.indexOf('.net')) || (!id1.details.value.indexOf('.www'))) {
	        alert("Don't specify your site address in Details fields");
	        id1.details.focus();
	        return false;
	    }
	    if (id1.details.value.length <= 1) {
	        alert("Enter Your Trade Lead Details");
	        id1.details.focus();
	        return false; 
	    }
    }
    if (tlType=="exist" || tlType=="tlpd") {
        if ((!id1.pymt_mode[0].checked) && (!id1.pymt_mode[1].checked) && (!id1.pymt_mode[2].checked) && (!id1.pymt_mode[3].checked) && (!id1.pymt_mode[4].checked) && (!id1.pymt_mode[5].checked) && (!id1.pymt_mode[6].checked)) {
   	       alert("Please check Your Mode Of Payment");
           id1.pymt_mode[0].focus();
 	       return false;
	    }	    
    }
}

function typedown(obj,defaultval) {
  if(obj.value==defaultval) {
	obj.value=''
	}
}