function removeByIndex(arrayName,arrayIndex){ 
arrayName.splice(arrayIndex,1); 
}

var gclidurl = window.location.href;
var check_analytics;
var field = 'gclid';
if(gclidurl.indexOf('?' + field + '=') != -1) {
 check_analytics = "yes";
}else if(gclidurl.indexOf('&' + field + '=') != -1){
 check_analytics = "yes";
} else {
	 check_analytics = "no";
}
hu = window.location.search.substring(1);
Date.prototype.getDayName = function(shortName){
    var Days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
    if (shortName) {
        return Days[this.getDay()].substr(0, 3);
    }
    else {
        return Days[this.getDay()];
    }
}
Date.prototype.getMonthName = function(){
    return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][this.getMonth()];
}
function SelectDuration(){
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var duration = ""
    }
    else
    {
        var duration = querySt("duration");
    }
    if (duration == '1')     {
        removeAllOptions(document.form.duration);
        addOption(document.form.duration, "1", "Weeks Holiday", selected);
    }
    else 
        if (duration == '2') {
            removeAllOptions(document.form.duration);
            addOption(document.form.duration, "1", "Weeks Holiday", selected);
       }
        else 
            if (duration == '3') {
                removeAllOptions(document.form.duration);
               addOption(document.form.duration, "1", "Weeks Holiday", selected);
            }  else {
                removeAllOptions(document.form.duration);
                addOption(document.form.duration, "1", "Weeks Holiday", selected);
            }
    SelectDepDay();
}

function SelectDepDay(){
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var date_range_start = ""
    }
    else
    {
        var date_range_start = querySt("date_range_start");
    }
    
    if (document.form.duration.value == '1') {
        removeAllOptions(document.form.date_range_start);
        addOption(document.form.date_range_start, "7", "Sun - Sun", selected);
    }
    else 
        if (document.form.duration.value == '2') {
        
            if (date_range_start == "2") //then means we print out normal
            {
                removeAllOptions(document.form.date_range_start);
                addOption(document.form.date_range_start, "2", "Thur - Sun", selected);
                addOption(document.form.date_range_start, "1", "Wed - Sun", selected);
            }
            else {
                removeAllOptions(document.form.date_range_start);
                addOption(document.form.date_range_start, "1", "Wed - Sun", selected);
                addOption(document.form.date_range_start, "2", "Thur - Sun", selected);
            }
        }
        else {
            removeAllOptions(document.form.date_range_start);
            addOption(document.form.date_range_start, "3", "Sun - Weds", selected);
        }
    SelectDates_Airport();  
}


function Change_Duration(){
	 if (hu == "" || check_analytics == "yes") {
	var date_range = document.form.date_range.value;
	var no_days = document.form.days_duration.value;
    } else {
	var date_range = querySt("date_range");
	var no_days = querySt("days_duration");
	}
if (date_range == "4-Jun-2011"){
date_range = "5-Jun-2011";
}
Set_2week_dates(no_days, date_range);
}

function Change_Durationx(){
	var date_range = document.form.date_range.value;
	var no_days = document.form.days_duration.value;
Set_2week_dates(no_days, date_range);
}



function Set_2week_dates(no_days, the_date){
     var date_zero = "";
    var date_zero2 = "";
	var select_date = the_date;
	var date_range =select_date;
	var the_season = document.form.Season.value;
	if (the_season == 7)
	{
    var e = new Date('10/01/2012');
    var d = new Date('05/06/2012');
	var f = new Date('05/13/2011');
	
	
	} else {
    var e = new Date('09/30/2011');
    var d = new Date('05/01/2011');
	var f = new Date('05/08/2011');
	}
	 var site_area = document.form.site_area.value;



if (no_days == 14 && the_season != 7){
 f = new Date('05/15/2011');
}
if (no_days == 14 && the_season == 7){
 f = new Date('05/20/2012');
}

	var day_add = 7;
    var i = e;
    removeAllOptions(document.form.date_range);
    do {
        month = d.getMonthName();
        monthf = f.getMonthName();
					if (d.getDate() < 9) {
						date_zero = "0";
					}
					else {
						date_zero = "";
					}
					if (f.getDate() < 9) {
						date_zero2 = "0";
					}
					else {
						date_zero2 = "";
					}


        var the_date_to_match = d.getDate() + "-" + month + "-" + d.getFullYear();
        var the_string_date = d.getDate() + "," + month + "," + d.getFullYear();
        var myDate2 = new Date(the_string_date);
        var myDate = new Date();
        var today = new Date();
        
		var change_date = date_zero + d.getDate()+ " " +month;

		if (change_date == "05 Jun" && site_area != "beach"){
				d = new Date('06/04/2011');
						if (change_date == "05 Jun" && site_area == "beach"){
							d = new Date('06/05/2011');
						}

						f = new Date('06/12/2011');
							if (no_days == 14 || no_days == 15){
								f = new Date('06/19/2011');
							}
				 var the_date_to_match = d.getDate() + "-" + month + "-" + d.getFullYear();
		} else {
					var the_date_to_match = d.getDate() + "-" + month + "-" + d.getFullYear();
		}


						if (myDate2 > today) {
										if (date_range == the_date_to_match) {
											var selected = " selected";
										}
										else {
											var selected = "";
										}					
							addOption(document.form.date_range, d.getDate() + "-" + month + "-" + d.getFullYear(), date_zero + d.getDate() + " " + month + " - " + date_zero2 + f.getDate() + " " + monthf, selected);
					
						}
if (change_date == "07 Jan"){
	       d.setDate(d.getDate() + 8);
		 f.setDate(f.getDate() + 7);

} else if(change_date == "05 Jun" && site_area != "beach"){
	       d.setDate(d.getDate() + 8);
		 f.setDate(f.getDate() + 7);


	}else {
        d.setDate(d.getDate() + 7);
        f.setDate(f.getDate() + 7);
}
        
    }
    while (d < e);
var selected = "";
set_15_days(no_days)


  }

