/************************************************************
 _____         _   __  __                  ____
|  ___|_ _ ___| |_|  \/  | ___ _ __  _   _|___ \
| |_ / _` / __| __| |\/| |/ _ \ '_ \| | | | __) |
|  _| (_| \__ \ |_| |  | |  __/ | | | |_| |/ __/
|_|  \__,_|___/\__|_|  |_|\___|_| |_|\__,_|_____|

* FastMenu2 - Dynamic HTML menus by Idan-Hadli
* FastCart2 / FastWeb2 / FastList2 Web application
* by Idan-Hadli
* ver 2.1.4 05/2007
*
*************************************************************
*    PLEASE NOTE, THIS SOFTWARE IS COPYRIGHT PROTECTED!     *
*************************************************************
*
* Copyright (c)1998-2008 Idan-Hadli
* All rights reserved.
* http://fastweb2.com | info@fastweb2.com
*
*************************************************************/

var timer;
//-----------------------------------------------
function hoovin(catid) {
	if (MENU_TD_USEBGRIMG == 1) {
		var myBkgSrt=document.getElementById(catid).style.backgroundImage;
		if (myBkgSrt.length > 0 ) {
			eval("document.getElementById('" + catid +"').style.backgroundImage='url(images/html_imges/"+ MENU_TD_BGHLIMG +")';fmClean('menu_" + catid + "');stoper();fastmenu('menu_" + catid + "',catid);");
		}
	}
	else {
		//alert(document.getElementById(catid).style.background);
		//var myBkgSrt=document.getElementById(catid).style.background;
		//if (myBkgSrt.length > 0 ) {
			eval("document.getElementById('" + catid +"').style.background='"+ MENU_TD_HLCOLOR2 + "';fmClean('menu_" + catid + "');stoper();fastmenu('menu_" + catid + "',catid);");
		//}
	}
}
//-----------------------------------------------
function hoovout(catid) {
	if (MENU_TD_USEBGRIMG == 1) {
		var myBkgSrt=document.getElementById(catid).style.backgroundImage;
		if (myBkgSrt.length > 0 ) {
			eval("document.getElementById('" + catid +"').style.backgroundImage='url(images/html_imges/"+ MENU_TD_BGREGIMG +")';");
		}
	}
	else {
		//var myBkgSrt=document.getElementById(catid).style.background;
		//if (myBkgSrt.length > 0 ) {
			eval("document.getElementById('" + catid +"').style.background='"+ MENU_TD_REGCOLOR2 + "';");
		//}
	}
}
//-----------------------------------------------
function buildHomeMenu(menu) {
	var myTopPos = 0;
	var myLeftPos = 0;
	var myTmenu="";

	if (myHomeMenu[menu]) {
		myTmenu = myTmenu + "<div onMouseOut=dotimeout('"+menu+"'); onMouseOver=stoper(); id='dt"+menu+"'><center><table border='0' cellspacing='"+MENU_TBL_CSPC+"' cellpadding='"+MENU_TBL_CPAD+"' width='"+MENU_TBL_WIDTH+"' dir='"+MENU_TD_DIR+"' id='" +menu +"' style='visibility: hidden; ;  padding: 0px 0px 0px 0px; position: absolute; left: " + myLeftPos + "px ; top: " + myTopPos + "px; z-index: 999' bgcolor='"+MENU_TBL_COLOR+"'>";
		for (i=0;i<myHomeMenu[menu].length;i++) {
			myTmenu += "<tr><td width='100%' style='"+MENU_TD_CUSTOMSTYLE+"' align='"+MENU_TD_ALIGN+"' valign='"+MENU_TD_VALIGN+"' bgcolor='"+MENU_TD_REGCOLOR+"' onMouseOver='this.style.background=\""+MENU_TD_HLCOLOR+"\"' onMouseOut='this.style.background=\""+MENU_TD_REGCOLOR+"\"' "+MENU_TD_NOWRAP+">";
			myTmenu += "<a href='" + myHomeMenuUrl[menu][i] + "' style='text-decoration: none'><span class='nav_simania' style='text-decoration: none'>" + myHomeMenu[menu][i]+ "</span></a></td></tr>";
		}
		myTmenu = myTmenu + "</table></center></div>";
		document.write(myTmenu);
	}
}
//-----------------------------------------------
function dotimeout(menu){
	if (menu) {
		timer = setTimeout("fmClean('" + menu + "')",110);
	}
}
//-----------------------------------------------
function dotimeout2(){
		timer = setTimeout("fastmenuClean()",110);
}
//-----------------------------------------------
function stoper() {
	clearTimeout(timer);
}
//-----------------------------------------------
function fastmenuCleanOthers(menu) {
	if (myHomeMenu[menu]) {
		for (g=0;g<myHomeMenu.length;g++) {
			if (myHomeMenu[g] != myHomeMenu[menu]) {
				document.getElementById(myHomeMenu[g]).style.visibility = "hidden";
			}
		}
	}
}
//-----------------------------------------------
function fastmenuClean() {
	if (myHomeMenu.length > 0) {
		for (g=0;g<myHomeMenu.length;g++) {
			document.getElementById(myHomeMenu[g]).style.visibility = "hidden";
		}
	}
}
//-----------------------------------------------
function fmClean(menu) {
	if (myHomeMenu[menu]) {
		document.getElementById(menu).style.visibility = "hidden";
	}
}
//-----------------------------------------------
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
//-----------------------------------------------
function fastmenu(menu,catid) {
	if (MENU_TYPE == "V" ) {
		if (document.getElementById(menu)) {
			document.getElementById(menu).style.left = findPosX(document.getElementById(catid))- MENU_TBL_WIDTH + MENU_LEFT_OFFSET;
			document.getElementById(menu).style.top = findPosY(document.getElementById(catid)) + MENU_TOP_OFFSET;
			document.getElementById(menu).style.visibility = "visible";
		}
	}
	else {
		if (document.getElementById(menu)) {
			document.getElementById(menu).style.left = findPosX(document.getElementById(catid))-(MENU_TBL_WIDTH-document.getElementById(catid).offsetWidth) + MENU_LEFT_OFFSET;
			document.getElementById(menu).style.top = findPosY(document.getElementById(catid)) + document.getElementById(catid).offsetHeight + MENU_TOP_OFFSET;
			document.getElementById(menu).style.visibility = "visible";
		}
	}
}
//-----------------------------------------------
function getwSize() {
  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;
  }
  return myWidth;
}
//-----------------------------------------------
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }
//-----------------------------------------------
  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
//----------------------------------------------- 
