function changeto(e,highlightcolor){
    source=ie? event.srcElement : e.target
    if (source.tagName=="TABLE")
    return
    while(source.tagName!=highlightbehavior && source.tagName!="HTML")
    source=ns6? source.parentNode : source.parentElement
    if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
    source.style.backgroundColor=highlightcolor
}

function contains_ns6(lead, follow) { //check if follow is contained by lead
    while (follow.parentNode)
    if ((follow = follow.parentNode) == lead)
        return true;
    return false;
}

function P8_hideSelect(a) {
     //var m,t=(a==1)?"visible":"visible";
     //m=MM_findObj("topAreaToSearch");
	 //if(m) {
  	 //   for(var i=0;i<m.length;i++) {
     //       m[i].style.visibility=t;
     //   }
     //}
}


function changeback(e,originalcolor){
    if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
    return
    else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
    return
    if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
    source.style.backgroundColor=originalcolor
}


function doDateRangeSearch(interfaceToUse, topDropDownIndex) {

    var mySelected =  MM_findObj('dateRangeFilter').selectedIndex;
    var dateRangeFilterVal = MM_findObj('dateRangeFilter')[mySelected].value;

    var nValue = 0;

    if (MM_findObj('N')) {
      nValue = MM_findObj('N').value;
    }

    // if the selected value is not equal to what we are currently sorting by..
    if (!$('Nf') || dateRangeFilterVal != MM_findObj('Nf').value) {
        var targetUrl = '/search/searchWorldatWork.jsp?N=' + nValue;
        if (MM_findObj('Ntt')) {
            targetUrl = targetUrl + '&Ntt=' + splitWithPluses(MM_findObj('Ntt').value);
        }
        targetUrl = targetUrl + '&Ntk=' + interfaceToUse + '&Ntx=' + escape('mode+matchallpartial');
        targetUrl = targetUrl + '&pmttInterfaceSelectedDrop=' + topDropDownIndex;

        // only append Nf if they want to do a range filter
        if (dateRangeFilterVal != 'nodatefilter') {
            targetUrl = targetUrl + '&Nf=' + dateRangeFilterVal;
        }

        window.location=targetUrl;
        return false;

    }
    return false;
}




function doSearchFromSearchBox() {

    // figure out what search interface to use....
    // general is default and searches everything...
    var searchInterface = 'General';


    if (MM_findObj('searchTerm') && (MM_findObj('searchTerm').value).length > 0 &&
        MM_findObj('searchTerm').value != 'Please enter search' &&
        MM_findObj('searchTerm').value != searchPrompt) {

        var targetUrl = '/search/searchWorldatWork.jsp?N=0&Ntt=';
        targetUrl = targetUrl + splitWithPluses(MM_findObj('searchTerm').value) + '&Ntk=' + searchInterface + '&Ntx=' + escape('mode+matchallpartial');
        window.location=targetUrl;
        return false;
    } else {
        MM_findObj('searchTerm').value = 'Please enter search';
        MM_findObj('searchTerm').focus();
        MM_findObj('searchTerm').select();
        return false;
    }
}



// submit this form on enter (username, password input field)
function enter(me,ev)
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (ev) keycode = ev.which;
    else return true;
    if (keycode == 13) {
    me.form.submit();
    return false;
    }
    else
    return true;
}



function startTimer()
{
   stopTimer();
   timerID = setTimeout("hideMenus()", 10000);
}

function stopTimer()
{
   clearTimeout(timerID);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function goThere(topAreaToSearch) {

   var selectedIndex = topAreaToSearch.selectedIndex;
   var selectedValue = topAreaToSearch.options[selectedIndex].value;

   if (selectedIndex == 5) {
       topAreaToSearch.selectedIndex = 0;
   }


   if (selectedValue && selectedValue != '') {
        MM_findObj('searchTerm').value = 'taking you there';
        MM_findObj('searchTerm').focus();
        MM_findObj('searchTerm').select();
        // one second pause so they see our message
        setTimeout("window.location = '" + selectedValue + "'", 1000);
        // window.location = selectedValue;
   } else {
        // only want to give them the search prompt if they
        // haven't entered anything into the search box...
        if (MM_findObj('searchTerm').value.length == 0 ||
            MM_findObj('searchTerm').value == 'taking you there') {

            MM_findObj('searchTerm').value = searchPrompt;
            MM_findObj('searchTerm').focus();
            MM_findObj('searchTerm').select();
        } else {
            MM_findObj('searchTerm').focus();
        }
   }
}




function splitWithPluses(sourceValue) {

    var finishedStr = '';

    if (sourceValue && sourceValue.length > 0) {
        var word_array = sourceValue.split(' ');
        var indice = 0;
        while (indice < word_array.length) {
            if (finishedStr.length > 0) {
                finishedStr = finishedStr + '+';
            }
            finishedStr = finishedStr + word_array[indice];
            indice++;
        }
    }

    if (finishedStr.length <= 0) {
        finishedStr = sourceValue;
    }
    return finishedStr;
}



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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

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 to hide select menus and show top menu
function P7_hideSelect(a){ //v1.0 by PVII
     var g,h=(a==1)?"hidden":"visible";
     if(document.getElementsByTagName) {
         g=document.getElementsByTagName("select");
         if (g) {
             for (var i=0;i<g.length;i++) {
                 if (g[i].name != "topAreaToSearch") {
                     g[i].style.visibility=h;
                 }
             }
         }
     }
}

 function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// script for email-friend page
function mailpage() {
    mail_str = "/mypeers/email-page.jsp?loc=" + location.href;
    location.href = mail_str;
}

function showPrintable(yesno) {
	var leftnavdiv = MM_findObj('leftnavdiv');
	var topnavdivstd = MM_findObj('topnavdivstd');
	var topnavdivprint = MM_findObj('topnavdivprint');
	var footerdivstd = MM_findObj('footerdivstd');
	if (yesno)	{
		leftnavdiv.style.visibility = "hidden";
		leftnavdiv.style.display="none";
		topnavdivstd.style.visibility = "hidden";
		topnavdivstd.style.display="none";
		footerdivstd.style.visibility = "hidden";
		footerdivstd.style.display="none";
		topnavdivprint.style.visibility = "visible";
		topnavdivprint.style.display="block";
	} else {
		leftnavdiv.style.visibility = "visible";
		leftnavdiv.style.display="block";
		topnavdivstd.style.visibility = "visible";
		topnavdivstd.style.display="block";
		footerdivstd.style.visibility = "visible";
		footerdivstd.style.display="block";
		topnavdivprint.style.visibility = "hidden";
		topnavdivprint.style.display="none";
	}
	return false;
}
