function Buttonon(imag){
	document[imag].src = eval(imag+"on.src");
}

function Buttonoff(imag){
	document[imag].src = eval(imag+".src");
}

function ButtonAll(arr,imag){
//alert(arr,imag);
if (arr == 1){
	Buttonoff('hatar');
	Buttonoff('phons1');
	Buttonoff('phons');
	}else if(arr == 2) {
	Buttonoff('nose');
	//Buttonoff('modahot');
	Buttonoff('mivzakim');
	Buttonoff('hadash');
	}else if(arr == 3){
	Buttonoff('hatare');
	Buttonoff('hatarim');
	Buttonoff('clicke');
	}
	Buttonon(imag);
}




if(document.images){


// *********** Buttons On ********************************
			
            
			hataron = new Image();
            hataron.src= "images/buttons/b_hatar_on.gif";
			phons1on= new Image()
            phons1on.src= "images/buttons/b_phons1_on.gif"
			phonson= new Image()
            phonson.src= "images/buttons/b_phons_on.gif"
			noseon = new Image();
			noseon.src= "images/buttons/nose_on.gif"
//			modahoton = new Image();
//			modahoton.src= "images/buttons/b_modahot_on.gif"
			mivzakimon = new Image();
            mivzakimon.src= "images/buttons/b_mivzakim_on.gif";
			hadashon = new Image();
            hadashon.src= "images/buttons/b_ma_hadash_on.gif";
			hatareon = new Image();
            hatareon.src= "images/buttons/b_hatare_on.gif";
			hatarimon = new Image();
            hatarimon.src= "images/buttons/b_hatarim_on.gif";
			clickeon = new Image();
            clickeon.src= "images/buttons/b_click_on.gif";


		    
			hatar = new Image();
            hatar.src= "images/buttons/b_hatar.gif";
			phons1 = new Image();
		    phons1.src= "images/buttons/b_phons1.gif";
			phons = new Image();
		    phons.src= "images/buttons/b_phons.gif";
			nose = new Image();
            nose.src= "images/buttons/nose.gif";
//			modahot = new Image();
//            modahot.src= "images/buttons/b_modahot.gif"
			mivzakim = new Image();
            mivzakim.src= "images/buttons/b_mivzakim.gif";
			hadash = new Image();
            hadash.src= "images/buttons/b_ma_hadash.gif";
			hatare = new Image();
            hatare.src= "images/buttons/b_hatare.gif";
			hatarim = new Image();
            hatarim.src= "images/buttons/b_hatarim.gif";
			clicke= new Image();
            clicke.src= "images/buttons/b_click.gif";
	}			



/** Expanding Menu Routines **/

var lineHeight = 20;
var steps = 5;
var delay = 1;
var curExpandedNode = null;
var canvasRef   = null;
var canvasRef1  = null;
var inMotion    = false;
var inMotion1   = false;
var curTimeout  = null;
var curTimeout1 = null;


function Underline(underline)
{
	if (underline)
		event.srcElement.style.textDecoration = "underline";
	else
		event.srcElement.style.textDecoration = "";
}


function Expand()
{
       
	var cr = canvasRef;
	var numItems  = cr.children.length;
	var maxHeight = numItems * lineHeight;
	var nextStep  = Math.round(maxHeight / steps) + (((maxHeight % steps) > 0) ? 1 : 0);
	var counter;


	if (nextStep < 1)
		nextStep = 1;

	if (!inMotion)
	{
		cr.style.pixelHeight = 1;
		cr.style.display	 = "inline";
	}

	if (cr.style.pixelHeight + nextStep >= maxHeight)
	{
		
		clearTimeout(curTimeout);
		curTimeout = null;

		delta = cr.style.pixelHeight + nextStep - maxHeight;
		cr.style.pixelHeight = maxHeight;
		cr = cr.parentElement.parentElement;

		while (cr.tagName.toUpperCase() == "DIV")
		{
			cr.style.pixelHeight = cr.children.length * lineHeight + maxHeight;
			maxHeight = cr.style.pixelHeight;
			cr = cr.parentElement.parentElement;
		}

		inMotion = false;
	}
	else
	{

		cr.style.pixelHeight += nextStep;
		cr = cr.parentElement.parentElement;

		while (cr.tagName.toUpperCase() == "DIV")
		{
			cr.style.pixelHeight += nextStep + 1;
			cr = cr.parentElement.parentElement;
		}

		curTimeout = setTimeout("Expand();",delay);
		inMotion = true;
	}
}


