$(function() {
	$("#tabs-container").tabs({cookie:{ expires: 30 }});
	$("#ask-question,#panel-1 ul li p a,#panel-2 ul li p a,#panel-3 ul li p a,#panel-4 ul li p a,#panel-5 ul li p a").wrapInner("<span></span>");
	$("#ask-question span").addClass("clearfix");
	$("#tabs li:nth-child(1),#tabs li:nth-child(3),#tabs li:nth-child(4)").addClass("doubleLine");
/*	$("#question-expand ul").after("<span id='closeForm' style='color:#fff;'>close</span>");*/
	$('#ask-question p:first-child,#ask-question #closeForm').click(function(){
		$('#ask-question ul').slideToggle("normal");
/*		$('#ask-question #closeForm').toggle();*/
		$('#ask-question p').toggleClass("clicked");
	});
	$("#formProblem").validate();
	$("#formProblem").submit(function(){
		if ($("#formProblem").valid() == true){
			$("#form-error-message").slideUp("fast");
			$.cookie('problem-asked', 'yes', { expires: 30 });
		}
		else{
			$("#form-error-message").fadeIn("normal");
		}

		/* if purchase-id-gen is 'on' add a random purchase ID to the retURL  */
		if ($("#purchase-id-gen").attr("value") == ("on")){ 
			var retURL = $("[name=retURL]").attr("value");
			var newURL = retURL + "?orderid=" + Math.ceil(100000000000*Math.random());
			$("[name=retURL]").attr("value", newURL);
		}
		
	});
	if ($.cookie('problem-asked') == ("yes")) {
		$('#ask-question h3,#question-expand').css("display","none");
		$("#ask-question span").append("<div class='formMessage'>Thanks for describing your problem.<br /><em>We will respond shortly with information on how Arena can help solve your problem.</em></div>");
	}
});