function set_15_days(no_days){

            removeAllOptions(document.form.days_duration);
			if (no_days == 15){
			addOption(document.form.days_duration, "15", "15", selected);
			addOption(document.form.days_duration, "8", "8", selected);
			} else if (no_days == 14){
			addOption(document.form.days_duration, "14", "14", selected);
			addOption(document.form.days_duration, "7", "7", selected);			
			} else if (no_days == 7){
			addOption(document.form.days_duration, "7", "7", selected);
			addOption(document.form.days_duration, "14", "14", selected);			
			}else{
			addOption(document.form.days_duration, "8", "8", selected);
			addOption(document.form.days_duration, "15", "15", selected);
            }
}



function SelectPaxs1(y, x){
    hu = window.location.search.substring(1);
	var theurllocation = location.href;
    if (hu == "" || check_analytics == "yes") {
        var no_adults = ""
		if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){ 
		no_adults = 4;
		}

    } else {
        var no_adults = querySt("no_adults");
    }

	
    
    if (no_adults == "") {
        removeAllOptions(document.form.no_adults);
				for (i = x; i <= y; i++) {
				
					if (i == 2) {
						selected = "selected";
					}
					else {
						selected = "";
					}
					
					addOption(document.form.no_adults, i, i, selected);
				}
    
	
	} else {
    
        removeAllOptions(document.form.no_adults);
			for (i = x; i <= y; i++) {
					if (no_adults == i) {
						selected = "selected";
					} else {
						selected = "";
					}
				addOption(document.form.no_adults, i, i, selected);
			}
        
    }
}


function force_beach_change(a,b) {
        removeAllOptions(document.form.no_adults);
		x=2;
		y=60;
        for (i = x; i <= y; i++) {
        
            if (i == a) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            
            addOption(document.form.no_adults, i, i, selected);
        }
        removeAllOptions(document.form.no_children);
		x=0;
		y=20;
        for (i = x; i <= y; i++) {
        
            if (i == b) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            
            addOption(document.form.no_children, i, i, selected);
        }
}

function force_passengers() {
var discount_code = document.form.our_discounts.value;
var num_adults =  parseInt(document.form.no_adults.value);
var num_children = parseInt( document.form.no_children.value);
var total_pax = num_adults+num_children;
var theurllocation = location.href;
var c=num_children;
var d=num_adults;
var e=total_pax;
if (discount_code ==0){
	return false;
}
if (discount_code == 1){
	if (document.form.Season.value == "4" || document.form.Season.value == "6") {	
		a=8;
		b=15;
		workout_change(a,b,c,d,e);
	}else {
		force_beach_change(2,1);
	}
} 
if (discount_code == 2){
	if (document.form.Season.value == "4" || document.form.Season.value == "6") {	
		a=17;
		b=24;
		workout_change(a,b,c,d,e);
	}else{
		force_beach_change(2,2);
	}
}
if (discount_code == 3){
	if (document.form.Season.value == "4" || document.form.Season.value == "6") {
	a=25;
	b=34;
	workout_change(a,b,c,d,e);
	} else {
	force_beach_change(2,3);
	}
}
if (discount_code == 4){

	if (document.form.Season.value == "4" || document.form.Season.value == "6") {
	a=35;
	b=99;
	workout_change(a,b,c,d,e);
	} else {
	force_beach_change(6,0);
	}

}
if (discount_code == 5){
force_beach_change(8,0);
}

 //}
}

