﻿// JScript File
var obj;
function GetDataViaAJAX()
{
    if (window.XMLHttpRequest) 
    { 
        // Mozilla, Safari, ...
        obj = new XMLHttpRequest();
        if (obj.overrideMimeType) 
        {
            obj.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try
        {
        obj = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                obj = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e1)
            {
                obj = null;
            }
        }
    }//end else if

    if (obj==null) 
    {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }

    if(obj!=null)
    {
        obj.onreadystatechange = ProcessResponse;
        obj.open("GET", "http://www.worldwideproperty4u.com/ChangeType.aspx?id=" + document.getElementById("drpContinent").value,  true);
        //obj.open("GET", "http://localhost:1556/site/ChangeType.aspx?id=" + document.getElementById("drpContinent").value,  true);
        obj.send(null);         
    }
    return false;
}

function ProcessResponse()
{
    if(obj.readyState == 4)
    {
        if(obj.status == 200)
        {
        
        var continent =  document.getElementById("drpContinent");      
        
        var dsRoot=obj.responseXML.documentElement; 
        //var dsRoot=obj.responseText.documentElement; 
        var ddlOrders = document.getElementById("drpCountry");
        
        var orders = dsRoot.getElementsByTagName('CountryName');
        var orderId=dsRoot.getElementsByTagName('CountryID');
        var text; 
        var text1;
        var listItem;
        
        
        for (var count = ddlOrders.options.length-1; count >-1; count--)
        {
            ddlOrders.options[count] = null;
        }
        
        if(continent.value == 0)
        {
                text = "Countries";
                text1 = "0";
                listItem = new Option(text, text1, false, false);
                ddlOrders.options[ddlOrders.options.length] = listItem;
        }
        else
        { 
            for (var count = 0; count < orders.length; count++)
            {
                text = (orders[count].textContent || orders[count].innerText || orders[count].text);
                text1 = (orderId[count].textContent || orderId[count].innerText || orderId[count].text);
                listItem = new Option(text, text1, false, false);
                ddlOrders.options[ddlOrders.options.length] = listItem;
            }
        }
        changeText();
        }
        else
        {
            alert("Error retrieving data!" );
        }
    }
}

function validateEmail() {
var text = document.getElementById("txtEmail");
var strValue = text.value;
if(strValue.length <=0 ){ alert("Please enter email."); return; }

//var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

var objRegExp  = /(\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/i;

 if(!objRegExp.test(strValue)){ alert("Please enter valid email."); return; }

 window.open("registration.aspx?emailadd=" + strValue);
}

function changeContinent(obj){

var combo = document.getElementById("drpContinent");
for(var i=0;i<combo.options.length;i++)
{
if(combo.options[i].value==obj){
combo.selectedIndex = i;
}
}
 changeImage();
}

function changeImage() {
var combo = document.getElementById("drpContinent");

var mapdiv = document.getElementById("divmap");
if(combo.selectedIndex == 0){mapdiv.innerHTML = "<IMG id=\"imgMapWorld\" width=\"372\" height=\"190\" alt=\"World Map\" src=\"images/imgworldrelief.jpg\" useMap=\"#imgworldrelief_Map\" border=\"0\" >";}
else if(combo.selectedIndex == 1){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" height=\"189\" width=\"203\" alt=\"Africa Map\" src=\"images/mapafrica.jpg\" border=\"0\" useMap=#MapAfrica_Map >";}
else if(combo.selectedIndex == 2){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG src=\"images/mapasia.gif\" alt=\"Asia Map\" name=\"imgMapWorld\" width=\"203\" height=\"190\" border=\"0\" useMap=#MapAsia_Map id=\"imgMapWorld\" >";}
else if(combo.selectedIndex == 3){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"Central America - Caribbean Map\" src=\"images/MapCeAmCar.gif\" border=\"0\" useMap=#MapCAC_Map >";}
else if(combo.selectedIndex == 4){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"Europe Map\" src=\"images/mapeurope.jpg\" border=\"0\" useMap=#MapEurope_Map >";}
else if(combo.selectedIndex == 5){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"Middle East Map\" src=\"images/mapmiddleeast.jpg\" border=\"0\" useMap=#MapMiddleEast_Map >";}
else if(combo.selectedIndex == 6){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"North America Map\" src=\"images/mapnorthamerica.gif\" border=\"0\" useMap=#MapNorthAmerica_Map >";}
else if(combo.selectedIndex == 7){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"Oceania Map\" src=\"images/mapoceania.jpg\" border=\"0\" useMap=#MapOceania_Map >";}
else if(combo.selectedIndex == 8){mapdiv.innerHTML = "<a href=\"#\" onclick=\"javascript:changeContinent(0);\"><img src=\"images/smallworldmap.jpg\" border=\"0\" width=\"60\" height=\"40\" /></a><IMG id=\"imgMapWorld\" width=\"203\" height=\"190\" alt=\"South America Map\" src=\"images/mapsouthamerica.gif\" border=\"0\" useMap=#MapSouthAmerica_Map >";}

//var imgobj = document.getElementById("imgMapWorld");
//if(combo.selectedIndex == 0){imgobj.src = "images/imgworldrelief.jpg";}
//else if(combo.selectedIndex == 1){imgobj.src = "images/mapafrica.jpg";}
//else if(combo.selectedIndex == 2){imgobj.src = "images/mapasia.gif";}
//else if(combo.selectedIndex == 3){imgobj.src = "images/MapCeAmCar.gif";}
//else if(combo.selectedIndex == 4){imgobj.src = "images/mapeurope.jpg";}
//else if(combo.selectedIndex == 5){imgobj.src = "images/mapmiddleeast.jpg";}
//else if(combo.selectedIndex == 6){imgobj.src = "images/mapnorthamerica.gif";}
//else if(combo.selectedIndex == 7){imgobj.src = "images/mapoceania.jpg";}
//else if(combo.selectedIndex == 8){imgobj.src = "images/mapsouthamerica.gif";}
GetDataViaAJAX();

var label = document.getElementById("lblcontinent");
label.innerHTML = combo.options[combo.selectedIndex].innerHTML != "Continents"?combo.options[combo.selectedIndex].innerHTML:"";
changeText();
if(label.innerHTML.length > 0) {label.innerHTML += " - ";}
}

function changeText(){
var combocountry = document.getElementById("drpCountry");
var labe2 = document.getElementById("lblcities");
labe2.innerHTML = combocountry.options[combocountry.selectedIndex].innerHTML != "Countries"?combocountry.options[combocountry.selectedIndex].innerHTML:"";

}

function changeCountry(obj){

var combo = document.getElementById("drpCountry");
for(var i=0;i<combo.options.length;i++)
{
if(combo.options[i].value==obj){
combo.selectedIndex = i;
}
}
changeText();
}