jQuery(document).ready(function($) {

 /* begin --
 add interstitial page onload */

 $("#page").after('<div id="interstitial_overlay"></div><div id="interstitial_window"><div class="inner"><span class="top"><span class="lft"></span><span class="rgt"></span></span><div class="content"><div><h4>You are now leaving Asthma<abbr title="General Awareness and Perceptions">GAP</abbr>.com</h4><p class="continue"><a href="" title="" class="goto">Continue &gt;&gt;</a></p><p class="return-to-previous"><a href="javascript:void(0);" title="Back To Previous Page" class="close">&lt;&lt; Back to previous page</a></p></div><a href="javascript:void(0);" title="close window" class="close">Close Window</a></div><span class="bottom"><span class="lft"></span><span class="rgt"></span></span>\n</div></div>');

 var treatment_content = '<div><h4>You are now leaving Asthma<abbr title="General Awareness and Perceptions">GAP</abbr>.com to learn about a treatment option.</h4><fieldset><label>Please select your age, or the age of the person for whom you are seeking treatment information below.</label><p class="continue"><a href="http://www.mysymbicort.com/c/index.aspx" title="12 Years or Above">12 Years or Above</a> <a href="http://www.pulmicortflexhaler.com/Flexhaler/index.aspx" title="7 to 11 years ">7 to 11 years</a> <a href="http://www.pulmicortrespules.com/" title="12 months to 6 years ">12 months to 6 years</a></p><p class="return-to-previous"><a href="javascript:void(0);" title="Back To Previous Page" class="close">&lt;&lt; Back to previous page</a></p></fieldset></div>';

 var replace_content = '<div><h4>You are now leaving Asthma<abbr title="General Awareness and Perceptions">GAP</abbr>.com</h4><p class="continue"><a href="" title="" class="goto">Continue &gt;&gt;</a></p><p class="return-to-previous"><a href="javascript:void(0);" title="Back To previous page" class="close">&lt;&lt; Back to previous page</a></p></div>'

 /* end --
 add interstitial page onload */

 $("html").localScroll();






 $("form.search fieldset input[type='text']").focus(
	function() {
	 $(this).val("");
	}
);

 $("form.search fieldset input[type='text']").blur(
	function() {
	 if ($("form.search fieldset input[type='text']").val() == '') {
	  $("form.search fieldset input[type='text']").val('Search:')
	 }
	}
);


/*
 $("a[href='#treatment']").click(function() {
  $("#interstitial_window div.content div").replaceWith(treatment_content);
  $("#interstitial_window").addClass("treatment_options");
  $("object").css("visibility", "hidden");
  $("embed").css("visibility", "hidden");
  $("#interstitial_overlay").show();
  $("#interstitial_window.treatment_options").slideDown('slow');
 });
*/


 $("a[href^='https://'], a[href^='http://']").click(function() {

  if ($(this).attr("title") == 'click to download a pdf (portable document format) about the asthma action plan') {

  }
  else {
   $("object").css("visibility", "hidden");
   $("embed").css("visibility", "hidden");
   var link = $(this).attr("href");
   $("#interstitial_overlay").show();
   $("#interstitial_window").slideDown('slow');
   $(this).attr("id", "leaving");
   $(this).attr("href", "javascript:void(0);");
   $("#interstitial_window a.goto").attr("href", link);
  }
 });



 $("#interstitial_window a.close").click(function() {
  var link = $("#interstitial_window a.goto").attr("href");
  $("#interstitial_window").slideUp('fast', function() { $("#interstitial_overlay").hide(); });
  $("#leaving").attr("href", link);
  $("#leaving").removeAttr("id");
  $("object").css("visibility", "visible");
  $("embed").css("visibility", "visible");
  //$("#interstitial_window div.content div").replaceWith(replace_content);
 });



/* old email form script */
/*
 $("a.email").click(function() {
  $("object").css("visibility", "hidden");
  $("embed").css("visibility", "hidden");
  $("#email_overlay").show();
  $("#email_page").slideDown('slow');
 });


 $("#email_page a.close, #email_page a.cancel").click(function() {
  $("#email_page").slideUp('fast', function() { $("#email_overlay").hide(); });
  $("object").css("visibility", "visible");
  $("embed").css("visibility", "visible");
 });

*/











 /* begin Poll Script
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

	$("#poll input[type='radio']").attr("checked", "");

	var radioChecked = $("#poll input[type='radio']").attr("checked");

	// alert(radioChecked);
	var homeContentHeight = $("body.home #content").height()
	var homeRightColInnerWrapContentHeight = $("body.home #right_column #mod01 div.inner").height()



 	$("#poll input[type='radio']").click(function() {
  
  		$("#poll input[type='radio']").attr("checked", false);
  		$(this).attr("checked", true);
  		radioChecked = true
		
	});


	function viewResults() {
  
  		$("#poll div.user_selects").hide();
  		$("#poll div.results").fadeIn("slow"); $("#poll div.results label.yes, #poll div.results label.no").slideDown("slow");
	}


	function increaseHeight() {
  		
		homeContentHeight = homeContentHeight + 30;
		homeRightColInnerWrapContentHeight = homeRightColInnerWrapContentHeight + 30;
 		$("body.home #content").css("height", homeContentHeight);
 		$("body.home #right_column #mod01 div.inner").height(homeRightColInnerWrapContentHeight);
  		$("div.banner").css("position" , "static");
  		viewResults()
	
	}


	//var pNo = "notchecked";
	//var pYes = "notchecked";


	$("#poll input#poll_answer_no").click(function() {
		pNo ="checked";
		pYes = "notchecked";
			
	});

	$("#poll input#poll_answer_yes").click(function() {
		pNo ="notchecked";
		pYes = "checked";	
		
	});
	


	$("#poll div.submit a.submit").click(function() {

	   // var pNo = document.getElementById("poll_answer_no");
	   // var pYes = document.getElementById("poll_answer_yes");

		if  (document.cookie.length > 0 && PollTaken == "poll-taken" ) {

			alert("You Have Already Taken the Poll");

  		}
		else if( pNo == "notchecked" && pYes == "notchecked" ) {

	 		alert("Please specify 'yes' or 'no' before voting.");   return; }

		else {
			SaveVote();
		    increaseHeight();

		}   
	
	});


	$("#poll div.submit a[title='view poll results']").bind("click", increaseHeight);



	if ($("body").attr("class") == 'home three_column') {

		$("#yes-reponses").css("width", yesWidth);
		$("#no-reponses").css("width", noWidth);
		
	}


 /* end Poll Script
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */



});