﻿function sortApartmentList(sGoto) {
    window.location = sGoto;
}

function CopyFirstLastName(form) {
    form.BookingFirstName.value = form.GuestFirstName1.value;
    form.BookingLastName.value = form.GuestLastName1.value;
}

function toggleBillingInformation() {
    
    sVar = document.getElementById("BillingInformation").style.display
    
    if (sVar == "none") {
        document.getElementById("BillingInformation").style.display = "inline";
    }
    else {
        document.getElementById("BillingInformation").style.display = "none";
    }
}

function swapImage(url,description) {

    document.getElementById("mainPhoto").src = url    

    document.getElementById("apartmentGalleryDescription").innerHTML = description 
    
}

function changeForm(sAction) {

    document.getElementById("SearchImage").src = "/images/button_search.gif";

    document.getElementById("form1").action = sAction;

}

function validate_form() {
    
    valid = true;

    if (document.form1.Persons.selectedIndex == 0) {
        document.getElementById("PersonsText").style.color = "red";
        document.getElementById("Persons").style.backgroundColor = "red";
        document.getElementById("Persons").style.color = "white";
        valid = false;
    }
    else {
        document.getElementById("PersonsText").style.color = "black";
        document.getElementById("Persons").style.backgroundColor = "white";
        document.getElementById("Persons").style.color = "black";
    }

    startdatetext = false;
    enddatetext = false;
    
    if (document.form1.StartDate_day.selectedIndex == 0) {
        
        document.getElementById("StartDate_day").style.backgroundColor = "red";
        document.getElementById("StartDate_day").style.color = "white";
        valid = false;
        startdatetext = true
    }
    else {
        
        document.getElementById("StartDate_day").style.backgroundColor = "white";
        document.getElementById("StartDate_day").style.color = "black";
    }


    if (document.form1.StartDate_month.selectedIndex == 0) {
        
        document.getElementById("StartDate_month").style.backgroundColor = "red";
        document.getElementById("StartDate_month").style.color = "white";
        valid = false;
        startdatetext = true;
    }    
    else {
        
        document.getElementById("StartDate_month").style.backgroundColor = "white";
        document.getElementById("StartDate_month").style.color = "black";
    }

    if (document.form1.StartDate_year.selectedIndex == 0) {
        
        document.getElementById("StartDate_year").style.backgroundColor = "red";
        document.getElementById("StartDate_year").style.color = "white";
        valid = false;
        startdatetext = true;
    }
    else {
        
        document.getElementById("StartDate_year").style.backgroundColor = "white";
        document.getElementById("StartDate_year").style.color = "black";
    }

    if (startdatetext) {
        document.getElementById("StartDateText").style.color = "red";
    }
    else {
        document.getElementById("StartDateText").style.color = "black";
    }

    if (document.form1.EndDate_day.selectedIndex == 0) {        
        document.getElementById("EndDate_day").style.backgroundColor = "red";
        document.getElementById("EndDate_day").style.color = "white";
        valid = false;
        enddatetext = true;
    }
    else {        
        document.getElementById("EndDate_day").style.backgroundColor = "white";
        document.getElementById("EndDate_day").style.color = "black";
    }


    if (document.form1.EndDate_month.selectedIndex == 0) {        
        document.getElementById("EndDate_month").style.backgroundColor = "red";
        document.getElementById("EndDate_month").style.color = "white";
        valid = false;
        enddatetext = true;
    }
    else {        
        document.getElementById("EndDate_month").style.backgroundColor = "white";
        document.getElementById("EndDate_month").style.color = "black";
    }


    if (document.form1.EndDate_year.selectedIndex == 0) {        
        document.getElementById("EndDate_year").style.backgroundColor = "red";
        document.getElementById("EndDate_year").style.color = "white";
        valid = false;
        enddatetext = true;
    }
    else {       
        document.getElementById("EndDate_year").style.backgroundColor = "white";
        document.getElementById("EndDate_year").style.color = "black";
    }

    if (enddatetext) {
        document.getElementById("EndDateText").style.color = "red";
    }
    else {
        document.getElementById("EndDateText").style.color = "black";
    }
        
    return valid;
}

$(document).ready(function () {

    $(".showAllReviews").click(function () {
        $(this).fadeOut();
        $("#apartmentReviewListInner").fadeIn();
    });

});
