$(document).ready(function(){
	$('.textfield2').focus(function(){
		if($(this).val()==$(this).attr('id')){
			$(this).val('');
		}
	});
	$(".textfield2").bind("blur", function(){
		if($(this).val() == "") $(this).val(this.id);
	});
	
	$("#various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$("#calcMoney").bind("click", function(){
		var price = parseFloat($("#price1").val());
		var currencyRate = parseFloat($("#currencyRate").val());
		$("#calcprice").val(price*currencyRate);
	});
	
	$("#picsScrolling").cycle({
		/*fx: 'scrollLeft',7/
		/*fx: 'turnDown',*/
		/*fx: 'zoom',
		fx:     'scrollDown', 
		 easing: 'bounceout', */
		 fx: "fade"
	});
	/*
   $("#picsScrolling").cycle({
		fx:     'turnLeft',
		delay:  -4000
	});
	*/
	$(".menuOver").mouseover(function() {
//bind("mouseover", function(){
		$("li[name=hiddenMenu]").remove();
		var cat_id1 = $(this).attr("title");
		var cat_id = $(this).attr("name")
		//alert("getCats.php?"+"cat_id="+cat_id);
		$.ajax({
			type: "post",
			url: "getCats.php",
			data: "cat_id="+cat_id,
			beforeSend: function(html){
				$("#menuOverRegions"+cat_id+"-"+cat_id1).append('<li class="submenu" style="padding-left: 10px;" id="loadingSubmenu"><b>LOADING ...</b></li>');
			},
			success: function(html){
				$("#loadingSubmenu").remove();
				$("#menuOverRegions"+cat_id+"-"+cat_id1).append(html);
			},
			complete: function(html){
				$("#loadingSubmenu").remove();
			}
		});
	});
	$(".menuOverType").mouseover(function() {
//bind("mouseover", function(){
		$("li[name=hiddenMenu]").remove();
		//alert($(this).attr("name"));
		var type_id = $(this).attr("name")
		$.ajax({
			type: "post",
			url: "getTypes.php",
			data: "type_id="+type_id,
			beforeSend: function(html){
				$("#menuOverType"+type_id).append('<li class="submenu" style="padding-left: 10px;" id="loadingSubmenu"><b>LOADING ...</b></li>');
			},
			success: function(html){
				$("#loadingSubmenu").remove();
				$("#menuOverType"+type_id).append(html);
			},
			complete: function(html){
				$("#loadingSubmenu").remove();
			}
		});
	});
	$("#searchRegion").bind("change", function(){
		var region_id = $(this).val();
		//alert("getCities.php?"+"region_id="+region_id);
		$("#citiesHolder2").empty();
		$.ajax({
			type: "post",
			url: "/getCities.php",
			data: "region_id="+region_id,
			success: function(html){
				$("#citiesHolder2").empty();
				$("#citiesHolder2").append(html);
			}
		});
	});
	
	$("#sendToAFriend").bind("click", function(){
		if ($("#sendToAFriendFormContent").css("display") == "none"){
			$.ajax({
				type: "GET",
				url: "sendToAFriend.php",
				success: function(data){
					$("#sendToAFriendFormContent").empty();
					$("#sendToAFriendFormContent").append(data);
				}
			});
			$("#sendToAFriendFormContent").slideDown("fast");
		}else{
			$("#sendToAFriendFormContent").slideUp("fast");
		}
	});
	
	
	$("#showImages").bind("click", function(){
		$("#picturesRest").slideDown("slow");
		$(this).hide();
		$("#hideImages").show();
	});
	$("#hideImages").bind("click", function(){
		$("#picturesRest").slideUp("slow");
		$(this).hide();
		$("#showImages").show();
	});
	
	$("#showFloorplans").bind("click", function(){
		$("#hiddenFloors").slideDown("slow");
		$(this).hide();
		$("#hideFloorplans").show();
	});
	$("#hideFloorplans").bind("click", function(){
		$("#hiddenFloors").slideUp("slow");
		$(this).hide();
		$("#showFloorplans").show();
	});
});

function onBefore() { 
    $('#output').html( this.src); 
} 
function onAfter() { 
    $('#output').html( this.src) 
        .append( this.alt ); 
}

$(document).ready(function(){
	$("#infoMenu li").hover(
		function(){ $("ul", this).fadeIn("slow"); }, 
		function() { } 
	);
	if (document.all) {
		$("#infoMenu li").hoverClass ("sfHover");
	}
	$("#categoryMenu li").hover(
		function(){ $("ul", this).fadeIn("slow"); }, 
		function() { } 
	);
	if (document.all) {
		$("#categoryMenu li").hoverClass ("sfHover2");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	  

