var win=null

function openNewWindow(url, winname, winprops) {
	if (url != '') {
		win = window.open(url, winname, winprops);
	}
}

function submitToWindow(cmd) 
{ 
    window.open("","newWin","width=500,height=300,toolbar=0"); 
    var a = window.setTimeout(cmd,500); 
} 

function checkSearchForm() {
	if (document.search.searchtext.value == "Enter Keywords") {
		alert("please enter a Keyword.");
		document.search.searchtext.focus();
		return false;
	}
	if (document.search.searchlist.selectedIndex == 0)
		{
			alert("please select a Search Option.");
			document.search.searchlist.focus();
		return false;
	}

}
function Launch(url) {
	if (url != '') {
		win = window.open(url, "", "");
	}
}

function LaunchScrl(url,n,w,h) {
   lWin=window.open(url,n,"menubar=no,scrollbars=yes,status=no,width="+w+",height="+h+",top=300,left=300")
}
function LaunchCustom(url,w,h,opt) {
	if (url != '') {
	    if (opt!="") 
	        opt = ","+opt
		win = window.open(url, "", "width="+w+",height="+h+opt);
	}
}

function ValidateSearchForm() {
	var SearchString = document.SearchForm.search_word.value;
	if ((SearchString.length < 3)||( document.SearchForm.search_word.value == "Enter Keywords")) {
		alert("Search phrase must be at least 3 characters in length.");
		document.SearchForm.search_word.focus();
		return false;
	}
	else {
		return true
	}	

}

function outLinks()
{
	var d = document.links; 
	var j = "javascript:"; 
	var b = "_blank";
	var dom = document.domain;
	dom = replace(dom,":"+location.port,"");
	for (var i = 0; i < (d.length); i++) 
		if (d[i].protocol != j & d[i].hostname != dom & d[i].hostname == "cms.med.wayne.edu") 
		{
          d[i].hostname = dom ; 
          d[i].port = location.port ;
		}
}
window.onload = function() { outLinks() }; 

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


var persistmenu="no" 
//"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="local" 
//enter "sitewide" for menu to persist across site, "local" for this page only

//if (document.getElementById){ //DynamicDrive.com change
//    document.write('<style type="text/css">\n')
//   document.write('.audienceItemSecondary{display: none;}\n')
//    document.write('</style>\n')
//}

function SwitchMenu(obj,sel){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="audienceItemSecondary") {
				ar[i].style.display = "none";
				
			}}
			el.style.display = "block";
			 document.getElementById(sel).className=document.getElementById(sel).className+"Down"
			//alert(sel.className)
		}else{
			el.style.display = "none";
			document.getElementById(sel).className=replace(document.getElementById(sel).className,"Down","")
			
			
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate



 
function insertRow(theSel, newText, newValue)
{
  if (theSel.length == 0) {
    var newOpt1 = new Option(newText, newValue);
    theSel.options[0] = newOpt1;
    theSel.selectedIndex = 0;
  } else if (theSel.selectedIndex != -1) {
    var selText = new Array();
    var selValues = new Array();
    var selIsSel = new Array();
    var newCount = -1;
    var newSelected = -1;
    var i;
    for(i=0; i<theSel.length; i++)
    {
      newCount++;
      if (newCount == theSel.selectedIndex) {
        selText[newCount] = newText;
        selValues[newCount] = newValue;
        selIsSel[newCount] = false;
        newCount++;
        newSelected = newCount;
      }
      selText[newCount] = theSel.options[i].text;
      selValues[newCount] = theSel.options[i].value;
      selIsSel[newCount] = theSel.options[i].selected;
    }
    for(i=0; i<=newCount; i++)
    {
      var newOpt = new Option(selText[i], selValues[i]);
      theSel.options[i] = newOpt;
      theSel.options[i].selected = selIsSel[i];
    }
  }
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(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 ChangeLinkOnMouseOut(id) {
	document.getElementById(id).style.color='#ffffff'; 
	//document.getElementById(id).style.borderBottom='1px #3e4651 solid'
}
function ChangeLinkOnMouseOver(id) {
	ChangeLinkOnMouseOut('l1');
	ChangeLinkOnMouseOut('l2');
	ChangeLinkOnMouseOut('l3');
	ChangeLinkOnMouseOut('l4');
	document.getElementById(id).style.color='#90969c'; 
	//document.getElementById(id).style.borderBottom='1px #ffffff dashed'
}

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 printContent(headerTxt)
{ 
  var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; 
  var content_vlue = document.getElementById("pageContent").innerHTML;
  
  var docprint=window.open("","",disp_setting); 
   docprint.document.open(); 
   docprint.document.write('<html><head><title>ZANA Network - ' + headerTxt + ' (printable)</title>');
   docprint.document.write('<style type="text/css">');
   docprint.document.write('* { text-align:left; }');
   docprint.document.write('.pfText, .pfText img { display:none; }');
   docprint.document.write('h1 { font-size:16px; text-align:center; }');
   docprint.document.write('</style>');
   docprint.document.write('<link href="/css/print.css" rel="stylesheet" type="text/css" media="all" />'); 
   docprint.document.write('</head><body onLoad="self.print()"><center>');   
   docprint.document.write('<h1>' + headerTxt + ' (Printable)</h1>');
   docprint.document.write(content_vlue);          
   docprint.document.write('</center></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 
}
