// JScript source code
var mobilenumber;
var custname;
function fnValidate()
{
	/*if (document.frmContacts.txtOrganization.value=="")
    {  alert("Please Enter Company Name");
       document.frmContacts.txtOrganization.focus();
	   return false;
    }*/
	if (document.frmContacts.txtName.value=="")
    {  alert("Please Enter Your Name");
       document.frmContacts.txtName.focus();
	   return false;
    }
	if (document.frmContacts.txtEmail.value=="")
    {  alert("Please Enter Your Email ID");
       document.frmContacts.txtEmail.focus();
	   return false;
    }
	else
    { if(echeck(document.frmContacts.txtEmail.value)==false)
      {   document.frmContacts.txtEmail.value=""
          document.frmContacts.txtEmail.focus();
          return false;
      }
    }
	if (document.frmContacts.txtPISD.value=="")
    {  alert("Please Enter Country Code");
       document.frmContacts.txtPISD.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtPISD.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtPISD.value="";
		    document.frmContacts.txtPISD.focus();
		    return false; 
		}
	}
	
    if (document.frmContacts.txtPSTD.value=="")
    {  alert("Please Enter City Code");
       document.frmContacts.txtPSTD.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtPSTD.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtPSTD.value="";
		    document.frmContacts.txtPSTD.focus();
		    return false; 
		}
	}
    if (document.frmContacts.txtPNo.value=="")
    {  alert("Please Enter Phone");
       document.frmContacts.txtPNo.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtPNo.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtPNo.value="";
		    document.frmContacts.txtPNo.focus();
		    return false; 
		}
	}
	
	if (document.frmContacts.txtMobile.value=="")
    {  alert("Please Enter Mobile No");
       document.frmContacts.txtMobile.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtMobile.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtMobile.value="";
		    document.frmContacts.txtMobile.focus();
		    return false; 
		}
	}
	
	
	/*if (document.frmContacts.txtFISD.value=="")
    {  alert("Please Enter Country Code");
       document.frmContacts.txtFISD.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtFISD.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtFISD.value="";
		    document.frmContacts.txtFISD.focus();
		    return false; 
		}
	}
	
    if (document.frmContacts.txtFSTD.value=="")
    {  alert("Please Enter City Code");
       document.frmContacts.txtFSTD.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtFSTD.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtFSTD.value="";
		    document.frmContacts.txtFSTD.focus();
		    return false; 
		}
	}
    if (document.frmContacts.txtFNo.value=="")
    {  alert("Please Enter Fax");
       document.frmContacts.txtFNo.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtFNo.value))
	    {
		    alert("Please Enter Numeric Value");
		    document.frmContacts.txtFNo.value="";
		    document.frmContacts.txtFNo.focus();
		    return false; 
		}
	}*/
	/*if (document.frmContacts.txtSAddress.value=="")
    {  alert("Please Enter Address");
       document.frmContacts.txtSAddress.focus();
	   return false;
    }*/
	
	if (document.frmContacts.txtCity.value=="")
    {  alert("Please Enter City");
       document.frmContacts.txtCity.focus();
	   return false;
    }
	
	/*if (document.frmContacts.txtZip.value=="")
    {  alert("Please Enter Zip Code");
       document.frmContacts.txtZip.focus();
	   return false;
    }
	else
	{   if(CheckNumerals(frmContacts.txtZip.value))
	    {
		    alert("Please Enter 6 Digit Numeric Value");
		    document.frmContacts.txtZip.value="";
		    document.frmContacts.txtZip.focus();
		    return false; 
		}
	}*/
	if (document.frmContacts.txtCountry.value=="")
    {  alert("Please Enter Country");
       document.frmContacts.txtCountry.focus();
	   return false;
    }
	if (document.frmContacts.txtDescription.value=="")
    {  alert("Please Enter Your Message");
       document.frmContacts.txtDescription.focus();
	   return false;
    }
	
	mobilenumber = document.frmContacts.txtMobile.value;
	custname = document.frmContacts.txtName.value;
	
	//sendRequest('mobilenumber','custname');	
	sendRequest();	
	return true; 	
}


/*function sendRequest() {                   
    //var xmlhttp;
    //xmlhttp = null;
    var oReq = new XMLHttpRequest;
    
    //xmlhttp = createHTTPObject()
    //xmlhttp = getXMLHttpRequest();
    
    var oReq = getXMLHttpRequest();

    if (oReq != null) {
        var pathName;
        pathName = "http://www.smartresponse.in/conf_request.php?activity=click2call&cell=" + mobilenumber + "&name=" + custname + "&webid=vunique";
        oReq.open("GET", pathName, true);
        oReq.onreadystatechange = function() {
            try {
                if (oReq.readyState == 4) {
                    if (oReq.status == 200) {
						if(oReq.responseText.indexOf('SUCCESS')>0)
						alert('SUCCESS');
						return true;
                    }
                }
            } catch (e) {
                alert(e.name)
            }
        }        
		//xmlhttp.open("GET", pathName, true);
		//xmlhttp.send(null);
		oReq.send();
    }
    else {
        window.alert("AJAX (XMLHTTP) not supported.");
    }
}*/

function sendRequest() {  
    var pathName;
    pathName = "http://www.smartresponse.in/conf_request.php?activity=click2call&cell=" + mobilenumber + "&name=" + custname + "&webid=vunique";
    window.open(pathName,'welcome','width=300,height=200,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=no');
    window.opener.close();

    //WebRequest req = HttpWebRequest.Create(pathName); 
    //WebResponse webResponse = req.GetResponse(); 
}

function handler()
{
    if (oReq.readyState == 4 /* complete */) {
        if (oReq.status == 200) {
            alert(oReq.responseText);
        }
    }
}

function getXMLHttpRequest() 
{
    if (window.XMLHttpRequest) {
        return new window.XMLHttpRequest;
    }
    else {
        try {
            return new ActiveXObject("MSXML2.XMLHTTP.3.0");
        }
        catch(ex) {
            return null;
        }
    }
}
function createHTTPObject() {
    if (window.XMLHttpRequest)
        return new XMLHttpRequest();
    else if (window.ActiveXObject)
        return new ActiveXObject("Microsoft.XMLHTTP");
    else
        return null;
}
    
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 fnDiscardApostrophe(key)
{
	if ((key==39))
		return 0;
	else
		return key;
}

function fnDisallowApostrophe() 
{
	window.event.keyCode=fnDiscardApostrophe(window.event.keyCode);   	
	return true;
}

function CheckNumerals(key)
{
	if ((key<48|| key>57))
	{
		return 0;
	}	
	else
		return key;	

}

function fnCheckNumerals(){
window.event.keyCode=CheckNumerals(window.event.keyCode);   	
	return true;
}


