﻿function fnQuickContact()
{//e-Planet
    if(document.getElementById("tbxQCRName").value.Trim() == "")
    {
        jAlert('Please enter your name or company name !', 'Information...', function(){document.getElementById("tbxQCRName").focus();} );
        document.getElementById("tbxQCRName").focus();
        return false;
    }
    else if(document.getElementById("tbxQCREmail").value.Trim() == "")
    {
        jAlert('Please enter your Email Id!','Information...', function(){document.getElementById("tbxQCREmail").focus();} );
        document.getElementById("tbxQCREmail").focus();
        return false;
    }
    else if(document.getElementById("tbxQCRContactNo").value.Trim() == "")
    {
        jAlert('Please enter your contact number!','Information...', function(){document.getElementById("tbxQCRContactNo").focus();} );
        document.getElementById("tbxQCRContactNo").focus();
        return false;
    }
    
    var obXmlHttpRequest = GetXmlHttpRequest();
    if (obXmlHttpRequest==null){alert ("Your browser does not support AJAX!");return;}
    
    var params = "CompanyName="+document.getElementById("tbxQCRName").value.Trim().AjaxEncode();
    params += "&Email="+document.getElementById("tbxQCREmail").value.Trim().AjaxEncode();
    params += "&ContactNo="+document.getElementById("tbxQCRContactNo").value.Trim().AjaxEncode();
    params += "&Subject=e-Planet Infosystem :: Quick Contact";
    params += "&FromEmailType=FromQCREmail";

    var dt = new Date();
    var url='AllAjax/AjaxContact.aspx?dt='+dt.getSeconds();
    obXmlHttpRequest.onreadystatechange = function()
    {
        if (obXmlHttpRequest.readyState == 4)
        {
            document.getElementById("tbxQCRName").value = "";
            document.getElementById("tbxQCREmail").value = "";
            document.getElementById("tbxQCRContactNo").value = "";
            if (obXmlHttpRequest.responseText.indexOf("Error") > -1) { jAlert(obXmlHttpRequest.responseText, 'Error !'); return; }
            //if(obXmlHttpRequest.responseText == "true")
            //{
            jAlert("Thank you for your interest!\nWe will contact you soon.", 'Information...');
            //document.getElementById("divQCRMess").innerHTML="Thank you for your interest.We will contact you soon.";
            //}
            obXmlHttpRequest = null;
        }
    }
    obXmlHttpRequest.open("POST",url,true);
    obXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    obXmlHttpRequest.send(params);
}

function fnContactUs()
{//e-Planet
    if(document.getElementById("tbxFullName").value.Trim() == "")
    {
        jAlert('Please enter your Name!','Information...', function(){document.getElementById("tbxFullName").focus();} );
        return false;
    }
    else if(document.getElementById("tbxEmail").value.Trim() == "")
    {
        jAlert('Please enter your Email Id!','Information...', function(){document.getElementById("tbxEmail").focus();} );
        document.getElementById("tbxEmail").focus();
        return false;
    }
    if (fnCheckEmail(document.getElementById('tbxEmail'),true) == false) { fnShowAlert("Enter valid EmailID! "); return false; }
    var obXmlHttpRequest = GetXmlHttpRequest();
    if (obXmlHttpRequest==null){alert ("Your browser does not support AJAX!");return;}
    
    var params = "FullName="+document.getElementById("tbxFullName").value.Trim().AjaxEncode();
    params += "&CompanyName="+document.getElementById("tbxCompanyName").value.Trim().AjaxEncode();
    params += "&ContactNo="+document.getElementById("tbxContactNo").value.Trim().AjaxEncode();
    params += "&Email="+document.getElementById("tbxEmail").value.Trim().AjaxEncode();
    params += "&Subject=e-Planet Infosystem :: Contact Us";
    params += "&City="+document.getElementById("tbxCity").value.Trim().AjaxEncode();
    params += "&Description="+document.getElementById("tbxDescription").value.Trim().AjaxEncode();
    params += "&FromEmailType=FromContactUsEmail";
    
    var dt = new Date();
    var url='AllAjax/AjaxContact.aspx?dt='+dt.getSeconds();
    obXmlHttpRequest.onreadystatechange = function()
    { 
        if (obXmlHttpRequest.readyState==4)
        {
            try
            {
                document.getElementById("tbxFullName").value = "";
                document.getElementById("tbxCompanyName").value = "";
                document.getElementById("tbxContactNo").value = "";
                document.getElementById("tbxEmail").value = "";
                document.getElementById("tbxCity").value = "";
                document.getElementById("tbxDescription").value = "";
                obXmlHttpRequest=null;
            }catch(e){}
            jAlert("Thank you for your interest! \nWe will contact you soon.", 'Information...!');
        }
    }
    obXmlHttpRequest.open("POST",url,true);
    obXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    obXmlHttpRequest.send(params);
}

