//site functions

//execute any functions inside basescript tags
var basescript = document.getElementById("basescript");
if( basescript ){eval( basescript.innerHTML )};


base = {
		nav:function(){
	
		jQuery('.nav-enable').each(function(){
			
			
			var thisnav = jQuery(this);
			
			//default options
			var Nanim  = false;
			var Nspeed = 300;
			var Noffspeed = 100;
			var Nheight = 200;
			var Nlowlight = false;
			
			
			if(jQuery(this).attr('options')){
				
				var options = jQuery(this).attr('options');
				options = options.split("&");
				
				jQuery(options).each(function(){
					
					var opts = this.split('=');
						
					if(opts[0]=='animate'){Nanim=opts[1]}
					if(opts[0]=='offspeed'){Noffspeed=parseInt(opts[1])}
					if(opts[0]=='speed'){Nspeed=parseInt(opts[1])}
					if(opts[0]=='height'){Nheight=parseInt(opts[1])}
					if(opts[0]=='lowlight'){Nlowlight=opts[1]}
						
				});
			}
			
			var bodywidth = jQuery(this).width();
		
			jQuery(this).find('.base-nav-item').each(function(){
			
				/*var offsetleft = jQuery(this).position().left;
			
				var width = jQuery(this).find('.base-nav-drop').width();
				
				var overlap = (offsetleft+width)-bodywidth;
		
				if(overlap>0){jQuery(this).find('.base-nav-drop').css({marginLeft:(overlap*-1)})}
				*/
				
				if(Nanim=='slide'){
					
					var h = jQuery(this).find('.base-nav-drop').height();
					jQuery(this).find('.base-nav-drop').attr('realheight',h).css({height:0,overflow:'hidden'});
				
				}
				
				
			})
			
			
			
			if(Nanim=='slide'){
				
				jQuery(this).find('.base-nav-drop').css({height:0,overflow:'hidden'})
				
				
				//mouseover
				jQuery(this).find(".base-nav-item").hover(function(){
					
					if(Nlowlight!=false){
						jQuery(thisnav).find('.base-nav-item').children('a').addClass('off');
						clearTimeout(window.settempnav);
					}
					
					if(jQuery(this).hasClass('on')){jQuery(this).addClass('orig')}
					
					jQuery(this).addClass('on').children('a').removeClass('off');
					
					Nheight = jQuery(this).find('.base-nav-drop').attr('realheight');
					jQuery(this).find('.base-nav-drop').stop().animate({height:Nheight},{queue:false, duration:Nspeed})
					
					
				},function(){
				
						window.tempnav = jQuery(thisnav);
						window.settempnav = setTimeout("window.tempnav.find('.base-nav-item a').removeClass('off')",200);
					
					
					if(!jQuery(this).hasClass('orig')){jQuery(this).removeClass('on');}
					
					jQuery(this).find('.base-nav-drop').stop().animate({height:'0px'},{queue:false, duration:(Noffspeed+1),complete:function(){jQuery(this).hide()}})
				
				
				});
		
				
			}
			
			
			if(Nanim==false || Nanim == 'undefined' || Nanim=='off'){
				
				jQuery(this).find(".base-nav-item").hover(function(){
				
					if(Nlowlight!=false){
						jQuery(thisnav).find('.base-nav-item').children('a').addClass('off');
						clearTimeout(window.settempnav);
					}
					
					if(jQuery(this).hasClass('on')){jQuery(this).addClass('orig')}
					jQuery(this).addClass('on').children('a').removeClass('off');
					jQuery(this).addClass('on');
					jQuery(this).find('.base-nav-drop').show();
				
				
				},function(){
				
					window.tempnav = jQuery(thisnav);
					window.settempnav = setTimeout("window.tempnav.find('.base-nav-item a').removeClass('off')",200);
						
					if(jQuery(this).hasClass('orig')==false){
						jQuery(this).removeClass('on');
					}
					
					else{
						jQuery(this).removeClass('orig');
					}
					
					jQuery(this).find('.base-nav-drop').hide();
				
				
				});
			
			
			}
			
			jQuery(this).children().children('li').children('.base-nav-link').click(function(){
				
				if(jQuery(this).attr('href')=='#'){ return false }
			})
		
		
		})
		
		
	},
	
	racesDrop:function(){
	
		jQuery('.races-breadcrumb-item').hover(function(){
		
			jQuery(this).find('.base-races-dropdown').show()
		
		
		
		},function(){
		
			jQuery(this).find('.base-races-dropdown').hide()
		
		
		})
	
	
	
	
	
	},
}

base.nav();
base.racesDrop();



