/*
* BEGIN MSM CODE
*
* Copyright (c) 2003 MindShare Management LLC
* All rights reserved
*
*/

/*
 * BEGIN doNothing dummy routine
*/

function doNothing() {}

/*
 * END doNothing dummy routine
 *
 * BEGIN mouse position handler global variables
*/
var navName = navigator.appName;
var navVers = parseInt(navigator.appVersion);

var xMousePos = 0;    // Horizontal position of the mouse on the screen
var yMousePos = 0;    // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page
var xPagePos = 0;     // Mouse position relative to page
var yPagePos = 0;     // Mouse position relative to page

if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
/*
 * END mouse position handler global variables
 * 
 * BEGIN mouse position handler
*/
function captureMousePosition(e) {
if (document.layers) {
  // NN4
    //xPagePos = e.pageX+window.screenX; //(gets page location no matter scroll)
    //yPagePos = e.pageY+window.screenY;
    xPagePos = e.pageX;
    yPagePos = e.pageY;
    xMousePos = e.screenX;
    yMousePos = e.screenY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
  } else if(document.all) {
    if (navName=="Konqueror") {
      //xPagePos = window.event.x+document.body.scrollLeft+window.screenX; // (gets page location no matter scroll)
      //yPagePos = window.event.y+document.body.scrollTop+window.screenY;
      xPagePos = window.event.x;
      yPagePos = window.event.y;
      xMousePos = window.event.x+window.screenX;
      yMousePos = window.event.y+window.screenY;
    } else {
      //IE4+
      //xPagePos = window.event.x+document.body.scrollLeft+window.screenLeft; // (gets page location no matter scroll)
      //yPagePos = window.event.y+document.body.scrollTop+window.screenTop;
      xPagePos = window.event.x;
      yPagePos = window.event.y;
      xMousePos = window.event.x+window.screenLeft;
      yMousePos = window.event.y+window.screenTop;
    }
    xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
    yMousePosMax = document.body.clientHeight+document.body.scrollTop;
  } else if (document.getElementById) {
    //NN6+
    //xPagePos = e.pageX+window.screenX; //(get page location no matter scroll)
    //yPagePos = e.pageY+window.screenY;
    xPagePos = e.pageX;
    yPagePos = e.pageY;    
    xMousePos = e.screenX;
    yMousePos = e.screenY;
    xMousePosMax = window.innerWidth+window.pageXOffset;
    yMousePosMax = window.innerHeight+window.pageYOffset;
  }
}
/*
 * END mouse position handler
 *
 * BEGIN general use auxilary url window
*/

function urlWin(url,w,h) {
  // close window if it already exists
  // if(top.auxGen) {top.auxGen.close()}

  // Get Mouse position from handler
  var winl = xMousePos - (w/2);
  var wint = yMousePos - (h/2);
  var winprops = 'height='+h+',width='+w+',top='+wint+',left=';
  winprops += winl+',wrap,scrollbars=yes';

  auxUrl = window.open(url,'auxUrl',winprops);
  if (parseInt(navigator.appVersion) >= 4) { auxUrl.window.focus(); }
}
/*
 * END general use auxilary url window
 *
 * BEGIN general use auxilary window
*/

function auxWin(name,w,h,content) {
  // close window if it already exists
  // if(top.auxGen) {top.auxGen.close()}

  // Get Mouse position from handler
  var winl = xMousePos - (w/2);
  var wint = yMousePos - (w/2);
  var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',wrap,scrollbars=yes';
  var locate = document.location;
  auxGen = window.open('','',winprops);
  //  if (!auxwin.opener) auxwin.opener = self;
  with (auxGen.document) {
    writeln('<html><head><title>MindShare Management LLC:: '+name+'</title>');
    writeln('<script type=\'text/javascript\'>');
    writeln('function doNothing() {}');
    writeln('</script></head>');
    writeln('<link rel=stylesheet href="/lc/lib/standard.css">');
    writeln('</head>');
    writeln('<body bgcolor="#ffffff"><form name=form>');
    writeln(content);
    writeln('<div align="right">');
    writeln('<input type=button value="Close" onClick="if(opener.document.location !=\'' + locate + '\') { opener.document.location=\'' + locate + '\'}; self.close();">');
    writeln('</div>');
    writeln('</form></body></html>');
    close();
  }
  if (parseInt(navigator.appVersion) >= 4) { auxGen.window.focus(); }
}

/*
 * END general use auxilary window
 *
 *
 * BEGIN higlight a selection of css elements.
 *  obj is the object which holds the value of the old highlighted
 *      row.  It is reset to a dull color.
 *  new_id is the base_id of the css elements, where the elements
 *      have id's of the form "srow<base_id>_<n>"
 *  num is the number of elements to highglight.
 * Thus, if the input is (document.forms[0].oldrow,K,3),
 *  assuming oldrow.value = J:
 * - elements with ids of srowJ_0, srowJ_1, srowJ_2, srowJ_3
 *   will be reset to the dull color
 * - elments with ids of srowK_0 .. srowK_3 will have their
 *   background color highlighted
*/

