﻿// JScript File

var txtName;
var txtEmail;
var ddlCountry;
var txtMessage;

function cls_contact_us()
{
    this.complete= Completed;  
}

function Completed()
{
    var objContactUs= document.getElementById('divContactUs');
objContactUs.style.display= "none";

var objResult= document.getElementById('divContactUsResult');
objResult.style.display= "block";
}


function Load(txtNameId, txtEmailId, ddlCountryId, txtMessageId)
{
 txtName= document.getElementById(txtNameId);
 txtEmail= document.getElementById(txtEmailId);
 ddlCountry= document.getElementById(ddlCountryId);
 txtMessage= document.getElementById(txtMessageId);
}

function IsValid()
{
    var strError= "";
    
    if ( txtName == null )
        return true;
    
    if ( IsEmpty(txtName) )
        strError += "* Enter Name<br />";
    
    if( IsEmpty(txtEmail) )
        strError += "* Enter Email<br />";
    
    if( ! (IsEmpty(txtEmail) ||  IsValidEmail(txtEmail.value)) )
        strError+= "* Enter a valid email<br />";
    
    if( ddlCountry.selectedIndex == 0 )
        strError+= "* Select a country<br />";
        
    if(IsEmpty(txtMessage))
        strError += "* Enter a message<br />";
        
    if( strError.length > 1 )
    {
        document.getElementById('spnErrorMessage').innerHTML= 
        "<span style='color:red;font-weight:bold'>" + strError + "</span>";
        return false;
    }
    return true;
}

function Send(strUrl)
{
    if( ! IsValid() )
    {
        return false;
    }
    var objContactUs= new cls_contact_us();
    
    document.getElementById('spnErrorMessage').innerHTML="<img src='images/loading.gif' />"; 
    TestShAjax(strUrl + "&N=" + txtName.value + "&E=" + txtEmail.value + "&C=" + 
    ddlCountry.options[ddlCountry.selectedIndex].text + 
    "&M=" +  txtMessage.value, '','spnStatusMessage', objContactUs);
    
    return false;
}