function force_discounts(){

var num_adults =  parseInt(document.form.no_adults.value);
var num_children = parseInt( document.form.no_children.value);
var total_paxs = num_adults+num_children;
var theurllocation = location.href;
if (num_adults == 1)
{
SelectPaxsChildreload(20, 0);
} else {



if (document.form.Season.value == "4" || document.form.Season.value == "6") {	

		if (total_paxs == 2 && num_children == 0 )
		{
			Load_Discount_from_selection(0)
		}

		if (total_paxs >= 3 && total_paxs <=7 )
		{
			Load_Discount_from_selection(0)
		}

		if (total_paxs >= 8 && total_paxs <=16 )
		{
			Load_Discount_from_selection(1)
		}
		
		if (total_paxs >= 17 && total_paxs <=24 )
		{
			Load_Discount_from_selection(2)
		}

		if (total_paxs >= 25 && total_paxs <=34 )
		{
			Load_Discount_from_selection(3)
		}

		if (total_paxs >= 35 && total_paxs <=99 )
		{
			Load_Discount_from_selection(4)
		}

}else{

	if (num_adults == 2 && num_children == 1)
		{
			Load_Discount_from_selection(1)
		}
	if (num_adults == 2 && num_children == 2)
		{
			Load_Discount_from_selection(2)
		}
if (num_adults == 2 && num_children == 3)
		{
			Load_Discount_from_selection(3)
	}
		if (total_paxs >= 6 && total_paxs <=7 )
		{
			Load_Discount_from_selection(4)
		}

		if (total_paxs >= 8 && total_paxs <=11)
		{
			Load_Discount_from_selection(5)
		}

		if (total_paxs >= 12 && total_paxs <=19)
		{
			Load_Discount_from_selection(6)
		}
			
		if (total_paxs >= 20)
		{
			Load_Discount_from_selection(7)
		}


}
} //end of 1 pax if

 }
//}



function workout_change(a,b,c,d,e) {
if (e >= a && e <=b) {
	return false;
} else {
d = (a-c);
        removeAllOptions(document.form.no_adults);
		x=2;
		y=60;
        for (i = x; i <= y; i++) {
        
            if (i == d) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            
            addOption(document.form.no_adults, i, i, selected);
        }
}
}



function Load_Discount() {
	var theurllocation = location.href;
	if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){
		
	} else {

	
	removeAllOptions(document.form.our_discounts);
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var the_discount = 0;
    }
    else {
        var the_discount = querySt("our_discounts");
    }


	if (document.form.Season.value == "4") {
    var mydiscounts = new Array();
    mydiscounts[0] = "No Discount";
    mydiscounts[1] = "8+ Group \u00A3100 pp";
    mydiscounts[2] = "17+ Group \u00A3125 pp";
    mydiscounts[3] = "25+ Group \u00A3150 pp";
    mydiscounts[4] = "35+ Group \u00A3175pp";
		} else if(document.form.Season.value == "6") {
    var mydiscounts = new Array();
    mydiscounts[0] = "Early Bird \u00A375 pp";
    mydiscounts[1] = "8+ Group \u00A3100 pp";
    mydiscounts[2] = "17+ Group \u00A3125 pp";
    mydiscounts[3] = "25+ Group \u00A3150 pp";
    mydiscounts[4] = "35+ Group \u00A3175pp";

	} else {
		var mydiscounts = new Array();
	mydiscounts[0] = "No Discount";
	mydiscounts[4] = "Group discount 6+ \u00A340pp";
	mydiscounts[5] = "Group discount 8+ \u00A350pp";
	mydiscounts[6] = "Group discount 12+ \u00A360pp";
	mydiscounts[7] = "Group discount 20+ \u00A370pp";

	}
    for (x in mydiscounts) {
         if (the_discount == x) {
          var selected = " selected";
        }
        else {
            var selected = "";
        }
        addOption(document.form.our_discounts, x, mydiscounts[x], selected);
    }
	}
}
function Load_Discount_from_selection(the_discount) {
	var theurllocation = location.href;
	if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){
			} else {
	removeAllOptions(document.form.our_discounts);
	if (document.form.Season.value == "4") {

    var mydiscounts = new Array();
    mydiscounts[0] = "No Discount";
    mydiscounts[1] = "8+ Group \u00A3100 pp";
    mydiscounts[2] = "17+ Group \u00A3125 pp";
    mydiscounts[3] = "25+ Group \u00A3150 pp";
    mydiscounts[4] = "35+ Group \u00A3175pp";
	} else if(document.form.Season.value == "6") {
    var mydiscounts = new Array();
    mydiscounts[0] = "Early Bird \u00A375 pp";
    mydiscounts[1] = "8+ Group \u00A3100 pp";
    mydiscounts[2] = "17+ Group \u00A3125 pp";
    mydiscounts[3] = "25+ Group \u00A3150 pp";
    mydiscounts[4] = "35+ Group \u00A3175pp";

	} else {
	var mydiscounts = new Array();
	mydiscounts[0] = "No Discount";
	mydiscounts[4] = "Group discount 6+ \u00A340pp";
	mydiscounts[5] = "Group discount 8+ \u00A350pp";
	mydiscounts[6] = "Group discount 12+ \u00A360pp";
	mydiscounts[7] = "Group discount 20+ \u00A370pp";

	}

    for (x in mydiscounts) {
   
         if (the_discount == x) {
          var selected = " selected";
        }
        else {
            var selected = "";
        }
        addOption(document.form.our_discounts, x, mydiscounts[x], selected);
    }
	}

}


