// JavaScript Document
//Navigation function for > IE 7
mainNav = function() {
	$("#topnav li").bind("mouseenter",function(){
                this.className += "_over over";
	}).bind("mouseleave",function(){
                this.className = this.className.replace("_over over", "");
	});
}

$(document).ready(function(){

	/*Activate tabs*/
	$("#tab_menu").tabs();

	/*Activate top menu*/
	$("ul.sf-menu").superfish();
	
	/*Function that powers the sitemap toggle*/
	jQuery.fn.slideToggle = function(speed, easing, callback) {
	return this.animate({height: 'toggle'}, speed, easing, callback);  
	};
	
	/*Sitemap Toggle*/
	$("#sitemap").hide();
	$('.toggle').click(function() {
	  $(this).next().slideToggle('sitemap');
	})
	
	/*Knock-out the border element for the last related href	*/
	$(".related_info").each(function(){
	  $("a:last", this).css("border-bottom","none");
	}); 
	
	$(".awards").each(function(){
	  $("li:last", this).css("border-bottom","none");
	});
	
	/*Add stripes to the even list items*/
	$("ul.stripes li:even, ul#list_video li:even").addClass("stripes_even");
	
	/*Activate the news ticker on the index page*/
	$(".ticker").newsTicker(5000);

	/*activate the slider on the index page*/
	$("#slider").easySlider({
		prevText: ' ',
		nextText: ' ',		
		auto: true,
		continuous: true,
		pause: 5000
	});
	
	/*Activate the products overview carousel*/
	jQuery('#carousel_products').jcarousel({
        // Configuration goes here
    });

	/*Kill the hover on certain links in the main body*/
	$(".deck_pr_download a:hover").css("backgroundColor", "#fff");
	/*Activate the hovers over Events*/
	$(".list_events li").hover(function() {
		  $(this).addClass('event_hover');
		}, function() {
		  $(this).removeClass('event_hover');
	});
	
	/*Video Player Link handling*/
	$('a.theatre').click(function(event) {
			event.preventDefault();
			var strId = " #flash";
			var aLink = $(this).attr("href") + strId;
			$("#player_video").load(aLink);
		});
	
	/*manage some CSS clean up*/
	$(".table_downloads").each(function(){
	  $("p", this).css("margin-top","0");
	});
	
	//$('div#serialno').prepend('<span id="serialnospan"></span>'); 
	//$('#serialnospan').load('http://www.viewcast.com/serialno');
	
	//Client modal window stuff//
	$('a.jqmLogo').click(function(e) {  
		 //Cancel the link behavior  
		 e.preventDefault();  
		 //Get the A tag  
		 var id = $(this).attr('href');  
	   
		 //Get the screen height and width  
		 var maskHeight = $(document).height();  
		 var maskWidth = $(window).width();  
	   
		 //Set height and width to mask to fill up the whole screen  
		 $('#mask').css({'width':maskWidth,'height':maskHeight});  
		   
		 //transition effect       
		 $('#mask').show();      
		 $('#mask').fadeTo("fast",0.5);    
		 //$('#mask').show();
	
		 //Get the window height and width  
		 var winH = $(window).height();  
		 var winW = $(window).width();  
				 
		 //Set the popup window to center
		 $(id).addClass('dialog_modal');
		 $(id).css('top',  winH/2-$(id).height()/2);  
		 $(id).css('left', winW/2-$(id).width()/2); 
	   
		 //transition effect  
		 $(id).fadeIn(250);   
	   	 //$(id).show();
		
	 });  
	   
	 //if close button is clicked  
	 $('.window .close').click(function (e) {  
		 //Cancel the link behavior  
		 e.preventDefault();  
		 $('#mask, .window').hide();  
	 });       
	   
	 //if mask is clicked  
	 $('#mask').click(function () {  
		 $(this).hide();  
		 $('.window').hide();  
	 });
	 
	 //Reseller map stuff
	 $('#mapControl').hide();
	 $('a.showMap').click(function() {
		$('#mapInstruct').show(300);
		$('#flashmap').slideDown(300);
		$('#mapControl').hide(300);
	});
});