/* Miscellaneous collection of Javascript functions
 * for the Net10 site
 *
 * Author: Martin Bunen (martin.bunen@brightpoint.com)
 */
function openPopupWindow(url,toolbar,width,height,scrollbars,resizeable)
{
  winprops = "toolbar="+toolbar+",width="+width+",height="+height+",directories=0,status=0,scrollbars="+scrollbars+",resizeable="+resizeable+",menubar=0,location=0,copyhistory=0,fullscreen=0'"
  win = window.open(url,'',winprops);
}

/**
  * Prints current page
  */
function printPage()
{
  window.print();
}

/**
  * Opens a separate browser window in the left upper corner
  * with the specified URL
  *
  * @param url - the URL to open in the window
  * @param width - width of the window (default of 580 is used if not specified)
  * @param height - height of the window (default of 400 is used if not specified)
  */
function openWin(url,width,height)
{
  var winWidth;
  var winHeight;

  if(width)
  {
    winWidth=width;
  }
  else
  {
  	winWidth='780';
  }

  if(height)
  {
  	winHeight=height;
  }
  else
  {
  	winHeight='400';
  }

  var W = window.open(url,"","toolbar=no,width="+winWidth+",height="+winHeight+",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no,copyhistory=no")
}

/**
  * Rounds num to the dec points
  *
  * @param num - the number to be rounded
  * @param dec - the number of decimal points to be rounded to
*/
function round(num,dec)
{
  var rounded = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  return (rounded ==Math.floor(rounded)) ? rounded + '.00' : rounded;
}




/**
  * Checks if the strString is a number or not
  * @param strString - the value being tested
  *
 */
function isNumeric(strString)
{
  var strValidChars = "0123456789";
  var strChar;
  var result = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && result == true; i++)
  {
    strChar = strString.charAt(i);
    if (strValidChars.indexOf(strChar) == -1)
    {
       result = false;
    }
  }
    return result;
 }
var majorVersion = parseInt(navigator.appVersion);
var browser = navigator.appName;


function midScreenScroll(URL,winName,winW,winH,resize){ // puts the pop up in the middle of the screen
	halfW = screen.width/2;
	halfH = screen.height/2;
	newwin = window.open(URL,winName,'left='+parseInt(halfW-(winW/2))+',top='+parseInt(halfH-(winH/2)-40)+',width=' + winW + ',height=' + winH + ',scrollbars=1,menubar=0,statusbar=0,favorites=0,resizable=' + resize);
}

function MenuControl () { this.last=null; this.t=null; }
MenuControl.prototype.set = function(objId) {
	if (this.last != null && this.last != objId) document.getElementById(this.last).className='subMenu';
	clearTimeout(this.t);
	document.getElementById(objId).className = "subMenu active";
}
MenuControl.prototype.close = function (objId) {this.last = objId; this.t = setTimeout("document.getElementById('"+objId+"').className='subMenu'",1000); }
var DropMenu = new MenuControl();

function setInputText (obj) {
	if (obj.msg == null) { obj.msg = obj.value; }
	if (obj.value == "" && obj.msg != null) obj.value = obj.msg;
	else if (obj.value == obj.msg) obj.value = "";
}
