$(document).ready(function()
{
jQuery.ajaxq = function (queue, options)
{
	// Initialize storage for request queues if it's not initialized yet
	if (typeof document.ajaxq == "undefined") document.ajaxq = {q:{}, r:null};

	// Initialize current queue if it's not initialized yet
	if (typeof document.ajaxq.q[queue] == "undefined") document.ajaxq.q[queue] = [];
	
	if (typeof options != "undefined") // Request settings are given, enqueue the new request
	{
		// Copy the original options, because options.complete is going to be overridden

		var optionsCopy = {};
		for (var o in options) optionsCopy[o] = options[o];
		options = optionsCopy;
		
		// Override the original callback

		var originalCompleteCallback = options.complete;

		options.complete = function (request, status)
		{
			// Dequeue the current request
			document.ajaxq.q[queue].shift ();
			document.ajaxq.r = null;
			
			// Run the original callback
			if (originalCompleteCallback) originalCompleteCallback (request, status);

			// Run the next request from the queue
			if (document.ajaxq.q[queue].length > 0) document.ajaxq.r = jQuery.ajax (document.ajaxq.q[queue][0]);
		};

		// Enqueue the request
		document.ajaxq.q[queue].push (options);

		// Also, if no request is currently running, start it
		if (document.ajaxq.q[queue].length == 1) document.ajaxq.r = jQuery.ajax (options);
	}
	else // No request settings are given, stop current request and clear the queue
	{
		if (document.ajaxq.r)
		{
			document.ajaxq.r.abort ();
			document.ajaxq.r = null;
		}

		document.ajaxq.q[queue] = [];
	}
}	
	

$.ctrl = function(key, callback, args) {
    $(document).keydown(function(e) {
        if(!args) args=[]; // IE barks when args is null
        if(e.keyCode == key.charCodeAt(0) && e.ctrlKey) {
            callback.apply(this, args);
            return false;
        }
    });
};


$.ctrl('Q', function() {
    $("body").append('<div align="center" style="background-color: yellow; height: 20px; position: absolute; top: 5px; left: 500px; font-size: 16px; font-weight: bold; width: 150px;">Brišem CACHE!</div>');
   
  
   
	jQuery.ajaxq("vrsta",{
		url: "/program/DeleteCache.asp",
		success: function(html){}
	});
	jQuery.ajaxq("vrsta",{
		url: window.location.href,
		success: function(html){window.location = window.location.href;}
	});
	jQuery.ajaxq("vrsta",{
		url: "/program/DeleteCache.asp?disableDeleteCache=true",
		success: function(html){
			window.location = window.location.href;	
		}
	});	
	
	
});		

		
	$('.fastSearchBox .inputBox .input').focus(function()
	{
		if($(this).val() == $(this).parent().find('.inputHelp').text())
			$(this).val('').addClass('inputSelected');
	});
	
	$('.fastSearchBox .inputBox .input').blur(function()
	{
		if($(this).val().length == 0)
			$(this).val($(this).parent().find('.inputHelp').text()).removeClass('inputSelected');
	});	
	
	$('form#headerSearchBox').submit(function()
	{
		var sstring				= jQuery.trim($(this).find("input[name='sstring']").val());
		var getstringbigresult	= $(this).find("input[name='geostringbigresult']").val() + ", Hotels";
	
		if(sstring.length == 0 || sstring == $(this).find('.inputHelp').text())
		{
			alert('Prosim, vnesite pogoj za iskanje!');
			return false;
		}
		
		if(sstring.length < 3)
		{
			alert('Iskalni pogoj mora biti dolg vsaj 3 črke!');
			return false;
		}		
		
		/*
		* Filtracija po prevec splosnih pogojih, ki vracajo preveliko stevilo rezultatov
		*/
		if(getstringbigresult.search(new RegExp(sstring, "gi")) > -1)
		{
			alert('Pozor! Izbrali ste preveč splošen iskalni pojem. \n\nProsimo, da vnesete točno destinacijo, \nali pa kliknete nanjo na spodnjem seznamu!!');
			return false;
		}
		
		// vse vredu, submit form
		return true;			
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
				/* animationSpeed: 'normal',  fast/slow/normal */
				/* padding: 40,  padding for each side of the picture */
				/* opacity: 0.35,  Value betwee 0 and 1 */
				/* showTitle: true,  true/false */
				/* allowresize: true,  true/false */
				/*counter_separator_label: '/',  The separator for the gallery counter 1 "of" 2 */
				/*theme: 'light_rounded',  light_rounded / dark_rounded / light_square / dark_square */
				/*hideflash: false,  Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
				/*modal: false,  If set to true, only the close button will close the window */
				changepicturecallback: function(){ $(".desnipas").hide(); $("#uporabnikov_komentar_button").hide(); }, /* Called everytime an item is shown/changed */
				callback: function(){ $(".desnipas").show(); $("#uporabnikov_komentar_button").show(); } /* Called when prettyPhoto is closed */
			});		

$("#btn-naprej-mala-div").click(function(){
	if (galleryDIVcurent != galleryDIVmax){
		galleryDIVcurent = galleryDIVcurent + 1;
		$(".div_thumbs").hide();
		$("#div_thumbs_" + galleryDIVcurent).fadeIn();
	}
}).mouseover(function(){
	if (galleryDIVcurent != galleryDIVmax){
		$("#btn-naprej-mala-div").css("cursor","pointer");
		$("#btn-naprej-mala-div").css("background-image","url('img/gallery/btn-naprej-mala.gif')");
	}else{
		$("#btn-naprej-mala-div").css("cursor","default");
	}
}).mouseout(function(){
	$("#btn-naprej-mala-div").css("background-image","url('img/gallery/btn-naprej-mala-off.gif')");
	
}).mouseup(function(){
	if (galleryDIVmax == galleryDIVcurent + 1){
			$("#btn-naprej-mala-div").css("cursor","default");
			$("#btn-naprej-mala-div").css("background-image","url('img/gallery/btn-naprej-mala-off.gif')");
	}
});

$("#btn-nazaj-mala-div").click(function(){
	if (galleryDIVcurent != 1){
		galleryDIVcurent = galleryDIVcurent - 1;
		$(".div_thumbs").hide();
		$("#div_thumbs_" + galleryDIVcurent).fadeIn();
	}
}).mouseover(function(){
	if (galleryDIVcurent != 1){
		$("#btn-nazaj-mala-div").css("cursor","pointer");
		$("#btn-nazaj-mala-div").css("background-image","url('img/gallery/btn-nazaj-mala.gif')");
	}else{
		$("#btn-nazaj-mala-div").css("cursor","default");
	}
}).mouseout(function(){
	$("#btn-nazaj-mala-div").css("background-image","url('img/gallery/btn-nazaj-mala-off.gif')");
}).mouseup(function(){
	//alert(galleryDIVcurent);
	if (galleryDIVcurent == 2){
			$("#btn-nazaj-mala-div").css("cursor","default");
			$("#btn-nazaj-mala-div").css("background-image","url('img/gallery/btn-nazaj-mala-off.gif')");
	}
});
	

$(".div_podroben_izpis_mesecev").mouseenter(function(){
	var id = this.id.replace("div_podroben_izpis_mesecev_", "");
	var multiDays = $("#boolRazlicniIntervali_" + id).val();
	if (multiDays == "0"){
		$("#div_trajanje_" + id).show();
	}else{
		$("#div_izpisMesecev_" + id + "_" + multiDays).css("position", "absolute").css("top", "11px");
		$("#div_izpisMesecev_" + id + "_" + multiDays).css("left", "60px").show();
	}
	$("#div_izpisIntervalaMesecev_" + id).addClass("barva_meseci1");
}).mouseleave(function(e){
	var id = this.id.replace("div_podroben_izpis_mesecev_", "");
	var multiDays = $("#boolRazlicniIntervali_" + id).val();
	if (multiDays == "0"){
		$("#div_trajanje_" + id).hide();
	}else{
		$("#div_izpisMesecev_" + id + "_" + multiDays).css("left", "0px").hide();
	}
	$("#div_izpisIntervalaMesecev_" + id).removeClass("barva_meseci1");
	
	
});

$(".div_trajanje_stevilo").mouseenter(function(){
	var id = this.id.replace("div_trajanje_stevilo_", "");
	$("#div_izpisMesecev_" + id).css("top", $(this).position().top - 10);
	$("#div_izpisMesecev_" + id).css("left", $(this).position().left - $("#div_izpisMesecev_" + id).width() - 7).show();
	$("#div_trajanje_stevilo_" + id).addClass("barva_meseci1");
}).mouseleave(function(e){
	var id = this.id.replace("div_trajanje_stevilo_", "");
	$("#div_trajanje_stevilo_" + id).removeClass("barva_meseci1");
	$("#div_izpisMesecev_" + id).hide();
	
});





$(".div_meseciOdhodov_detajlno").mouseenter(function(){
	var id = this.id.replace("div_meseciOdhodov_detajlno_", "");
	$(this).addClass("barva_meseci1");
	$("#div_dneviOdhodov_" + id).css("top", $(this).position().top - 10);
	$("#div_dneviOdhodov_" + id).css("left", $(this).position().left - $("#div_dneviOdhodov_" + id).width() - 7).show();
	
	//$("#div_dneviOdhodov_" + id).show();
}).mouseleave(function(){
	var id = this.id.replace("div_meseciOdhodov_detajlno_", "");
	$(this).removeClass("barva_meseci1");
	$("#div_dneviOdhodov_" + id).hide();
});



$(".div_tocni_datumi").mouseenter(function(){
	
	var id = this.id.replace("div_tocni_datumi_", "");
	$(this).addClass("barva_meseci1");
	$("#div_prikaz_podrobnosti_" + id).css("top", $(this).position().top - 10);
	$("#div_prikaz_podrobnosti_" + id).css("left", $(this).position().left - $("#div_prikaz_podrobnosti_" + id).width() - 15);
	$("#div_prikaz_podrobnosti_" + id).show();
}).mouseleave(function(){
	var id = this.id.replace("div_tocni_datumi_", "");
	$(this).removeClass("barva_meseci1");
	$("#div_prikaz_podrobnosti_" + id).hide();
});

$(".div_prikaz_podrobnosti").mouseenter(function(){
	var id = this.id.replace("div_prikaz_podrobnosti_", "");
	$("#div_tocni_datumi_" + id).addClass("barva_meseci1");
	$("#div_prikaz_podrobnosti_" + id).show();
}).mouseleave(function(){
	var id = this.id.replace("div_prikaz_podrobnosti_", "");
	$("#div_tocni_datumi_" + id).removeClass("barva_meseci1");
	$("#div_prikaz_podrobnosti_" + id).hide();
});

	
});

