var subLinksUrl = "offers.php";
var imagesDir = "./files/tntn/";

/***************** Start Left Menu ****************/
$(document).ready(function() {
	$("#picsScrolling").cycle({
		/*fx: 'scrollLeft',7/
		/*fx: 'turnDown',*/
		/*fx: 'zoom',
		fx:     'scrollDown', 
		 easing: 'bounceout', */
		 fx: "fade"
	});
	$("a.openVideo").fancybox({ 
		'zoomSpeedIn': 300, 
		'frameWidth': 760, 
		'frameHeight': 430, 
		'centerOnScroll': false,
		'zoomSpeedOut': 300, 
		'overlayShow': true,

		'hideOnContentClick': true ,
		'callbackOnStart': function() { 
		},
		'callbackOnClose': function(){
			
		}
	});
	$("a[name='subLink']").bind("mouseover", function(e) {
		$("#menuOver").remove();
		var jsonData = null;	
		var idMenu = this.id;		
		$.ajax({
			type: "GET",
			url: "getSubMenus.php",
			data: "id=" + idMenu,
			dataType: "json",
			success: function(data) {
				jsonData = data	; 
				$(document.createElement("div")).attr({"id": "menuOver"}).css({"left": 178 + ($("#lim" + idMenu).offset().left - 178) + "px"}).insertBefore("#search").bind("mouseout", function(e) {$("#menuOver").remove();});		
				$("#menuOver").animate({
					width: "178px",
					height: (jsonData.length == 1 ? 32 : jsonData.length * 32) + "px"
				}, 400).bind("mouseout", function(e) {$("#menuOver").remove();});		
				/************ Sub Menu ***********/
				$(document.createElement("ul")).attr("id", "subMenuUL").appendTo("#menuOver");			
				$.each(jsonData, function(i) {
					if(i == 0)$(document.createElement("li")).attr({"class": "subMenuLI", "id": "l" + jsonData[i].id}).appendTo("#subMenuUL");
					if(i > 0)$(document.createElement("li")).attr({"class": "subMenuLI", "id": "l" + jsonData[i].id}).insertAfter("#l" + jsonData[i-1].id);
					$(document.createElement("a")).attr({"href": ("property-type-" + jsonData[i].link_title +"-" + jsonData[i].id + "-" + jsonData[i].lng + ".html"), "class": "subMenuLink", "id": "a" + jsonData[i].id}).text(jsonData[i].name).appendTo("#l" + jsonData[i].id);						
				});
			}
		});	
	});
	$("#subwarp").bind("mouseout", function(e) {
		$("#menuOver").remove();
	});
	$("#headerOffers").bind("mouseout", function(e) {
		$("#menuOver").remove();
	});	
		
});

function selectedMenu(id) {
		if (menu_id && document.getElementById(menu_id)) {
			document.getElementById(menu_id).style.display='block';
			document.getElementById(menu_id).style.visibility='visible';
		}						
		
}
