function trimStr(sString) {
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1){
         IsNumber = false;
      }
   }
   return IsNumber;
}


function check_date(dateStr){
 	var datePat = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;

	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert("Date is not in a valid format.");
		return false;
	}
	year = matchArray[1]; // parse date into variables
	month = matchArray[3];
	day = matchArray[4];
//	alert(year + ":" + month +":" +day);
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
   		}
   	}
	var myDate=new Date();
	myDate.setFullYear(year,month-1,day);
	var today = new Date();
	if (myDate>today){
		alert("Can't enter a future Date");
		return false;
	}
}
//check if the date difference is more tahn 18 Years
function checkfor18(chkDate){
 	var datePat = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;
	var matchArray = chkDate.match(datePat); // is the format ok?
	year = matchArray[1]; // parse date into variables
	month = matchArray[3];
	day = matchArray[4];	
	var myDate=new Date();
	myDate.setFullYear(year,month-1,day);	
	var currDate = new Date();
	var currMSec = Date.parse(currDate);
	var myDateMSec = Date.parse(myDate);
	//value of 18 years in millisec
	var mSec18Yers = Date.parse("Jan 1, 1988");
	if((currMSec-myDateMSec)>=mSec18Yers){
		return true;
	}
	else{
		return false;
	}
}

//check if the email is a valid email address
function checkMail(x){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function regType(str,str2){
	if(str=="x"){
		document.form1.action="regCompleted.php?msg=Free User";
		document.form1.submit();
	}
	else if(str=="i"){
		if(str2=='IN'){
			document.form1.action="regPlanISubType.php";
			document.form1.submit();		
		}
		else{
			document.form1.action="regPlanSubType.php";
			document.form1.submit();	
		}
	}
	else if(str=="promo"){
		document.form1.action="setPromo.php";
		document.form1.submit();
	}
}


function disclamer(){
	if(document.form1.b_agree[0].checked){
		alert("We regret!! You would not be able to register with us if you do not agree to our terms and condition");
		return false;
	}
}

//User Registration check
function checkReg(str){
	var b_fname = document.form1.b_fname.value;
	var b_email = document.form1.b_email.value;
	var b_pwd = document.form1.b_pwd.value;
	var c_pwd = document.form1.c_pwd.value;
	var tillDate = document.form1.b_day.value;
	var b_sec_ans = document.form1.b_sec_ans.value;
	var b_atl_email = document.form1.b_atl_email.value;
	if(str!="associate"){
		var b_activity = document.form1.b_activity.value;
		var b_sector = document.form1.b_sector.value;
		var b_subsector = document.form1.b_subsector.value;
	}
	var b_lan1 = document.form1.b_lan1.value;
	var b_country = document.form1.b_country.value;
	var b_zip = document.form1.b_zip.value;
	var b_ph_cd = document.form1.b_ph_cd.value;
	var b_ph_ad = document.form1.b_ph_ad.value;
	var b_ph = document.form1.b_ph.value;
	var d_display_name = document.form1.d_display_name.value;
	var b_mobile = document.form1.b_mobile.value;
	var b_title = document.form1.b_title.value;
	var b_sex = document.form1.b_sex.value;
	var b_sec_question= document.form1.b_sec_question.value;
//	var b_about = document.form1.b_about.value;
	var b_edu  = document.form1.b_edu.value;
	var b_occupation  = document.form1.b_occupation.value;
	if(b_fname==""){
		alert("Error!! The First Name can not be left Blank. ");
		document.form1.b_fname.focus();
		return false;	
	}
	if(d_display_name==""){
		alert("Error!! The Display Name can not be left Blank. ");
		document.form1.d_display_name.focus();
		return false;
	}
	if(b_title=="0"){
		alert("Error!! The Title can not be left Blank. ");
		document.form1.b_title.focus();
		return false;
	}
	if(b_sex=="0"){
		alert("Error!! The Gender can not be left Blank. ");
		document.form1.b_sex.focus();
		return false;
	}		
	if(b_email==""){
		alert("Error!! The Email address can not be left Blank. ");
		document.form1.b_email.focus();
		return false;	
	} if(checkMail(b_email)==false){
		alert("The Email address does not seems to be correct. \n Please re-enter");
		document.form1.b_email.value="";
		document.form1.b_email.focus();
		return false;
	}	
	if(b_pwd == ""){
		alert("Please enter a Password to proceed further");
		document.form1.b_pwd.focus();
		return false;
	}
	if(b_pwd != c_pwd){
		alert("Please retype the password.");
		document.form1.b_pwd.value="";
		document.form1.c_pwd.value="";
		document.form1.b_pwd.focus();
		return false;
	}
	if(b_sec_question == "0"){
		alert("Please select the Secret Question before proceeding further");
		document.form1.b_sec_question.focus();
		return false;
	}	
	if(b_sec_ans == ""){
		alert("Please enter a answer to your secret question");
		document.form1.b_sec_ans.focus();
		return false;
	}
	if(tillDate==""){
		alert("Error!! The Date is blank. Please enter a valid Date Of Birth before proceeding");
		document.form1.b_day.focus();
		return false;
	}
	else{
		if(check_date(tillDate)==false){
			document.form1.b_day.focus();
			return false;
		}
		else{
			if(checkfor18(tillDate)==false){
				alert("Error!! You need to be atleast 18 Years or above to Register as a Member");
				return false;
			}
		}
	}
	if(b_atl_email!=""){
		if(checkMail(b_atl_email)==false){
			alert("The Alternate Email address does not seems to be correct. \n Please re-enter");
			document.form1.b_atl_email.value="";
			document.form1.b_atl_email.focus();
			return false;
		}		
	}
	if(str!="associate"){
		if(b_activity=="0"){
			alert("Please select the Activity Type you belong to before you proceed");		
			document.form1.b_activity.focus();
			return false;		
		}
		if(b_sector=="0"){
			alert("Please select the Sector Type you belong to before you proceed");		
			document.form1.b_sector.focus();
			return false;		
		}	
		if(b_subsector=="0"){
			alert("Please select the Sub-Sector Type you belong to before you proceed");		
			document.form1.b_subsector.focus();
			return false;		
		}
	}
	if(b_edu == "0"){
		alert("Please select Education Level before proceeding further");
		document.form1.b_edu.focus();
		return false;
	}	
	if(b_occupation == "0"){
		alert("Please select Occupation Type before proceeding further");
		document.form1.b_occupation.focus();
		return false;
	}	
	if(b_lan1==""){
		alert("Error!! Please fill atleat one Language preference before proceeding further. ");
		document.form1.b_lan1.focus();
		return false;
	}	
	if(b_country=="0"){
		alert("Please select the Country you belong to before you proceed");
		document.form1.b_country.focus();
		return false;
	}
	if(b_zip==""){
		alert("Please enter the Postal code to before you proceed");
		document.form1.b_zip.focus();
		return false;
	}

	if(b_mobile==""){
		if((b_ph_cd=="")||(b_ph_ad=="")||(b_ph=="")){
			alert("The phone number should be filled with the country code and city code. Ex: 91-11-22411068");
			return false;
		}
		else{
			if((IsNumeric(b_ph_cd)==false)||(IsNumeric(b_ph_ad)==false)||(IsNumeric(b_ph)==false)){
				alert("Phone Number can only contain Numbers");
				return false;
			}
		}
	}
	else{
		if(IsNumeric(b_mobile)==false){
			alert("Mobile number can only contain Numbers");
			document.form1.b_mobile.focus();
			return false;
		}
		if((b_ph_cd!="")||(b_ph_ad!="")||(b_ph!="")){
			if((IsNumeric(b_ph_cd)==false)||(IsNumeric(b_ph_ad)==false)||(IsNumeric(b_ph)==false)){
				alert("Phone Number can only contain Numbers");
				return false;
			}		
		}
	}

	if(disclamer()==false){
		return false;
	}
}



//Corporate Registration check
function checkCorpReg(){
	var b_displaynm = document.form1.b_displaynm.value;
	var b_org = document.form1.b_org.value;
	var b_org_type = document.form1.b_org_type.value;
	var b_email = document.form1.b_email.value;
	var b_contact_email = document.form1.b_contact_email.value;
	var b_pwd = document.form1.b_pwd.value;
	var c_pwd = document.form1.c_pwd.value;
	var b_sec_question= document.form1.b_sec_question.value;
	var b_sec_ans = document.form1.b_sec_ans.value;	
	var b_activity = document.form1.b_activity.value;
	var b_sector = document.form1.b_sector.value;
	var b_subsector = document.form1.b_subsector.value;
	var b_country = document.form1.b_country.value;
	var b_state = document.form1.b_state.value;
	var b_zip = document.form1.b_zip.value;
	var b_mobile = document.form1.b_mobile.value;
	var b_ph_cd = document.form1.b_ph_cd.value;
	var b_ph_ad = document.form1.b_ph_ad.value;
	var b_ph = document.form1.b_ph.value;
	var b_lan1 = document.form1.b_lan1.value;
	var b_contact_person = document.form1.b_contact_person.value;
	var b_year_foundation = document.form1.b_year_foundation.value;
	var b_atl_email = document.form1.b_atl_email.value;
//	var b_about = document.form1.b_about.value;
	if(b_displaynm==""){
		alert("Error!! The Display Name can not be left Blank. ");
		document.form1.b_displaynm.focus();
		return false;
	}
	if(b_org==""){
		alert("Error!! The Organization/Company Name can not be left Blank. ");
		document.form1.b_org.focus();
		return false;
	}	
	if(b_org_type=="0"){
		alert("Error!! The Company Type can not be left Blank. ");
		document.form1.b_org_type.focus();
		return false;
	}
	if(b_year_foundation!=""){
		if(check_date(b_year_foundation)==false){
			document.form1.b_year_foundation.focus();
			return false;
		}
	}
	
	if(b_email==""){
		alert("Error!! The Email address can not be left Blank. ");
		document.form1.b_email.focus();
		return false;	
	}	
	if(checkMail(b_email)==false){
		alert("The Email address does not seems to be correct. \n Please re-enter");
		document.form1.b_email.value="";
		document.form1.b_email.focus();
		return false;
	}	
	if(b_pwd == ""){
		alert("Please enter a Password to proceed further");
		document.form1.b_pwd.focus();
		return false;
	}
	if(b_pwd != c_pwd){
		alert("Please retype the password.");
		document.form1.b_pwd.value="";
		document.form1.c_pwd.value="";
		document.form1.b_pwd.focus();
		return false;
	}
	if(b_sec_question == "0"){
		alert("Please select the Secret Question before proceeding further");
		document.form1.b_sec_question.focus();
		return false;
	}
	if(b_sec_ans == ""){
		alert("Please enter a answer to your secret question");
		document.form1.b_sec_ans.focus();
		return false;
	}
	if(b_atl_email!=""){
		if(checkMail(b_atl_email)==false){
			alert("The Alternate Email address does not seems to be correct. \n Please re-enter");
			document.form1.b_atl_email.value="";
			document.form1.b_atl_email.focus();
			return false;
		}		
	}
	if(b_activity=="0"){
		alert("Please select the Activity Type you belong to before you proceed");		
		document.form1.b_activity.focus();
		return false;		
	}
	if(b_sector=="0"){
		alert("Please select the Sector Type you belong to before you proceed");		
		document.form1.b_sector.focus();
		return false;		
	}	
	if(b_subsector=="0"){
		alert("Please select the Sub-Sector Type you belong to before you proceed");		
		document.form1.b_subsector.focus();
		return false;		
	}
	if(b_country=="0"){
		alert("Please select the Country you belong to before you proceed");
		document.form1.b_country.focus();
		return false;
	}
	if(b_state==""){
		alert("Please enter the state belong to before you proceed");
		document.form1.b_state.focus();
		return false;
	}
	if(b_zip==""){
		alert("Please enter the Postal code to before you proceed");
		document.form1.b_zip.focus();
		return false;
	}
	if(b_mobile==""){
		if((b_ph_cd=="")||(b_ph_ad=="")||(b_ph=="")){
			alert("The phone number should be filled with the country code and city code. Ex: 91-11-22411068");
			return false;
		}
		else{
			if((IsNumeric(b_ph_cd)==false)||(IsNumeric(b_ph_ad)==false)||(IsNumeric(b_ph)==false)){
				alert("Phone Number can only contain Numbers");
				return false;
			}
		}
	}
	else{
		if(IsNumeric(b_mobile)==false){
			alert("Mobile number can only contain Numbers");
			document.form1.b_mobile.focus();
			return false;
		}
		if((b_ph_cd!="")||(b_ph_ad!="")||(b_ph!="")){
			if((IsNumeric(b_ph_cd)==false)||(IsNumeric(b_ph_ad)==false)||(IsNumeric(b_ph)==false)){
				alert("Phone Number can only contain Numbers");
				return false;
			}		
		}
	}	
	if(b_contact_person==""){
		alert("Please enter the contact person before you proceed");
		document.form1.b_contact_person.focus();
		return false;		
	}
	if(b_contact_email==""){
		alert("Error!! The Contact Person's Email address can not be left Blank. ");
		document.form1.b_contact_email.focus();
		return false;	
	}	
	if(checkMail(b_contact_email)==false){
		alert("Error!! The Contact Person's Email address does not seems to be correct. \n Please re-enter");
		document.form1.b_contact_email.value="";
		document.form1.b_contact_email.focus();
		return false;
	}
	if(b_lan1==""){
		alert("Error!! Please fill atleat one Language preference before proceeding further. ");
		document.form1.b_lan1.focus();
		return false;
	}
/*	if(b_about==""){
		alert("Error!! You need to give a brief description about your company before you proceed further");
		document.form1.b_about.focus();
		return false;
	}	*/
	if(disclamer()==false){
		return false;
	}
}

//Creates the XML Object
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 to display the Pop Up for Financial Services

	function showFinService(){
		var selIndex = document.fin_form.finService.selectedIndex;
		var myLink = document.fin_form.finService.options[selIndex].value;
		if(myLink!=0){
			myLink = "http://" + myLink;
			window.open(myLink, "_new");
			return false;
		}
		else{
			return false;
		}
	}
	
//Dispalys the Activity in the Project search
	function loadActivity(str){
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){
  			alert ("Your browser does not support AJAX!");
	  		return;
	  	}
		var url="manage/getActivity.php";
		if(str=='y'){
			url=url+"?forproject=y&sid="+Math.random();
		}
		else{
			url=url+"?sid="+Math.random();
		}
//		alert(url);
		xmlHttp.onreadystatechange=fillActivitry;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
//Dispalys the Activity in the Project search
	function loadActivity2(str){
		xmlHttp2=GetXmlHttpObject()
		if (xmlHttp2==null){
  			alert ("Your browser does not support AJAX!");
	  		return;
	  	}
		var url="manage/getActivity.php";
		if(str=='y'){
			url=url+"?forproject=y&sid="+Math.random();
		}
		else{
			url=url+"?sid="+Math.random();
		}
	//	alert(url);
//if STR is 's' then fillActrivity is a simple list not a combo
		if (str == "s") {
			xmlHttp2.onreadystatechange = fillActivitySimple;
		}
		else {
			xmlHttp2.onreadystatechange = fillActivity;
		}
		xmlHttp2.open("GET",url,true);
		xmlHttp2.send(null);
	}

function fillActivitry(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
//		alert(nodeLen);
		for(var i=0; i< nodeLen ; i++){
	  		var opt = document.createElement("OPTION");
			opt.text = xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("prjActivity").options.add(opt);
		}
	}
}
function fillActivity(){ 
	if (xmlHttp2.readyState==4){
		var xmlDoc=xmlHttp2.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
//		alert(nodeLen);
		for(var i=0; i< nodeLen ; i++){
	  		var opt = document.createElement("OPTION");
			opt.text = xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("pActivity").options.add(opt);
		}
	}
}

