function bodyOnLoad(){
	initMenuByIDs('_mainMenu',	['_mm_01_area', 'null', '_mm_02_area', '_mm_02', '_mm_03_area', 'null', '_mm_04_area', '_mm_04', '_mm_05_area', '_mm_05'], 	false, true, false, 'menuMainItemL1Active', 0, true, 1000, true);
	initMenuByIDs('_mm_02', 	['_mm_02_01','null','_mm_02_02','null','_mm_02_03','null','_mm_02_04','null','_mm_02_05','null'], true, false, true, 'menuMainItemL2Active', 0, true, -1, true);
	initMenuByIDs('_mm_04', 	['_mm_04_01','null','_mm_04_02','null','_mm_04_03','null','_mm_04_04','null','_mm_04_05','null','_mm_04_06','null','_mm_04_07','null'], true, false, true, 'menuMainItemL2Active', 0, true, -1, true);
//	initMenu();	
	setAnchors();
}

// Info SubWindow Implementation
function alignToCenter(container,element){
	var width=element.offsetWidth;
	var height=element.offsetHeight;
	var left=Math.floor((container.offsetWidth/2)-(width/2));
	var top=Math.floor((container.offsetHeight/2)-(height/2));
	container.style.top=document.body.scrollTop;
	element.style.left=parseInt(left);
	element.style.top=parseInt(top);
}
function reAlignToCenter(){
	alignToCenter(getControlById("divInfoWindowContainer"),getControlById("divInfoWindow"));
}

function closeInfoWindow(){
	getControlById("divInfoWindowContainer").style.visibility="hidden";
	return false;
}

function showInfo(width, height, content){ // window variant
	infoCont=getControlById("divInfoWindowContainer");
	infoWind=getControlById("divInfoWindow");
	infoWind.innerHTML=content + '<p>&nbsp</p><p align="center"><input name="Close" type="button" value="Close"  onClick="closeInfoWindow();"></p>';
	alignToCenter(infoCont,infoWind);
	infoCont.style.visibility = "visible";
	window.onresize=reAlignToCenter;
	window.onscroll=reAlignToCenter;
}
// End of Info Subwindow Implemetation


function getControlById(id){
	if(document.all){
		return document.all[id];
	}else{
		return document.getElementById(id)
	}
}

function getControlHelper(controlId, helperSuffix) {
  return getControlDependentObj(controlId, "-hlp-", helperSuffix);
}

function getControlDependentObj(controlId, separator, suffix) {
  var dependentId = controlId + separator + suffix;
  var result = getControlById(dependentId);
  return result;
}

function __createHandlerFunction(owner, functionName, argString) {
  var argArray;
  var result;
  if (__createHandlerFunction.apply) {
    if (argString) {
      argArray = '[' + argString + ']';
    } else {
      argArray = 'arguments';
    }
    eval('result = function() { return arguments.callee.prototype.__owner.' + functionName + '.apply(arguments.callee.prototype.__owner,' + argArray + '); }');
  } else {
    var args = argString || '';
    eval('result = function() { return arguments.callee.prototype.__owner.' + functionName + '(' + args + '); }');
  }
  result.prototype.__owner = owner;
  return result;
}

function isSafari(){
  return checkBrowser('Safari');
}

function isMSIE() {
  return checkBrowser('MSIE') && !isOpera();
}

function isOpera() {
  return checkBrowser('Opera');
}

function isNetscape() {
  return checkBrowser('Netscape');
}

function isMozilla() {
  return checkBrowser('Mozilla') && !isOpera() && !isMSIE() && !isNetscape();
}

function checkBrowser(name) {
  return navigator.userAgent.indexOf(name) > -1;
}

function __getDocumentHeight() {
  if (isSafari())
    return self.innerHeight;
  else
    return document.body.clientHeight;
}

function showWindow(aLocation)
  {
	var infoWindow;
   if (infoWindow != null)
   {
    infoWindow.document.location = aLocation;
    infoWindow.focus();
   }
   else 
   {
     infoWindow = window.open(aLocation, "infoWindow", "scrollbars=1");
   }
}

