﻿// JScript File
// Used in Resources page to hide/unhide the div (Home/Content)
function fncShowContent(link, name)
{
    document.getElementById('Home').style.display = 'none';
    document.getElementById('Content').style.display = 'block';
    document.getElementById('mylink').href = link;
    document.getElementById('mylink').innerHTML = name;
}

function fncShowHome()
{
    document.getElementById('Home').style.display = 'block';
    document.getElementById('Content').style.display = 'none';
}
// Used for imgaes which change on hover
/*
The following 4 methods have been retrieved from the existing site.
Hence not changing the variable coding standards.
*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Used in consumer.master, Safe.aspx, prof_intermetiate.aspx and 20Coupon_offer.aspx 
// to randomly rotate the background images
function fncSwapBackground()
{
    if(document.getElementById('myStylesheet')== null || document.getElementById('myStylesheet').href.indexOf("Print") == -1)
    {
        // For page background
        var strPageContainer;
        var images_PageContainer = new Array ();
	    images_PageContainer[0] = 'images/whatis_background01.jpg';
	    images_PageContainer[1] = 'images/whatis_background02.jpg';
	    images_PageContainer[2] = 'images/whatis_background03.jpg';

	    var imgURLPageContainer = "url(" + images_PageContainer[rand(images_PageContainer.length)] + ")";	
        strPageContainer = document.getElementById('pageContainerTwo');
        strPageContainer.style.backgroundImage = imgURLPageContainer;
        
        // For Callout
        var strCallout;
        var images_Callout = new Array ();
	    images_Callout[0] = 'images/callout1.gif';
	    images_Callout[1] = 'images/callout2.gif';
	    images_Callout[2] = 'images/callout3.gif';

	    var imgURLCallout = "url(" + images_Callout[rand(images_Callout.length)] + ")";	
        strCallout = document.getElementById('pageHeaderIMG');   
        strCallout.style.backgroundImage = imgURLCallout;

   }
   else
   {
        document.getElementById('pageContainerTwo').style.backgroundImage = '';
   }
}
// random number generation
function rand(n) 
{
    return ( Math.floor ( Math.random ( ) * n ) );
}

function PrinterFriendly(obj,isForward)
{
    document.getElementById('myStylesheet').href= obj;
    fncSwapBackground();
}

// Randomly loading images in Professional module
var theImages = new Array()

//Random-loading images
theImages[0] = 'images/CARD_Header2.gif' // replace with names of images
theImages[1] = 'images/CARD_Header3.gif' // replace with names of images
theImages[2] = 'images/CARD_Header4.gif' // replace with names of images

var j = 0
var p = theImages.length;
var preBuffer = new Array()

for (i = 0; i < p; i++)
{
    preBuffer[i] = new Image()
    preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));

function showImage()
{
    if(whichImage==0)
    {
        document.write('<img src="'+theImages[whichImage]+'" border=0 width=400 height=156>');
    }
    else if(whichImage==1)
    {
        document.write('<img src="'+theImages[whichImage]+'" border=0 width=400 height=156>');
    }
    else if(whichImage==2)
    {
        document.write('<img src="'+theImages[whichImage]+'" border=0 width=400 height=156>');
    }
}
// used in what_is_bph.aspx page
function fncShowDiv()
{
    document.getElementById('init').style.display = 'none';
    document.getElementById('next').style.display = 'block';
}

function fncHideDiv()
{
    document.location.reload();
}
//Symptom Screener Code used in bph_symptoms_screener and tooltips_symptoms_screener pages

choiceArrayStr = "Not at all,Less than 1 time in 5,Less than half the time,About half the time,More than half the time,Almost always";
choiceArray = choiceArrayStr.split(',');

choice67ArrayStr = "None,1 time,2 times,3 times,4 times,5 times"
choice67Array = choice67ArrayStr.split(",");

function count()
{
	var myitem1score = 9;
	var myitem2score = 9;
	var myitem3score = 9;
	var myitem4score = 9;
	var myitem5score = 9;
	var myitem6score = 9;
	var myitem7score = 9;

	if (document.symptomscore.item1score.value != "-") {
		var myitem1score = document.symptomscore.item1score.value.valueOf();
	}
	if (document.symptomscore.item2score.value != "-") {
		var myitem2score = document.symptomscore.item2score.value.valueOf();
	}
	if (document.symptomscore.item3score.value != "-") {
		var myitem3score = document.symptomscore.item3score.value.valueOf();
	}
	if (document.symptomscore.item4score.value != "-") {
		var myitem4score = document.symptomscore.item4score.value.valueOf();
	}
	if (document.symptomscore.item5score.value != "-") {
		var myitem5score = document.symptomscore.item5score.value.valueOf();
	}
	if (document.symptomscore.item6score.value != "-") {
		var myitem6score = document.symptomscore.item6score.value.valueOf();
	}
	if (document.symptomscore.item7score.value != "-") {
		var myitem7score = document.symptomscore.item7score.value.valueOf();
	}
		
	var allcheckboxes = 0;
	if (myitem1score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	if (myitem2score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}	
	if (myitem3score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	if (myitem4score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	if (myitem5score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	if (myitem6score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	if (myitem7score == 9) {
		var allcheckboxes = allcheckboxes + 1;
	}
	
	if (allcheckboxes != 0) {
		alert("Please select one circle for each question before calculating your score. Thank you.");	
	}
	else {
		var mytotalscore = eval(myitem1score.valueOf()) + eval(myitem2score.valueOf()) + eval(myitem3score.valueOf()) + eval(myitem4score.valueOf()) + eval(myitem5score.valueOf()) + eval(myitem6score.valueOf()) + eval(myitem7score.valueOf());
		
		if (mytotalscore <= 7) 
		{
            document.symptomscore.calculated.value = "Your symptoms can be an indication of mild BPH.  Do you have BPH?  Only your doctor can tell you for sure. ";
            document.symptomscore.calculated.value += "Since an enlarged prostate by itself may or may "
            document.symptomscore.calculated.value += "not cause problems, your BPH severity is determined by the number of "
            document.symptomscore.calculated.value += "symptoms you are experiencing and the degree to which they are interfering "
            document.symptomscore.calculated.value += "with your life.  To help your doctor understand your condition better, you "
            document.symptomscore.calculated.value += "may want to keep a symptom diary for a few days before your appointment, "
            document.symptomscore.calculated.value += "noting any problems you are having and when they occur.  Talking to your "
            document.symptomscore.calculated.value += "doctor about your symptom score is a good way to see if you need treatment. "
            document.symptomscore.calculated.value += "If you do need treatment, the score can help your doctor decide on the best "
            document.symptomscore.calculated.value += "treatment for you. "; 
		}

		if (mytotalscore <= 19  && mytotalscore > 7) 
		{
            document.symptomscore.calculated.value = "Your symptoms can be an indication of moderate BPH.  Do you have BPH?  Only your doctor can tell you for sure. "
            document.symptomscore.calculated.value += "Since an enlarged prostate by itself may or may "
            document.symptomscore.calculated.value += "not cause problems, your BPH severity is determined by the number of "
            document.symptomscore.calculated.value += "symptoms you are experiencing and the degree to which they are interfering "
            document.symptomscore.calculated.value += "with your life.  To help your doctor understand your condition better, you "
            document.symptomscore.calculated.value += "may want to keep a symptom diary for a few days before your appointment, "
            document.symptomscore.calculated.value += "noting any problems you are having and when they occur.  Talking to your "
            document.symptomscore.calculated.value += "doctor about your symptom score is a good way to see if you need treatment. "
            document.symptomscore.calculated.value += "If you do need treatment, the score can help your doctor decide on the best "
            document.symptomscore.calculated.value += "treatment for you. "; 
		}
		if (mytotalscore <=35 && mytotalscore > 19)
		{
            document.symptomscore.calculated.value = "Your symptoms can be an indication of severe BPH.  Do you have BPH?  Only "
            document.symptomscore.calculated.value += "your doctor can tell you for sure.   Since an enlarged prostate by itself may or "
            document.symptomscore.calculated.value += "may not cause problems, your BPH severity is determined by the number of "
            document.symptomscore.calculated.value += "symptoms you are experiencing and the degree to which they are interfering "
            document.symptomscore.calculated.value += "with your life.  To help your doctor understand your condition better, you "
            document.symptomscore.calculated.value += "may want to keep a symptom diary for a few days before your appointment, "
            document.symptomscore.calculated.value += "noting any problems you are having and when they occur.  Talking to your "
            document.symptomscore.calculated.value += "doctor about your symptom score is a good way to see if you need treatment. "
            document.symptomscore.calculated.value += "If you do need treatment, the score can help your doctor decide on the best "
            document.symptomscore.calculated.value += "treatment for you. ";
		}
		/*
		Only the following code snippet hides the screener div and unhides the screener results div
		Displays the selected answer, total score, analysis text of the score and its value to the user
		*/
		document.getElementById('screener').style.display = 'none';
	    document.getElementById('screenerResults').style.display = 'block';
    	scrollTo(0,0);
	    document.getElementById('resultText').innerHTML = document.symptomscore.calculated.value;
	    document.getElementById('resultScore').innerHTML= mytotalscore;
	    document.getElementById('result1').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choiceArray[myitem1score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem1score;
	    document.getElementById('result2').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choiceArray[myitem2score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem2score;
	    document.getElementById('result3').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choiceArray[myitem3score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem3score;
	    document.getElementById('result4').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choiceArray[myitem4score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem4score;
	    document.getElementById('result5').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choiceArray[myitem5score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem5score;
	    document.getElementById('result6').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choice67Array[myitem6score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem6score;
	    document.getElementById('result7').innerHTML="<SPAN class='homepagecontent_blackbold'>Your answer:</SPAN> <SPAN class='homepagecontent'>"+ choice67Array[myitem7score]+"<BR /><BR /><SPAN class='homepagecontent_blackbold'>Your answer value: </SPAN>" + myitem7score;
	    document.getElementById('resultScoreFooter').innerHTML= mytotalscore;
	}
}

function checkBoxValidate1(cb) {
document.symptomscore.item1score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item1[" + j + "].checked") == true) {
document.symptomscore.item1[j].checked = false;
if (j == cb) {
document.symptomscore.item1[j].checked = true;
         }
      }
   }
}
function checkBoxValidate2(cb) {
document.symptomscore.item2score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item2[" + j + "].checked") == true) {
document.symptomscore.item2[j].checked = false;
if (j == cb) {
document.symptomscore.item2[j].checked = true;
         }
      }
   }
}
function checkBoxValidate3(cb) {
document.symptomscore.item3score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item3[" + j + "].checked") == true) {
document.symptomscore.item3[j].checked = false;
if (j == cb) {
document.symptomscore.item3[j].checked = true;
         }
      }
   }
}
function checkBoxValidate4(cb) {
document.symptomscore.item4score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item4[" + j + "].checked") == true) {
document.symptomscore.item4[j].checked = false;
if (j == cb) {
document.symptomscore.item4[j].checked = true;
         }
      }
   }
}
function checkBoxValidate5(cb) {
document.symptomscore.item5score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item5[" + j + "].checked") == true) {
document.symptomscore.item5[j].checked = false;
if (j == cb) {
document.symptomscore.item5[j].checked = true;
         }
      }
   }
}
function checkBoxValidate6(cb) {
document.symptomscore.item6score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item6[" + j + "].checked") == true) {
document.symptomscore.item6[j].checked = false;
if (j == cb) {
document.symptomscore.item6[j].checked = true;
         }
      }
   }
}
function checkBoxValidate7(cb) {
document.symptomscore.item7score.value= cb
for (j = 0; j < 6; j++) {
if (eval("document.symptomscore.item7[" + j + "].checked") == true) {
document.symptomscore.item7[j].checked = false;
if (j == cb) {
document.symptomscore.item7[j].checked = true;
         }
      }
   }
}

function Persist_Results(){
document.hidden_form_fields.submit();
}
function Persist_Results_From_Print_Page(){
document.hidden_form_fields_print.submit();
}