function fillActivitySimple(){ 
	if (xmlHttp2.readyState==4){
		var xmlDoc=xmlHttp2.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		activityStr="";//&#9642; <a href='offerList.php?stype=n&b_activity=0'>Any</a><br>";
//		alert(nodeLen);
		for(var i=0; i< nodeLen ; i++){
	  		var opt = document.createElement("OPTION");
			opt.text = xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("pActivity").options.add(opt);			
	  		activityStr = activityStr + "&#9642; <a href='offerList.php?stype=n&b_activity="+xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue+"'>"+xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue +"<a><br>";
		}
		document.getElementById("activityList").innerHTML=activityStr;
	}
}

	function loadSector(str,str2){
		if(str!=0){
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null){
  				alert ("Your browser does not support AJAX!");
	  			return;
		  	} 
		  	document.getElementById("imgLoadC").style.visibility="visible";
			var url="manage/getSector.php";
			url=url+"?pid="+str;
			if(str2=="proj"){
				url=url+"&forprojectSector=y&sid="+Math.random();
			}else{
				url=url+"&sid="+Math.random();
			}
			xmlHttp.onreadystatechange=fillSector;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		else{
			document.getElementById("prjSector").options.length=0;
			var opt = document.createElement("OPTION");
			opt.text = "--Select One--";
			opt.value = 0;
			document.getElementById("prjSector").options.add(opt);
			document.getElementById("prjSubSector").options.length=0;
			var opt = document.createElement("OPTION");
			opt.text = "--Select One--";
			opt.value = 0;
			document.getElementById("prjSubSector").options.add(opt);
  			return false;			
		}
	}
	
	function loadCity(str){
		if(str!=0){
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null){
  				alert ("Your browser does not support AJAX!");
	  			return;
		  	} 
		  	document.getElementById("imgLoadC3").style.visibility="visible";
			var url="getCity.php";
			url=url+"?pid="+str;
			xmlHttp.onreadystatechange=fillCity;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);			
		}
	}
