/**
 * Starts all javascript which is needed after dom has been built.
 */
$(document).ready(function() {
	initMainNav();
	
	if ($.browser.msie) {
  		if($.browser.version.substr(0,1) < 8) { initIE() };
	}
	
	if($(".showcaseList").is("ul")) { initShowcase() }; // Init showcase effect
	if($(".downloadList").is("ul")) { initDownloads() }; // Init download effect
});

function initMainNav() {
	
}

function initIE() {
	
	$(".listing:first-child").css({"border-top":"2px solid #B7B8B9", "margin":"0px 0 10px 0", "position":"relative", "top":"32px"});
	$(".panel:first-child").css({"border-top":"2px solid #B7B8B9", "margin":"0px 0 35px 0", "position":"relative", "top":"32px"});
	
	}

/**
 * initShowcase
 * Activates the image effects for all image links to display the visual view of a linked image.
 */
function initShowcase() {
		
		var teaserImageLink = $(".showcaseList .logo a");
		
		teaserImageLink.prepend('<div class="effect">&nbsp;</div>');
		teaserImageLink.parents("li").find(".effect").hide();
		
		teaserImageLink.bind("mouseenter",function() {
			showEffect($(this));
		}).bind("mouseleave",function() {
			hideEffect($(this));
		}).bind("click", function() {
			callURL($(this));
		});
		
		function hideEffect(object) {
			if($.support.opacity) {
				object.parents("li").find(".effect").stop(true, true).fadeOut(800);
			} else {
				object.parents("li").find(".effect").hide();
			}
		}
		
		function showEffect(object) {
			if($.support.opacity) {
				object.parents("li").find(".effect").stop(true, true).fadeIn(800);
			} else {
				object.parents("li").find(".effect").show();
			}
		}
		
		function callURL(object) {
			object.find("a").click();
		}
		
	}
	

/**
 * initDownloads
 * Activates the image effects for all image links to display the visual view of a linked image.
 */
function initDownloads() {
		
		var teaserImageLink = $(".downloadList .image a");
		
		teaserImageLink.prepend('<div class="effect">&nbsp;</div>');
		teaserImageLink.parents("li").find(".effect").hide();
		
		teaserImageLink.bind("mouseenter",function() {
			showEffect($(this));
		}).bind("mouseleave",function() {
			hideEffect($(this));
		}).bind("click", function() {
			callURL($(this));
		});
		
		function hideEffect(object) {
			if($.support.opacity) {
				object.parents("li").find(".effect").stop(true, true).fadeOut(800);
			} else {
				object.parents("li").find(".effect").hide();
			}
		}
		
		function showEffect(object) {
			if($.support.opacity) {
				object.parents("li").find(".effect").stop(true, true).fadeIn(800);
			} else {
				object.parents("li").find(".effect").show();
			}
		}
		
		function callURL(object) {
			object.find("a").click();
		}
		
	}