var activeMenu = 0;
/*
function activateMenu(menuLayerRef, top, left,imgObject) {

 // if (activeMenu != menuLayerRef) {
	 if (activeMenu) hideMenu("menu" + activeMenu); 
	menuID = "menu" + menuLayerRef;
	activeMenu = menuLayerRef;
	hideMenu(menuID);

	if (top!=0){
		document.getElementById(menuID).style.top = top +"px";
	}
	if (left!=0){
		document.getElementById(menuID).style.left = left +"px"; 
	}
    showMenu(menuID)
   //}
}
	
function showMenu(layerID) {
	document.getElementById(layerID).style.visibility = "visible";
	document.getElementById(layerID).style.zIndex= "10";
}
function hideMenu(layerID) {
	document.getElementById(layerID).style.visibility = "hidden";
}

// check if there's a menu active
function turnOff() {
	if (activeMenu) {
		menuID = "menu" + activeMenu;
		hideMenu(menuID);
		activeMenu = 0;
	}
}

//document.body.onclick = hideMenu(menu_321);
//document.body.onmouseup=turnOff();
//document.getElementsByTagName("body").onclick = turnOff;
document.body.onclick = turnOff;


function getTop(oElement)
{
// returns the y coordinate of an HTML element, 
// even if the element's position was not explicitly set.
var tempY = 0;
var tempObj = oElement;
while (tempObj.offsetParent)
	{
	tempY += tempObj.offsetTop;
	tempObj = tempObj.offsetParent;
	}
return(tempY);
}

function getLeft(oElement)
{
// returns the y coordinate of an HTML element, 
// even if the element's position was not explicitly set.
var tempY = 0;
var tempObj = oElement;
while (tempObj.offsetParent)
	{
	tempY += tempObj.offsetLeft;
	tempObj = tempObj.offsetParent;
	}
return(tempY);
}
*/


/*yifat 29/12/2005*/
function buildSelectPage(pageCounter,currentSeg){
header_pageSelector=document.getElementById("header_pageSelector");
footer_pageSelector=document.getElementById("footer_pageSelector");
if (pageCounter==0)	pageCounter=1;

		var currentSeg = parseInt(currentSeg);
		for(i=1;i<=pageCounter;i++){
			p=i-1;
			header_pageSelector.options[i-1] = new Option(i ,i);
			footer_pageSelector.options[i-1] = new Option(i ,i);
		}
if (header_pageSelector.options[currentSeg-1]!=null)	header_pageSelector.options[currentSeg-1].selected=true;
if (header_pageSelector.options[currentSeg-1]!=null)footer_pageSelector.options[currentSeg-1].selected=true;

		//build next Segment href
		headerNextPageSelector=document.getElementById("header_next_pageSelector");
		footerNextPageSelector=document.getElementById("footer_next_pageSelector");

		if (headerNextPageSelector!=null)	headerNextPageSelector.style.display='none';
		if (footerNextPageSelector!=null)	footerNextPageSelector.style.display='none';

		ForumSegId=currentSeg+1;
		if (currentSeg<pageCounter){
				next_pageSelector="javascript:gotoPage('"+ForumSegId+"')";


			if (headerNextPageSelector!=null){
				headerNextPageSelector.href=next_pageSelector;
				headerNextPageSelector.style.display='';
			}
			if (footerNextPageSelector!=null){
				footerNextPageSelector.href=next_pageSelector;
				footerNextPageSelector.style.display='';
			}
		}
		//build prev Segment href
		
		headerPrevPageSelector=document.getElementById("header_prev_pageSelector");
		footerPrevPageSelector=document.getElementById("footer_prev_pageSelector");

		if (headerPrevPageSelector!=null) headerPrevPageSelector.style.display='none';
		if (footerPrevPageSelector!=null) footerPrevPageSelector.style.display='none';


		var IsPrevSeg=0;
		prevSeg=currentSeg-1;

			if (currentSeg>1){
				prev_pageSelector="javascript:gotoPage('"+prevSeg+"')";
			

			if (headerPrevPageSelector!=null) {
				headerPrevPageSelector.href=prev_pageSelector;
				headerPrevPageSelector.style.display='';
			}
			if (footerPrevPageSelector){
				footerPrevPageSelector.href=prev_pageSelector;
				footerPrevPageSelector.style.display='';
			}
		}

	}

