		
		$(document).ready(function(){
			
			$('select#site_lang_menu OPTION:first').addClass('first_item');
			$('select#site_lang_menu OPTION:not(.dont_display):last').addClass('last_item');
			$('select#site_lang_menu')
				.change(function(){				
					location.href = $(this).val();
				})
				.selectmenu({
					style:  'dropdown',
					width: 180
				});
			
			// lightbox
			$(".lightbox").lightbox();
			
			$('.datepicker').datePicker({clickInput:true, createButton:false}).val(new Date().asString()).trigger('change');
;
			$('.cal_link A')
			.bind('click', function(){
				var index = $('.cal_link A').index($(this));
				$('.datepicker').eq(index).dpDisplay();
				return false;

				
			})
			/*.bind( 'dateSelected', function(e, selectedDate, $td){
				alert('You selected ' + selectedDate);
			}
			)*/;


			
			//------------------------- footer middle UL ----------------------
			$("#footer_middle UL LI").after('<li>|</li>');
			$("#footer_middle UL LI:last").remove();
			//------------------------- /footer middle UL ----------------------
			
			
			//----------------------------- gallery :last LI -----------------------------
			$(".gallery_list LI:odd").addClass("last");
			//----------------------------- /gallery :last LI ----------------------------
			
			
			//----------------------------- news wrapper :last LI ------------------------
			$(".news_wrapper:last").addClass("last");
			//----------------------------- /news wrapper :last LI -----------------------
			
			
			//----------------------------- e-razglednice -----------------------------
			can_go_er_next = 1;
			can_go_er_prev = 1;
			if( $("#er_panel").length && $("#er_panel UL LI").length ){
				
				img_width = $("#er_panel UL LI").eq(0).width();
				slide_speed = 700;
				
				$("#er_next").click(function(){
					
					if( can_go_er_next && can_go_er_prev ){
						
						can_go_er_next = 0;
						
						// get current pos
						current_left 	= Math.abs(parseInt($("#er_panel_slider").css('left')));
						new_left 		= current_left + img_width;
						current_img  	= current_left / img_width;
							
	
						// next or go to start
						if( current_img < $("#er_panel_slider UL").length - 2){ new_left = '-' + new_left + 'px'; }
						else { new_left = '0px'; }
						
						// animate
						$("#er_panel_slider").animate({
						
							left: new_left
							
						}, slide_speed, "swing", function(){ can_go_er_next = 1; });							
					}
					
						
					return false;
					
				});
				
				
				$("#er_prev").click(function(){
					
					if( can_go_er_next && can_go_er_prev ){
						
						can_go_er_prev = 0;
						
						// get current pos
						current_left = Math.abs(parseInt($("#er_panel_slider").css('left')));
						new_left = current_left - img_width;
						current_img  = current_left / img_width;
	
			
						// next or go to start
						if( current_img && current_img < $("#er_panel_slider UL").length - 1){ new_left = '-' +  new_left + 'px'; }
						//else { new_left = '0px'; }
						else { new_left = '-' + parseInt(parseInt(current_left) - parseInt(img_width)) + 'px'; /*new_left = '0px';*/ }
		
						// animate
						$("#er_panel_slider").animate({
						
							left: new_left
							
						}, slide_speed, "swing", function(){ can_go_er_prev = 1; });								
					}
					
				
						
					return false;					
					
				});
				
				
				input_1_old_val = input_2_old_val = "";
				$(".l_1 INPUT").focus(function(){
				
					if( input_1_old_val == "" ) input_1_old_val = $(this).val();
					$(this).val('');
					return false;
					
				}).blur(function(){
				
					if( $(this).val() == "" ) $(this).val(input_1_old_val);
					return false;
					
				});
				
				$(".l_2 INPUT").focus(function(){
				
					if( input_2_old_val == "" ) input_2_old_val = $(this).val();
					$(this).val('');
					return false;
					
				}).blur(function(){
			
					if( $(this).val() == "" ) $(this).val(input_2_old_val);				
					return false;
					
				});
				
				$(".btn_send_er").click(function(){
				
					form_id = $(this).attr('rel');
					
					$("#" + form_id).eq(0).submit();
				
					return false;
					
				}).blur(function(){
					
					return false;
					
				});

				
			}
			//----------------------------- /e-razglednice ----------------------------
	
			
			
			//----------------------------- gallery slider -----------------------------
			can_go_next = 1;
			can_go_prev = 1;
			if( $("#gallery_slider").length && $("#gallery_slider IMG").length ){

				img_width = $("#gallery_slider IMG").eq(0).width();
				slide_speed = 700;
				
				$("#gallery_next A").click(function(){
					
					if( can_go_next && can_go_prev ){
						
						can_go_next = 0;
						
						// get current pos
						current_left = Math.abs(parseInt($("#gallery_slider").css('left')));
						new_left = current_left + img_width;
						current_img  = current_left / img_width;
							
	
						// next or go to start
						if( current_img < $("#gallery_slider IMG").length - 1){ new_left = '-' + new_left + 'px'; }
						else { new_left = '0px'; }
						
						// animate
						$("#gallery_slider").animate({
						
							left: new_left
							
						}, slide_speed, "swing", function(){ can_go_next = 1; });							
					}
					
						
					return false;
					
				});
				
				
				$("#gallery_prev A").click(function(){
					
					if( can_go_next && can_go_prev ){
						
						can_go_prev = 0;
						
						// get current pos
						current_left = Math.abs(parseInt($("#gallery_slider").css('left')));
						new_left = current_left - img_width;
						current_img  = current_left / img_width;
	
			
						// next or go to start
						if( current_img && current_img < $("#gallery_slider IMG").length - 1){ new_left = '-' +  new_left + 'px'; }
						else { new_left = '-' + parseInt(parseInt(current_left) - parseInt(img_width)) + 'px'; /*new_left = '0px';*/ }
		
						// animate
						$("#gallery_slider").animate({
						
							left: new_left
							
						}, slide_speed, "swing", function(){ can_go_prev = 1; });								
					}
					
				
						
					return false;					
					
				});
				
				$("#gallery_back A").click(function(){
					
					history.back(1);
					return false;
					
				});
				
				
			}	
			//----------------------------- /gallery slider ----------------------------
			
			
			
			//----------------------------- contact form ----------------------------
			if( $("#btn_submit_contact_form").length ){

				// put text in value=""
				$("#cf_name").val($("#cf_name").attr('alt'));
				$("#cf_email").val($("#cf_email").attr('alt'));
				$("#cf_phone").val($("#cf_phone").attr('alt'));
				$("#cf_msg").val($(".cf_msg").text());
			
				// assign input click events
				$("#cf_name , #cf_phone , #cf_email , #cf_msg").click(function(){
				
					if( $(this).val() == $(this).attr('alt') ) $(this).val('');
					
					if( $(this).attr('id') == "cf_msg" ){ if( $(this).val() == $(".cf_msg").text() ) $(this).val(''); }
					
					
				}).blur(function(){
					
					if( $(this).val() == "" ) $(this).val($(this).attr('alt'));
					
					if( $(this).attr('id') == "cf_msg" ){ 
						if( $(this).val() == "" ) $(this).val($(".cf_msg").text()); 
					}
					
				});
				
				$("#btn_submit_contact_form").click(function(){
					
					// get lang
					var site_query 	= window.location.href; 
					gy 				= (site_query).split('/');
					lang 			= gy[3];
				
					// check fields
					submit_form = 1;
					submit_form = check_contact_fields(lang);
					
					if( submit_form ){ $("FORM#site_contact_form").eq(0).submit(); }
					
				
					return false;
					
				});
				
			}
			//----------------------------- contact form ---------------------------
			
			//----------------------------- ballon ---------------------------
			// only for 4 langs ( hr, it, de, en )
			
			location_array 	= location.href.split('/');
			lang 			= location_array[3];
			page_id 		= location_array[5];
			//if( (lang == "en" || lang == "hr" || lang == "it" || lang == "de" ) && (page_id == 1) ){
			if( (page_id == 1) ){
				
				$("BODY").append('<div id="ballon"></div>');
				$("#ballon").addClass('ballon3_lang_' + lang);
				
				var viewportWidth = $(window).width();
				new_left = parseInt( (viewportWidth - 395) / 2 );
				$("#ballon").css('left', new_left + 'px');
				
				$("#ballon").click(function(){
					
					if( lang == "hr"  ) window.location.href = '/hr/content/8/posebna-ponuda/';
					else if( lang == "en"  ) window.location.href = '/en/content/8/special-offer/';
					else if( lang == "de"  ) window.location.href = '/de/content/8/sonderangebot/';
					else if( lang == "it"  ) window.location.href = '/it/content/8/offerta-speciale/';
					else if( lang == "cz"  ) window.location.href = '/cz/content/8/zvlastni-nabidka/';
					else if( lang == "hu"  ) window.location.href = '/hu/content/8/kiemelt-ajanlatunk/';
					else if( lang == "sk"  ) window.location.href = '/sk/content/8/mimoriadna-ponuka/';
					
					//$("#ballon").remove();
					return false;
					
				});				
			}
			//----------------------------- /ballon ---------------------------


		});