function SelectPaxs2(y, x){
    y = y * 1;
    x = x * 1;
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var no_adults = ""
    }
    else {
        var no_adults = querySt("no_adults");
    }
       
    if (no_adults != "") {
    
        removeAllOptions(document.form.no_adults);
        for (i = 2; i <= y; i++) {
        
            if (no_adults == i) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            addOption(document.form.no_adults, i, i, selected);
        }
    }
    else {
        removeAllOptions(document.form.no_adults);
        for (i = 2; i <= y; i++) {
            if (no_adults == i) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            addOption(document.form.no_adults, i, i, selected);
            
        }
    }
}


function SelectPaxsChildreload(y, x){
	var no_adults = document.form.no_adults.value;
	var no_children_form = document.form.no_children.value;
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var no_children = ""
    }
    else 
    {
        var no_children = querySt("no_children");
    }


	if (no_adults == 1 && no_children_form < 1) {
		if (document.form.date_range.value != "26-Dec-2010"){
		var one_child=1;
		} else {
		var one_child=0;
		}
	} else {
		var one_child=document.form.no_children.value;
	}

if (no_children == "") 
    {
        removeAllOptions(document.form.no_children);      
		for (i = x; i <= y; i++) {

            if (one_child == i) {
                selected = "selected";
            } else {
                selected = "";
            }
            addOption(document.form.no_children, i, i, selected);
        }


    }  else {

		no_children = document.form.no_children.value;

			if (no_adults == 1 && no_children < 1) {
		if (document.form.date_range.value != "26-Dec-2010"){
var no_children = 1;
		} else {
	var no_children = 0;
		}


			}
		        removeAllOptions(document.form.no_children);
        for (i = x; i <= y; i++) {
            if (no_children == i) {
               selected = "selected";
            } else {
                selected = "";
            }
            addOption(document.form.no_children, i, i, selected);
        }
    }
    
}

function SelectPaxsChild(y, x){
	var no_adults = document.form.no_adults.value;
	var no_children_form = document.form.no_children.value;
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var no_children = ""
    }
    else
    {
        var no_children = querySt("no_children");
    }
	if (no_adults == 1 && no_children_form < 1) {
		if (document.form.date_range.value != "26-Dec-2010"){
		var one_child=1;
		} else {
		var one_child=0;
		}
	} else {
		var one_child=document.form.no_children.value;
	}
if (no_children == "")     {
        removeAllOptions(document.form.no_children);      
		for (i = x; i <= y; i++) {

            if (one_child == i) {
                selected = "selected";
            } else {
                selected = "";
            }
            addOption(document.form.no_children, i, i, selected);
        }


    }  else {
        removeAllOptions(document.form.no_children);
        for (i = x; i <= y; i++) {
            if (no_children == i) {
                selected = "selected";
            } else {
                selected = "";
            }
            addOption(document.form.no_children, i, i, selected);
        }
    }
    
}

function SelectPaxsinf(y, x){
    hu = window.location.search.substring(1);
    if (hu == "" || check_analytics == "yes") {
        var no_infants = ""
    }
    else 
    {
        var no_infants = querySt("no_infants");
    }
    
    if (no_infants == "") //then means we print out normal
    {
        removeAllOptions(document.form.no_infants);
        for (i = x; i <= y; i++) {
            addOption(document.form.no_infants, i, i, selected);
        }
    }
    else {
        removeAllOptions(document.form.no_infants);
        addOption(document.form.no_infants, no_infants, no_infants, selected);
        for (i = x; i <= y; i++) {
            if (no_infants == i) {
                selected = "selected";
            }
            else {
                selected = "";
            }
            addOption(document.form.no_infants, i, i, selected);
        }
    }
    
}

function SelectSubCat(){
Get_Resort();   
SelectSubCat_Loaded();
Get_The_Airport();

}

