// JavaScript Document
jQuery(document).ready(function() {
    jQuery('#nav li').each(function(index, val) {
    	if(jQuery(val).hasClass('hasChildren')) {
    		jQuery(val).bind('mouseenter', function() { jQuery(val).addClass('over'); });
    		jQuery(val).bind('mouseleave', function() { jQuery(val).removeClass('over'); });
    	}
    });
    
    jQuery('#nav li ul li').each(function(index, val) {
    	if(jQuery(val).hasClass('hasChildren')) {
    		jQuery(val).bind('mouseenter', function() { jQuery(val).addClass('over'); });
    		jQuery(val).bind('mouseleave', function() { jQuery(val).removeClass('over'); });
    	}
    });
    
    jQuery('#nav li ul li a').each(function(index, val) {
    	jQuery(val).bind('mouseenter', function() { jQuery(val).addClass('over'); });
    	jQuery(val).bind('mouseleave', function() { jQuery(val).removeClass('over'); });
    });
    
    jQuery('.listing .product').each(function(index, val) {
    		jQuery(val).bind('mouseenter', function() { jQuery(val).addClass('over'); });
    		jQuery(val).bind('mouseleave', function() { jQuery(val).removeClass('over'); });
    });
    
});

function setFooter() {
	
	var windowHeight = jQuery(window).height();

	if (windowHeight > 0) {
		contentHeight = Math.max(jQuery('#outerWrapper').height(), jQuery('#wrapper').height(), jQuery('#galleryContainer').height());
		footerHeight = jQuery('#footer').height() + 20; // no idea why 30 but it works.
	
		var difference = (windowHeight - (contentHeight + footerHeight) - parseInt(jQuery('#footer').css('padding-top')));

		if (difference >= 0) {
			jQuery('#footer').css('position', 'relative');
			jQuery('#footer').css('top', difference + 'px');
		} else {
			jQuery('#footer').css('position', 'static');
		}
	}
}
