// JavaScript Document

function ArchitectureValidation(e1,mode)
{

    var valid=1;
    var e1Value = e1.value;
    if(e1Value.length==0) return true;
    if(mode==0){var regex = new RegExp(/^[a-zA-Z]+$/); valid=regex.test(e1.value)}                  //char but not space .
    if(mode==1){var regex = new RegExp(/^[a-zA-Z0-9\s]+$/); valid=regex.test(e1.value)}              //char int space
    if(mode==2){var regex = new RegExp(/^[a-zA-Z0-9.,_\-\s]+$/); valid=regex.test(e1.value)}         //char int _-., space
    if(mode==3){var regex = new RegExp(/^[a-zA-Z0-9.,_\-\s]+$/); valid=regex.test(e1.value)}         //char int _-., space
    if(mode==4){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9._ \-]+$/); valid=regex.test(e1.value)}   //char int _-. space
    if(mode==5){var regex = new RegExp(/^[0-9]+$/); valid=regex.test(e1.value)}             //only int not space
    if(mode==6){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9!._ \s\-]+$/); valid=regex.test(e1.value)}//char then int ! . space
    if(mode==7){var regex = new RegExp(/^[0-9,.]+$/); valid=regex.test(e1.value)}             //only int not space , .
    if(mode==8){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9!?._ \-]+$/); valid=regex.test(e1.value)}//char then int ! . - _ ? space
    if(mode==9){var regex = new RegExp(/^[0-9]?[0-9,]+$/); valid=regex.test(e1.value)}        //int , not space
    if(mode==10){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9:._ \-]+$/); valid=regex.test(e1.value)} //char . - _ : space
    if(mode==11){var regex = new RegExp(/^[0-9+]+$/); valid=regex.test(e1.value)}                    // int + only
    if(mode==12){var regex = new RegExp(/^[0-9.]+$/); valid=regex.test(e1.value)}                    // int . only
    if(mode==13){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9_]+$/); valid=regex.test(e1.value)}//char then int and underscore
    if(mode==14){var regex = new RegExp(/^[0-9.]+$/); valid=regex.test(e1.value)}             //only int  .
    //if(mode==14){var regex = new RegExp(/^[0-9][0-9].[0-9][0-9]+$/); valid=regex.test(el.value)}//fraction
	if(mode==15){var regex = new RegExp(/^[a-zA-Z\s]+$/); valid=regex.test(e1.value)} //char and space
	 if(mode==16){var regex = new RegExp(/^[0-9]+$/); valid=regex.test(e1.value)}  //only int
    if(!valid) 
    {
    return true;
    }
    else return false;
}
var lmsg="";



function validateuser(formname)

{

var msg

msg=""


if ( ( formname.iden[0].checked == false ) && ( formname.iden[1].checked == false ) ) 
{
msg += "Please select your identity for login. \n";

}
if(formname.username.value == "")
{

msg += "Please enter your username for login. \n";

}

if(formname.password.value == "")
{

msg += "Please enter the Password. \n";

}

if((formname.password.value.length)<5)

{

msg += "Password must be more than 6 Digit. \n";

}

if((formname.password.value)!=(formname.confirmPass.value))

{

msg += "Password && confirm Password Not match. \n";

}

var email_str = formname.email.value;

var filter=/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/
if(!(filter.test(email_str)))

{

msg+= "E-Mail Id: Not a valid Email ID\n";

}
if(formname.mobile.value == "")

{

msg += "Please enter Mobile/TelePhone Number. \n";

}
if(formname.mobile.value != "")

{
	if(ArchitectureValidation(document.getElementById("mobile"),5))
        {
            msg+= "Mobile: Not a valid Number.\n";
            
        }
	
}
if(formname.country.value == "")

{

msg += "Please enter your country . \n";

}
if(formname.state.value == "")

{

msg += "Please enter your state. \n";

}
if(formname.city.value == "")

{

msg += "Please enter your city. \n";

}
if(!(msg==""))

{

lmsg+="Kindly Provide Valid Information For the Following Fields:\n";

lmsg+="__________________________________________________________\n";

lmsg+="\n";

lmsg+=msg;

lmsg+="__________________________________________________________\n";

alert(lmsg);

lmsg="";

msg="";

return false;

} 

return true;

}



