$(document).ready(function(){
	$("#pageflip").hover(function() {
		$("#pageflip img , .msg_block").stop()
			.animate({
				width: '307px', 
				height: '319px'
			}, 500); 
		} , function() {
		$("#pageflip img").stop() 
			.animate({
				width: '50px', 
				height: '52px'
			}, 220);
		$(".msg_block").stop() 
			.animate({
				width: '50px', 
				height: '50px'
			}, 200);
	});	
});

//jquery ui - butoni
$(function(){
//hover states on the static widgets
	$('.dialog_link').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
});
//end

$(function(){
	$("#datepicker").datepicker({ onClose: function(dateText, inst) { alert(dateText) } });
});


//tooltip
this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
// starting the script on page load
$(document).ready(function(){
	tooltip();
});

this.tooltip2 = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip2").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip2'>"+ this.t +"</p>");
		$("#tooltip2")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip2").remove();
    });	
	$("a.tooltip2").mousemove(function(e){
		$("#tooltip2")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
// starting the script on page load
$(document).ready(function(){
	tooltip2();
});
//end

//login dialog
$(document).ready(function(){
$('#dialogLogin').dialog({
	autoOpen: false,
	width: 250,
	draggable: false,
	hide: 'scale',
	modal: true,
	resizable: false,
	buttons: {
			"Вход": function() { 
				$('#logme').submit(); 
			}, 
			"Отказ": function() { 
				$(this).dialog("close"); 
			}
			}
});
			
// Dialog Link
$('#dL').click(function(){
	$('#dialogLogin').dialog('open'); 
	return false;
});


//video
$('#videoLogin').dialog({
	autoOpen: false,
	width: 660,
	draggable: false,
	hide: 'scale',
	modal: true,
	resizable: false,
	buttons: {
			"Затвори": function() { 
				$(this).dialog("close"); 
				$('#hbanner').show(200);
			}
			}
});
$('#videopen').click(function(){
	$('#hbanner').hide();
	$('#videoLogin').dialog('open'); 
	return false;
});

//mailing
$('#mailingsave').click(function(){
$.post("http://www.zonacomfort.eu/bg/contacts/savemailing",
	  { emailx: $("#emailm").val(), tpl: "1" },
	  function(data){
	    alert(data);
	    $("#emailm").val('');
	  }
);
});
//endmailing

});
//end login dialog
