// JavaScript Document

$(document).ready(function(){
	
	$('div.co-order div').hide();
	
	
	var clearMePrevious = 'Enter your .CO domains for General Availability pre-registration here.\n\n(One per line)';
	
	$('div.co-order form textarea').html(clearMePrevious);

	$('div.co-order form textarea').focus(function() {
		if($(this).val()==clearMePrevious) {
			$(this).val('');
		}
	});
	
	$('div.co-order li.general h3').before('<span class="arrow"></span>');
	$('div.co-order form textarea').css('margin-top', '96px');
	$('div.co-order li.general div').show();
	
	$('div.co-order li h3').css('cursor', 'pointer').click( function() {
		if ($(this).next().is(':hidden')) {
			$('div.co-order li span.arrow').remove();
			$('div.co-order div').not(':hidden').slideUp();
			$(this).next().slideDown();
			$(this).before('<span class="arrow"></span>');
	
			if ($(this).parent().hasClass('sunrisea')) {
				$('input[name=t]').val('sr');
				clearMePrevious = 'This stage has ended and is no longer available.';
				$('div.co-order textarea').animate({
					marginTop: '0px',
					borderTopColor: '#666',
					borderRightColor: '#666',
					borderBottomColor: '#666',
					borderLeftColor: '#666',
					color: '#aaa'
				}, 500, function() {
					$(this).html(clearMePrevious);
				});
				$('div.co-order form input').fadeOut();
			} else if ($(this).parent().hasClass('sunrise')) {
				$('input[name=t]').val('srb');
				clearMePrevious = 'This stage has ended and is no longer available.';
				$('div.co-order textarea').animate({
					marginTop: '32px',
					borderTopColor: '#c1ce2f',
					borderRightColor: '#c1ce2f',
					borderBottomColor: '#c1ce2f',
					borderLeftColor: '#c1ce2f',
					color: '#aaa'
				}, 500, function() {
					$(this).html(clearMePrevious);
				});
				$('div.co-order form input').fadeOut();
			} else if ($(this).parent().hasClass('landrush')) {
				$('input[name=t]').val('lr');
				clearMePrevious = 'This stage has ended and is no longer available.';
				$('div.co-order textarea').animate({
					marginTop: '64px',
					borderTopColor: '#f36f21',
					borderRightColor: '#f36f21',
					borderBottomColor: '#f36f21',
					borderLeftColor: '#f36f21',
					color: '#aaa'
				}, 500, function() {
					$(this).html(clearMePrevious);
				});
				$('div.co-order form input').fadeOut();
			} else {
				$('input[name=t]').val('ga');
				clearMePrevious = 'Enter your .CO domains for General Availability pre-registration here.\n\n(One per line)';
				$('div.co-order textarea').animate({
					marginTop: '96px',
					borderTopColor: '#01a8cb',
					borderRightColor: '#01a8cb',
					borderBottomColor: '#01a8cb',
					borderLeftColor: '#01a8cb',
					color: '#000'
				}, 500, function() {
					$(this).html(clearMePrevious);
				});
				$('div.co-order form input').fadeIn();
			}
		}
	});
	
	$('div.co-faq ul.nav li a').not(':last').after('&nbsp;|&nbsp;');
	$('div.co-faq ul li div').hide();
	$('div.co-faq ul li h3').wrapInner('<a href="javascript:void(0)"></a>');
	$('div.co-faq ul li h3 a').prepend('<span class="more">Show</span>');
	$('div.co-faq ul li h3 a').click( function() {
		if ($(this).parent().next().is(':hidden')) {
			$(this).parent().next().slideDown('fast');
			$(this).prev().prev().addClass('click');
		} else {
			$(this).parent().next().slideUp('fast');
			$(this).prev().prev().removeClass('click');
		}
	});

});
