$(document).ready(function() {


    $("div#entryrules").hide();
	$('a.linkEntryrules').click(function() {
		$("div#entryrules").show();
		$("div#entryform").hide();
		return false;
	});
    $('a.linkApplicationForm').click(function() {
		$("div#entryform").show();
		$("div#entryrules").hide();
		return false;
	});

//$("ol#OL12 li").append("12."+$(this).text());

//$('ol#OL12 > li').each(function() {
//    $(this).prepend("<span>12." + ($(this).index()+1) + "</span>&nbsp;&nbsp;&nbsp;");
//});

$("ol#OL12 li").prepend(function() {
   return $("<span />", {text: '12.'+($(this).index()+1)+' ' });
});


	$('.pageantLinks').hide();
	
	//WIDTHS & HEIGHTS
	//$(window).width();
	//$(document).width();
	//$(window).height();
	//$(document).height();

    $('#loggedIn P').hover(
		function() {
		$('#mciTop').toggleClass("btnON");
	});
	
	
//MENU

//BUTTON RIGHHT OF A TAG
$('ul.subnav').parent().append("<span title='Expand menu'></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  

//BUTTON INSIE A TAG
//$('ul.subnav').parent().children('a').append("<span title='Expand menu'></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  
$("ul.topnav li span").click(function() { //When trigger is clicked...  

	//Following events are applied to the subnav itself (moving subnav up and down)  
	$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
	//BUTTON INSIE A TAG
	//$(this).parents('li').find('ul.subnav').slideDown('fast').show();

	$(this).parent('li').hover(function() {
	//BUTTON INSIE A TAG
	//$(this).parents('li').hover(function() {
	}, function(){  
		$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		//BUTTON INSIE A TAG
		//$(this).children('ul.subnav').slideUp('slow'); 
	});  

	//Following events are applied to the trigger (Hover events for the trigger)  
	}).hover(function() {  
		$(this).addClass("subhover"); //On hover over, add class "subhover"  
	}, function(){  //On Hover Out  
		$(this).removeClass("subhover"); //On hover out, remove class "subhover"  
}); 
	
	
	
	
	
	
	
	
	
	//MENU
    $('a.openMenu').click(function() {
		if ($("div#mciMenuWrap").is(":hidden")) {
		$(this).toggleClass("btnON");
		$(this).attr("title", "Close Menu");
		$(this).html("Close Menu");
		$("div#mciLoadWrap,div#mciMiddle1").slideUp("slow");
		$("div#mciMenuWrap").slideDown("slow");
		} else {
		$(this).toggleClass("btnON");
		$(this).attr("title", "View Menu");
		$(this).html("View Menu");
		$("div#mciMenuWrap").slideUp("slow");
		$("div#mciMiddle1").slideDown("slow");
		
		}
	});
    $('div#mciMenuWrap a').click(function() {
		//LOADING CLICKED LINK
		$("div#mciMenuWrap").slideUp("fast");
		$("div#mciLoadWrap").slideDown("slow");
	});
	//SPONSORS
    $('a.linkSponsors').click(function() {
		if ($("div#mciSponsors").is(":visible")) {
		$("div#mciSponsors").slideUp("slow");
		} else {
		$("div#mciSponsors").slideDown("slow");
		}
	});
	
//	$('a.linkSponsors').click(function() {
//    	$("div#mciSponsors").next().slideToggle();
//  	});

	$("UL#ulPageants LI").hover(
	  function() { $(this).children(".pageantLinks").show(); },
	  function() { $(this).children(".pageantLinks").hide(); }
	);
});
