/*
EASY TABS 1.2 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Need Help? http:/www.kollermedia.at/archive/2007/07/10/easy-tabs-12-now-with-autochange
You can use this Script for private and commercial Projects, but just leave the two credit lines, thank you.
*/

//EASY TABS 1.2 - MENU SETTINGS
//Set the id names of your tablink (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id name of your tabcontentarea (without a number at the end)
var tabcontent_idname = new Array("tabcontent") 
//Set the number of your tabs
var tabcount = new Array("2")
//Set the Tab wich should load at start (In this Example:Tab 2 visible on load)
var loadtabs = new Array("1")  
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 0;
//the speed in seconds when the tabs should change
var changespeed = 3;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;
//END MENU SETTINGS

/*Swich EasyTabs Functions - no need to edit something here*/
/*function easytabs(menunr, active) {if (menunr == autochangemenu){currenttab=active;}if ((menunr == autochangemenu)&&(stoponhover==1)) {stop_autochange()} else if ((menunr == autochangemenu)&&(stoponhover==0))  {counter=0;}menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){document.getElementById(tablink_idname[menunr]+i).className='tab'+i;document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}var timer; counter=0; var totaltabs=tabcount[autochangemenu-1];var currenttab=loadtabs[autochangemenu-1];function start_autochange(){counter=counter+1;timer=setTimeout("start_autochange()",1000);if (counter == changespeed+1) {currenttab++;if (currenttab>totaltabs) {currenttab=1}easytabs(autochangemenu,currenttab);restart_autochange();}}*/
/*function restart_autochange(){clearTimeout(timer);counter=0;start_autochange();}
function stop_autochange(){clearTimeout(timer);counter=0;}*/

/*window.onload=function(){
var menucount=loadtabs.length; var a = 0; var b = 1; do {easytabs(b, loadtabs[a]);  a++; b++;}while (b<=menucount);
if (autochangemenu!=0){start_autochange();}
}*/

var min=11;
var max=14;
function up() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function toggleReturn(radioDirection){
            var returnSection = document.getElementById("returnSection");
            if (radioDirection == "one"){ //one way flight, hide return section, and clear text input areas
                        returnSection.style.visibility = "hidden";
                        returnSection.style.display = "none";
                        returnSection.width="22%";
                        document.getElementById("_retdateus").value="";
            }else if (radioDirection == "round"){ // round trip, show return section, and put the values in oppositely
                        returnSection.style.visibility = "visible";
                        returnSection.style.display = "block";
                        returnSection.width="22%";
            }
}

function toggleReturnNew(radioDirection){
            var returnSection = document.getElementById("returnID");
            if (radioDirection == "one"){ //one way flight, hide return section, and clear text input areas
                        Document.getElementById("_retdateus").value="";
                        returnSection.style.visibility = "hidden";
                        returnSection.style.display = "none";
                        //returnSection.width="22%";
            }else if (radioDirection == "round"){ // round trip, show return section, and put the values in oppositely
                        Document.getElementById("_retdateus").value="";
                        //window.addEvent('domready', function() { myCal = new Calendar({_retdateus : 'm/d/Y' }, { direction: 1, tweak: { x: -125, y: 20 }} )});
                        returnSection.style.visibility = "visible";
                        returnSection.style.display = "block";
                        //returnSection.width="22%";
            }
}
function english(){
            //location = "http://www.google.com";
            alert("this should open the appropriate language page, \nwe are still awaiting approval for the desgin of the\nenglish page to proceed to other languages");
}
function toggleSearch(){
            var oSrch = document.getElementById("srchbar");
            var fsr = document.getElementById("fsr");
            if (oSrch.style.visibility=="hidden"){
                        oSrch.style.visibility="visible";
                        oSrch.style.display="block";
                        fsr.innerHTML = "-";
            }else if(oSrch.style.visibility="visible"){
                        oSrch.style.visibility="hidden";
                        oSrch.style.display="none";
                        fsr.innerHTML = "+";
            }
}
function toggleStatus(){
            var oStatus = document.getElementById("flightStatus");
            var fss = document.getElementById("fss");
            if (oStatus.style.visibility=="hidden"){
                        oStatus.style.visibility="visible";
                        oStatus.style.display="block";
                        fss.innerHTML = "-";
            }else if(oStatus.style.visibility="visible"){
                        oStatus.style.visibility="hidden";
                        oStatus.style.display="none";
                        fss.innerHTML = "+";
            }
}
 
