$(function() {
	
					$('.cd-academy').countdown({until:$.countdown.UTCDate(-8, 2012,  8 - 1, 18), format: 'DHMS', layout: 
						  '<ul id="timer">' + '<hr />'+
							  '<ul id="timer_days" class="timer_numbers">{dnn}</ul>'+
							  '<ul id="timer_hours" class="timer_numbers">{hnn}</ul>'+ 
							  '<ul id="timer_mins" class="timer_numbers">{mnn}</ul>'+
							  '<ul id="timer_seconds" class="timer_numbers">{snn}</ul>'+
							'<ul id="timer_labels">'+
								'<ul id="timer_days_label" class="timer_labels">days</ul>'+
								'<ul id="timer_hours_label" class="timer_labels">hours</ul>'+
								'<ul id="timer_mins_label" class="timer_labels">mins</ul>'+
								'<ul id="timer_seconds_label" class="timer_labels">secs</ul>'+
								'<ul id="timer_wording_label" class="timer_labels">OSS Academy 2012 Countdown</ul>'+
							'</ul>'+							
						'</ul>'});
						
						$('.cd-masters').countdown({until:$.countdown.UTCDate(-8, 2012,  3 - 1, 5), format: 'DHMS', layout: 
						  '<ul id="timer">' + '<hr />'+
							  '<ul id="timer_days" class="timer_numbers">{dnn}</ul>'+
							  '<ul id="timer_hours" class="timer_numbers">{hnn}</ul>'+ 
							  '<ul id="timer_mins" class="timer_numbers">{mnn}</ul>'+
							  '<ul id="timer_seconds" class="timer_numbers">{snn}</ul>'+
							'<ul id="timer_labels">'+
								'<ul id="timer_days_label" class="timer_labels">days</ul>'+
								'<ul id="timer_hours_label" class="timer_labels">hours</ul>'+
								'<ul id="timer_mins_label" class="timer_labels">mins</ul>'+
								'<ul id="timer_seconds_label" class="timer_labels">secs</ul>'+
								'<ul id="timer_wording_label" class="timer_labels">OSS Masters 2012 Countdown</ul>'+
							'</ul>'+							
						'</ul>'});
						$('.cd-foundation').countdown({until:$.countdown.UTCDate(-8, 2012,  7 - 1, 9), format: 'DHMS', layout: 
						  '<ul id="timer">' + '<hr />'+
							  '<ul id="timer_days" class="timer_numbers">{dnn}</ul>'+
							  '<ul id="timer_hours" class="timer_numbers">{hnn}</ul>'+ 
							  '<ul id="timer_mins" class="timer_numbers">{mnn}</ul>'+
							  '<ul id="timer_seconds" class="timer_numbers">{snn}</ul>'+
							'<ul id="timer_labels">'+
								'<ul id="timer_days_label" class="timer_labels">days</ul>'+
								'<ul id="timer_hours_label" class="timer_labels">hours</ul>'+
								'<ul id="timer_mins_label" class="timer_labels">mins</ul>'+
								'<ul id="timer_seconds_label" class="timer_labels">secs</ul>'+
								'<ul id="timer_wording_label" class="timer_labels">OSS Foundation 2012 Countdown</ul>'+
							'</ul>'+							
						'</ul>'});
						  

		
	$('a.external').attr('target', '_blank');
	
	
	$('a.tip').qtip({
	   position: {
		  at: 'top center',
		  my: 'bottom center'
	   }, 
	   style: {
			 classes: 'ui-tooltip-dark ui-tooltip-rounded'
	   }
	});
	
	if ($("input.focus-clear").length > 0) {
		
		$("input.focus-clear").each(function(i) {
		
		$defaulttext = $(this).val();
		
				$(this).focus(function() {
					//$defaulttext = $(this).val();
					if ($(this).val() == $defaulttext) {
						$(this).val('');
					}
				}).blur(function() {
					if ($(this).val() == '') {
						$(this).val($defaulttext);
					}
				}).keypress(function() {
					$(this).removeClass("focus-clear");
				});
		});
		
	}
	
	subNavigation();
	
});



function subNavigation() {
	
	if ($('.secondary-navigation').length > 0) {
		
		$('.secondary-navigation ul li').each(function() {
			if ($(this).find('ul').length > 0) {
				$(this).find('a').eq(0).addClass('has-children');
			}
		});
		
		initialExClass = "open";
		
		 $('.secondary-navigation .has-children').wrap('<div class="has-children-wrap clear" />');
		 
		 var expcoll = $('<a />')
       			.attr('href', '#')
				.attr('class', 'arrow')
       			.html('<span class="' + initialExClass + '">show/hide</span>');		
				
		$(".has-children-wrap").prepend(expcoll);
		
		$('.secondary-navigation .has-children-wrap a.arrow').click(function() {
					
				$(this).parent().next().slideToggle(200);
				$(this).children().toggleClass("close", 500);
				return false;
		});
		
	}
	
}
