var __logon_info = null; //will always be set in header.jsp or header_home.jsp. if not login, it remains null, or will be LogonInfo object
var __host_id = null; //the visited host id

function getOS(){
   if(navigator.userAgent.indexOf("MSIE")>0)return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2;
   if(isSafari=navigator.userAgent.indexOf("Opera")>0)return 3;
   if(isSafari=navigator.userAgent.indexOf("Netscape")>0)return 4;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 5;  
   if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 6;
   if(isMozilla=navigator.userAgent.indexOf("Gecko")>0)return 7;
   return 0;
}

/*used to auto resize the height of the iframe*/
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]  
var FFextraHeight=getFFVersion>=0.1? 16 : 0   
function dyniframesize(iframename) {  
  var pTar = null;  
  if (document.getElementById) {  
    pTar = document.getElementById(iframename);  
  } else {
    eval('pTar = ' + iframename + ';');  
  }  
  
  if (pTar && !window.opera){  
    //begin resizing iframe  
    pTar.style.display="block"  
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){  
      //ns6 syntax  
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;   
    } else if (pTar.Document && pTar.Document.body.scrollHeight){  
      //ie5+ syntax  
      pTar.height = pTar.Document.body.scrollHeight + 30;  
    }  
  }  
}
/* END OF used to auto resize the height of the iframe*/


function removeBlankChildNode(obj){
	var list = obj.childNodes;
    var size = list.length;
    
    for (var i = size - 1; i >= 0; i-- ){
        if ( list[i].nodeType == 3
        || list[i].nodeType == 8)
            obj.removeChild(obj.childNodes[i]);
    }
}

var $j;

String.prototype.trim=function()
{
	return this.replace(/(^\s*)|(\s*$)/g,"");
}

function openRoom(url){
	popupDialog(url);
	//var feature = "dialogWidth:"+width+"px;dialogheight:"+height+"px;dialogLeft:"+left+"px;dialogTop:"+top+"px;scroll:no;status:no;help:no;resizable:no"
	//window.open(url,"classroom","");
}

function popupDialog(url){ 
    var x = 0;  
    var y = 0; 
    var isMSIE= (navigator.appName == "Microsoft Internet Explorer");
    if (isMSIE) {           
         window.open(url, "", "width="+screen.availWidth+",height="+screen.availHeight+",left="+x+",top="+y+",status=no,directories=no,scrollbars=no,resizable=no"  ); 
     } else { 
        window.open(url, "", "top=" + y + ",left=" + x + ",scrollbars=no,dialog=no,modal=no,width=" + screen.availWidth + ",height=" + screen.availHeight + ",resizable=no" ); 
        //eval('try { win.resizeTo(width, height); } catch(e) { }'); 
       // win.focus();             
    } 
}

/**
 * add replaceAll capability to String
 */
String.prototype.replaceAll = stringReplaceAll;

function stringReplaceAll (findText, repText){
  var reg = new RegExp(findText,"g");
  return this.replace(reg, repText);
}

/**
 * add trim capability to String
 */
String.prototype.trim = function(){  
    return this.replace(/(^\s*)|(\s*$)/g, "");  
}

/**
 * add remove capability to Array
 * @param array
 * @param attachId
 * @return
 */
function removeArray (array, attachId) {
    for (var i = 0, n = 0; i < array.length; ++i) {
        if (array[i] != attachId) {
            array[n++] = array[i]
        }
    }
    array.length -= 1;
    return array;
}
Array.prototype.remove = function (obj) {
    return removeArray(this, obj);
};