function gotoPage(pageSelect){
//alert (pageSelect);
pageSelectValue=pageSelect;
if (ZoneName.indexOf("Forum")==-1){
	a_segHrefId="segHrefId"+pageSelect;
		//	alert(a_segHrefId);
	if (document.getElementById(a_segHrefId)!=null)	newLocation=	document.getElementById(a_segHrefId).href;
		//	alert(newLocation);
	location.href=newLocation;
}else{

	if (document.getElementById("segind_Forum")!=null){
		document.getElementById("segind_Forum").value=pageSelectValue;
	}
	if (document.getElementById("ForumForm")!=null){
		document.getElementById("ForumForm").submit();
	}
}

}


function selectTimePeriod()
{
select_newdays=document.getElementById("select_newdays")
location.href=siteAddress+"/bin/en.jsp?enZone="+ZoneName+"&enPage="+currentEnPage+"&newdaysedit="+select_newdays[select_newdays.selectedIndex].value +"&newFocusPage=1";
}


function SelectStatus(){
	applicationParams="";
	oEnStatus=document.getElementById("oEnStatus")
	if (oEnStatus.applicationParam!=null)
		applicationParam=oEnStatus.applicationParam;
	location.href=siteAddress+"/bin/en.jsp?enZone="+ZoneName+"&enPage="+currentEnPage+"&EnStatus="+oEnStatus[oEnStatus.selectedIndex].value+"&"+applicationParams+"&newFocusPage=1";
}


function SelectItemsOrder()
{
	order=document.getElementById("order")
	location.href=siteAddress+"/bin/en.jsp?enZone="+ZoneName+"&enPage="+currentEnPage+"&order="+order[order.selectedIndex].value+"&newFocusPage=1";
}

function confirmDel(url)
{
	if(confirm("Are You sure You want to delete this item?"))
		location.href = url;
}

function openPrintUtilWin(){
	if (ZoneName.indexOf("Forum")==-1){
			winLocation=siteAddress+"/bin/en.jsp?enZone="+ZoneName+"&enInfolet=/WEBINF/Infolets/Components/print_utils/print_utils.jsp&enPage=ComponentPage";
			if (winLocation!=''){
				newWind = window.open(winLocation,"" ,"WIDTH=700 ,HEIGHT =450,scrollbars=yes ,directories=yes,status=yes,toolbar=yes,titlebar=yes, menubar =yes,resizable=yes ");
				newWind.moveTo(10,5);
			}
	}else{
		if (document.getElementById("opusPageBackgrounds"))	document.getElementById("opusPageBackgrounds").disabled =true;
		if (document.getElementById("printStyle"))	{
			document.getElementById("printStyle").rel ="stylesheet";
			document.getElementById("printStyle").disabled = false;
			css_printStyle_disabled=false;
		}
	}
}
function cancel_printStyle(){
	var bgFlag=true;
	if (userSecondaryStyle.indexOf("off"))	bgFlag=false;
	if (document.getElementById("opusPageBackgrounds"))	document.getElementById("opusPageBackgrounds").disabled =bgFlag;
	if (document.getElementById("printStyle"))	
		{
		document.getElementById("printStyle").disabled = true;
		css_printStyle_disabled=true;
		}
}

function printForum(printFlag){
	if (printFlag)
	{
		print();
	}
	var bgFlag=true;
	if (userSecondaryStyle.indexOf("off"))	bgFlag=false;
	if (document.getElementById("opusPageBackgrounds"))	document.getElementById("opusPageBackgrounds").disabled =bgFlag;
	if (document.getElementById("printStyle"))	{
		document.getElementById("printStyle").disabled = true;
		css_printStyle_disabled=true;
	}
}






// Elinor 21/3/04: Use for Copy Address

/* 

accessible SELECT 

from    http://themaninblue.com/experiment/AccessibleSelect/   

slightly modiifed by Itai

*/





function initSelect()


{

var theSelect=document.getElementsByTagName("select");
	for(var n=0;n<theSelect.length;n++){
		if(theSelect[n].size==0){
			theSelect[n].changed = false;

			theSelect[n].onfocus = selectFocussed;


			theSelect[n].myonchange =theSelect[n].onchange;

			theSelect[n].onchange = selectChanged;

			theSelect[n].onkeydown = selectKeyed;

			theSelect[n].onclick = selectClicked;

		}
	}


return true;


}


function selectChanged(theElement)


