function doJump(state)
{

	if (state != "Select Your State") 
	{
		state = state.replace(".","");
		state = state.replace(" ","-");
		state = state.replace(" ","-");
		state = state.toLowerCase();

		window.location = "/physician-finder-results/#" + state;	
	}
	
}

$(document).ready(function() {
   
   	$(".headline").click(function(){
		$(this).parent().nextAll().toggle("slow"); // Changed next() to nextAll() - INNOVAH
		//alert($(this).parent().parent().children(".chevron").attr("class"));
		if ($(this).parent().parent().children(".chevron").attr("src") == "/wp-content/themes/apda/images/chevron_down.jpg") {
			$(this).parent().parent().children(".chevron").attr("src","/wp-content/themes/apda/images/chevron.jpg");
		} else {
			$(this).parent().parent().children(".chevron").attr("src","/wp-content/themes/apda/images/chevron_down.jpg");
		}
		return false; // Keep page from jumping to top - INNOVAH
		
   	});
   	
   	$(".question_text").click(function(){
		
		//$(this).parent().next().toggle("slow")
		$(this).parent().next().toggle("slow");
		if ($(this).children(".chevron_2").attr("src") == "/wp-content/themes/apda/images/chevron_down.jpg") {
			$(this).children(".chevron_2").attr("src","/wp-content/themes/apda/images/chevron.jpg");
		} else {
			$(this).children(".chevron_2").attr("src","/wp-content/themes/apda/images/chevron_down.jpg");
		}
		return false; // Keep page from jumping to top - INNOVAH
   	});
   	
   	$(".close_x").click(function(){
		
		$(this).parent().toggle("slow");
		
		if ($(this).parent().parent().find(".chevron_2").attr("src") == "/wp-content/themes/apda/images/chevron_down.jpg") {
			$(this).parent().parent().find(".chevron_2").attr("src","/wp-content/themes/apda/images/chevron.jpg");
		} else {
			$(this).parent().parent().find(".chevron_2").attr("src","/wp-content/themes/apda/images/chevron_down.jpg");
		}
		return false;  // Keep page from jumping to top - INNOVAH	
   	});
   	
	$(".subcategory").hide();
	$(".question_answer").hide();
	$(".question_list").hide();
	
	$(".popup").hide();
	// Generic Show Hide Panel - INNOVAH
	$("a.showhide").click(function(){
		$(this).parent().find('.popup').toggle("slow");
		return false; // Keep page from jumping to top - INNOVAH	
   	});
	$("a.close").click(function(){
		$(this).parents('.popup').slideUp("slow");
		return false; // Keep page from jumping to top - INNOVAH	
   	});
	// End Generic Show Hide Panel
	
	
	//// /treatment-options/apda-medical-advisory-board-position-statement-on-treatment/
	
	//alert($("#adv_board_link").attr("id"));
	$("#adv_board_popup").prev().children("span").children("a").click(function(){
		
		$(this).parent().next().toggle("slow");
		
	});
	
	$("#adv_board_popup").hide();
	
 });
 
function videoCompleteHandler(videoName) {
  //alert("videoCompleteHandler called - videoName: " + videoName);
  //$("#videoBox").html('<img src="'+videoName+'.png" width="640" height="360" alt="" title="APDA" />');
  //var divID = videoName + "CO";
  //$('#APDA_Video_Library').flash().remove();
  $('#videoBox').html('<iframe src="'+videoName+'.php" width="640" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0"></iframe>');
  //$('#videoBox').html('');
  //$('#APDA_HomepageCO').show();
}


