﻿// JScript File

function GenerateRequests() 
     {
           var doc;
           try
           {
               doc=new ActiveXObject('Msxml2.DOMDocument.3.0');
               //doc=document.implementation.createDocument("","",null);
           }
           catch (e)
           {
                // Internet Explorer
              try
              {
                  doc=new ActiveXObject("Msxml2.XMLHTTP");
                  doc=document.implementation.createDocument("","",null);
              }
              catch (e)
              {
                    // Firefox, Opera 8.0+, Safari
                  doc=document.implementation.createDocument("","",null);
              }
           }
           doc.async = false;
           var nodelist;
           if (doc.load('CoronaFiles.xml')) {
            //doc.setProperty('SelectionLanguage', 'XPath');
            //nodelist= doc.selectNodes('gallery/images/image');
            nodelist=doc.getElementsByTagName("Page");
           }
           var count=0;
           var i=0;
           count=nodelist.length;
           for(i=0;i<count;i++)
           {       
                var attributevalues=nodelist[i].attributes;
                
                try
                {
                    if (requests = new XMLHttpRequest()) 
                    { 
                        requests = new XMLHttpRequest();
                        try 
                        {
                            requests.open("GET", attributevalues[0].value , true);
                            //doc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                        } 
                        catch (e) 
                        {
                            alert(e);
                        }
                        requests.send(null);
                    }    
                }
                catch(e)
                {
                    if (window.ActiveXObject) 
                    { // IE
                        try
                        {
                            requests=new ActiveXObject('Msxml2.DOMDocument.3.0');
                            requests.open("GET", attributevalues[0].value , true);
                            requests.send();
                        }
                        catch (e)
                        {
                          // Internet Explorer
                            try
                            {   
                                requests=new ActiveXObject("Msxml2.XMLHTTP");
                                requests.open("GET", attributevalues[0].value , true);
                                requests.send();
                            }
                            catch (e) 
                            {
                                alert("try");
                            }
                         }
                    }
                }
                //alert(attributevalues[0].value);
                //document.write ('<img src=Exterior/thumbnails/' + attributevalues[3].value + ' style="border:2pt solid white" alt="armchair_001" onclick="' + "changeimage('" + attributevalues[3].value + "')" + '"  onmouseover="' + "changeimage('" + attributevalues[3].value + "')" + '"  />');
           }
     }
     function ChangePanel()
     {
         document.getElementById ("leftcolumn").style.height=document.getElementById ("rightcolumn").style.height;
     } 
     function changeimage(s)
     {
         var visibility= document.getElementById (s).style .display ;
         if(visibility=='none')
         {
             document.getElementById (s).style .display  ="block";
         } 
         else
         {
             document.getElementById (s).style .display ="none";
         }
     }
     function StateChange() 
     {
        if (doc.readyState == 4) 
        {// Complete
            if (doc.status == 200) 
            { // OK response
                x=doc.responseText;
                index_start=x.indexOf("*");
                index_end=x.indexOf("**");
                var resultstring=x.slice(index_start+1,index_end);
                alert(resultstring);
            }  
            else 
            {
                alert("Problem: " + doc.statusText);
            }
        }
     }
     
     function ProcessStateChange() 
     {
        if (doc.readyState == 4) 
        {// Complete
            if (doc.status == 200) 
            { // OK response
                x=doc.responseText;
                index_start=x.indexOf("*");
                index_end=x.indexOf("**");
                var resultstring=x.slice(index_start+1,index_end);
                document.getElementById ("placeelement").innerHTML=resultstring;
            }  
            else 
            {
                alert("Problem: " + doc.statusText);
            }
        }
        
     }
     function ChangePage(s)
     {  
        try
        {
            if (doc = new XMLHttpRequest()) 
            { 
                doc = new XMLHttpRequest();
                doc.onreadystatechange = ProcessStateChange;
                try 
                {
                    doc.open("GET", s , true);
                    //doc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                } 
                catch (e) 
                {
                    alert(e);
                }
                doc.send(null);
            } 
        }
        catch(e)
        {
            if (window.ActiveXObject) 
            { // IE
                try
                {
                    doc=new ActiveXObject('Msxml2.DOMDocument.3.0');
                    doc.onreadystatechange = ProcessStateChange;
                    doc.open("GET", s , true);
                    doc.send();
                }
                catch (e)
                {
                  // Internet Explorer
                    try
                    {   
                        doc=new ActiveXObject("Msxml2.XMLHTTP");
                        doc.onreadystatechange = ProcessStateChange;
                        doc.open("GET", s , true);
                        doc.send();
                    }
                    catch (e) 
                    {
                        alert("try");
                    }
                 }
            }
        }
     }
     function validations()
     {
        var email=document.getElementById ("txtEmailID").value;
        //var emailRegxp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2})$/;
        var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
        if (emailRegxp.test(email)!= true)
        {
            alert("Email address appears to be incorrect");
            return;
        }    
        if(document.getElementById ("drpCountry").value=="select")
        {
            alert("Please select the country");
            return ;
        }
        if (doc = new XMLHttpRequest()) 
        { 
            doc = new XMLHttpRequest();
            doc.onreadystatechange = StateChange;
            try 
            {
                doc.open("GET", "frmQuickContact1.aspx?tn=" + document.getElementById ("txtName").value + "&te=" + document.getElementById ("txtEmailID").value + "&tp=" + document.getElementById ("txtPhoneNo").value + "&dc=" + document.getElementById ("drpCountry").value + "&tc=" + document.getElementById ("txtComments").value , true);
                //doc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            } 
            catch (e) 
            {
                alert(e);
            }
            doc.send(null);
        } 
        else if (window.ActiveXObject) 
        { // IE
            try
            {
                doc=new ActiveXObject('Msxml2.DOMDocument.3.0');
                doc.onreadystatechange = StateChange;
                doc.open("GET", "frmQuickContact1.aspx?tn=" + document.getElementById ("txtName").value + "&te=" + document.getElementById ("txtEmailID").value + "&tp=" + document.getElementById ("txtPhoneNo").value + "&dc=" + document.getElementById ("drpCountry").value + "&tc=" + document.getElementById ("txtComments").value , true);
                doc.send();
            }
            catch (e)
            {
              // Internet Explorer
                try
                {   
                    doc=new ActiveXObject("Msxml2.XMLHTTP");
                    doc.onreadystatechange = StateChange;
                    doc.open("GET", "frmQuickContact1.aspx?tn=" + document.getElementById ("txtName").value + "&te=" + document.getElementById ("txtEmailID").value + "&tp=" + document.getElementById ("txtPhoneNo").value + "&dc=" + document.getElementById ("drpCountry").value + "&tc=" + document.getElementById ("txtComments").value , true);
                    doc.send();
                }
                catch (e) 
                {
                    alert("try");
                }
             }
        }
     } 