function fillSector(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		document.getElementById("prjSector").options.length=0;
  		var opt = document.createElement("OPTION");
		opt.text = "--Select One--";
		opt.value = 0;		
		document.getElementById("prjSector").options.add(opt);
		for(var i=0; i< nodeLen ; i++){
			var nm= xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
	  		var opt = document.createElement("OPTION");
			opt.text = nm;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("prjSector").options.add(opt);	
		}
		document.getElementById("imgLoadC").style.visibility="hidden";
	}
}


	function loadSector2(str,str2){
		if(str!=0){
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null){
  				alert ("Your browser does not support AJAX!");
	  			return;
		  	} 
		  	document.getElementById("imgLoadC").style.visibility="visible";
			var url="manage/getSector.php";
			url=url+"?pid="+str;
			if(str2=="proj"){
				url=url+"&forprojectSector=y&sid="+Math.random();
			}else{
				url=url+"&sid="+Math.random();
			}
			xmlHttp.onreadystatechange=fillSector2;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		else{
			document.getElementById("prjSector").options.length=0;
			var opt = document.createElement("OPTION");
			opt.text = "--Select One--";
			opt.value = 0;
			document.getElementById("prjSector").options.add(opt);
			document.getElementById("prjSubSector").options.length=0;
			var opt = document.createElement("OPTION");
			opt.text = "--Select One--";
			opt.value = 0;
			document.getElementById("prjSubSector").options.add(opt);
  			return false;			
		}
	}
	
