/*

	Filename             sitewide.js
	Detail               Site functionality
	Author:              thunder::tech inc.
	License:             CLIENT is defined as the owner of online property from which this file resides or this code is referenced in.
						 ADDITIONAL PARTY is defined as anyone other than thunder::tech or CLIENT.
						 No right is granted to ADDITIONAL PARTY to sell, distribute, modify or otherwise transfer the following source code without explicit written permission by CLIENT or thunder::tech.

*/

/*  ================================
     Sitewide JavaScript
    ================================ */

thunder.client.project.pageLoaded = function()
{
	//thunder.client.project.flashReplace();
	//thunder.client.modify.rollImages();
	//thunder.client.modify.linkOptions();
	//thunder.client.modify.tabSet();
	thunder.client.modify.treeMenu(false);
	//thunder.client.modify.treeMenu(false, [thunder.client.modes.separatorTreeMenu]);
	//thunder.client.modify.treeMenu(false, [thunder.client.modes.imageTreeMenu]);
	//thunder.client.modify.selfLabelFields();
	//thunder.client.modify.requireFields();
	//thunder.client.modify.dropSelector(true);
	thunder.client.modify.scrollFeature(960, 8000, 1000);
	thunder.client.workarounds.alphaImages();
	thunder.client.workarounds.labelAsBrowser();
	$(".nav-dropdown").each(function(){
		$(".thunder-nav:last a", this).css("border-bottom", "none");
		if($(".thunder-nav", this).size() > 12){
			$(this).addClass("dd2");
			$(this).append('<img src="/Portals/_default/skins/MrGasket/images/dd2-left.png" class="dd2-left"><img src="/Portals/_default/skins/MrGasket/images/dd2-right.png" class="dd2-right"><img src="/Portals/_default/skins/MrGasket/images/dd2-arrow.png" class="dd2-arrow">');
			
			//15 = arrow width - dropdown left offset
			$(".dd2-arrow").css("left", ($(this).parent().width() - 15) / 2);
			
			//12 = how many links per column
			$(this).width(232 * Math.ceil($(".thunder-nav", this).size() / 12));

			var numOfCols= Math.ceil($(".thunder-nav", this).size() / 12);
			for (i=0; i< numOfCols; i++){
				$(".thunder-nav", this).slice(i*12, (i+1)*12).wrapAll("<div class='dd-column'></div>");
			}
			$(".dd-column").each(function(){ 
				$(".thunder-nav:last a", this).css("border-bottom", "none"); 
				$(".thunder-nav:first a", this).css("border-top", "none"); 
				$(".thunder-nav:first", this).prepend('<img src="/Portals/_default/skins/MrGasket/images/dd-seperator.jpg" />'); 
				
			});
		} else{
			$(this).prepend('<img src="/Portals/_default/skins/MrGasket/images/dd1-top.png" class="dd1-top" />');
			$(this).append('<img src="/Portals/_default/skins/MrGasket/images/dd1-bot.png" />');
			
		}
	});
	
	$(".subNav a").hover(function(){ $("img", this).addClass("subArrow"); }, function(){ $("img", this).removeClass("subArrow"); });
	$(".subNav a:last").css("border-bottom", "none");
	
	$(".thunder-tree-menu > .thunder-nav").mouseenter(function(){
		//15 = arrow width - dropdown left offset
		$(".dd2-arrow").css("left", ($(this).width() - 15) / 2);												   
	});
	
	var count = 1;
	$('.slider > li').each(function(){
		$(this).append('<div class="count">' + count + '</div>');
		count +=1;
	});
	$('.slider').scrollIt({
		    menuHeight: 50,
			menuWidth: 335,
			itemHeight: 50,
			itemWidth: 62,
			initialItem:0
    });
    	$(window).load(function(){
		$(".bg-layout").height($(".subpage").outerHeight() + 300);		
				
	});
}

thunder.client.project.flashReplace = function()
{
	$('.flash-billboard').flash(
		{
			swf: 'flash/billboard.swf',
			height: 200,
			width: 800,
			allowFullScreen: true,
			allowScriptAccess: 'always',
			hasVersion: 9,
			wmode: 'transparent',
			flashvars: {
				basePath: ''
			}
		}
	);
}

$(document).ready(thunder.client.project.pageLoaded);
