﻿    /**************** JScript File ****************************/
    
    var destinationAirportArray;
    var count=0;
    
    //Save Destination Airport in an ArrayList
    function SaveDestinationAirport(destinationAirportCity_,category_)
    {      
        if(count==0 && category_==1)
        {   
            destinationAirportArray=new Array(destinationAirportCity_.options.length);     
            for(var i=0; i < destinationAirportCity_.options.length;i++)
            {     
                  destinationAirportArray [i] = new Array(2);          
                  destinationAirportArray[i][0]=destinationAirportCity_.options[i].text;               
                  destinationAirportArray[i][1]=destinationAirportCity_.options[i].value;               
            }          
             count=1;
         }        
     }
    
    
    function ShowHideCodeValue( category_,originAirport_, destinationAirport_)
    {      
        var category=document.getElementById(category_);
        var originAirport = document.getElementById(originAirport_);
        var destinationAirport = document.getElementById(destinationAirport_);
        var selectedValue = originAirport.value;         
              
        if(originAirport.selectedIndex > 0)
        {                
             SaveDestinationAirport(destinationAirport,category.value);           
             destinationAirport.options.length = 0;
            //Remove all elements from dropdown
            for(var i=0; i < destinationAirport.options.length;i++)
            {
                destinationAirport.remove(i);
            }
            //Reload  Destination Airport in the dropdown
            for(var i=0; i< destinationAirportArray.length;i++)
            {         
                if(destinationAirportArray[i][1] != selectedValue)
                {                    
                  destinationAirport.options.add(new Option(destinationAirportArray[i][0],
                  destinationAirportArray[i][1]));
                }
            }
        }        
    }
    
    
    function ShowReader(flightRssUrl_,hotelRssUrl_,originAirport_, destinationAirport_,termsConditions_,category_)
    {     
        var originAirport = document.getElementById(originAirport_); 
        var destinationAirport = document.getElementById(destinationAirport_);
        var termsConditions = document.getElementById(termsConditions_);
        var category = document.getElementById(category_);

        if(category.selectedIndex==0 && originAirport.selectedIndex > 0 && destinationAirport.selectedIndex > 0 && termsConditions.checked == true)
         {        
            document.getElementById('DivRssReader').style.display = "block";
            document.getElementById('DivRss').style.display = "none";
            document.getElementById('LnkManual').href = flightRssUrl_ + '?From=' + originAirport.value  + '&To=' +  destinationAirport.value;
            document.getElementById('Lnkmyyahoo').href = 'http://e.my.yahoo.com/config/cstore?.opt=content&.url='+flightRssUrl_+'?From=' +  originAirport.value+ '%26To=' + destinationAirport.value;
            document.getElementById('Lnkgoogle').href = 'http://www.google.com/ig/add?feedurl='+flightRssUrl_+'?From=' +  originAirport.value + '%26To=' +  destinationAirport.value;
           
            document.getElementById('Lnkngsub').href = 'https://www.newsgator.com/ngs/si.aspx?ReturnUrl='+flightRssUrl_+'?From=' +  originAirport.value + '%26To=' +  destinationAirport.value;

        document.getElementById('Lnkmodern11').href = 'http://www.bloglines.com/sub/'+flightRssUrl_+'?From=' +  originAirport.value + '%26To=' + destinationAirport.value;
  
            return false;
        }
        else if(category.selectedIndex==1  && destinationAirport.selectedIndex > 0 && termsConditions.checked == true)
        {
            document.getElementById('DivRssReader').style.display = "block";
            document.getElementById('DivRss').style.display = "none";
            document.getElementById('LnkManual').href = hotelRssUrl_+  destinationAirport.value;
            document.getElementById('Lnkmyyahoo').href = 'http://e.my.yahoo.com/config/cstore?.opt=content&.url=' + hotelRssUrl_+ destinationAirport.value ;
            document.getElementById('Lnkgoogle').href = 'http://www.google.com/ig/add?feedurl='+hotelRssUrl_+ destinationAirport.value;

            document.getElementById('Lnkngsub').href = 'https://www.newsgator.com/ngs/si.aspx?ReturnUrl='+hotelRssUrl_+ destinationAirport.value;

            document.getElementById('Lnkmodern11').href = 'http://www.bloglines.com/sub/'+hotelRssUrl_+ destinationAirport.value;
            return false;
        }
        else
        {
            if(destinationAirport.selectedIndex == 0)                
            {
                alert("Please select a destination");
                destinationAirport.focus();
                return false;
            }
            if(termsConditions.checked == false)
            {
                alert("You must agree to CheapOair's RSS terms of use");
                termsConditions.focus();
                return false;                                
            }
          
            if(category_ == "1" &&originAirport.selectedIndex == 0)
            {
                alert("Please select an origin");
                originAirport.focus();
                return false;
            }                          
        }       
    }
    
    
    function  ShowRSSGenerator(category_,originAirport_, destinationAirport_, termsConditions_)
    { 
        document.getElementById('DivRssReader').style.display = "none";
        document.getElementById('DivRss').style.display = "block";

        document.getElementById(destinationAirport_).selectedIndex = 0;
        document.getElementById(termsConditions_).checked = false;
    
        if(document.getElementById(category_).selectedIndex ==0)
        {
          document.getElementById(originAirport_).selectedIndex = 0;
        } 
           return false;
    }
     

    
    function taxesfees() 
    { 
        window.open('DesktopModules/Misc/Rss/Taxes_Fees.html','taxesfees','top=200,left=200,toolbars=no,location=no,directories=no,menubar=no,width=550,height=280,resizable=no,scrollbars=yes,status=no,titlebar=no'); 
    }
    
    function payment() 
    { 
        window.open('DesktopModules/Misc/Rss/fare_rules.html','payment','width=540,height=300,top=200,left=200,resizable=no,scrollbars=yes,toolbar=no,status=no,titlebar=no'); 
    }
    
    

  function showDiv(ctrlId_,url_)
   {    
        var pos = $("#"+ctrlId_).offset(); 
        var width = $("#"+ctrlId_).width();  
  
        $("#popup").css( { "left": (pos.left + width + (-1)) + "px", "top":pos.top + "px" } ).show(100);       
        SetRedirectURL(url_);
        return false;
   }
   
 function SetRedirectURL(rssLink_)
{   
    var iframe= $('#iframeRss').contents();   
    iframe.find('#blogLines').attr( "href",'http://www.bloglines.com/sub/'+rssLink_);
    iframe.find('#myyahoo').attr("href", 'http://e.my.yahoo.com/config/cstore?.opt=content&.url='+rssLink_);
    iframe.find('#google').attr( "href",'http://www.google.com/ig/add?feedurl='+rssLink_);
    iframe.find('#newsgotor').attr( "href",'https://www.newsgator.com/ngs/si.aspx?ReturnUrl='+rssLink_);
   
}

function HideDiv()
{ 
   window.parent.document.getElementById('popup').style.display= "none";    
}

window.parent.document.onclick=HideDiv;

function ShowDiv1()
{ 
   $("#popup").show();    
}
function HideDiv1()
{ 
    $("#popup").hide();
}