function fillSector2(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		document.getElementById("prjSector").options.length=0;
  		var opt = document.createElement("OPTION");
		opt.text = "--Any--";
		opt.value = 0;		
		document.getElementById("prjSector").options.add(opt);
		for(var i=0; i< nodeLen ; i++){
			var nm= xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
	  		var opt = document.createElement("OPTION");
			opt.text = nm;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("prjSector").options.add(opt);	
		}
		document.getElementById("imgLoadC").style.visibility="hidden";
	}
}
	
	
function fillCity(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		document.getElementById("city_id").options.length=0;
  		var opt = document.createElement("OPTION");
		opt.text = "--Select One--";
		opt.value = 0;		
		document.getElementById("city_id").options.add(opt);
		for(var i=0; i< nodeLen ; i++){
			var nm= xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
	  		var opt = document.createElement("OPTION");
			opt.text = nm;
			opt.value = nm;// xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("city_id").options.add(opt);	
		}
  		var opt = document.createElement("OPTION");
		opt.text = "Others";
		opt.value = "Other";		
		document.getElementById("city_id").options.add(opt);
		document.getElementById("imgLoadC3").style.visibility="hidden";
	}
}

function checkCity(str){
	if(str=="Other"){
		document.getElementById("newcity").style.visibility="visible";
	}
	else{
		document.getElementById("newcity").style.visibility="hidden";
	}
}

