jQuery(function($){
//Peload css Images

$.preloadCssImages();


//SET USER TYPE (CONSUMER/COMMERCIAL)
	if($("div").hasClass("consumer"))
	{
		 $('.user-type-consumer a').addClass(' current'); 
	}
	
	if($('div').hasClass("commercial")) 
	{
		 $('.user-type-commercial a').addClass(' current'); 
	}
//TABLE 
//ZEBRA STRIPPING
	$('tr:odd').addClass('alt');
	
//COMPARISON TABLE
$('.comparison-tbl tr').not('th').each(function(idx){   

	$('.comparison-tbl tr td:first-child').addClass('first-child');
	
	});

//DROP DOWN MENUS
	var menuNav = 
	{
		timer: null,
		currentLink: null,
		currentQuery: null,
		show: function(link, query)
		{
			menuNav.resetTimer();
			if(menuNav.currentQuery)
			{
				menuNav.timedHide();
			}
			menuNav.currentLink = link;
			menuNav.currentQuery = query;
			$(query).show();
			link.children().addClass('current');
		},
		hide: function()
		{
			if(!menuNav.currentQuery) { return; }
			menuNav.timer = setTimeout(menuNav.timedHide, 100);
		},	
		timedHide: function() 
		{
			if(!menuNav.currentQuery){return;}
			$(menuNav.currentQuery).hide();
			menuNav.currentLink.children().removeClass('current');
			menuNav.currentQuery = null;
			menuNav.currentLink = null;
		},
		resetTimer: function()
		{
			if(menuNav.timer){ clearTimeout(menuNav.timer); }
		}	
	};

	$('#global-nav-wrap .menu-preview').each(function(idx)
	{
		var menuPreview = $(this);
			menuPreview.remove().appendTo('#doc');
			menuPreview.mouseover(menuNav.resetTimer);
			menuPreview.mouseout(menuNav.hide);
			menuPreview.bgiframe();
	});
	
	$('#global-nav-wrap a.nav-item-link').each(function(idx)
	{
		var menuName  = /\s?menu-(\w*)\s?.*/.exec(this.parentNode.className);
		if(!menuName){ return; }
		var query = '.menu-preview-'+ menuName[1];
		
		$(this.parentNode)
			.mouseover(function() { menuNav.show($(this), query); })
			.mouseout(function() { menuNav.hide(); })
			$(this).removeAttr('title');
	})

	//TOOLTIPS
	$('.index-2 .tooltip-preview').each(function(idx){
		var tipPreview = $(this);
			tipPreview.remove().appendTo('#doc');
			tipPreview.mouseover(menuNav.resetTimer);
			tipPreview.mouseout(menuNav.hide);			
			tipPreview.bgiframe();
	});

	$('.index-2 span.tip-item').each(function(idx)
	{
		var tipName  = /\s?tip-item-(\w*)\s?.*/.exec(this.parentNode.className);
		if(!tipName){ return; }
		var query = '.tooltip-preview-'+ tipName[1];
		

		$(this.parentNode)
			.mouseover(function(e) { 
				menuNav.show($(this), query);
				
				offset = $(this).offset();
				$(query).css({'top':offset.top});
			})	
			.mouseout(function(e) { menuNav.hide(); })
			$(this).removeAttr('title');
	});


	if ($('#videos').length)
	{
		var so = swfobject.embedSWF('flash/player.swf?&file=/flash/'+window.clip+'.flv&image=images/video-bg-img.jpg', 'vid-player', '580', '345', '9.0.0');
		
		//console.log(window.clip.toLowerCase());
		
		$('.'+window.clip.toLowerCase()).css('display', 'block');
	}
	
});//#end