function Shrink()
{
	var cr = canvasRef1;
	var numItems  = cr.children.length;
	var maxHeight = numItems * lineHeight;
	var nextStep  = Math.round(maxHeight / steps);
	var counter;


	if (nextStep < 1)
		nextStep = 1;

	if (!inMotion1)
	{
		cr.style.pixelHeight = maxHeight;
		cr.style.display     = "inline";
	}

	if (cr.style.pixelHeight - nextStep <= 1)
	{
		clearTimeout(curTimeout1);
		curTimeout1 = null;

		cr.style.display = "none";
		cr.style.pixelHeight = 1;
		CloseInner(cr);

		cr = cr.parentElement.parentElement;

		while (cr.tagName.toUpperCase() == "DIV")
		{
			cr.style.pixelHeight -= maxHeight;
			cr = cr.parentElement.parentElement;
		}

		inMotion1 = false;
	}
	else
	{
		cr.style.pixelHeight -= nextStep;
		curTimeout1 = setTimeout("Shrink();",delay);
		inMotion1 = true;
	}
}


function CloseInner(cr)
{
	var counter;
	var curCR = cr;
	var curCanvas;


	curCR = curCR.parentElement.parentElement;

	while (curCR.tagName == "DIV")
	{
		if (curCR.children.length == 0)
		{
			curCR.style.display = "none";
			curCR.style.pixelHeight = 1;
		}
		//else
		//	curCR.style.pixelHeight = curCR.children.length * lineHeight;

		curCR = curCR.parentElement.parentElement;
	}

	if (cr.children.length == 0)
		return;

	for (counter = 0; counter < cr.children.length; counter++)
		if (cr.children[counter].className.toUpperCase().indexOf("TREEMENU") > -1)
		{
			CloseInner(cr.children[counter].children[1]);
			cr.children[counter].children[1].style.display = "none";
			cr.children[counter].children[1].style.pixelHeight = 1;
			cr.children[counter].children[0].style.fontWeight  = "";
		}
}



function ExpandMenu()
{
	var counter;
	var closeCanvas = null;
	var findCanvas  = null;
	

    
	if (inMotion || inMotion1)
		return;
	    //return "1";

	curExpandedNode = event.srcElement.parentElement.parentElement;
	
	if (typeof(curExpandedNode.link) == "undefined")
		return;
	    //return "2";

	if (curExpandedNode.link.length > 0 && curExpandedNode.children[1].children.length == 0)
	{
		if (curExpandedNode.link.charAt(0) == ",")
			window.open(curExpandedNode.link.substr(1),"","scrollbars=1,width=750,height=600,status=1,toolbar=1,location=1,menubar=1,resizable=1");
		else
			location = curExpandedNode.link + "?boneID=" + curExpandedNode.linkID +
					   ((curExpandedNode.show == "1") ? "&subs=1" : "");
		return;
		//return "3";
	}
	
	if (curExpandedNode.children[1].style.display == "inline")
	{
		curExpandedNode.children[0].style.fontWeight = "";
		canvasRef1 = curExpandedNode.children[1];
		Shrink();
		return;
		//return "4";
	}

	closeCanvas = curExpandedNode.parentElement.children;

	for (counter = 0; counter < closeCanvas.length; counter++)
		if (closeCanvas[counter].className.toUpperCase().indexOf("TREEMENU") != -1)
			if (closeCanvas[counter].children[1].style.display == "inline")
			{
				closeCanvas[counter].children[0].style.fontWeight = "";
				canvasRef1 = closeCanvas[counter].children[1];
				Shrink();
				break;
			}

	findCanvas = curExpandedNode.children;

	for (counter = 0; counter < findCanvas.length; counter++)
		if (findCanvas[counter].className.substr(0,6).toUpperCase() == "CANVAS")
		{
			if (findCanvas[counter].children.length > 0)
				if (findCanvas[counter].style.display == "inline")
					findCanvas[counter].style.display = "none";
				else
				{
					curExpandedNode.children[0].style.fontWeight = "bold";
					canvasRef = findCanvas[counter];
					Expand();
				}

			break;
		}
		
		//return "5";
}


function FindCatID(container,catID)
{

	var counter;
	var childs	  = container.children;
	var curCanvas = null;
	var add = 0;
   
   
	for (counter = 0; counter < childs.length; counter++)
		if (childs[counter].linkID == catID)
		{
		    
			curCanvas = childs[counter].parentElement;

			while (curCanvas.tagName == "DIV")
			{
				curCanvas.parentElement.children[0].style.fontWeight = "bold";
				curCanvas.style.pixelHeight = curCanvas.children.length * lineHeight + add;
				add = curCanvas.style.pixelHeight;
				curCanvas.style.display = "inline";
				curCanvas = curCanvas.parentElement.parentElement;
			}
			
			break;
		}
		else

			FindCatID(childs[counter],catID);
}


function RestoreMenu(catID)
{    
	if (catID.length > 0)
		FindCatID(menuContainer,catID);
}