function getSubSector(str,str2){
	if (str==0){ 
		document.getElementById("prjSubSector").options.length=0;
		var opt = document.createElement("OPTION");
		opt.text = "--Select One--";
		opt.value = 0;
		document.getElementById("prjSubSector").options.add(opt);
  		return false;
  	}
  	else{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){
  			alert ("Your browser does not support AJAX!");
  			return;
	  	} 
	  	document.getElementById("imgLoadC2").style.visibility="visible"; 
		var url="manage/getSector.php";
		var b_activity = document.getElementById("prjActivity").value;
		var b_sector = document.getElementById("prjSector").value;
		url=url+"?pid="+b_sector;
		//alert(url);	
		if(str2=="proj"){
			url=url+"&forprojectSector=sy&sid="+Math.random();
		}else{
			url=url+"&sid="+Math.random();
		}
		xmlHttp.onreadystatechange=fillSubSector;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}


function fillSubSector(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		document.getElementById("prjSubSector").options.length=0;
  		var opt = document.createElement("OPTION");
		opt.text = "--Select One--";
		opt.value = 0;		
		document.getElementById("prjSubSector").options.add(opt);			
		for(var i=0; i< nodeLen ; i++){
			var nm= xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
	  		var opt = document.createElement("OPTION");
			opt.text = nm;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("prjSubSector").options.add(opt);	
		}
		document.getElementById("imgLoadC2").style.visibility="hidden";
	}
}