function hlight(obj,new_id,num) {
  var old_id = obj.value;
  var o_base = 'srow' + old_id.toString() + '_';
  var n_base = 'srow' + new_id.toString() + '_';
  for ( var j=0; j<=num; j++ ) {
    o_elmnt = o_base + j.toString();
    n_elmnt = n_base + j.toString();
    document.getElementById(o_elmnt).style.backgroundColor="#cbcfbc";
    document.getElementById(o_elmnt).style.fontWeight="normal";    
    document.getElementById(n_elmnt).style.backgroundColor="#eef2de";
    document.getElementById(n_elmnt).style.fontWeight="bold"; 
    obj.value=new_id;
  }
}

/*
 * END hlight
 *
 * BEGIN showDiv
*/

  function showDiv(whichDiv) {
    if (document.getElementById) {
      document.getElementById(whichDiv).style.visibility='visible';
    } else if (document.layers) {
      document.layers[whichDiv].visibility='show';
    } else {
      document.all[whichDiv].style.visibility='visible';
    }
  }

/*
 * END showDiv
 *
 * BEGIN hideDiv
*/

  function hideDiv(whichDiv) {
    if (document.getElementById) {
      document.getElementById(whichDiv).style.visibility='hidden';
    } else if (document.layers) {
      document.layers[whichDiv].visibility='hidden';
    } else {
      document.all[whichDiv].style.visibility='hidden';
    }
  }

/*
 * END hideDiv
 *
 * BEGIN writeDiv
*/
  // the parentID is required for ns4.  It can be safely set to null
  // unless the div is nested, in which case it should be set to the name
  // of the parent div.  This, of course, should be avoided.
  // sText can be the content, or an eval-able javascript function, e.g.
  // Date()
  // Of course, sText must be Url escaped...
  // Mucho thanks to http://www.sitepoint.com/article/1024
  function writeDiv(ID,parentID,sText) {
    if (document.layers) {
        var oLayer = (parentID)? eval('document.' + parentID + '.document.' + ID + '.document') : document.layers[ID].document;
        oLayer.open();
        oLayer.write(sText);
        oLayer.close();
      }
      else if (document.all) document.all[ID].innerHTML = sText
      else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
        document.getElementById(ID).innerHTML = sText;
      }
  }

  function moveDiv(ID,parentID,xPos,yPos) {
    if (document.layers) {
        var oLayer = (parentID)? eval('document.' + parentID + '.document.' + ID + '.document') : document.layers[ID].document;
        oLayer.top=yPos;
        oLayer.left=xPos;
      }
      else if (document.all) {
        document.all[ID].style.posTop=yPos;
        document.all[ID].style.posLeft=xPos;
      }
      else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
        document.getElementById(ID).style.top=yPos;
        document.getElementById(ID).style.left=xPos;
      }
  }
/*
 * END writeDiv
 *
 * BEGIN showTipDiv
*/
  function showTipDiv(sText) {
    hideDiv('div_tip');
    writeDiv('div_tip',null,sText);
    moveDiv('div_tip',null,xPagePos,yPagePos);
    showDiv('div_tip');
  }
/*
 * END writeDiv
 *
 * BEGIN hideTipDiv
*/

  function hideTipDiv() {
    hideDiv('div_tip');
  }

/*
 * END hideTipDiv
 *
 * BEGIN showWinDiv
*/
  function showWinDiv(title,sText,w,h) {
    if (document.layers) {
      var oLayer = document.layers['div_tip'].document;
      oLayer.width=w;
      // oLayer.height=h;
    } 
    else if (document.all) {
      document.all['div_tip'].style.width=w;
      // document.all['div_tip'].style.height=h;
    } 
    else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
      document.getElementById('div_tip').style.width=w;
      // document.getElementById('div_tip').style.height=h;
    }
    var myText = '<table cellspacing="0" width="100%"><tr>';
    myText += '<td style="background-color:#ffffff; text-align: left; width:5%">'
    myText += '<a href="javascript:hideTipDiv()">';
    myText += '<img src="/images/x.gif" style="width:16px; height:14px; border:0;"></a></td>';
    myText += '<td style="background-color: #ffffff; ';
    myText += 'border: 0; padding:3px; top:0; left:0; ';
    myText += 'font-family: arial,helvetica,verdana,sans serif; ';
    myText += 'font-size: 14px; font-weight: bold; color: #ab7923; ';
    myText += 'width: 90%; text-align: center">';
    myText += title + '</td>';
    myText += '<td style="background-color:#ffffff; text-align: right; width:5%">'
    myText += '<a href="javascript:hideTipDiv()">';
    myText += '<img src="/images/x.gif" style="width:16px; height:14px; border:0;"></a></td></tr>';
    myText += '<tr><td colspan="2" style="padding: 5px; padding-bottom:15px">'
    myText += sText + '</td></tr></table>';
    hideDiv('div_tip');
    writeDiv('div_tip',null,myText);
    moveDiv('div_tip',null,xPagePos-10,yPagePos-10);
    showDiv('div_tip');
   }
    
/*
 *
 * END MSM CODE
*/