function SelectSubCat_Loaded(){
    if (hu == "" || check_analytics == "yes") {
        var destination = "";
    }
    else {
        var destination = querySt("destination");
        if (destination.length > 15) {
            var mySplitDestination = destination.split("*");
            destination = mySplitDestination[0];
            
        }
    }
	var aURL = document.location.href;
	var aPosition = aURL.indexOf("luxury-ski-holidays");
	var bPosition = aURL.indexOf("LUXURY");
	var luxury_chalets = "No";
	if (aPosition != -1) { 
	 luxury_chalets = "Yes";
	}
	if (bPosition != -1) { 
	 luxury_chalets = "Yes";
	}
    var myresort = document.form.resort.value;
    var Season = document.form.Season.value;
	removeAllOptions(document.form.destination);
    for (x in chalet_array_final) {
        var mySplitResult = chalet_array_final[x].split(",");
        if (myresort == "all_resorts") {
            removeAllOptions(document.form.destination);
            addOption(document.form.destination, "all_chalets", "All Chalets", selected);

        }
        else 
            if (myresort == "cheapest") {
                removeAllOptions(document.form.destination);
                addOption(document.form.destination, "cheapest-hotel", "Cheapest Deals", selected);
            }
            else {          
                if (mySplitResult[0] == myresort) {
                   
					 if (Season != "3") { 
							my_destination = mySplitResult[7];
					 } else {
							my_destination = mySplitResult[8];
					 }
					
					if (destination == my_destination) {
                        selected = "selected";
                    } else {
                        selected = "";
                    }
                    if (Season == "3") { // means its a summer
							if (mySplitResult[9] == "1" || mySplitResult[9] == "2" || mySplitResult[9] == "99") {
									addOption(document.form.destination, mySplitResult[7], mySplitResult[1], selected);
							}
                    } 
					      if (Season == "5") { // means its a summer
							if (mySplitResult[9] == "1" || mySplitResult[9] == "2" || mySplitResult[9] == "99") {
									addOption(document.form.destination, mySplitResult[7], mySplitResult[1], selected);
							}
                    } 
					
					
					if (Season == "7") { // means its a summer
							if (mySplitResult[9] == "1" || mySplitResult[9] == "2" || mySplitResult[9] == "99") {
									addOption(document.form.destination, mySplitResult[7], mySplitResult[1], selected);
							}
                    } 
					

					if ((Season == "8" || Season == "6") && luxury_chalets == "No") {  // means its a Winter Normal
						if ((mySplitResult[9] == "0" || mySplitResult[9] == "2" || mySplitResult[9] == "99") && mySplitResult[14] == "0") {
							 addOption(document.form.destination, mySplitResult[7], mySplitResult[1], selected);
						}
                    }

					if ((Season == "8" || Season == "6") && luxury_chalets == "Yes") {  // means its a Winter luxury 
						if (mySplitResult[14] == "1" || mySplitResult[9] == "99"){
							if (mySplitResult[9] == "0" || mySplitResult[9] == "2" || mySplitResult[9] == "99") {
								 addOption(document.form.destination, mySplitResult[7], mySplitResult[1], selected);
							}
						}
					}






                }
            }
    }
    selected = "";
	Get_The_Airport();

}

function reloadform(){
    Get_Season();
    SelectSubCat();
    SelectPaxsChild(20, 0);
    SelectPaxsinf(20, 0)
    SelectPaxs1(60, 2);
    SelectDates_Airport();
/*	Load_Discount();*/
}

function fillCategory(){
    hu = window.location.search.substring(1);
   if (hu == "" || check_analytics == "yes" ) {
        var resort = "";
        var destination = "";
        var no_adults = "";
        var duration = "";
        var date_range_start = "";
        var date_range = "";
        var dep_airport = "";
        var submitb = "";
        var Season = "";
		var days_duration =7;
    } else {
        var Season = querySt("Season");
        var resort = querySt("resort");
        var destination = querySt("destination");
        if (destination.length > 15) {
            var mySplitDestination = destination.split("*");
            destination = mySplitDestination[0];
            resort = mySplitDestination[3];
        }
        var no_adults = querySt("no_adults");
        var duration = querySt("duration");
        var date_range_start = querySt("date_range_start");
        var date_range = querySt("date_range");
        var dep_airport = querySt("dep_airport");
        var submitb = querySt("submitb");
		var days_duration = querySt("days_duration");
    }
    
    Get_Season();
	SelectSubCat();
    SelectPaxsChild(20, 0);
    SelectPaxsinf(20, 0)
    SelectPaxs1(60, 1);
    SelectDates_Airport();
	/*Load_Discount();*/



    var theurllocation = location.href;
 if (theurllocation.indexOf("beach-holidays") != -1) 	{
	Change_Duration();
 }
  if (theurllocation.indexOf("activity-holidays-search-beach") != -1) 	{
	Change_Duration();
 }

   if (theurllocation.indexOf("/activity-holidays-search/booking.php?Season=4") != -1) 	{
 }
    if (theurllocation.indexOf("Season=4") != -1) 	{
 }
 if (days_duration == "14")
 {
	  Change_Duration();
 }




}