function loadVideoRestricted(uRestriction,uLevel,videoNum){
	//alert("loadVideo called - uRestriction: " + uRestriction + ", uCap: " + uCap + ", videoNum: " + videoNum);
	var str = uRestriction;
	str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
    	return letter.toUpperCase();
	});
	
	//alert ('uRestriction: ' + uRestriction + ', uLevel: ' + uLevel);
	
	var level, restrictionLevel;
		if (uRestriction == 'administrator') {
			restrictionLevel = 0;
		} else if (uRestriction == 'apda_board_member') {
			restrictionLevel = 1;
		} else if (uRestriction == 'physician') {
			restrictionLevel = 2;
		} else if (uRestriction == 'member') {
			restrictionLevel = 3;
		}
		
		if (uLevel == 'administrator') {
			level = 0;
		} else if (uLevel == 'apda_board_member') {
			level = 1;
		} else if (uLevel == 'physician') {
			level = 2;
		} else if (uLevel == 'member') {
			level = 3;
		} else {
			level = 99;
		}
		
		if (restrictionLevel < level) {
			//alert("this content is restricted");
			document.getElementById('inline1').innerHTML='<div style="border:1px solid #321307; background-color:#715441; padding:7px; width:900px; height:500px; vertical-align:middle; left:auto; right:auto;" align="center" ><table width="100%" height="100%" style="color:#000; font-weight:bold;"><tr><td align="middle">This video is restricted to '+str+'s.</td></tr><!--<tr><td>Please <a href="/login" title="Login">login</a> as a '+str+' to view.</td></tr>--></table></div>';
			//location.reload();
			//return;
		} else {
			loadVideo(videoNum);
		}
}

function loadVideo(videoNum){
  seriesId = "APDA" + videoNum + "Welcome";

  var so = new SWFObject("/wp-content/themes/apda/swf/videoPlayerAPDA.swf", "APDA_Video_Library", "640", "400", "10");
  so.addParam("allowScriptAccess", "always");
  so.addParam("width", "640");
  so.addParam("height", "400");
  so.addParam("style","");
  so.addParam("id","APDA_Video_Library");
  so.addParam("name","APDA_Video_Library");
  so.addParam("wmode","transparent");
  so.addParam("allowFullScreen","true");
  so.addParam("quality","high");
  so.addVariable("autostart","true");
  so.addVariable("videoSkin","/wp-content/themes/apda/swf/SkinUnderPlayStopSeekFullVol.swf");
  //so.addVariable("callback","analytics");
  if (videoNum == 1) {
                  so.addVariable("videoName","/wp-content/uploads/2011/06/APDA_Homepage.flv");
                  $("#APDAVideoTitle").html("<h2 style='color:#321307; margin-top:10px;'>Welcome to APDA</h2>");
                  $("#APDAVideoDesc").html("<p>Hear from the APDA founder and members of the Medical Advisory Board about the organization and its mission to help patients become their own advocates.</p>");
  } else if (videoNum == 2) {
                  so.addVariable("videoName","/wp-content/uploads/2011/06/NewAtAPDA.flv");
                  $("#APDAVideoTitle").html("<h2 style='color:#321307; margin-top:10px;'>New Site Features</h2>");
                  $("#APDAVideoDesc").html("<p>Learn what’s new on the APDA website. Find out about helpful new features for patients and partners, including a physician finder and interactive treatment comparison chart.</p>");
  } else if (videoNum == 3) {
                  so.addVariable("videoName","/wp-content/uploads/2011/06/APDA_HCP_Welcome.flv");
                  $("#APDAVideoTitle").html("<h2 style='color:#321307; margin-top:10px; line-height:12px;'>Welcome to the APDA</h2>");
                  $("#APDAVideoDesc").html("<p style='font-size:smaller;'>APDA is dedicated to providing medically accurate information to support those with Peyronie&acute;s disease. Watch this video to learn more about APDA&acute;s mission and vision and how healthcare professionals contribute by providing their medical expertise.</p>");
  } else if (videoNum == 4) {
  	//alert('grabbing 4');
                  so.addVariable("videoName","/wp-content/uploads/2011/06/APDA_Psychological.flv");
                  $("#APDAVideoTitle").html("<h2 style='color:#321307; margin-top:10px; line-height:12px;'>Psychological Impact</h2>");
                  $("#APDAVideoDesc").html("<p style='font-size:smaller;'>Peyronie’s disease can be both emotionally and physically devastating. But, as psychologist Christian Nelson describes in this video, there is hope for a positive way forward. Watch as he discusses important topics such as intimacy, relationships and communicating with your partner.<br /><a href='/living-with-peyronies/impact-on-relationships/' title='Ask Dr. Nelson a Question'>Ask Dr. Nelson a Question</a></p>");
  }

  so.write("videoBox");
}


  
  