function toggleNumber(){
            var temp = document.getElementById("flightNumber");
            if (temp.style.visibility=="hidden"){
                        temp.style.visibility = "visible";
                        temp.style.display="block";
            }else{
                        temp.style.visibility = "hidden";
                        temp.style.display = "none";
            }
}
function download(){
            location = "http://www.kativik.qc.ca/html/aipai/index.html";
}
function down() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function owc(){
            var oneway = document.getElementById("oneWay");
            oneway.checked=true;
}
function SITA(){
            // check the user input to make sure the dates are valid and the selections are ok.
            var depCity = document.getElementById("_origin");
            var destCity = document.getElementById("_destination");
            var _val = depCity.options[depCity.selectedIndex].value;
            var _val2 = destCity.options[destCity.selectedIndex].value;
            var _depDate = document.getElementById("_depdateus");
            var ret = document.getElementById("_retdateus");
            var temp= document.getElementById("returnWay");
            if (document.getElementById("_adults").value == ""){document.getElementById("_adults").value="1";}
            try{
                        if (Number(_val) == 0){
                                    alert("Please select a valid Departure City");
                                    depCity.focus();
                                    return false;
                        }else if(Number(_val2) == 0){
                                    alert("Please select a valid Arrival City");
                                    destCity.focus();
                                    return false;
                        }else if(_depDate.value == ""){
                                    alert("Please select a valid departure date");
                                    _depDate.focus();
                                    return false;
                        }else if (depCity.value == destCity.value){
                                    alert("Departure and Destination cities/airports cannot be the same\nplease check your input and try again");
                                    destCity.focus();
                                    return false;
                        }else if (ret.value == "" && temp.checked){
                                    alert("Please select a valid departure date");
 
                                    return false;
                        }else if (document.getElementById("oneWay").checked){
                                    ret.value=" ";
 
                                    // if one way and return date chosen, clear chosen date
                        }else if (document.getElementById("returnWay").checked){
 
                        }
            }catch(exp){
 
            }
            checkDates();
            //convertDate();
            document.forms["formBookingEngine"].submit();
}
function checkDates(){
            var dep = document.getElementById("_depdateus");
            var ret = document.getElementById("_retdateus");
            if (dep.value == ret.value){
                        alert("Departure date and Return date CANNOT be the same");
                        return false;
            }
}
function checkAdults(){
            var index  = document.getElementById("_adults").selectedIndex;
            /*var adults = document.getElementById("_adults");
            nbrAdults = Number(adults.value);
            if (isNaN(adults.value)){
                        alert("Please enter single digit numeric values only");
                        adults.focus();
                        adults.select();
                        return false;*/
            for(var num=(document.getElementById("_children").options.length);num >=0;num--){
            document.getElementById("_children").options.remove(num);
            }
            for (var num= 0 ;num<(9 - index); num++){
            var newoption = document.createElement('<option value=' +  num + '>');
            document.getElementById("_children").options.add(newoption);
            newoption.innerText = num;
           
            }
            for(var num=(document.getElementById("_infants").options.length);num >=0;num--){
            document.getElementById("_infants").options.remove(num);
            }
            for (var num= 0 ;num <= ( index+1); num++){
            var newoption = document.createElement('<option value=' +  num + '>');
            document.getElementById("_infants").options.add(newoption);
            newoption.innerText = num;
           
            }
           
}
function convertDate(){
            var _depDate = document.getElementById("_depdateus");
            var _retDate = document.getElementById("_retdateus");
            if (!_depDate)return;
            var dt = new Date(_depDate.value.toString());
            var str_dt = dt.getDate() + "/" + (dt.getMonth()+1) + "/" + dt.getYear();
            _depDate.value= ""+str_dt;
            dt = null;
            dt = new Date(_retDate.value.toString());
            var returning = document.getElementById("returnWay");
            if (returning.checked ){
                        if (_retDate.value == ""){
                                    _retDate.value="";
                                    return;
                        }
                        str_dt = null;
                        str_dt =dt.getDate() + "/" + (dt.getMonth()+1) + "/" + dt.getYear();
                        _retDate.value=str_dt+"";
            }
}
function expand(ids){
            var t = document.getElementById(ids);
            t.size=t.options.length -4;
 
}
function contract(ids){
            var t = document.getElementById(ids);
            t.size=1;
}

function StaffroomPopup(lang){
   
    owin= window.open('Staffroom11/login.aspx?lang='+lang,'_parent', 'height=290,width=360,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no'); 
      
 } 
function showPosition()
  {
    var oElement = document.all.sample_attach_src_parent;
    
    alert("The TD element is at (" + oElement.offsetLeft + 
          "," + oElement.offsetTop + ")\n" + "The offset parent is " 
          + oElement.offsetParent.tagName );
  }

function GetdepdateusF(numb){

 var  datestatus ="";
 dt = new Date() ;
 p_Number = new Number(1);
 datestatus=(dt.getDate() + p_Number);

 
 //datestatus = dt.getDate();
 return datestatus;

}

function SitaFlyStatus(){
dt = new Date() ;
var FlyNumber = document.getElementById("flightNumber");
var depCity = document.getElementById("_origin");
var destCity = document.getElementById("_destination");
var _val = depCity.options[depCity.selectedIndex].value;
var _val2 = destCity.options[destCity.selectedIndex].value;

var radioObj = document.forms['formBookingEngine'].elements['_depdateusF'];

if (radioObj[0].checked){
    dt.setDate(dt.getDate() -1);
    radioObj[0].value = dt.getMonth() + dt.getDay() + dt.getFullYear();
    
}else if (radioObj[1].checked){
  
    radioObj[1].value = dt.getMonth().toString() + dt.getDate().toString() + dt.getFullYear().toString();
    
}else
{
    dt.setDate(dt.getDate() +1);
   document.forms['formBookingEngine'].elements['Radio3'].value =  (dt.getMonth()+1).toString() +"/"+ dt.getDate().toString() +"/"+ dt.getFullYear().toString();
   

}




    try{
                        if (Number(_val) == 0 && FlyNumber.value==0){
                                    alert("Please select a valid Departure City");
                                    depCity.focus();
                                    return false;
                        }else if(Number(_val2) == 0 && FlyNumber.value==0  ){
                                    alert("Please select a valid Arrival City");
                                    destCity.focus();
                                    return false;                        
                        }else if (depCity.value == destCity.value){
                                    alert("Departure and Destination cities/airports cannot be the same\nplease check your input and try again");
                                    destCity.focus();
                                    return false;
                        }
            }catch(exp){
 
            }
            
            //convertDate();
            alert(document.forms['formBookingEngine'].elements['Radio3'].value);
            document.forms["formBookingEngine"].submit();


}
