<!-- hide script from old browsers

function zobraz(obrazek) {
document.images.acc_pic.src=obrazek;
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function loadOnStart(){
	$(".confirm-delete").css('display', 'none');
	$(".pic-deleter a").click( function(ev){
		ev.preventDefault();
		question = $(this).attr('rel');
		$("#"+question).css('display', 'block');
	})
	$(".prettyPhoto").prettyPhoto();
	$(".sortButton").click( function(ev){
		var l_sort = $(this).attr('rel');
		var l_sort_old = $("#l_sort").val();
		var l_sort_dir = $("#l_sort_dir").val();
		$("#l_sort").val(l_sort);
		if (l_sort == l_sort_old) {
			if (l_sort_dir == 'ASC' ) $("#l_sort_dir").val('DESC');
			if (l_sort_dir == 'DESC') $("#l_sort_dir").val('ASC');
			
		}else{
			$("#l_sort_dir").val('ASC')
		}
		$(".listForm").submit();
	})
	$("a, input, .bulletIcons li, #gridButtons li, .tab_name, .tab_booked").tooltip({ 
		showURL: false 
	});
	$('.dateTimeField').datetimepicker({
		dateFormat: 'dd.mm.yy',
		showMinute: false,
		stepHour: 2,
		hourMin:9,
		hourMax:20
	});
	$('.dateField').datepicker({
		dateFormat: 'dd.mm.yy'
	});
	tinyMCE.init({
		// General options
		mode : "specific_textareas",
		editor_selector : "editor",
		theme : "advanced",
		theme_advanced_resizing : true,
		// Example content CSS (should be your site CSS)
		content_css : "/css/tiny-mce.css",
		plugins : "spellchecker,pagebreak,style,layer,table,save",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,help,code",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat",
		theme_advanced_statusbar_location : "bottom"
	});
	
	$('#lusr_email, #lusr_pass, #searchBox, #rusr_email, #tellafriend_to ').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value) {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = default_value;
	        }
	    });
	});
	$('#s_from').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value || this.value=='min') {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = 'min';
	        }
	    });
	});
	$('#s_to').each(function() {
	    var default_value = this.value;
	    $(this).focus(function() {
	        if(this.value == default_value || this.value=='max') {
	            this.value = '';
	        }
	    });
	    $(this).blur(function() {
	        if(this.value == '') {
	            this.value = 'max';
	        }
	    });
	});

}

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

window.onload = function() {
	loadOnStart();
	externalLinks();
}

$(document).ready(function(){
	$('#gallery').galleryView({
		panel_width: 465,
		panel_height: 400,
		frame_width: 90,
		frame_height: 90,
		gallery_padding:30,
		pause_on_hover: true
	});
	// Checking for change on property-edit.php llord to call AJAX for new data
	$('#llord_id1, #llord_id2, #llord_id3').change(function() {
		var str = "";
		var bodyContent = "";
		var fieldset = new Array('','','','','');
		str += $(this).val();
		var setIdent = $(this).attr('id');
		var numIdent = setIdent.substr(8,1);
		if (str!=''){
		bodyContent = $.ajax({
			  url: "/ajax-handler.php",
			  global: false,
			  type: "POST",
			  data: ({request : 'user_info',
				request_value: str}),
			  dataType: "html",
			  async:false,
			  success: function(msg){
				 
			  }
		   }
		).responseText;
		var fieldset = bodyContent.split('<val>');
		}
		$("#llord"+ numIdent+ "_usr_surname").val(fieldset[0]);
		$("#llord"+ numIdent+ "_usr_firstname").val(fieldset[1]);
		$("#llord"+ numIdent+ "_usr_phone").val(fieldset[2]);
		$("#llord"+ numIdent+ "_usr_mobile").val(fieldset[3]);
		$("#llord"+ numIdent+ "_usr_email").val(fieldset[4]);
	});
	$('#tellfriend').hide();
 	$('.emailToFriend a, #tellfriend a').click(function(ev) {
		ev.preventDefault();
		$("#tellfriend").fadeToggle('slow');
	});
	$('#tellafriend_form').submit(function(ev){
		ev.preventDefault();
		var email = $('#tellafriend_to').attr('value');
		var request_id = $('#tellafriend_property_id').attr('value');
		if (email!=''){
			bodyContent = $.ajax({
				  url: "/ajax-handler.php",
				  global: false,
				  type: "POST",
				  data: ({request : 'email_to_friend',
					request_value: email,
					request_id: request_id }),
				  dataType: "html",
				  async:false,
				  success: function(data) {
						$('#tellfriendMessage').html(data);
					  }
			   }).responseText;
			var fieldset = bodyContent.split('<val>');
		}else{
			$('#tellfriendMessage').html("Please insert email address");
		}
	})
});

// end hiding script from old browsers -->

