

function getElementsByClass( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
}


sfHover = function() { // when mouse is over the mainmenu 
	var sfEls = document.getElementById("ja-cssmenu").getElementsByTagName("li");
	
	for (var i=0; i<sfEls.length; ++i) {
		sfEls[i].onmouseover=function() { //when mouse is over a special menu item
			
			
			//mostafa hack - fix sub menus level1 in RTL templates						
			if(this.className.indexOf("havechild") != -1) 
			this.childNodes[1].style.left = this.offsetLeft + this.offsetWidth +58;
			//end of hack
					
			clearTimeout(this.timer);
			if(this.className.indexOf("sfhover") == -1){
				
				this.className+="sfhover";}
		}
		sfEls[i].onmouseout=function() {
			
			this.timer = setTimeout(sfHoverOut.bind(this), 20);
			//mostafa hack - fix sub menus level1 in RTL templates						
			if(this.className.indexOf("havechild") != -1)
			this.childNodes[1].style.left="-999em";
			//end of hack
		}
	}
}

function sfHoverOut() {
	clearTimeout(this.timer);
	this.className=this.className.replace(new RegExp("sfhover\\b"), "");

}

if (window.attachEvent) window.attachEvent("onload", sfHover);



