//Cache control

/* ***********************************

     notestips.com (c) copyright 2002
     AUTHOR: Mike Golding
     MAIL:   mike@notestips.com
     TITLE:  notestips-global.js

     MODIFIED: 6/8/02

   *********************************** */

// Browser detect code is a PART of http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
// Ultimate client-side JavaScript client sniff. Version 3.03
// (C) Netscape Communications 1999-2001.  Permission granted to reuse and distribute.

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_notes = (agt.indexOf("lotus-notes") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
    var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);


    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    var is_winme = ((agt.indexOf("win 9x 4.90")!=-1) || (agt.indexOf("windows me")!=-1));
    var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1) || (agt.indexOf("windows 2000")!=-1));
    var is_winxp = ((agt.indexOf("windows nt 5.1")!=-1) || (agt.indexOf("windows xp")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    var is_linux = (agt.indexOf("inux")!=-1);


var vFlashVersion    = "0";
var vPageTitle       = document.title.replace(/\s/g, "%20");
var vPageURL         = location.pathname.replace(/\s/g, "%20");
var vBrowser         = "";
var vOS 	     = "";

if(is_win31){vOS="Windows 3.x";
}else if(is_win95){vOS="Windows 95";
}else if(is_winme){vOS="Windows ME";
}else if(is_win2k){vOS="Windows 2000";
}else if(is_win98){vOS="Windows 98";
}else if(is_winxp){vOS="Windows XP";
}else if(is_winnt){vOS="Windows NT";
}else if(is_os2){vOS="OS2";
}else if(is_mac){vOS="Macintosh";
}else if(is_linux){vOS="Linux";
}else{vOS="other";}




if(is_gecko){vBrowser="Mozilla";
}else if(is_nav2){vBrowser="Netscape 2";
}else if(is_nav3){vBrowser="Netscape 3";
}else if(is_nav4){vBrowser="Netscape 4";
}else if(is_nav6){vBrowser="Netscape 6";
}else if(is_ie3){vBrowser="Internet Explorer 3";
}else if(is_ie4){vBrowser="Internet Explorer 4";
}else if(is_ie5){vBrowser="Internet Explorer 5";
}else if(is_ie5_5){vBrowser="Internet Explorer 5.5";
}else if(is_ie6){vBrowser="Internet Explorer 6";
}else if(is_aol3){vBrowser="AOL 3";
}else if(is_aol4){vBrowser="AOL 4";
}else if(is_aol5){vBrowser="AOL 5";
}else if(is_aol6){vBrowser="AOL 6";
}else if(is_notes){vBrowser="Lotus Notes";
}else if(is_opera2){vBrowser="Opera 2";
}else if(is_opera3){vBrowser="Opera 3";
}else if(is_opera4){vBrowser="Opera 4";
}else if(is_opera5){vBrowser="Opera 5";
}else if(is_opera6){vBrowser="Opera 6";
}else if(is_ie && is_mac){vBrowser="IE Mac";
}else{vBrowser="other";}


var vColors          = Math.pow (2,window.screen.colorDepth).toString();
var vColorDepth      = window.screen.colorDepth + "bit";
var vResWidth        = window.screen.width.toString();
var vResHeight       = window.screen.height.toString();
var vReferrer	     = document.referrer;
var vJava            = "";
if (navigator.javaEnabled() < 1) vJava = "No";
if (navigator.javaEnabled() == 1) vJava = "Yes";



/* ***********************************

     GENERAL FUNCTIONS

   *********************************** */


//GET CSS CUTOFF POINT
if(window.screen.width == 800){
   winCSSCut = 790;
} else if (window.screen.width > 1020){
   winCSSCut = 800;
}


//HACK TO STOP COL3 CSS ELEMENTS OVERLAPPING
function checkSize() {
/*
  //GET WINDOW WIDTH
  if (is_major>3) {
    if (is_nav || is_gecko || is_opera) {
      var winWidth = window.innerWidth;
    }		
    if (is_ie){
      var winWidth = document.body.offsetWidth;
    }
  }
	
  var rightcol = document.getElementById("rightcolumn");
  if(winWidth < winCSSCut){
    rightcol.style.display = "none";
  }else{
    rightcol.style.display = "";
  }
*/	
}




  function View_Search(){
    vQuery = document.forms[0].SearchQuery.value;
    vType = getCheckedValue(document.forms[0].SearchType);
    if(vQuery != ""){
      if(vType == 0){
	var vView = "web-all"
      }else if(vType == 1){
	var vView = "search-articles"
      }else if(vType == 2){
	var vView = "search-news"
      }else if(vType == 3){
	var vView = "search-comments"
      }
      
      document.location = '/80256B3A007F2692/' + vView + '?SearchView&Query=' + vQuery + '&SearchOrder=1&SearchMax=250&SearchWV=FALSE&Start=1&Count=10'

    }else{
      alert("You must enter some words to search for.");
      document.forms[0].SearchQuery.focus();
    }
  }























function showDIV(aDIVName) {
 	eval ("document.all." + aDIVName + ".style.visibility = 'visible'");
}

  	
function hideDIV(aDIVName) {
        //Hide - DO NOT Reclaim screen Space
	eval ("document.all." + aDIVName + ".style.visibility = 'hidden'");
}


function displayDIV(aDIVName) {
 	eval ("document.all." + aDIVName + ".style.display = ''");
}

  	
function removeDIV(aDIVName) {
        //Hide - Reclaim screen Space
	eval ("document.all." + aDIVName + ".style.display = 'none'");
}


function popup_window(the_page,the_target,the_width,the_height) {
  window.open(the_page,the_target,"status=no,menubar=no,scrollbars=no,resizable=no,width=" + the_width + ",height=" + the_height);
  return false;
}


function popup_window_modal(the_page,the_target,the_width,the_height) {
window.showModalDialog(the_page,the_target,"resizable:no;center:no;help:no;status:no;menubar=no,scroll=no;dialogLeft:100;dialogTop:100;dialogWidth:" + the_width + "px;dialogHeight:" + the_height + "px");

  return false;
}


function enterPress() {
  if (window.event.keyCode==13){
    return false;
  }
}



function view_replace_nodocuments(aMessage){
  var h2 = document.getElementsByTagName("h2");
  for (var vLoop = 0; vLoop < h2.length; vLoop++){
    if (h2[vLoop].childNodes[0].nodeValue == "No documents found"){
      h2[vLoop].childNodes[0].nodeValue = aMessage;
    }
    h2[vLoop].style.visibility = 'visible';
  }
}


/* ***********************************

     STYLE SWITCHER FUNCTIONS

   *********************************** */

function manage_links() {
  oOptions = document.forms[0].targetwindow; 
  for(i=0; i < oOptions.length; i++) { 
    if(oOptions[i].checked) { 
       vTarget = oOptions[i].value; 
    }
  }
  for(i=0; i < document.links.length; i++) { 
    vLink = document.links[i]; 
    vLink.title = vLink.href; 
    vLink.target = vTarget; 
  }       
}

function selectStyle (vCookieName, vSelection) {
  makeCookie(vCookieName, vSelection, 90, '/');
  if (vCookieName == 'layout'){
  setActiveStyleSheet(vSelection)
  }else{
    self.location = self.location;
  }
}

function setActiveStyleSheet(pTitle) {
  var vLoop, vLink;
  for(vLoop=0; (vLink = document.getElementsByTagName("link")[vLoop]); vLoop++) {
    if(vLink.getAttribute("rel").indexOf("style") != -1 && vLink.getAttribute("title")) {
      vLink.disabled = true;
      if(vLink.getAttribute("title") == pTitle) vLink.disabled = false;
    }
  }
}

function checkStylesheet(){
  if (document.cookie.indexOf('style=')!=-1) {
    css = readCookie('style');
    //alert("STYLE: " + css);
    document.write('<style type="text/css" media="screen">@import "/stylesheets/' + css + '.css";</' + 'style>\n');
  }else{
    //alert("STYLE: Default");
    document.write('<style type="text/css" media="screen">@import "/stylesheets/notestips-style-original.css";</' + 'style>\n');
  }

  if (document.cookie.indexOf('layout=')!=-1) {
    css = readCookie('layout');  
    //alert("LAYOUT: " + css);
    setActiveStyleSheet(css)
  }else{
    //alert("LAYOUT: Default");
    setActiveStyleSheet("notestips-layout-3column")
  }
}






/* ***********************************

     COOKIE FUNCTIONS

   *********************************** */


function makeCookie(Name,Value,Expiry,Path,Domain,Secure){
  if (Expiry != null) {
    var datenow = new Date();
    datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
    Expiry = datenow.toGMTString();
  }

  Expiry = (Expiry != null) ? '; expires='+Expiry : '';
  Path = (Path != null)?'; path='+Path:'';
  Domain = (Domain != null) ? '; domain='+Domain : '';
  Secure = (Secure != null) ? '; secure' : '';

  document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
}


function readCookie(Name) {
  var cookies = document.cookie;
  if (cookies.indexOf(Name + '=') == -1) return null;
  var start = cookies.indexOf(Name + '=') + (Name.length + 1);
  var finish = cookies.substring(start,cookies.length);
  finish = (finish.indexOf(';') == -1) ? cookies.length : start + finish.indexOf(';');
  return unescape(cookies.substring(start,finish));
}


function cookies(){
  makeCookie('view_cookie',pagename,90,'/');
  makeCookie('database_cookie',database,90,'/');
  x = readCookie('type_cookie');
}





function deleteCookie(name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1000);
  var cval = readCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


/* ***********************************

     WEB POLL FUNCTIONS

   *********************************** */


  //FUNCTION
  function Doc_RecordVote(aRating){
    location.replace("/80256BE80083BF07/(web-agent)+vote?open&id=" + document.forms[0].Doc_Poll_ID.value + "&vote=" + aRating);
  }


  //FUNCTION
  function Doc_PollSubmit(){
    vForm = document.forms[0];
    var vErrors = new Array();
    CheckChecked(vErrors, vForm.Doc_Poll_Result,	"")
    CheckErrors(vErrors, vForm, 'Doc_RecordVote(getCheckedValue(document.forms[0].Doc_Poll_Result));');
    return false;
  }



/* ***********************************

     VALIDATION FUNCTIONS

   *********************************** */


  //FUNCTION  
  function getCheckedValue(aField){
    for (var r=0; r < aField.length; r++){
      if (aField[r].checked){return aField[r].value}
    }
  }

  //FUNCTION
  function CheckChecked(aErrors, aField, aMsg){	
    for (var r=0; r < aField.length; r++){
      if (aField[r].checked){var vChecked = "1"}
    }

    if (vChecked != "1"){
      aErrors[aErrors.length] = aMsg + "You must select an option to vote for"
      return false;
    }
  }

  //FUNCTION
  function CheckErrors(aErrors, aForm, aNoErrorAction){
    var vMsg = "";
    if(aErrors[0] == "" || aErrors[0] == null){
      deleteCookie('vote_cookie');
      makeCookie('vote_cookie2',"1",10,'/');
      eval(aNoErrorAction);
    }else{
      for (var i=0; i <= aErrors.length-1; i++){
      vMsg = vMsg + (i+1) + ". " + aErrors[i] + "\n";
    }
      alert("The following ERRORS were found...\n\n\n" + vMsg + "\n\nPlease correct these errors and re-submit.")
    }
    return false;
  }
