

function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "00";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}



function Clicked_Hidden_Element (oThis, DivToMakeVisible, saOtherElementsToHide, saOtherElementsToUnBold)  
{
    this.Hide_nonClicked_Elements(saOtherElementsToHide);
    this.UnBold_nonClicked_Elements(saOtherElementsToUnBold);
    var oSaveAsObjectDiv = document.getElementById(DivToMakeVisible);
    oSaveAsObjectDiv.style.display = (oSaveAsObjectDiv.style.display == '')  ? 'none' : '';

    oThis.style.fontWeight = (oSaveAsObjectDiv.style.display == '')  ? 'bold' : '';
}   
 
function Clicked_Hidden_Element_NoClickClose (oThis, DivToMakeVisible, saOtherElementsToHide, saOtherElementsToUnBold)  
 {
    this.Hide_nonClicked_Elements(saOtherElementsToHide);
    this.UnBold_nonClicked_Elements(saOtherElementsToUnBold);
    var oSaveAsObjectDiv = document.getElementById(DivToMakeVisible);
    oSaveAsObjectDiv.style.display = (oSaveAsObjectDiv.style.display == '')  ? '' : '';
    
    oThis.style.fontWeight = (oSaveAsObjectDiv.style.display == '')  ? 'bold' : '';
    
 } 
 

   
function Hide_nonClicked_Elements (sElementsToHide)  
{
    if (sElementsToHide != null && sElementsToHide != "")
    {
        aElementsToHide = sElementsToHide.split(",");
        for (var i = 0; i < aElementsToHide.length; i++)
        {
            var Obj = document.getElementById(aElementsToHide[i]);
            Obj.style.display = (Obj.style.display == '')  ? 'none' : 'none'; // hide all
        }
    }
} 

function UnBold_nonClicked_Elements (sElementsToHide)  
{
    if (sElementsToHide != null && sElementsToHide != "")
    {
        aElementsToHide = sElementsToHide.split(",");
        for (var i = 0; i < aElementsToHide.length; i++)
        {
            var Obj = document.getElementById(aElementsToHide[i]);
            Obj.style.fontWeight = ''; 
        }
    }
} 



//+-------------------------------------------------------------
//| Object type editableString is a string that can be edited with
//| a number of useful methods contained below.
//+-------------------------------------------------------------
function EditableString(str) {
this.data = str;
}

//+-------------------------------------------------------------
//| replaceAll replaces all source strings with destination strings,
//| returning a new EditableString containing the result.
//+-------------------------------------------------------------
EditableString.prototype.replaceAll = function (srcStr, dstStr) {
this.pat = new RegExp(srcStr,"g");
var newStr = this.data.replace (this.pat, dstStr);
return new EditableString(newStr);
} 


function GetWidth()
{

var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  return myWidth;

}

function GetHeight()
{
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  return myHeight;

}


function addJavascript(jsname,pos) {
	var th = document.getElementsByTagName(pos)[0];
	var s = document.createElement('script');
	s.setAttribute('type','text/javascript');
	s.setAttribute('src',jsname);
	th.appendChild(s);
	} 

function AddEvent(obj, eventType, functionName)
{
    if (obj.addEventListener)
    {
        obj.addEventListener(eventType, functionName, false);
        return true;
    }
    else if (obj.attachEvent)
    {
        var r = obj.attachEvent("on"+eventType, functionName);
        return r;
    }
    else
    {
        return false;
    }
}



function getCheckedValue(radioObj) {
    if(!radioObj)
        return "";
    var radioLength = radioObj.length;
    if(radioLength == undefined)
        if(radioObj.checked)
            return radioObj.value;
        else
            return "";
    for(var i = 0; i < radioLength; i++) {
        if(radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}




function Utility_Get_ScreenSize() 
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  
  return {"Height" : myHeight, "Width": myWidth};
}

function Utility_Get_PageSize() 
{
  if ( window.innerHeight && window.scrollMaxY ) // Firefox 
  {
	pageWidth = window.innerWidth + window.scrollMaxX;
	pageHeight = window.innerHeight + window.scrollMaxY;
  }
  else 
    if ( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
		else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{ 
		pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
  
  return {"Height" : pageHeight, "Width": pageWidth};
}


function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
		
		return {"Left": curleft, "Top": curtop};
	}
	else
		return {"Left": 0, "Top": 0};
	
}
	
	
	
	