function validatelogin(formname)

{

var msg

msg=""

if(formname.login_user.value == "")

{

msg += " User Name: Enter User Name for login!\n";

}

if(formname.login_password.value == "")

{

msg += " Password : Enter password for login!\n";

}

if(!(msg==""))

{

lmsg+="Kindly Provide Valid Information For the Following Fields:\n";

lmsg+="__________________________________________________________\n";

lmsg+="\n";

lmsg+=msg;

lmsg+="__________________________________________________________\n";

alert(lmsg);

lmsg="";

msg="";

return false;

}

return true;

}



function validate_ask(formname)

{

var msg

msg=""

if(formname.askque.value == "")

{

msg += "Question:\n";

}

if(formname.Category.value == "")

{

msg += "Select Category:\n";

}

/*if(formname.Subcategory.value == "")

{

msg += "Select Sub Category:\n";

}
*/
if(!(msg==""))

{

lmsg+="Kindly Provide Valid Information For the Following Fields:\n";

lmsg+="__________________________________________________________\n";

lmsg+="\n";

lmsg+=msg;

lmsg+="__________________________________________________________\n";

alert(lmsg);

lmsg="";

msg="";

return false;

}

return true;

}
function active_req()
{
	
	var where_to= confirm("Do you want to Activate  !!");
	if (where_to== true)
	{
	//alert('yes')
	// return false;
	//window.location="requirment_buy.php?Delete=Delete" ;
	}
	else
	{
		return false;
	}
}
function inactive_req()
{
	
	var where_to= confirm("Do you want to Inactivate  !!");
	if (where_to== true)
	{
	//alert('yes')
	// return false;
	//window.location="requirment_buy.php?Delete=Delete" ;
	}
	else
	{
		return false;
	}
}
function delete_req()
{
	
	var where_to= confirm("Do you want to Delete  !!");
	if (where_to== true)
	{
		
	}
	else
	{
		return false;
	}
}
function update_req()
{
	
	var where_to= confirm("Do you want to Update  !!");
	if (where_to== true)
	{
	//alert('yes')
	// return false;
	//window.location="requirment_buy.php?Delete=Delete" ;
	}
	else
	{
		return false;
	}
}
function delete_sub()
{
	
	var where_to= confirm("Do you want to Delete Sub Category !!");
	if (where_to== true)
	{
		
	}
	else
	{
		return false;
	}
}
<!--
function popup(url) 
{
 var width  = 300;
 var height = 200;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}
// -->
function popup_big(url) 
{
 var width  = 500;
 var height = 300;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}
