﻿
        function fillDomesticddl(objValue)//
        {
     
             try //For Internet Explorer And Mozilla And Google Chrome 
             {
               var xmlhttp;
               if (window.XMLHttpRequest)
               {
                   xhttp = new window.XMLHttpRequest();
               }
               else // Internet Explorer 5/6 
               {
                   xhttp = new ActiveXObject("Microsoft.XMLHTTP");
               }
               xhttp.open("GET", "XmlHandler.ashx?PackType=" + objValue, false);
               xhttp.send("");
               xmlDoc1 = xhttp.responseXML;
               var x = xmlDoc1.getElementsByTagName("lst");
               ClearDropDown(document.getElementById('ddlCity'));
               AddItem('All', '', document.getElementById('ddlCity'));
               for (var i = 0; i < x.length; i = i + 1) 
               {
                   var ddlValue = x[i].getAttribute("id");
                   var ddlText = x[i].getAttribute("name");
                   AddItem(ddlText, ddlValue, document.getElementById('ddlCity'));
               }
            }
           catch (ex) {
                  alert(ex);
            }
        }
        
        function packageAlphas(objValue,city)//
        {
        
             try //For Internet Explorer And Mozilla And Google Chrome 
             {
               var xmlhttp;
               if (window.XMLHttpRequest)
               {
                   xhttp = new window.XMLHttpRequest();
               }
               else // Internet Explorer 5/6 
               {
                   xhttp = new ActiveXObject("Microsoft.XMLHTTP");
               }
               xhttp.open("GET", "XmlHandler.ashx?packAlpha="+city+"&PackType=" + objValue, false);
               xhttp.send("");
               xmlDoc1 = xhttp.responseXML;
               var x = xmlDoc1.getElementsByTagName("lst");
               var text='';
               if(document.getElementById('divAlpha')!=null)
               {
                   for (var cntr = 0; cntr < x.length; cntr = cntr + 1) 
                   {
                       var ddlValue = x[cntr].getAttribute("id");
                       var ddlValue1 = x[cntr].getAttribute("name");
                       if(cntr>0)
                            text=text+" | <a id=\""+ddlValue+"\" class=\"alpha-normal\" onclick=\"javascript:redirect(this.id);\">"+ddlValue1+"</a>";
                       else
                            text="<a id=\""+ddlValue+"\" class=\"alpha-normal\" onclick=\"javascript:redirect(this.id);\">"+ddlValue1+"</a>";
                      
                   }
                   if(text=='')
                       text="<a id=\"all\" class=\"alpha-normal\" onclick=\"javascript:redirect(this.id);\">View all</a>";
                   else
                       text=text+" | <a id=\"all\" class=\"alpha-normal\" onclick=\"javascript:redirect(this.id);\">View all</a>";
                       
               
                   document.getElementById('divAlpha').innerHTML=text;
               }
//               AddItem('All', '', document.getElementById('ddlCity'));
//               for (var i = 0; i < x.length; i = i + 1) 
//               {
//                   var ddlValue = x[i].getAttribute("id");
//                   var ddlText = x[i].getAttribute("name");
//                   AddItem(ddlText, ddlValue, document.getElementById('ddlCity'));
//               }
            }
           catch (ex) {
                  alert(ex);
            }
        }
        
        
        function redirect(id)
        {
            var alpha="";
            var url=location.href;
            var queryStrings=url.split('?');
            if(id.length<4)
            {
              alpha=id;
            }
            if(queryStrings.length>1)
            {
                if (location.href.match("city-packages.aspx")==null)
                {
                    var cityqs=getQuerystring("city");
                    if(cityqs!="")
                    {
                        url=url.replace("&city="+cityqs,"");
                        url=url.replace("city="+cityqs+"&","");
                    }
                }
                var qs=getQuerystring("alpha");
                if(qs == "")
                   url=url+"&alpha="+alpha;
                 else
                    {
                        url=url.replace("&alpha="+qs,"&alpha="+alpha);
                        url=url.replace("?alpha="+qs,"?alpha="+alpha);
                    }
            }
            else
            {
                url=url+"?alpha="+alpha;
            }
            window.open(url,"_self");
        }
        
        
        function getQuerystring(key, default_)
        {
          if (default_==null) default_="";
          key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
          var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
          var qs = regex.exec(window.location.href);
          if(qs == null)
            return default_;
          else
            return qs[1];
        }
        
        function setValueAlpha(alpha)
        {
            if(document.getElementById(alpha)!=null)
            document.getElementById(alpha).className="alpha-selected";
        }
        
        function setValue(theme,city,duration,type)
        {
            document.getElementById("ddlType").value=type;
            document.getElementById("ddlThemes").value=theme;
            document.getElementById("ddlCity").value=city;
            document.getElementById("ddlDuration").value=duration;
        }
        
        function redirectPage(id)
        {
            var type=document.getElementById("ddlType").value;
            var theme=document.getElementById("ddlThemes").value;
            var city=document.getElementById("ddlCity").value;
            var duration=document.getElementById("ddlDuration").value;
            if(document.getElementById('flagTheme')!=null)
            {
                if(document.getElementById('flagTheme').value=='true')
                {
                    theme=document.getElementById("ddlThemes").value;
                }
                else
                {
                    theme="";
                }
            }
            if(document.getElementById('flagDuration')!=null)
            {
                if(document.getElementById('flagDuration').value=='true')
                {
                    duration=document.getElementById("ddlDuration").value;
                }
                else
                {
                    duration="";
                }
            }
            if(id=='blank')
            {
                theme='';
                duration='';
                city='';
            }
            if(city=='')
            {
                if(type=='domestic')
                    window.open("domestic-packages.aspx?theme="+theme+"&city="+city+"&du="+duration+"&type="+type,"_self");
                else if(type=='international')
                    window.open("international-packages.aspx?theme="+theme+"&city="+city+"&du="+duration+"&type="+type,"_self");
                else if(type=='incredibile')
                    window.open("incredible-india-packages.aspx?theme="+theme+"&city="+city+"&du="+duration+"&type="+type,"_self");
            }
            else
            {
                 window.open("city-packages.aspx?theme="+theme+"&city="+city+"&du="+duration+"&type="+type,"_self");
            }
        }
        
        function getVal(type)
        {
            if(type=='theme')
            document.getElementById('flagTheme').value='true';
            if(type=='duration')
            document.getElementById('flagDuration').value='true';
        }
       
        
