﻿function openWin( windowURL, windowName, windowFeatures) {
     window.open( windowURL, windowName, windowFeatures ) ;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) 
{	//v4.0
  	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 && document.getElementById) x=document.getElementById(n); return x;
}
function showISI() {
	MM_showHideLayers('divFlash','','show')
 	window.document.aravaScroller_Consumer.Play();
}


function doClear(theText) {
    if (theText.value == theText.defaultValue) {
        theText.value = ""
    }
}

function submitSearchForm()
{
    if (validateSearchText(document.forms["searchForm"].elements["SearchText"].value)) {
      return true;
    } else {
      return false;
    }
}

function clearSearch()
{
   if (document.forms["searchForm"].elements["SearchText"].value == 'Enter search term')
     {document.forms["searchForm"].elements["SearchText"].value = '';}
}

function validateSearchText(searchText)
{
    var valid = true;
    
    if (searchText.length == 0 || searchText == 'Enter search term') {
 	    window.alert ("Please enter a search text.");
  		valid = false;
 	}
 	else
 	{
 	    var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
 		for (var i = 0; i < searchText.length; i++) {
  		    if (iChars.indexOf(searchText.charAt(i)) != -1) {
  			    window.alert ("Your search text has special characters. \nThese are not allowed.\nPlease remove them and try again.");
  			    valid = false;
  			    break;
  	        }
        }
     }
     return valid;
}
 

// Registration Validation
function validateAge(source, args) {  

    var now = new Date();
    if(args.Value == "") {
        args.IsValid = true;
        return;
    }
    try {
        var dif = eval (now.getFullYear() + "-" + args.Value);
        args.IsValid = dif > 17;
    } catch(x) {
        args.IsValid = true;        
    }  
}

function gotoGlossary(term) 
{
    window.location = window.root+ 'glossary.aspx#'+term;
}

function exitSite(destination,interstitial)
{
	openWin(window.root + 'exitsite.aspx?url=' + destination + "&inst="+interstitial ,'pop_up','width=620,height=350,scrollbars=auto');
}
function openSymptomsPrint(resultQueryString)
{
	//openWin(window.root + 'helpful_resources/symptoms_checklist.aspx?prf=true&'+resultQueryString,'pop_up','width=800,height=700,scrollbars=yes');
	var prfWin = window.open(window.root + 'helpful_resources/symptoms_checklist.aspx?prf=true&'+resultQueryString,'Print_Page','width=800,height=700,scrollbars=yes'); 
    prfWin.print();
}
function openJournalPrint()
{
	//openWin(window.root + 'helpful_resources/prostate_journal.aspx?prf=true&','pop_up','width=800,height=700,scrollbars=yes');
    var prfWin = window.open(window.root + 'helpful_resources/prostate_journal.aspx?prf=true&','Print_Page','width=800,height=700,scrollbars=yes'); 
    prfWin.print();
}