function Get_The_Airport(){

	var season = parseInt(document.form.Season.value);
	var winter = true;
	var season_result  = (season % 2);
	if (season_result === 1){
		winter = false; 
	} 
    if (hu == "" || check_analytics == "yes") {
        var dep_airport = "";
        
    }
    else {
        var dep_airport = querySt("dep_airport");
        var lake_garda = document.form.resort.value;
     }
    removeAllOptions(document.form.dep_airport);
    var x; 
    var myairports = new Array();
	if (document.form.resort.value == "garda" || document.form.resort.value == "mayrhofen"){
		var myairports = new Array();
			myairports[0] = "LGW,London Gatwick (LGW)";
						if (document.form.resort.value == "garda"){
							myairports[1] = "EDI,Edinburgh (EDI)";
						}
						if (document.form.resort.value == "mayrhofen"){
							myairports[1] = "STN,London Stansted (STN)";
						}
		SelectDates_Airport_Garda();
	}
	else if (winter == false){
					var myairports = new Array();
					 if (document.form.resort.value == "les_deux_alpes"){
							myairports[0] = "ALL,All London Airports";
							myairports[1] = "LGW,London Gatwick (LGW)";
							myairports[2] = "STN,London Stansted (STN)";
							myairports[3] = "FER,Ferry";
							myairports[4] = "XXX,Self Travel";
								}
	else if (document.form.resort.value == "vassiliki"){
    var myairports = new Array();
    myairports[0] = "LGW,London Gatwick (LGW)";
SelectDates_Airport();
					 }else{
							myairports[0] = "ALL,All London Airports";
							myairports[1] = "LTN,London Luton (LTN)";
							myairports[2] = "LGW,London Gatwick (GTW)";
							myairports[3] = "BRS,Bristol (BRS)";
							myairports[4] = "LPL,Liverpool (LPL)";
							myairports[5] = "EDI,Edinburgh (EDI)";
							myairports[6] = "FER,Ferry";
							myairports[7] = "XXX,Self Travel";
					 }
	SelectDates_Airport();
}else{
    var myairports = new Array();
	myairports[0] = "ALL,All London Airports";
	myairports[1] = "LGW,London Gatwick (LGW)";
    myairports[2] = "LTN,London Luton (LTN)";
   // myairports[3] = "BRS,Bristol (BRS)";
   // myairports[4] = "LPL,Liverpool (LPL)";
    //myairports[5] = "EDI,Edinburgh (EDI)";
    myairports[3] = "MAN,Manchester (MAN)";
	myairports[4] = "BHX,Birmingham (BHX)";
	myairports[5] = "GLA,Glasgow (GLA)";
    //myairports[8] = "BFS,Belfast (BFS)";
	myairports[6] = "FER,Ferry";
    myairports[7] = "XXX,Self Travel";

	SelectDates_Airport();
}
    
    for (x in myairports) {
        var mySplitResult = myairports[x].split(",");     
         if (dep_airport == mySplitResult[0]) {
            var selected = " selected";
        }
        else {
            var selected = "";
        }
        addOption(document.form.dep_airport, mySplitResult[0], mySplitResult[1], selected);
    }
    
}


function SelectDates_Airport(){
			if (hu == "" || check_analytics == "yes") {
				var date_range = ""
				var season = ""  
			}
			else {
				var date_range = querySt("date_range");       
				if ((date_range.indexOf('0')) == 0) {
					date_range = date_range.substr(1);            
				}
			}
     var date_zero = "";
    var date_zero2 = "";
    var date_vars = "7";
    var Season = document.form.Season.value
    var resort = document.form.resort.value
    var e = new Date('05/06/2011');
    var site_area = document.form.site_area.value;

			if (Season == "7") {
				e = new Date('10/02/2012');
				if (date_vars == '7') {
					var d = new Date('05/06/2012');
					var f = new Date('05/13/2012');
					var day_add = 7;
				}
			}

			if (Season == "8") {
				e = new Date('04/27/2013');
				var d = new Date('12/02/2012');
				var f = new Date('12/09/2012');
				var day_add = 7;

			}



      if (Season == "6") {
		e = new Date('04/28/2012');
	    	   var theurllocation = location.href;
			   var d = new Date('12/03/2011');
			   var f = new Date('12/10/2011');
			if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){
				d = new Date('12/03/2011');
				f = new Date('12/10/2011');
		}
if (resort == "st_anton")
{
	//		   var d = new Date('12/16/2011');
		//	   var f = new Date('12/23/2011');
}

           var day_add = 7;
    }
	   
    var i = e;
    removeAllOptions(document.form.date_range);
    do {
        month = d.getMonthName();
        monthf = f.getMonthName();
		if (d.getDate() <=  9) {
            date_zero = "0";
         } else {
            date_zero = "";
        }

        if (f.getDate() <= 9) {
            date_zero2 = "0";
        } else {
            date_zero2 = "";
        }
		var the_test = d.getDate() -1;
        var the_date_to_match = d.getDate() + "-" + month + "-" + d.getFullYear();
		var the_date_to_match2 = the_test + "-" + month + "-" + d.getFullYear();
        var the_string_date = d.getDate() + "," + month + "," + d.getFullYear();
        var myDate2 = new Date(the_string_date);
        var myDate = new Date();
        var today = new Date();
		var change_date = date_zero + d.getDate()+ " " +month;

		if (change_date == "07 Jan"){
			f = new Date('01/15/2011');
		}
	//if (change_date == "30 Dec"){
	//		f = new Date('01/08/2011');
		//}


		if (change_date == "05 Jun" && site_area != "beach"){
			d = new Date('06/04/2011');
			f = new Date('06/12/2011');
		}
	if (site_area == "beach" && change_date == "05 Jun"){
			d = new Date('06/05/2011');
		}
        if (myDate2 > today) {
		   if (date_range == the_date_to_match) {
                var selected = " selected";
            }  else {
                var selected = "";
            }

            if (date_range == the_date_to_match2) {
                var selected = " selected";
            }
		 addOption(document.form.date_range, d.getDate() + "-" + month + "-" + d.getFullYear(), date_zero + d.getDate() + " " + month + " - " + date_zero2 + f.getDate() + " " + monthf, selected);         
        }
if (change_date == "07 Jan"){
	       d.setDate(d.getDate() + 8);
        //f.setDate(f.getDate() + 8);
		 f.setDate(f.getDate() + 7);

} else if(change_date == "05 Jun" && site_area != "beach"){
	       d.setDate(d.getDate() + 8);
        //f.setDate(f.getDate() + 8);
		 f.setDate(f.getDate() + 7);

//} else if(change_date == "30 Dec"){
	    //   d.setDate(d.getDate() + 9);
        //f.setDate(f.getDate() + 8);
		// f.setDate(f.getDate() + 7);

} else if(change_date == "19 Feb"){
	       d.setDate(d.getDate() + 7);
        //f.setDate(f.getDate() + 8);
		 f.setDate(f.getDate() + 6);

	}else {
        d.setDate(d.getDate() + 7);
        f.setDate(f.getDate() + 7);
}
	}
    while (d < e);
   if (date_range == "4-Jun-2011"){
   var dd= querySt("days_duration");
	   if (dd==8 ){
	set_15_days(8);
	   } else {
		set_15_days(15);
	   }
   }
    

 if (resort=="garda"  || resort =="mayrhofen"){
	 SelectDates_Airport_Garda();
 }   
    
}

