/* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+ <http://cherne.net/brian/resources/jquery.hoverIntent.html> @param  f  onMouseOver function || An object with configuration options @param  g  onMouseOut function  || Nothing (use configuration options object) @author    Brian Cherne <brian@cherne.net> */
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
$(document).ready(function() { if(document.getElementById("contact")) { gMap(); } ddMenu(); faqs(); if(document.getElementById("gallery")) { var totalW = 0; $("#imagesSlider ul li").each(function(i) { totalW += $(this).width(); $(this).attr("id","img_"+i); }); $("#imagesSlider ul").css("width",totalW); $("#imagesSlider ul li:last-child").addClass("last"); gallery(); } });
function gMap() { $("#address").append("<div id=\"gMap\"></div>"); var map = new GMap2(document.getElementById("gMap")); map.setCenter(new GLatLng(42.662155,23.294706), 15); var customUI = map.getDefaultUI(); customUI.maptypes.hybrid = false; map.setUI(customUI); var latlng = new GLatLng(42.661818,23.29320); map.addOverlay(new GMarker(latlng)); }
function gallery() { var rightMove = 0; var clicks = 0; var listLen = $("#imagesSlider ul li").length; var moveSpeed = ($("li#img_"+clicks).width())+1; $("#imagesSlider").append("<span class=\"control\"><a href=\"#\" class=\"prev\">&lt;&lt;</a><a href=\"#\" class=\"next\">&gt;&gt;</a></span>"); $("#imagesSlider").hover(function() { $(".control").fadeIn("fast"); },function() { $(".control").fadeOut("fast"); }); $("#imagesSlider a.next").click(function() { rightMove = rightMove-moveSpeed; clicks = clicks+1; moveSpeed = ($("li#img_"+clicks).width())+1; $("#imagesSlider ul li:first-child").animate({width: "toggle", opacity: "toggle"}, "slow",function() { $("#imagesSlider ul").append("<li id=\"img_"+(parseInt($("#imagesSlider ul li:last-child").attr("id").replace("img_",""))+1)+"\">"+$("#imagesSlider ul li:first-child").html()+"</li>"); $("#imagesSlider ul li:first-child").remove(); }); return false; }); $("#imagesSlider a.prev").click(function() { clicks = clicks-1; moveSpeed = ($("li#img_"+clicks).width())+1; rightMove = rightMove+moveSpeed; ultimo = $("#imagesSlider ul li:last-child"); $("#imagesSlider ul li:last-child").remove(); $("#imagesSlider ul li:first-child").before("<li style=\"display: none;\" id=\"img_"+(parseInt($("#imagesSlider ul li:first-child").attr("id").replace("img_",""))-1)+"\">"+ultimo.html()+"</li>"); $("#imagesSlider ul li:first-child").animate({width: "toggle", opacity: "toggle"}, "slow",function() { }); return false; }); }
function ddMenu() { $("#menu li").hoverIntent({ sensitivity: 5, interval: 100, over: menuHover, timeout: 300, out: menuOut }); }
function menuHover() { $(this).find("ul").fadeIn("slow"); }
function menuOut() { $(this).find("ul").fadeOut("slow"); }
function faqs() { $("dl dt").click(function() { if($(this).next().is(":hidden")) { $("dl").find(".opened").removeClass().slideUp("slow"); $(this).next().addClass("opened").slideDown("slow"); } else { $(this).next().removeClass("opened").slideUp("slow"); } }); }
