jQuery(document).ready(function($){
	
	$curnav = $("#nav_top a.hover").addClass('selected');
	
	$("#nav_top a").each(function(i){
		$(this)
			.bind('mouseover', function(evt){
				$("#nav_top a:not(.selected')").removeClass('hover');
				$(this).addClass('hover');
			})
			.bind('mouseleave', function(evt){	
				$("#nav_top a:not(.selected')").removeClass('hover');
			})
			.bind('click', function(evt){
				$(this).unbind('mouseleave');
				$("#nav_top a").removeClass('hover');
				$(this).addClass('hover');
			});
	});
	$("a.btn_prodinfo").bind('click', function(evt){
		$("#nav_top a").removeClass('hover');
		$("#nav_top a#nav_prodinfo").addClass('hover');
	});
	
	// do some lightbox/fancybox/thickbox
	$("a.btn_prodinfo, a#nav_prodinfo").fancybox({frameWidth:640, frameHeight:520, centerOnScroll:false, padding:0, overlayShow:true, overlayOpacity:0.7, hideOnContentClick:false, callbackOnStart:hoverClose, callbackOnClose:fancyboxclose});
	
	
	// create the video player
	$('<div id="videoplayer"></div>').appendTo('.playercontainer').hide();
	$(".videothumbs a.video").youtube({embed:true,player:'#videoplayer'});
	
	
	
	$(".playercontainer a.video").each(function(){
		// display the first video inside the videoplayer
		var url = $(this).attr('href');
		var options = {};
		options.maxWidth = $("#videoplayer").width();
		options.maxHeight = $("#videoplayer").height();
		$(this).embed(url,options);
		$(".videothumbs a.video:eq(0) .videoplaying").show();
	});
	
	
	$("a#btn_viewallads, a#btn_prodinfo, a#btn_playnow").bind('mouseover mouseleave', function(evt){
		if($.browser.msie && $.browser.version.substr(0,1) <= 6) {
			$(this).toggleClass('hover');
		}		
	});
	
});
var $curnav = null;
var hoverClose = function() {
	$("div#fancy_close").bind('hover', function(evt){
		// IE6 PNG fix hover
		$(this).toggleClass('hover');
	});
};
var fancyboxclose = function(){
	$("#nav_top a").removeClass('hover');
	$("#nav_top a.selected").addClass('hover');
}


// Image swap for submit button
function showImage(imgId,typ) {
	var objImg = document.getElementById(imgId);
	if (objImg) {
		if (typ == "2")
			objImg.src = "images/btn_submit.png";
	   else if (typ == "1")
		   objImg.src = "images/btn_submit_o.png";
   }
};