function Do_Duration(){
		if (document.form.date_range.value == "4-Jun-2011"){
	set_15_days(8);
		} else {
			var selected_duration =document.form.days_duration.value;
				if (selected_duration != "14" && selected_duration != "7" ){
					set_15_days(7);
				}
		}

}








function SelectDates_Airport_Garda(){
    if (hu == "" || check_analytics == "yes") {
        var date_range = ""
        var season = ""
        
    }
    else {
        var date_range = querySt("date_range");
        
        if ((date_range.indexOf('0')) == 0) {
            date_range = date_range.substr(1);
            
        }
    }
    
    
    var date_zero = "";
    var date_zero2 = "";
    var date_vars = "7";
    var Season = document.form.Season.value
    var resort = document.form.resort.value
    var e = new Date('04/25/2010');
   
	
	if (Season == "5") {
        e = new Date('09/11/2011');
            var d = new Date('05/07/2011');
            var f = new Date('05/14/2011');
            var day_add = 7;
 
    }



    if (Season == "3") {
        e = new Date('09/19/2010');
           var d = new Date('06/05/2010');
            var f = new Date('13/05/2010');
            var day_add = 7;

    }
    
    if (Season == "4") {
        e = new Date('04/24/2011');
            var d = new Date('12/05/2010');
            var f = new Date('12/12/2010');
            var day_add = 7;
    }

    var i = e;
    removeAllOptions(document.form.date_range);
    do {
        month = d.getMonthName();
        monthf = f.getMonthName();
        if (d.getDate() < 9) {
            date_zero = "0";
            //	alert(d.getDate());
        }
        else {
            date_zero = "";
        }
        if (f.getDate() < 9) {
            date_zero2 = "0";
            //	alert(f.getDate());
        }
        else {
            date_zero2 = "";
        }
        var the_date_to_match = d.getDate() + "-" + month + "-" + d.getFullYear();
        var the_string_date = d.getDate() + "," + month + "," + d.getFullYear();
        var myDate2 = new Date(the_string_date);
        var myDate = new Date();
        var today = new Date();
        
        if (myDate2 > today) {
            if (date_range == the_date_to_match) {
                var selected = " selected";
            }
            else {
                var selected = "";
            }
			
            addOption(document.form.date_range, d.getDate() + "-" + month + "-" + d.getFullYear(), date_zero + d.getDate() + " " + month + " - " + date_zero2 + f.getDate() + " " + monthf, selected);
        
        }
        d.setDate(d.getDate() + 7);
        f.setDate(f.getDate() + 7);
        
    }
    while (d < e);
       
    
}





function Get_Season(){

    if (hu == "" || check_analytics == "yes") {
        var Season = ""
    }
    else {
        var Season = querySt("Season");
    }
    removeAllOptions(document.form.Season);
    var y;
    var myseasons = new Array();
    var theurllocation = location.href;
	
    if ((theurllocation.indexOf("activity-holidays") != -1) || (theurllocation.indexOf("mountain-biking-holidays") != -1)) {
		//myseasons[0] = "5,Summer 2011";
		myseasons[0] = "7,Summer 2012";
		myseasons[1] = "6,Winter 2011/12";
		myseasons[2] = "8,Winter 2012/13";
		
	} else if (theurllocation.indexOf("beach-holidays") != -1) 	{
	myseasons[0] = "7,Summer 2012";
	//myseasons[1] = "7,Next Summer 2012";
	 } else if (theurllocation.indexOf("luxury-ski-holidays") != -1) 	{

	  myseasons[0] = "6,Winter 2011/12";
	  myseasons[1] = "8,Winter 2012/13";

	} else {
		myseasons[0] = "6,Winter 2011/12";
       // myseasons[1] = "5,Summer 2011";
		myseasons[1] = "7,Summer 2012";
		myseasons[2] = "8,Winter 2012/13";


    }
    
    
    
    
    
    for (y in myseasons) {
        var mySplitResults = myseasons[y].split(",");
        if (Season == mySplitResults[0]) {
            var selected = " selected";
        }
        else {
            var selected = "";
        }
        addOption(document.form.Season, mySplitResults[0], mySplitResults[1], selected);
    }
    Get_Resort();
}