function fnContactUsSD() {//e-Planet
    if (document.getElementById("tbxFullName").value.Trim() == "") {
        jAlert('Please enter your Name!', 'Information...', function() { document.getElementById("tbxFullName").focus(); });
        return false;
    }
    else if (document.getElementById("tbxEmail").value.Trim() == "") {
        jAlert('Please enter your Email Id!', 'Information...', function() { document.getElementById("tbxEmail").focus(); });
        document.getElementById("tbxEmail").focus();
        return false;
    }
    if (fnCheckEmail(document.getElementById('tbxEmail'), true) == false) { fnShowAlert("Enter valid EmailID! "); return false; }
    var obXmlHttpRequest = GetXmlHttpRequest();
    if (obXmlHttpRequest == null) { alert("Your browser does not support AJAX!"); return; }

    var params = "FullName=" + document.getElementById("tbxFullName").value.Trim().AjaxEncode();
    params += "&CompanyName=" + document.getElementById("tbxCompanyName").value.Trim().AjaxEncode();
    params += "&ContactNo=" + document.getElementById("tbxContactNo").value.Trim().AjaxEncode();
    params += "&Email=" + document.getElementById("tbxEmail").value.Trim().AjaxEncode();
    params += "&Subject=e-Planet Infosystem :: Contact Us";
    params += "&City=" + document.getElementById("tbxCity").value.Trim().AjaxEncode();
    params += "&Description=" + document.getElementById("tbxDescription").value.Trim().AjaxEncode();
    params += "&FromEmailType=FromContactUsEmail";

    var dt = new Date();
    var url = 'AllAjax/AjaxContact.aspx?dt=' + dt.getSeconds();
    obXmlHttpRequest.onreadystatechange = function() {
        if (obXmlHttpRequest.readyState == 4)
        {
        alert(obXmlHttpRequest.responseText);
            try {
                document.getElementById("tbxFullName").value = "";
//                document.getElementById("tbxCompanyName").value = "";
//                document.getElementById("tbxContactNo").value = "";
//                document.getElementById("tbxEmail").value = "";
//                document.getElementById("tbxCity").value = "";
                document.getElementById("tbxDescription").value = "";
                obXmlHttpRequest = null;
            } catch (e) { }
            jAlert("Thanks for the wishes!", 'Information...!');
        }
    }
    obXmlHttpRequest.open("POST", url, true);
    obXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    obXmlHttpRequest.send(params);
}

function fnAppArchQuickContact()
{//e-Planet
    if(document.getElementById("tbxEmail").value.Trim() == "")
    {
        jAlert('Please enter your Email Id!','Information...', function(){document.getElementById("tbxEmail").focus();} );
        document.getElementById("tbxEmail").focus();
        return false;
    }
    else if(document.getElementById("tbxContactNo").value.Trim() == "")
    {
        jAlert('Please enter your contact number!','Information...', function(){document.getElementById("tbxContactNo").focus();} );
        document.getElementById("tbxContactNo").focus();
        return false;
    }
    var obXmlHttpRequest = GetXmlHttpRequest();
    if (obXmlHttpRequest==null){alert ("Your browser does not support AJAX!");return;}
    
    var params = "CompanyName="+document.getElementById("tbxName").value.Trim().AjaxEncode();
    params += "&Email="+document.getElementById("tbxEmail").value.Trim().AjaxEncode();
    params += "&ContactNo="+document.getElementById("tbxContactNo").value.Trim().AjaxEncode();
    params += "&Subject=e-Planet Infosystem :: Application Architect";
    params += "&FromEmailType=FromAppArchEmail";

    var dt = new Date();
    var url='AllAjax/AjaxContact.aspx?dt='+dt.getSeconds();
    obXmlHttpRequest.onreadystatechange = function()
    { 
        if (obXmlHttpRequest.readyState==4)
        {
            document.getElementById("tbxName").value = "";
            document.getElementById("tbxEmail").value = "";
            document.getElementById("tbxContactNo").value = "";
            //if(obXmlHttpRequest.responseText == "true")
            //{
                jAlert("Thank you for your interest!\nWe will contact you soon.", 'Information...!');
                try{
                document.getElementById("divAlertMessage").innerHTML  = "";
                document.getElementById("alertbackground").style.display = "none";
                document.getElementById("alertbox").style.display = "none";
                }catch(e){}
            //}
 		    obXmlHttpRequest=null;
        }
    }
    obXmlHttpRequest.open("POST",url,true);
    obXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    obXmlHttpRequest.send(params);
}

function GetXmlHttpRequest()
{//e-Planet
    var obXmlHttpRequest=null;
    try
    {   // Firefox, Opera 8.0+, Safari
        obXmlHttpRequest=new XMLHttpRequest();
    }
    catch (e)
    {   // Internet Explorer
        try
        {
            obXmlHttpRequest=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            obXmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return obXmlHttpRequest;
}

String.prototype.Trim = function (){return this.replace(/^\s*/, "").replace(/\s*$/, "");}

String.prototype.AjaxEncode = function ()
{//e-Planet
	var strSource = escape(this).Replace("+","%2B"); return strSource;
}

String.prototype.Replace = function(stringBy,stringTo)
{//e-Planet
    var strReturn = this;
    while(strReturn.indexOf(stringBy) > -1)
    {
        strReturn = strReturn.replace(stringBy,"╪");
    }
    while(strReturn.indexOf("╪") > -1)
    {
        strReturn = strReturn.replace("╪",stringTo);
    }
    return strReturn;
}