function getSubSector2(str,str2){
	if (str==0){ 
		document.getElementById("prjSubSector").options.length=0;
		var opt = document.createElement("OPTION");
		opt.text = "--Any--";
		opt.value = 0;
		document.getElementById("prjSubSector").options.add(opt);
  		return false;
  	}
  	else{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){
  			alert ("Your browser does not support AJAX!");
  			return;
	  	} 
	  	document.getElementById("imgLoadC2").style.visibility="visible"; 
		var url="manage/getSector.php";
		var b_activity = document.getElementById("pActivity").value;
		var b_sector = document.getElementById("prjSector").value;
		url=url+"?pid="+b_sector;
		//alert(url);	
		if(str2=="proj"){
			url=url+"&forprojectSector=sy&sid="+Math.random();
		}else{
			url=url+"&sid="+Math.random();
		}
		xmlHttp.onreadystatechange=fillSubSector2;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}


function fillSubSector2(){ 
	if (xmlHttp.readyState==4){
		var xmlDoc=xmlHttp.responseXML.documentElement;
		var nodeLen = xmlDoc.getElementsByTagName("pname").length;
		document.getElementById("prjSubSector").options.length=0;
  		var opt = document.createElement("OPTION");
		opt.text = "--Any--";
		opt.value = 0;		
		document.getElementById("prjSubSector").options.add(opt);			
		for(var i=0; i< nodeLen ; i++){
			var nm= xmlDoc.getElementsByTagName("pname")[i].childNodes[0].nodeValue;
	  		var opt = document.createElement("OPTION");
			opt.text = nm;
			opt.value = xmlDoc.getElementsByTagName("pid")[i].childNodes[0].nodeValue;
			document.getElementById("prjSubSector").options.add(opt);	
		}
		document.getElementById("imgLoadC2").style.visibility="hidden";
	}
}






function submitReg(str){
	if(str=="i"){
		form1.action="userReg.php";
		form1.submit();
	}
	else if(str=="c"){
		form1.action="corpReg.php";
		form1.submit();	
	}
	else if(str=="ai"){
		form1.action="userAssociateReg.php";
		form1.submit();	
	}
	else if(str=="ac"){
		form1.action="corpAssociateReg.php";
		form1.submit();	
	}
}
//Go to the specified Page
function gotoPage(str){
	window.location=str;
}


function checkPayDetails(str){
	if(str=="dd"){
		var b_bank_details=document.form2.b_bank_details.value;
		var b_amt = document.form2.b_amt.value;
		var b_dd_no=document.form2.b_dd_no.value;
		if(b_bank_details==""){
				alert("Please fill the Bank Details to proceed further");
				document.form2.b_bank_details.focus();
				return false;		
		}
		if(b_amt==""){
				alert("Please fill the Payment Amount to proceed further");
				document.form2.b_amt.focus();
				return false;		
		}
		else{
			if(IsNumeric(b_amt)==false){
				alert("Please fill the Payment Amount can only be a numeric field");
				document.form2.b_amt.value="";
				document.form2.b_amt.focus();
				return false;	
			}
		}
		if(b_dd_no==""){
				alert("Please fill a valid Payorder number to proceed further");
				document.form2.b_dd_no.focus();
				return false;		
		}
		else{
			if(IsNumeric(b_dd_no)==false){
				alert("Please fill the Payment Amount can only be a numeric field");
				document.form2.b_dd_no.value="";
				document.form2.b_dd_no.focus();
				return false;	
			}
		}	
	}
	else if(str="cc"){
		var firstName = document.form1.firstName.value;
		var lastName = document.form1.lastName.value;
		var email = document.form1.email.value;
		var cardno = document.form1.cardno.value;
		var cvv2Number = document.form1.cvv2Number.value;
		var b_country = document.form1.b_country.value;
		var state_text = document.form1.state_text.value;
		var city = document.form1.city.value;
		var address = document.form1.address.value;
		var zip = document.form1.zip.value;
		if(firstName==""){
				alert("Please fill the First name to proceed further");
				document.form1.firstName.focus();
				return false;
		}
		if(lastName==""){
				alert("Please fill the last name to proceed further");
				document.form1.lastName.focus();
				return false;
		}
		if(email==""){
				alert("Please fill the Email Address to proceed further");
				document.form1.email.focus();
				return false;
		}
		if(cardno==""){
				alert("Please fill the Credit Card Number to proceed further");
				document.form1.cardno.focus();
				return false;
		}
		if(cvv2Number==""){
				alert("Please fill the Card Verification Number to proceed further");
				document.form1.cvv2Number.focus();
				return false;
		}
		if(b_country==""){
				alert("Please select the Country  to proceed further");
				document.form1.b_country.focus();
				return false;
		}
		else if(b_country!="US"){
			if(state_text==""){
				alert("Please fill the State to proceed further");
				document.form1.state_text.focus();
				return false;
			}			
		}
		if(city==""){
				alert("Please fill the City to proceed further");
				document.form1.city.focus();
				return false;
		}
		if(zip==""){
				alert("Please fill the Pin/Zip to proceed further");
				document.form1.zip.focus();
				return false;
		}
		
		
	}
}