function openInfoWindow(numWidth, numHeight, strLocation) {
	var popUpinfoWindow;
	if (popUpinfoWindow != null){
		popUpinfoWindow.document.location = strLocation;
		popUpinfoWindow.focus();
	}
	else {
		popUpinfoWindow = window.open(strLocation, "popUpinfoWindow", "scrollbars=1 resizable=1");
	}
	popUpinfoWindow.resizeTo(numWidth, numHeight);
}

function isViewletCompliant()
{
  answer=true;
  version=Math.round(parseFloat(navigator.appVersion) * 1000);
  if (navigator.appName.substring(0,9) == "Microsoft")
  {
    if(version<4000) answer=false;
  }
  if (navigator.appName.substring(0,8) == "Netscape")
  {
    if ((navigator.appVersion.indexOf("Mac")> 0) && (version<5000))
      answer=false;
    else
    if (version<4060)
      answer=false;
  }

  plugins=navigator.plugins;
  if (answer==false && plugins!=null)
  {
    for(i=0;i!=plugins.length;i++)
    if((plugins[i].name.indexOf("Java Plug-in")>=0) && (plugins[i].name.indexOf("1.0")<0))
    answer=true;
  }
  return answer;
}

function openViewlet(htmlFile,htmlWidth,htmlHeight)
{
  str = 'resizable=0,toolbar=0,menubar=0,';
  str = str + 'scrollbars=0,status=0,location=0,directory=0,width=350,height=200';

  version=Math.round(parseFloat(navigator.appVersion) * 1000);

  if(navigator.appName.indexOf("Konqueror")!=-1) // konqueror
  {
    htmlWidth+=18;
    htmlHeight+=96;
  }

  if(navigator.appName.indexOf("Netscape")!=-1)
  {
    if(version>=5000)
    {
      if(navigator.appVersion.indexOf("Mac")!=-1) // Netscape6+ on mac
      {
        htmlHeight+=5;
      }
    }
  }

  if(navigator.appName.indexOf("Microsoft")!=-1)
  {
    if(navigator.appVersion.indexOf("Mac")!=-1) // IE on Mac
    {
       htmlWidth  -= 11;
       htmlHeight -= 11;
    }
  }

    if(!isViewletCompliant())
    {
      open("http://www.qarbon.com/warning/index.html",'Leelou',str);
    }
    else
    {
      window.open(htmlFile,'Leelou','width='+htmlWidth+',height='+htmlHeight+',top=10,left=20');
    }

}

// Block Expander Implementation

var arrAnchs=new Array();
var arrBlocks=new Array();
var arrBlocksIsVisible=new Array();

function setAnchors(){
	var numAnchorCount = document.anchors.length;
//	alert ("expander init; Anchors Count: " + numAnchorCount);
	if(document.getElementById("blockExpandable" + (numAnchorCount-1))){
		for(var i=0; i<numAnchorCount; i++){
			anc=document.anchors[i];
			var ind=anc.name.substr(6,1);
			//anc.onClick="expandBlock("+ind+");"
			anc.href = "javascript:expandBlock("+ind+");";
			arrBlocks[ind]=document.getElementById("blockExpandable"+i);
			arrAnchs[ind]=anc;
			if(arrBlocks[ind].className=="visibleBlock"){
				arrBlocksIsVisible[ind]=true;
				anc.className="linkCollapse"
			}else{
				arrBlocksIsVisible[ind]=false;
				anc.className="linkExpand"
			}
		//alert ("Block - anchor found: " + ind + " -- " + arrBlocks[ind].id);
		}
	};
}

function expandBlock(ind){
//	alert("Anc = " + ind  + " === " + arrBlocks[ind].id);
	if(arrBlocksIsVisible[ind]){
		arrBlocks[ind].style.display = "none";
		arrBlocks[ind].className="hiddenBlock";
		arrAnchs[ind].className="linkExpand"
	}else{
		arrBlocks[ind].style.display = "block";
		arrBlocks[ind].className="visibleBlock";
		arrAnchs[ind].className="linkCollapse"
	}
	arrBlocksIsVisible[ind]=!arrBlocksIsVisible[ind];
}