function trim(str)
{
    if(!str || typeof str != 'string')
        return null;

    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
function changepwd()
{
	var current_password = trim(document.getElementById("current_password").value);	
	var new_password = trim(document.getElementById("new_password").value);	
	var con_password = trim(document.getElementById("con_password").value);	
	
	if(current_password=="" || current_password==null )
	{
		alert("Please enter current password!!");
		document.getElementById("current_password").focus();
		return false;
	}
	if(new_password=="" || new_password==null )
	{
		alert("Please enter New password!!");
		document.getElementById("new_password").focus();
		return false;
	}
	if(con_password=="" || con_password==null )
	{
		alert("Please enter confirm password!!");
		document.getElementById("con_password").focus();
		return false;
	}
	if(con_password!=new_password )
	{
		alert("confirm password not match with new password!!");
		document.getElementById("con_password").focus();
		return false;
	}
}
function AjaxPostNew(strURL, pFlag) 
{
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) 
	{
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	self.xmlHttpReq.open('get', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() 
	{
		if(self.xmlHttpReq.readyState == 4) 
		{
			pList = self.xmlHttpReq.responseText;
			//alert("abcdaaassssssssssssssssssssssssssssssssss "+ pList+ "sssssssssssssssssssssssssssssaaaaaaaaa");
			switch(pFlag)			
			{
				case 1:
					AfterSubCat(pList);
				break;	
				case 2:
					AfterMailToContactPreson(pList);
				break;
				case 3:
					AfterAcceptRequest(pList);
				break;
			}
		}
		
	}
	self.xmlHttpReq.send(null);
}
function getSubCat(p)
{
	
	strURL = "getSubCat.php?val="+p;

	AjaxPostNew(strURL,1);
}
function AfterSubCat(pContent)
{
document.getElementById("divSubcat").innerHTML=pContent;
}
function allcheck()
{
	
	var sel_quant=	document.getElementById("selQun").value ;
	var pay_type=	document.getElementById("pay_type").value ;
	var hdnresponse=	document.getElementById("hdnresponse").value ;
	
	if(sel_quant =="0")
	{
		alert("Please select Total Leads !!");
		document.getElementById("selQun").focus();
		return false;
	}
	if(pay_type =="")
	{
		alert("Please select Payment Option Option !!");
		document.getElementById("pay_type").focus();
		return false;
	}
	if(hdnresponse==1)
	{
		var where_to= confirm("Your account has lead. Do you want to Increase your leads!!");
		if (where_to== true)
		{
			
		}
		else
		{
			return false;
		}
	}
	
	
	//alert("casjhdasd");
	
}
function AfterBuyRequest(pContent)
{
	
	//alert(pContent);
	if(pContent!=0)
	{
		//return alert_buyer();
		var where_to= confirm("Your account has lead. Do you want to Increase your leads!!");
		if (where_to== true)
		{
			
		}
		else
		{
			return false;
		}
	}
	
}
function alert_buyer()
{
	
	var where_to= confirm("Your account has lead. Do you want to Increase your leads!!");
	if (where_to== true)
	{
		
	}
	else
	{
		return false;
	}
}
function popuppwd()
{
    mywindow = window.open("forgot_password.php", "my", "width=450,height=270");
    my.moveTo(300, 270);
}

function validateforget_password()
{    
	
	
	var forget_emailid                    = document.getElementById("forget_emailid").value;
   
	if(forget_emailid=="")
    {
      alert("Please Enter Your Email ID");
      document.getElementById('forget_emailid').focus();
      return false;
    }
	if(forget_emailid !='')
    {
        if(echeck(document.getElementById("forget_emailid").value)==false)
        {
            document.getElementById("forget_emailid").focus();
            return false;
        }
    } 
}
function echeck(str) 
{
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
       alert("Invalid E-mail ID.")
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       alert("Invalid E-mail ID.")
       return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Invalid E-mail ID.")
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
        alert("Invalid E-mail ID.")
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        alert("Invalid E-mail ID.")

        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
        alert("Invalid E-mail ID.")
        return false
     }
    
     if (str.indexOf(" ")!=-1){
        alert("Invalid E-mail ID.")
        return false
     }

     return true                    
}
function charge()
{
	var sel_quant=	document.getElementById("selQun").value ;
	var category=	document.getElementById("hdnidcat").value ;
	var p =sel_quant * category;
	document.getElementById("txtTotal").value=  p;
	//alert(p);
	
}

function acceptRequest(uid,qid,cid)
{
	
	
	var where_to= confirm("Acceptance of the question will minus 1 lead from your account. Do you want to continue?");
	if (where_to== true)
	{
		strURL = "accept.php?uid="+uid+"&qid="+qid+"&cid="+cid;
		AjaxPostNew(strURL,3);
		
	}
	else
	{
		return false;
	}
}
function AfterAcceptRequest(p)
{
	//alert(p);
	return false;
	//window.href.location="expert_home.php?mode=read&res=accept&qid="+p;
}
function chkMess()
{
	var txtMessage=	document.getElementById("txtMessage").value ;
	if(txtMessage=="")
    {
      alert("Please Enter Your Message to reply");
      document.getElementById('txtMessage').focus();
      return false;
    }
}
