var askAndreaRequestSubmitted = false;

function sendAskAndreaRequest() {
	if ( ! askAndreaRequestSubmitted ) {	
		
		askAndreaRequestSubmitted = true;

		var name = document.getElementById("name").value.trim();
		var email = document.getElementById("email").value.trim();
		var city = document.getElementById("city").value.trim();
		var state = document.getElementById("state").value.trim();
		var question = document.getElementById("question").value.trim();
		var getHTVNews = document.getElementById("chkHTVNews");
		getHTVNews = document.getElementById("chkHTVNews").checked ? "True" : "";
		
		document.getElementById("submitResponse").style.display = "block";
		updateInnerHTML("submitResponse", "Submitting your question...");
	
		createRequest();
		var url = "/askAndrea.do";
		request.open("POST", url, true);
		request.onreadystatechange = updateAskAndrea;
		
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send("name="+escape(name)+"&email="+escape(email)+"&city="+escape(city)+"&state="+escape(state)+"&question="+escape(question)+"&getHTVNews="+escape(getHTVNews));
	}
}

function updateAskAndrea() {
	if ( confirmUpdateElementWithResponseText("submitResponse") ) {
		askAndreaRequestSubmitted = false;
		if (document.getElementById("submitResponse").innerHTML.substring(0,9) == "Thank you") {
			document.getElementById("name").value = "";
			document.getElementById("email").value = "";
			document.getElementById("city").value = "";
			document.getElementById("state").value = "";
			document.getElementById("question").value = "";
		}
	}
}

var MissHowardStern = {
	activeButton : null,
	activeArea : null,
	hideShow : function(button, elem) {
		this.activeButton.removeClass('active');
		this.activeArea.css('display','none');
		button.addClass('active');
		elem.css('display','block');
		this.activeButton = button;
		this.activeArea = elem;
	}
};
$(function() { 
	$('#photoImages a').lightBox({
		imageLoading: '/images/lightbox-ico-loading.gif',
		imageBtnClose: '/images/lightbox-btn-close.gif',
		imageBtnPrev: '/images/lightbox-btn-prev.gif',
		imageBtnNext: '/images/lightbox-btn-next.gif',
		imageBlank: '/images/lightbox-blank.gif'
	});
	
	MissHowardStern.activeButton = $('#about');
	MissHowardStern.activeArea = $('#about_section');

	$('#about').click(function(e) {
		if($('#about').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#about_section'));
	});
	
	$('#cast').click(function(e) {
		if($('#cast').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#cast_section'));
	});
	
	$('#episodes').click(function(e) {
		if($('#episodes').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#episodes_section'));
	});
	
	$('#news').click(function(e) {
		if($('#news').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#news_section'));
	});
	
	$('#askAndrea').click(function(e) {
		if($('#askAndrea').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#askAndrea_section'));
	});
	
	$('#downloads').click(function(e) {
		if($('#downloads').hasClass('active')) return;
		MissHowardStern.hideShow($(this), $('#downloads_section'));
	});
	
	$('#gotQuestion').mouseover(function(e) {
		$(this).css('border-color','#ffffff');
	});
	$('#gotQuestion').mouseout(function(e) {
		$(this).css('border-color','#ec008c');
	});
	$('#gotQuestion').click(function(e) {
		$('#askAndrea').trigger('click');
	});
	
	$('#tout2').mouseover(function(e) {
		$(this).css('border-color','#ffffff');
	});
	$('#tout2').mouseout(function(e) {
		$(this).css('border-color','#ec008c');
	});	
	$('#tout2').click(function(e) {
		$('#downloads').trigger('click');
	});
	
	$('.andreaQuestion').mouseover(function(e) {
		$(this).addClass('hover');
	});
	$('.andreaQuestion').mouseout(function(e) {
		$(this).removeClass('hover');
	});
	$('.andreaQuestion').click(function(e) {
		location.href = "#top";
		$('#missHowardFlashContent').html('');
		var so = new SWFObject("/swf/videoPlayer.swf", "missHowardFlashContent", "452", "287", "8", "#000000");
		so.addParam("scale", "noscale");
		so.addParam("wmode", "transparent");
		so.addVariable("optionsxml", "/swf/opt_missHowardStern.xml");
		so.addVariable("videoUrl", "howardtv/missHowardStern/askAndrea/" + $(this).find("span.displayNone").html());
		so.write("missHoward_flashContent");
	});	
});






