
 function checkSurvey(survey) {
     if (survey.value == "0") {
         document.getElementById("survey_value").style.display = "inline";
     } else {
         document.getElementById("survey_value").style.display = "none";
     }
 }

$(document).ready(function(){
    $("#arrowUp").click(function () {
        $('#hotelPictures').scrollTo( '-=450px', 800 );

    });
});
$(document).ready(function(){
    $("#arrowDown").click(function () {
        $('#hotelPictures').scrollTo( '+=450px', 800 );

    });
});


 function showSurcharges(span, e) {

    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    }
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX +
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY +
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }

        c = document.getElementById(span.id + "div").innerHTML;
		//$("body").append("<div id='preview' class='hahaha'>" + c + "</div>");
        $("#preview").html(c);
        $('#preview').hide();
        $("#preview")
			.css("top",(/*e.pageY*/cursor.y - 40) + "px")
			.css("left",(/*e.pageX*/cursor.x - 320) + "px")
            .fadeIn(300)
            ;
 }

 function hideSurcharges() {
        $("#preview").fadeOut(300);
 }

this.imagePreview = function(){
	/* CONFIG */

		xOffset = 40;
		yOffset = - 320;

		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result

	/* END CONFIG */
	$("span.preview").hover(function(e){

        c = document.getElementById(this.id + "div").innerHTML;
		//$("body").append("<div id='preview' class='hahaha'>" + c + "</div>");
        $("#preview").html(c);
        $('#preview').hide();
        $("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
            .fadeIn(300)
            ;
    },
	function(){
		this.title = this.t;
        $("#preview").fadeOut(300);
		//setTimeout("$('#preview').remove()", 1000);
    });
    /*
	$("span.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});*/
};

function checkPaymentForm()
{
    var email = document.getElementById('emailcustomer');
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email.value)) {
        alert('Zadejte platnou e-mailovou adresu.');
        email.focus();
        return false;
    }

    if (document.getElementById("amount_input") == null) return true;

    amount_min = parseInt(document.getElementById("amount_min").value, 10);
    amount_max = parseInt(document.getElementById("amount_max").value, 10);
    amount_input = parseInt(document.getElementById("amount_input").value, 10);

    if (amount_input < amount_min)
    {
        if (amount_min < amount_max)
        {
            alert("Zálohu je možné splatit minimálně ve výši 30%, tedy " + format_number(amount_min, " ") + " Kč.");
            document.getElementById("amount_input").value = amount_min;
        }
        else
        {

        }
        return false;
    }

    if (amount_input > amount_max)
    {
        alert("Maximální možná částka je " + format_number(amount_max, " ") + " Kč.");
        document.getElementById("amount_input").value = amount_max;
        return false;
    }

    document.getElementById("amount_real").value = (amount_input * 100);

    alert("Chystáte se zaplatit částku ve výši "+format_number(amount_input, " ")+" Kč, po této úhradě zbyde k zaplacení "+format_number((amount_max - amount_input), " ")+" Kč.");
    return true;
}

function format_number($cislo,$oddelovac) {
   $cislo += "";        // pretypovani cisla na retezec
   $pocet_cislic = $cislo.length;
   $tisice = $cislo.substring(0,$pocet_cislic-3);
   $stovky = $cislo.substring($pocet_cislic-3,$pocet_cislic);
   $cislo = $tisice + $oddelovac + $stovky;
   return($cislo);
}

function getSubDestination($destination, $id, $first_choice, global_url) {
        var ajaxConfig = {
        type: "GET",
        url: global_url + "inc/ajaxEnquiry.jsp",
        data: "type=regions&par=" + encodeURI($destination),
        success: function (msg2) {
            var response = eval('(' + msg2 + ')');

            var regions = response.regions;

            $("#"+$id).html("<option value=''>" + $first_choice + "</option>");//removeOption(/./);

            for (i = 0; i < regions.length; i++) {
                $("#"+$id).append("<option value='" + regions[i].name + "(" + regions[i].abbreviation + ")'>" + regions[i].name + "</option>");
            }
        }
    };

    $.ajax(ajaxConfig);
}

function getHotels($destination, $id, $first_choice, global_url) {
        var ajaxConfig = {
        type: "GET",
        url: global_url + "inc/ajaxEnquiry.jsp",
        data: "type=hotels&par=" + encodeURI($destination.split("(")[1].slice(0, -1)),
        success: function (msg2) {
            var response = eval('(' + msg2 + ')');

            var hotels = response.hotels;

            $("#"+$id).html("<option value=''>" + $first_choice + "</option>");//removeOption(/./);

            for (i = 0; i < hotels.length; i++) {
                $("#"+$id).append("<option value='" + hotels[i] + "'>" + hotels[i] + "</option>");
            }
        }
    };

    $.ajax(ajaxConfig);
}