$(window).bind("load", function() { 

	   //setup the height and position for your sticky footer
       var footerHeight = 0,
           footerTop = 0,
           $footer = $("#footer");

       positionFooter();

       function positionFooter() {

                footerHeight = $footer.height();
                footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";

               if ( ($(document.body).height()+footerHeight) < $(window).height()) {
                   $footer.css({
                        position: "absolute"
                   }).animate({
                        top: footerTop
                   })
               } else {
                   $footer.css({
                        position: "relative"
                   })
               }

       }

       $(window)
               .scroll(positionFooter)
               .resize(positionFooter)

});



$(document).ready(function() {

			var theWindow        = $(window),
			    $bg              = $("#bg"),
			    aspectRatio      = $bg.width() / $bg.height();
			    			    		
			function resizeBg() {
				
				if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
				    $bg
				    	.removeClass()
				    	.addClass('bgheight');
				} else {
				    $bg
				    	.removeClass()
				    	.addClass('bgwidth');
				}
							
			}
			                   			
			theWindow.resize(function() {
				resizeBg();
			}).trigger("resize");
		






// filtering



$(function() {

        var newSelection = "";

        $(".p-menu a").click(function(){


                $(".p-menu a").removeClass("this");
                $(this).addClass("this");

                newSelection = $(this).attr("rel");

                $(".type").not("."+newSelection).hide();
                $("."+newSelection).show();

        });

});


// colorbox
$(".parasol a").colorbox({initialWidth:450, initialHeight:200});
$(".p-pol a").colorbox({initialWidth:450, initialHeight:200});						   
// menu
$("a.oferta").hover(
   function() {
      $(this).addClass('ie-hover');
   },
   function() {
      $(this).removeClass('ie-hover');
   }
);

		$('.dropdown').each(function () {
		$(this).parent().eq(0).hoverIntent({
			timeout: 100,
			over: function () {
			var current = $('.dropdown:eq(0)', this);
			current.slideDown(300);
			},
			out: function () {
			var current = $('.dropdown:eq(0)', this);
			current.slideUp(300);
			}
			});
		});




});


// tooltip script written by Alen Grakalic (http://cssglobe.com)

this.tooltip = function(){	
		xOffset = -15;
		yOffset = 10;		
	$(".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")
			.show("fast");
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$(".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();
});


