$(document).ready(function(){

    $('#leftmenu #current-container li.li_sub').mouseover(function(){
        $('div', this).css('display', 'block');
        $('a:first', this).css('background', 'none');
    }).mouseout(function(){
        $('div', this).css('display', 'none');
        $('a:first', this).css('background', 'url(img/lia_arrow.gif) right center no-repeat');
    });

    $(".tm1, .dd1").hover(function(){
        $(".dd1").css('display', 'block');
    }, function(){
        $(".dd1").css('display', 'none');
    });
    $(".tm2, .dd2").hover(function(){
        $(".dd2").css('display', 'block');
    }, function(){
        $(".dd2").css('display', 'none');
    });
    $(".tm3, .dd3").hover(function(){
        $(".dd3").css('display', 'block');
    }, function(){
        $(".dd3").css('display', 'none');
    });
    $(".tm4, .dd4").hover(function(){
        $(".dd4").css('display', 'block');
    }, function(){
        $(".dd4").css('display', 'none');
    });
    $(".tm5, .dd5").hover(function(){
        $(".dd5").css('display', 'block');
    }, function(){
        $(".dd5").css('display', 'none');
    });

    $(".collapse_reserv").toggle(function(){
        $(".reserv").css('display', 'block');
    }, function(){
        $(".reserv").css('display', 'none');
    });

  //  $(function(){
  //     var zIndexNumber = 2000;
  //     $('div').each(function(){
  //         $(this).css('zIndex', zIndexNumber);
  //       zIndexNumber -= 5;
  //     });
  //  });

//     $(function(){
//        var zIndexNumber = 2000;
//        $('div').each(function(){
//    if($(this)[0].getAttribute('class') != "LMA"){
//    $(this).css('zIndex', zIndexNumber);
//    console.log($(this).style.zIndex);
//    zIndexNumber -= 5;
//    }
//        });
//    });

$(function(){
        var zIndexNumber = 2000;
        $('div').each(function(){
    if($(this)[0].className.indexOf("~LMA~") == -1){
    $(this).css('zIndex', zIndexNumber);
    zIndexNumber -= 5;
    }
        });
    });


});

function OpenWin(){
    windop = window.open("reservation.php", "Reservation", "height=550,width=550,status=no,toolbar=no,menubar=no,directories=no,location=no,left=300,top=300,resizable=no,scrollbars=no,locationbar=no");
}

function transfer(f){
    if (f.transferbox.checked) {
        f.transfertype.disabled = 0;
    }
    else {
        f.transfertype.disabled = 1;
        f.transfertype.value = "";
    }
}

function checkdday(){
    var selMonth = document.reservation.dmonth;
    var selDay = document.reservation.dday;
    var curDay = document.reservation.dday.selectedIndex;
    var u = selMonth.selectedIndex;
    selDay.options.length = 0;
    selDay.options[0] = new Option("");

    if (u == 2) {
        j = 28;
    }
    if ((u == 1) || (u == 3) || (u == 5) || (u == 7) || (u == 8) || (u == 10) || (u == 12)) {
        j = 31;
    }
    if ((u == 4) || (u == 6) || (u == 9) || (u == 11)) {
        j = 30;
    }

    for (i = 1; i != j + 1; i++) {
        selDay.options[i] = new Option(i);
    }

    selDay.selectedIndex = curDay;
}

function checkaday(){
    var selMonth = document.reservation.amonth;
    var selDay = document.reservation.aday;
    var curDay = document.reservation.aday.selectedIndex;
    var u = selMonth.selectedIndex;
    selDay.options.length = 0;
    selDay.options[0] = new Option("");

    if (u == 2) {
        j = 28;
    }
    if ((u == 1) || (u == 3) || (u == 5) || (u == 7) || (u == 8) || (u == 10) || (u == 12)) {
        j = 31;
    }
    if ((u == 4) || (u == 6) || (u == 9) || (u == 11)) {
        j = 30;
    }

    for (i = 1; i != j + 1; i++) {
        selDay.options[i] = new Option(i);
    }

    selDay.selectedIndex = curDay;
}