function checkLoginInfo(){
	var uname = document.login_form.admin.value;
	var pass = document.login_form.pass.value;
	if(uname ==""){
		alert("Please fill the user name before proceeding further");
		document.login_form.admin.focus();
		return false;
	}
	if(pass ==""){
		alert("Please fill the Password before proceeding further");
		document.login_form.pass.focus();
		return false;
	}	
}



//Show Hide payment options
	function showPay(str){
		if(str=="dd"){
			document.getElementById("DDPay").style.position="absolute";
			var my_width = (document.body.clientWidth - 500)/2;
			document.getElementById("DDPay").style.left=my_width;		
			document.getElementById("CCPay").style.visibility="hidden";
			document.getElementById("DDPay").style.visibility="visible";
		}
		else{
			document.getElementById("CCPay").style.position="absolute";
			document.getElementById("CCPay").style.top=265;
			var my_width = (document.body.clientWidth - 500)/2;
			document.getElementById("CCPay").style.left=my_width;
			document.getElementById("CCPay").style.visibility="visible";
			document.getElementById("DDPay").style.visibility="hidden";		
		}
	}
	
	
	
	function valPass(){
		var o_pass = document.form1.o_pwd.value;
		var n_pass = document.form1.n_pwd.value;
		var c_pass = document.form1.c_pwd.value;
		if(o_pass == ""){
			alert("Please enter a Old Password to proceed further");
			document.form1.o_pwd.focus();
			return false;
		}
		if(n_pass == ""){
			alert("Please enter a New Password to proceed further");
			document.form1.n_pwd.focus();
			return false;
		}
		if(n_pass != c_pass){
			alert("Please retype the password. The new password does not match");
			document.form1.n_pwd.value="";
			document.form1.c_pwd.value="";
			document.form1.n_pwd.focus();
			return false;
		}
		return true;
	}
	
	function loadOthers(){
		var b_offer_type = document.sform1.b_offer_type.value;
		if((b_offer_type=="-1")){//||(b_offer_type=="0")){
			document.getElementById("othersID").style.visibility="visible";
			document.getElementById("other_cat").focus();
		}
		else{
			document.getElementById("othersID").style.visibility="hidden";
			document.getElementById("other_cat").selectedIndex=0;
		}
	}

	function checkProject(){
		var b_offer_type = document.sform1.b_offer_type.value;
		var b_activity = document.sform1.b_activity.value;
		var b_sector = document.sform1.b_sector.value;
		var b_subsector = document.sform1.b_subsector.value;
		var b_country = document.sform1.b_country.value;
		var b_city = document.sform1.b_city.value;
		var b_offer_brief = trimStr(document.sform1.b_offer_brief.value);
		var b_offer_desc = trimStr(document.sform1.b_offer_desc.value);
		if (b_offer_type == 0) {
			alert("You need to select the Offer Type before you proceed further");
			document.sform1.b_offer_type.focus();
			return false;			
		}
		if(b_offer_type=="-1"){
			var b_o_offer = document.sform1.b_o_offer.value;
			if(b_o_offer=="0"){
				alert("You need to fill the Other Business Type before you proceed further");
				document.sform1.b_o_offer.focus();
				return false;
			}
		}
		if(b_activity==0){
			alert("You need to fill the Activity before you proceed further");
			document.sform1.b_activity.focus();
			return false;			
		}
		if(b_sector==0){
			alert("You need to fill the Sector before you proceed further");
			document.sform1.b_sector.focus();
			return false;			
		}
		if(b_subsector==0){
			alert("You need to fill the Sub-Sector before you proceed further");
			document.sform1.b_subsector.focus();
			return false;
		}
		if(b_country!="0"){
			if(b_city=="0"){
				alert("You need to fill the City before you proceed further");
				document.sform1.b_city.focus();
				return false;
			}
		}
		if(b_offer_brief==""){
			alert("You need to fill the Requirements/Offers in brief before you proceed further");
			document.sform1.b_offer_brief.focus();
			return false;			
		}
		if(b_offer_desc==""){
			alert("You need to fill the Requirements/Offers in Details before you proceed further");
			document.sform1.b_offer_desc.focus();
			return false;			
		}				
	}
	
	function checkReply(){
		var offer = document.form1.b_offer_reply.value;
		if(offer==""){
			alert("You need to fill you comments about the Requirements/Offers in brief before you proceed further");
			document.form1.b_offer_reply.focus();
			return false;				
		}
	}
	
	function searchProject(){
		var sectorList=document.projectForm.b_activity.value;
		if(sectorList=="0"){
			alert("Please Select the Activity before proceeding further");
			return false;
		}
	}
	
	
	function loadState(str){
		if(str=="US"){
			document.getElementById("cityText").style.visibility="hidden";
			document.getElementById("cityDrop").style.visibility="visible";
		}
		else{
			document.getElementById("cityText").style.visibility="visible";
			document.getElementById("cityDrop").style.visibility="hidden";			
		}
	}
	
	function checkNewsId(){
//		alert("hi");
		var b_news=document.newsform1.b_news.value;
		if(b_news==""){
			alert("You need to fill the email Address before you proceed further");
			document.newsform1.b_news.focus();
			return false;			
		}
		else{
			if(!checkMail(b_news)){
				alert("You need to proper email Address before you proceed further");
				document.newsform1.b_news.value="";
				document.newsform1.b_news.focus();
				return false;	
			}
		}
	}
	
	function checkPayType(){
		var chosen = ""
		len = document.form1.R1.value;
		if (len == "") {
			alert("You need to choose the Plan before proceeding further");
			return false;
		}
		else{
			return true;
		}
	}
	
	
	
