// JavaScript Document
var mImg = 0;
var cImg = -1, iId;

$(function(){
		   
// Main button drop down / accordion
		   

									  $('.navbar ul li ul').each(function(){
										if ($(this).is(':visible')){
									  	if ($(this).parents("li:eq(0)").find(".talent").is(':true')){
											  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px 0px !important;');}
											  											  
											  if ($(this).parents("li:eq(0)").find(".event").is(':true')){
												  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -43px !important;');}
												  
												  if ($(this).parents("li:eq(0)").find(".consulting").is(':true')){
													  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -86px !important;');}
													  
													  if ($(this).parents("li:eq(0)").find(".design").is(':true')){
														  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -129px !important;');}
														  
														  if ($(this).parents("li:eq(0)").find(".speakers").is(':true')){
															  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -172px !important;');}
															  
															  if ($(this).parents("li:eq(0)").find(".news").is(':true')){
																  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -215px !important;');}
									  }});

			
		   $(".arrow").click(function(e){
									  e.preventDefault();
									  

									  if ($(this).parents("li:eq(0)").find(".submenu").is(':hidden')){
										  $(".button").attr('style','');
										  $(".submenu").slideUp(500, function(){setTimeout("$('.navbar .submenu.display:eq(0)').removeClass('display');",500);});
										  $(this).parents("li:eq(0)").find(".submenu").slideDown(500);
										  $(".arrow").attr('style','');
										  $(this).attr('style','background-image:url(images/navbar.jpg); background-position: -305px 0px !important;');
										  
										  if ($(this).parents("li:eq(0)").find(".talent").is(':true')){
											  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px 0px !important;');}
											  											  
											  if ($(this).parents("li:eq(0)").find(".event").is(':true')){
												  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -43px !important;');}
												  
												  if ($(this).parents("li:eq(0)").find(".consulting").is(':true')){
													  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -86px !important;');}
													  
													  if ($(this).parents("li:eq(0)").find(".design").is(':true')){
														  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -129px !important;');}
														  
														  if ($(this).parents("li:eq(0)").find(".speakers").is(':true')){
															  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -172px !important;');}
															  
															  if ($(this).parents("li:eq(0)").find(".news").is(':true')){
																  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -215px !important;');}										  }
										  else{
											  $(this).parents("li:eq(0)").find(".submenu").slideUp(500, function(){$(".button").attr("style",""); setTimeout("$('.navbar .submenu.display:eq(0)').removeClass('display');",500);});
											  $(this).attr('style','');
											  
											  }
											  });
		   

		   $(".arrow").mouseover(function(){
									  if ($(this).parents("li:eq(0)").find(".submenu").is(':true')){
										  
										  if ($(this).parents("li:eq(0)").find(".talent").is(':true')){
											  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px 0px !important;');}
											  											  
											  if ($(this).parents("li:eq(0)").find(".event").is(':true')){
												  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -43px !important;');}
												  
												  if ($(this).parents("li:eq(0)").find(".consulting").is(':true')){
													  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -86px !important;');}
													  
													  if ($(this).parents("li:eq(0)").find(".design").is(':true')){
														  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -129px !important;');}
														  
														  if ($(this).parents("li:eq(0)").find(".speakers").is(':true')){
															  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -172px !important;');}
															  
															  if ($(this).parents("li:eq(0)").find(".news").is(':true')){
																  $(this).parents("li:eq(0)").find(".button").attr('style','background-position: -138px -215px !important;');}										  }
										  else{
											  $(this).parents("li:eq(0)").find(".button").attr('style','');
											  }
											  });
		   $(".arrow").mouseout(function(){
										 if ($(this).parents("li:eq(0)").find(".submenu").is(':hidden')){
											 $(this).parents("li:eq(0)").find(".button").attr('style','');
										 }
										 })
		   




// submenu drop down / accordion
		   /*$(".submenu a").click(function(e){
									  if ($(this).parents("li:eq(0)").find(".sub_submenu").length){e.preventDefault();
									  if ($(this).parents("li:eq(0)").find(".sub_submenu").is(':hidden')){
										  $(".sub_submenu").slideUp(300);
										  $(this).parents("li:eq(0)").find(".sub_submenu").slideDown(300);
										  }
										  else{
											  $(this).parents("li:eq(0)").find(".sub_submenu").slideUp(300);
											  }
											  }});*/
// empty searchbox
$('input[type="text"]').focus(function(){if(this.value == this.defaultValue) this.value=""});
$('input[type="text"]').blur(function(){if(this.value == "") this.value = this.defaultValue});

// news tab

		   /*$(".news_tab a").click(function(e){
									  if ($(".flash_box_news").width()==30){
										  $(".flash_box_news").animate({width: "266px"}, 500 );										  
										  }
										  else{
											  $(".flash_box_news").animate({width: "30px"}, 500 );
											  }
											  });*/


// contact slide down
		   $(".slidedown a").click(function(e){
									e.preventDefault();
									  if ($("#slide_down").is(':hidden')){
										  $("#slide_down").slideDown(300);										  ;
										  }
										  else{
											  $("#slide_down").slideUp(300);
											  }
											  });
		   
		   $(".slide_down a img.exit").click(function(e){
											  $("#slide_down").slideDown(300);											  
											  });
		   
// contact slide up
		   $(".slideup a").click(function(e){
									e.preventDefault();
									  if ($("#slide_up").is(':hidden')){
										  $("#slide_up").slideDown(300);										  ;
										  }
										  else{
											  $("#slide_up").slideUp(300);
											  }
											  });
		   $(".slide_up a img.exit").click(function(e){
											  $("#slide_up").slideUp(300);											  
											  });


// generic submit button

			$(".submit_form").click(function(e){
											 e.preventDefault();
											  $(this).parents("form").submit();											  
											  });
			
			
// print button

			$(".print").click(function(e){
											 e.preventDefault();
											  window.print();											  
											  });				
			

// roster popup
	$(".roster_module a.player").click(function(e){
									e.preventDefault();
									if (!$(this).parents(".roster_module").find(".roster_popup").length){
										var img_src=$(this).parents(".roster_module").find("img").attr('src');
										$(this).parents(".roster_module").append('<div style="position:relative; z-index:1000;"><div class="roster_popup"><div class="roster_popup_rounded_top">&nbsp;</div><div class="roster_popup_content"><a href="#" class="close" onclick="$(this).parents(\'.roster_module\').find(\'.roster_popup\').hide();"><img src="images/btn_exit.gif" /></a><img src="'+img_src.replace('/thumbnails','')+'" /><hr /><div class="left_name"><p><a href="#">'+$(this).parents(".roster_module").find(".first_name").html()+'<br />'+$(this).parents(".roster_module").find(".last_name").html()+'</a></p></div><div class="right_team"><p><a href="#">'+$(this).parents(".roster_module").find(".team_city").html()+'<br />'+$(this).parents(".roster_module").find(".team_name").html()+'</a></p></div><div class="clear">&nbsp;</div></div><div class="roster_popup_rounded_bottom">&nbsp;</div></div></div>');
										}
									  if ($(this).parents(".roster_module").find(".roster_popup").is(':hidden')){
										  $(".roster_popup").hide();
										  $(this).parents(".roster_module").find(".roster_popup").fadeIn(500);										  ;
										  }
										  else{
											  $(this).parents(".roster_module").find(".roster_popup").hide();
											  }
											  });
	


// custom dropdown

	if($('.myselectbox').length){
	$('.myselectbox').selectbox();
}

});
                function text_change() {
                                $('.news_feed ul li').each(function(){
                                if ($(this).is(':visible')) $(this).fadeOut(800, function(){text_change_finish();});
                                }); 
			}
				
				function text_change_finish(){
							if (cImg==(mImg-1)) cImg = -1;
                                cImg++;
                                var ci = 0;
                                var clicked = cImg;
                                $('.news_feed ul li').each(function(){
                                                if (clicked==ci) $(this).fadeIn(800);
                                                ci++;
                                });	
				}


// custom checkbox


$(document).ready(function(){
	$(".custom_checkbox").click(function(){
		($(this).hasClass('custom_checkboxed')) ? $(this).removeClass('custom_checkboxed') : $(this).addClass('custom_checkboxed');
		$(this.hash).trigger("click");
		return false;
	});
});