{


		var theSelect = (theElement && theElement.value) ? theElement  : this;	
		if (!theSelect.changed)			return false;


		 if (theSelect.myonchange)
		 {
			 theSelect.myonchange();
		 }


	

return true;


}





function selectChanged2(theElement)

{


if (theElement==null)
{
	theElement=this;
}

if (theElement!=null)
{

var theSelect = (theElement && theElement.value)
 ? theElement  : this;	

if (!theSelect.changed)	return false;


//alert("The select has been changed to " + theSelect.value);

/*
	if (theElement.name!=null)
	{

		theElement_name=theElement.name;

		if (theElement_name.indexOf("fontName")!=-1)
		{
			changeFontName(theElement); 
		}
			if (theElement_name.indexOf("fontSize")!=-1)
		{
			changeFontSize(theElement); 
		}
	}
	*/

	 theElement.myonchange();
	theSelect.changed = false;


	return true;


}

}








function selectClicked()


{

this.changed = true;


}








function selectFocussed()


{


this.initValue = this.value;


return true;


}










function selectKeyed(e)
{
var keyCodeTab = "9";
var keyCodeEnter = "13";
var keyCodeEsc = "27";
var evt = (e) ? e : window.event;
if ((evt.keyCode == keyCodeEnter || evt.keyCode == keyCodeTab) && this.value != this.initValue)
	{
	this.changed = true;
	selectChanged(this);
	}
	
else 
	if (evt.keyCode == keyCodeEsc)
		
	this.value = this.initValue;
       	else
 		 
	this.changed = false;

return true;
}


function  changeFontName(selectObj){
	editor_num=theElement_name.substr(theElement_name.length-1, theElement_name.length);
	editors[editor_num].ou_changeFontName(selectObj[selectObj.selectedIndex].text);
  }

function changeFontSize(selectObj){
			editor_num=theElement_name.substr(theElement_name.length-1, theElement_name.length);
			editors[editor_num].ou_changeFontSize(selectObj[selectObj.selectedIndex].text);
  }

function 	SelectObjectAction(selectObj){

		selectObjValue=selectObj.value;

		selectObect=selectObj;
		selectObect.value='';

		var index=selectObjValue.indexOf("_URL:");
		var actionType='';
		var actionText='';
		if (index!=-1)
		{
			actionType=selectObjValue.substring(0,index);
			actionText=selectObjValue.substring(index+5);
		}
	

	if (actionText.length>0)
	{
		 if (actionType.indexOf("delete")!=-1){
			
			confirmDelete(actionText);
		}else if (actionType.indexOf("restoreButton")!=-1){
			inputC=confirm('?האם לבטל את הערכים שניתנו לפריט זה על-ידך ולחזור לערכי ברירת המחדל' );
			if(inputC==true){
					document.location=actionText;
			}
		}else if (actionType.indexOf("OpDocedit")!=-1){
			ShowAddOrEditObjectOpDocSection('show');
		}else if ((actionType.indexOf("addZone")!=-1) &&(ZoneName.indexOf("Forum")==-1)){

			if(document.getElementById("insertZonePannel")) {
				document.getElementById("insertZonePannel").style.display="block";
			}
		}
			else{
				document.location=actionText;
		}
	}
}


function SelectMessageThreadStyle(){
	if (document.getElementById("select_messageStyle").value==1){
			showMainMsgOnly();
	}
	if (document.getElementById("select_messageStyle").value==2){
			CloseAllThreads();
	}

	if (document.getElementById("select_messageStyle").value==3){
			OpenAllThreads();
	}
//	document.getElementById("select_messageStyle").value=0;
}
function insertZone(){
	var newZoneClass="";
	if(	document.getElementById("insert_zone_class")){
		newZoneClass=document.getElementById("insert_zone_class").value;
	}
	if(newZoneClass.length>0){
		document.location=siteAddress+"/bin/en.jsp?enZone="+ZoneName+"&enPage=FocusPage&enDisplay=add&enDispWhat=Zone&newZoneClass="+newZoneClass;
	}else{
		alert("בחר את סוג הנושא אותו אתה מעונין ליצור");
	}
}

function cancel_insertZone(){
	if(	document.getElementById("insert_zone_class") )	document.getElementById("insert_zone_class").value=null;
	if(document.getElementById("insertZonePannel"))	document.getElementById("insertZonePannel").style.display="none";
}