function Get_Resort(){

    if (hu == "" || check_analytics == "yes") {
        var resort = "";
        var Season = "";
    }
    else {
        var resort = querySt("resort");
        var destination = querySt("destination");
        if (destination.length > 15) {
            var mySplitDestination = destination.split("*");
            resort = mySplitDestination[3];
        }
    }
    removeAllOptions(document.form.resort);
    var x;
    
    
    
	if (document.form.Season.value == "8" || document.form.Season.value == "6") {
			var theurllocation = location.href;
			if ((theurllocation.indexOf("luxury") != -1) || (theurllocation.indexOf("LUXURY") != -1)){
						var myresorts = new Array();
						myresorts[0] = "all_resorts,All Resorts";
						myresorts[1] = "chamonix,Chamonix";
						myresorts[2] = "courchevel,Courchevel";
						myresorts[3] = "la_plagne,La Plagne";
						myresorts[4] = "les_arcs,Les Arcs";
						myresorts[5] = "les_gets,Les Gets";
						myresorts[6] = "les_menuires,Les Menuires";
						myresorts[7] = "meribel,Meribel";
						myresorts[8] = "morzine,Morzine";
						myresorts[9] = "sainte_foy,Sainte Foy";
						myresorts[10] = "st_anton,St Anton";
						myresorts[11] = "tignes,Tignes";
						myresorts[12] = "val_disere,Val D isere";
			}else {
						var myresorts = new Array();
						myresorts[0] = "all_resorts,All Resorts";
						myresorts[1] = "cheapest,Cheapest";
						myresorts[2] = "alpe_dhuez,Alpe D'Huez";
						myresorts[3] = "chamonix,Chamonix";
						myresorts[4] = "courchevel,Courchevel";
						myresorts[5] = "la_plagne,La Plagne";
						myresorts[6] = "les_arcs,Les Arcs";
						//myresorts[7] = "les_deux_alpes,Les Deux Alpes";
						myresorts[7] = "les_gets,Les Gets";
						myresorts[8] = "meribel,Meribel";
						myresorts[9] = "morzine,Morzine";
						myresorts[10] = "sainte_foy,Sainte Foy";
						myresorts[11] = "st_anton,St Anton";
						myresorts[12] = "tignes,Tignes";
						myresorts[13] = "val_disere,Val D Isere";
						myresorts[14] = "val_thorens,Val Thorens";

			}
        }  else {
            var myresorts = new Array();
            myresorts[0] = "all_resorts,All Resorts";
            myresorts[1] = "cheapest,Cheapest";
            myresorts[2] = "chamonix,Chamonix";
            myresorts[3] = "les_gets,Les Gets";
            myresorts[4] = "morzine,Morzine";
            myresorts[5] = "tignes,Tignes";
			myresorts[6] = "vassiliki,Vassiliki - Greece";

        }

		var aURL = document.location.href;
		var aPosition = aURL.indexOf("luxury-holidays");
		var bPosition = aURL.indexOf("ski-weekends");
if (aPosition != -1)
{
	//alert("Luxury");
	        var myresorts = new Array();
            myresorts[0] = "chamonix,Chamonix";
            myresorts[1] = "les_arcs,Les Arcs";
	        myresorts[2] = "les_gets,Les Gets";
			myresorts[3] = "meribel,Meribel";
            myresorts[4] = "sainte_foy,Sainte Foy";
			myresorts[5] = "st_anton,St Anton";
            myresorts[6] = "tignes,Tignes";
}

		var aURL = document.location.href;
		var aPosition = aURL.indexOf("beach-holidays");
if (aPosition != -1)
{
	//alert("Luxury");
	        var myresorts = new Array();
		myresorts[0] = "vassiliki,Vassiliki - Greece";
}

		var aPosition = aURL.indexOf("activity-holidays-search-beach");
if (aPosition != -1)
{
	//alert("Luxury");
	        var myresorts = new Array();
		myresorts[0] = "vassiliki,Vassiliki - Greece";
}
    for (x in myresorts) {
        var mySplitResult = myresorts[x].split(",");
		if (resort == "les_2_alpes"){
			resort = "les_deux_alpes";
		}
        if (resort == mySplitResult[0]) {
            var selected = " selected";
        }
        else {
            var selected = "";
        }
        addOption(document.form.resort, mySplitResult[0], mySplitResult[1], selected);
        
    }
    SelectDates_Airport();
}
