 $(document).ready(function() { 
        $('ul.sf-menu').superfish({ 
            delay:       800,                            // one second delay on mouseout 
            animation:   {opacity:'show', height:'show'},  // fade-in and slide-down animation 
            speed:       200,                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: false                            // disable drop shadows 
        }); 
		
		/*var div=$('.imm-row-center');
		var div2=$('.imm-td1');
		for(i=0; i<div.length; i++)
		{
			//if (myLinks[i].getAttribute("target") == "_blank")
			var top =(div[i].height()-div2[i].height())/2;
			div2[i].css('margin-top', top);
		}*/
		//var top = ( $('.imm-row-center').height() - $('.imm-row-center').children(":first").height() ) / 2;
    //$('.imm-row-center').children(":first").css('margin-top', top);
	   
	  
	   //$('.jScrollPaneContainer').css('width','520px');
    });
 
function initialize_immobili(){
	var options = { 
        target:        '#imm-scroll',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback  
    }; 
 
    // $('#imm-scroll').jScrollPane({scrollbarWidth:8, scrollbarMargin:0,reinitialiseOnImageLoad:true});
	 
	// bind form using 'ajaxForm' 
	//$('#prov').selectbox();
    $('#search').ajaxForm(options);
	//$('#search').submit();
	$('#search').ajaxSubmit(options);
	
	
	
} 
 // pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    //alert('About to submit: \n\n' + queryString);
	$('#imm-scroll').html('<img class="center" src="img/loader.gif" alt="loading..." />');
	
	
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    $("a.iframe").fancybox({ 
						   'zoomSpeedIn': 300, 
						   'zoomSpeedOut': 300, 
						   'overlayShow': false,
						  // 'callbackOnShow': ciaociao,
						   'hideOnContentClick': false,
						   'frameWidth': 800,
						   'frameHeight': 700
						   }); 
	 $('#imm-scroll').jScrollPane({scrollbarWidth:8, scrollbarMargin:0,reinitialiseOnImageLoad:true,autoRefresh: true});
	// $('#imm-scroll').validate();
}

function goToImm(str,tipo){
	location.href=location.href=str+'.php?&cat='+tipo;
}

/*-----CONTACT--------*/
function initialize_contact()
{
	
	$("[class^=validate]").validationEngine({
		success :  send_contact,
		failure : function() {}
	});
	
 
}

function send_contact(){
	var options = { 
       target:        '#contact-response',   // target element(s) to be updated with server response 
        beforeSubmit:  contactRequest,  // pre-submit callback 
        success:       contactResponse  // post-submit callback  
    };
    
	$('#contact-form').ajaxSubmit(options);
}

function contactRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    //alert('About to submit: \n\n' + queryString);
	
	$('#contact-response').html('<img src="img/ajax-loader.gif" alt="loading..." />');
	$("#contact-response").fadeIn("slow");
	
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function contactResponse(responseText, statusText)  { 

	 $("#contact-response").html(responseText);
	 $("#contact-response0").fadeIn("slow");
	 setTimeout("$('#contact-response').fadeOut('slow');",2500)
                   
}


/*--------END CONTACT----------*/

/*---------RICHIESTA----------*/
function send_rich(){
	var options = { 
      // target:        '#contact-response',   // target element(s) to be updated with server response 
       // beforeSubmit:  contactRequest,  // pre-submit callback 
        success:       richResponse  // post-submit callback  
    };
    
	$('#request').ajaxSubmit(options);
}

function richResponse(responseText, statusText)  { 

	 alert(responseText);
	
                   
}
/*--------END RICHIESTA----------*/
(function($){
    jQuery.doAfter = function(time,f){
        $('body').animate({opacity:1},time,f);
    };
})(jQuery);


function ciaociao(){
	//$('#fancy_close').pngFix(); 
	
}

function resizeIframe(){
jQuery("#fancy_frame").load(sizeIFrame);
	}
	
function sizeIFrame() {
	
	/*$("#pikame").PikaChoose({
								show_prev_next:false,
								slide_enabled:false,
								auto_play: false,
								show_captions: true
						
						
											});*/
//var helpFrame = jQuery("#fancy_frame");
//var fancy_outer=jQuery("#fancy_outer");

//var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
//alert(innerDoc.body.scrollHeight + 35);
//fancy_outer.height(innerDoc.body.scrollHeight + 35);
}

function checkIE(){
	var ievs = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));

// IF BROWSER IS IE 6 LOAD IE6 STYLE

if (ievs){

var iev=new Number(RegExp.$1);

if (iev==6) {

return true;

}
else
{
	return false;	
}
}	
	
}