function hotellist(){
    var region = document.reservation.region;
    var hotel = document.reservation.hotel;
    var curRegion = document.reservation.region.selectedIndex;
    var curHotel = document.reservation.hotel.selectedIndex;
    var u = region.selectedIndex;

    hotel.options.length = 0;
    hotel.options[0] = new Option("");

    if (u == 1) {
        hotel.options[1] = new Option("Iberostar Tabarka Beach, 5*");
    }

    if (u == 2) {
        hotel.options[1] = new Option("Bizerta Resort, 4*");
    }

    if (u == 3) {
        hotel.options[1] = new Option("El Mouradi Gammarth, 5*");
    }

    if (u == 4) {
        hotel.options[1] = new Option("El Mouradi Africa, 5*");
        hotel.options[2] = new Option("Dar El Medina, 4*");
        hotel.options[3] = new Option("Le Consul, 4*");
        hotel.options[4] = new Option("Le Pacha, 3*");
    }

    if (u == 5) {
        hotel.options[1] = new Option("--- 5* hotels ---");
        hotel.options[1].disabled = 1;
        hotel.options[2] = new Option("Any 5* hotel");
        hotel.options[3] = new Option("Royal Azur Thalassa Golf, 5*");
        hotel.options[4] = new Option("Golden Yasmine Mehari Hammamet, 5*");
        hotel.options[5] = new Option("Golden Yasmine Residence Mehari Hammamet, 5*");
        hotel.options[6] = new Option("Hasdrubal Thalassa & SPA Hammamet Yasmine, 5*");
        hotel.options[7] = new Option("Vincci Taj Sultan, 5*");
        hotel.options[8] = new Option("Riu Palace Oceana, 5*");
        hotel.options[9] = new Option("Riu Palace Hammamet Marhaba, 5*");
        hotel.options[10] = new Option("Sofitel Saphir Palace Yasmine Hammamet, 5*");
        hotel.options[11] = new Option("Iberostar Solaria, 5*");
        hotel.options[12] = new Option("--- 4* hotels ---");
        hotel.options[12].disabled = 1;
        hotel.options[13] = new Option("Any 4* hotel");
        hotel.options[14] = new Option("Sol Azur Beach Congres, 4*");
        hotel.options[15] = new Option("Les Orangers Beach Resort & Bungalow, 4*");
        hotel.options[16] = new Option("Abou Nawas Hammamet, 4*");
        hotel.options[17] = new Option("Vincci Lella Baya, 4*");
        hotel.options[18] = new Option("Vincci Nozha Beach, 4*");
        hotel.options[19] = new Option("Riu Park El Kebir, 4*");
        hotel.options[20] = new Option("Riu Marco Polo, 4*");
        hotel.options[21] = new Option("Thalassa Shalimar, 4*");
        hotel.options[22] = new Option("Residence Diar Lemdina, 4*");
        hotel.options[23] = new Option("El Mouradi Hammamet Resort, 4*");
        hotel.options[24] = new Option("Iberostar Averroes, 4*");
        hotel.options[25] = new Option("Iberostar Chich Khan, 4*");
        hotel.options[26] = new Option("--- 3* hotels ---");
        hotel.options[26].disabled = 1;
        hotel.options[27] = new Option("Any 3* hotel");
        hotel.options[28] = new Option("Bel Azur Thalassa, 3*");
        hotel.options[29] = new Option("Residence Mahmoud, 3*");
        hotel.options[30] = new Option("Kilma Hotel, 3*");
        hotel.options[31] = new Option("Le Prince Hotel, 3*");
        hotel.options[32] = new Option("Fourati Hammamet, 3*");
        hotel.options[33] = new Option("Le Hammamet Hotel, 3*");
        hotel.options[34] = new Option("Roayl Residence Hammamet, 3*");
        hotel.options[35] = new Option("Complex Khayam, 3*");
    }

    if (u == 6) {
        hotel.options[1] = new Option("--- 5* hotels ---");
        hotel.options[1].disabled = 1;
        hotel.options[2] = new Option("Any 5* hotel");
        hotel.options[3] = new Option("El Mouradi Palace, 5*");
        hotel.options[4] = new Option("El Mouradi Palm Marina, 5*");
        hotel.options[5] = new Option("Diar El Andalous, 5*");
        hotel.options[6] = new Option("--- 4* hotels ---");
        hotel.options[6].disabled = 1;
        hotel.options[7] = new Option("Any 4* hotel");
        hotel.options[8] = new Option("Thalassa Sousse, 4*");
        hotel.options[9] = new Option("Vincci El Kantaoui Center, 4*");
        hotel.options[10] = new Option("Riu Green Park, 4*");
        hotel.options[11] = new Option("Riu Bellevue Park, 4*");
        hotel.options[12] = new Option("El Mouradi Club Kantaoui, 4*");
        hotel.options[13] = new Option("El Mouradi Port El Kantaoui, 4*");
        hotel.options[14] = new Option("Hasdrubal Thalassa & SPA Port El Kantaoui, 4*");
        hotel.options[15] = new Option("--- 3* hotels ---");
        hotel.options[15].disabled = 1;
        hotel.options[16] = new Option("Any 3* hotel");
        hotel.options[17] = new Option("Royal Beach, 3*");
        hotel.options[18] = new Option("El Mouradi Club Selima, 3*");
    }

    if (u == 7) {
        hotel.options[1] = new Option("Thalassa Monastir, 5* lux");
        hotel.options[2] = new Option("Thalassa Village Skanes, 4*");
        hotel.options[3] = new Option("El Mouradi Skanes, 4*");
    }

    if (u == 8) {
        hotel.options[1] = new Option("--- 5* hotels ---");
        hotel.options[1].disabled = 1;
        hotel.options[2] = new Option("Any 5* hotel");
        hotel.options[3] = new Option("Vincci Nour Palace, 5*");
        hotel.options[4] = new Option("El Mouradi Mahdia, 5*");
        hotel.options[5] = new Option("--- 4* hotels ---");
        hotel.options[5].disabled = 1;
        hotel.options[6] = new Option("Any 4* hotel");
        hotel.options[7] = new Option("Thalassa Mahdia, 4*");
        hotel.options[8] = new Option("Riu El Mansour 4*");
        hotel.options[9] = new Option("--- 3* hotels ---");
        hotel.options[9].disabled = 1;
        hotel.options[10] = new Option("El Mouradi Cap Mahdia, 3*");
    }

    if (u == 9) {
        hotel.options[1] = new Option("Sofitel Palm Beach Tozeur, 5*");
        hotel.options[2] = new Option("El Mouradi Tozeur, 4*");
    }

    if (u == 10) {
        hotel.options[1] = new Option("El Mouradi Douz, 4*");
    }

    hotel.options[hotel.options.length] = new Option("--- Other ---");
}