//Forget Password Form
	function checkDetails(myForm){
		var b_grp = myForm.b_grp.value;
		var u_email = myForm.u_email.value;
		if(b_grp=="0"){
			alert("Please select the User type to reset the Password");
			myForm.b_grp.focus();
			return false;
		}
		if(u_email==""){
			alert("Please enter the Email Id which you use to login");
			myForm.u_email.focus();
			return false;
		}
		var b_sec_question = myForm.b_sec_question.value;
		var b_sec_ans = myForm.b_sec_ans.value;
		var b_day = myForm.b_day.value;
		if (b_sec_question == "0") {
			alert("Please Select a Secret Question before proceeding further")
			myForm.b_sec_question.focus();
			return false;
		}
		if (b_sec_ans == "") {
			alert("Please fill your Secret answer before proceeding further");
			myForm.b_sec_ans.focus();
			return false;
		}
		if(b_grp=="i"){
			if(b_day==""){
				alert("Please enter the Date of Birth before proceeding further");
				myForm.b_day.focus();
				return false;
			}
		}
	}

//Show fields in forget pwd form 
	function showPwdForm(myVal){
		if(myVal.value=="0"){
			hideForm1();
			hideForm2();
		}
		else if(myVal.value=="i"){
			showForm1();
			showForm2();
		}
		else{
			showForm1();
			hideForm2();
		}
	}

	function hideForm1(){
		document.getElementById("myField1").style.visibility = "hidden";
		document.getElementById("submitButt").style.visibility = "hidden";
	}
	function showForm1(){
		document.getElementById("myField1").style.visibility = "visible";
		document.getElementById("submitButt").style.visibility = "visible";
	}
	function hideForm2(){
		document.getElementById("myField2").style.visibility = "hidden";
	}
	function showForm2(){
		document.getElementById("myField2").style.visibility = "visible";
	}