function isValidEmail(email, strict){
    if (!strict)
        email = email.replace(/^\s+|\s+$/g, '');
    return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
}

function checkdate(){

    cd = new Date();
    cday = cd.getDate();
    cmonth = cd.getMonth();
    cyear = cd.getFullYear();
    aday = document.getElementById('aday').value;
    amonth = document.getElementById('amonth').value;
    ayear = document.getElementById('ayear').value;
    ad = new Date(ayear, amonth, aday);
    dday = document.getElementById('dday').value;
    dmonth = document.getElementById('dmonth').value;
    dyear = document.getElementById('dyear').value;
    dd = new Date(dyear, dmonth, dday);

    j = 0;
    if (aday == '') {
        j++;
    }
    if (dday == '') {
        j++;
    }
    if (amonth == '') {
        j++;
    }
    if (dmonth == '') {
        j++;
    }
    if (ayear == '') {
        j++;
    }
    if (dyear == '') {
        j++;
    }
    if (j > 0 && j < 6) {
        document.getElementById('cd_dates').style.display = 'block';
        document.getElementById('cd_oad').style.display = 'none';
        document.getElementById('cd_bttf').style.display = 'none';
        return false;
    }
    else {
        document.getElementById('cd_dates').style.display = 'none';
    }

    if (j == 0) {
        //alert('ChD enabled');
        i = 0;
        if (cd.getTime() > ad.getTime()) {
            i++;
            document.getElementById('cd_oad').style.display = 'block';
        }
        else {
            document.getElementById('cd_oad').style.display = 'none';
        }
        if (ad.getTime() > dd.getTime()) {
            i++;
            document.getElementById('cd_bttf').style.display = 'block';
        }
        else {
            document.getElementById('cd_bttf').style.display = 'none';
        }
        if (i == 0) {
            return true;
        }
        else {
            return false;
        }
    }

    return true;

}

function show_transport(){
    q = document.getElementById('tt');
    w = document.getElementById('hiddentransfer');
    if (q.value == "Individual") {
        w.disabled = 0;
        w.style.display = "inline";
    }
    else {
        w.disabled = 1;
        w.value = "";
        w.style.display = "none";
    }
}

/*function images(){
 n=document.getElementsByClassName("images");
 nl=n.length;
 for (var i=0; i<nl; i++) {
 n[i].setAttribute("onMouseOver","this.style.fontWeight = 'bold';");
 n[i].setAttribute("onMouseOut","this.style.fontWeight = 'normal';");}}*/


function pricer(th, id1){	nod = document.getElementById(id1);
	if(th=="Price"){nod.disabled=false;}else{nod.disabled=true;}
	alert(node);}

function disabler(th, id1){
	nod = document.getElementById(id1);
	if(th){nod.disabled=false;}else{nod.disabled=true;}}