// JavaScript Document

function menu(id, dir)
{
  if(document.getElementById(id))
  {
	  var itemm = document.getElementById(id);
	  var pos = new Array();
	  pos = getPosition(itemm);
	  var width = itemm.offsetWidth;
	  //alert(pos[0]);
	
	  if(document.getElementById(id+'box'))
	  {
		  itemm = document.getElementById(id+'box');
		  //alert(document.getElementById(id+'boxinner').offsetWidth)
		  //alert(document.width);
		  itemm.style.position = "absolute";
		  
		  var winwidth;
		  if(window.innerWidth && window.innerWidth!=undefined)
		    winwidth = window.innerWidth;
		  else if(document.width && document.width!=undefined)
		    winwidth = document.width;
		  else
		    winwidth = document.body.offsetWidth;
		  
		  //alert("winwidth: " + winwidth + "\npos[0]: " +pos[0] + "\nwidth: " + width)
		  if(dir=="rtl")
		  {
		    if(isIE)
		        itemm.style.right = (parseInt(winwidth) - parseInt(pos[0]) - (parseInt(width)/2)) + "px";
			    //itemm.style.right = (parseInt(winwidth) - parseInt(pos[0]) - 10) + "px";
			else
			    itemm.style.right = (parseInt(winwidth) - parseInt(pos[0]) - parseInt(width)) + "px";
			    //itemm.style.right = (parseInt(winwidth) - parseInt(pos[0]) - 60) + "px";
		  }
		  else
		  {
		        itemm.style.left = (parseInt(pos[0]) + parseInt(width) - parseInt(width)) + "px";
		  }
		  
		  itemm.style.top = (parseInt(pos[1]) + 25) + "px";
		  
		  itemm.style.display = "block";
		}//end if

	}//end if
}//end func menu

function submenu(id, dir)
 {
	var depth = id.substr(parseInt(id.length)-1);
    var subid = id+'sub';
    subm = document.getElementById(subid); 
    subm.style.position = "absolute";
    var p = document.getElementById(id);
    //alert(p.clientWidth + " " + p.offsetWidth);
//	var pos = new Array();
//	pos = getPosition(p);
	
	var j = depth;
	var k = 0;
	for(var i=1; i<j; i++)
	{
	    var fakeid = id.substr(0, parseInt(id.length)-1)+i;
	    if(!document.getElementById(fakeid))
	    {
	        depth = parseInt(depth)-1;
	        k++;
	    }
	}//end for
	
	var width = subm.style.width;

	if(dir=="rtl")
		subm.style.left =  (- parseInt(width)+5) + "px";
	else
		subm.style.right = (- parseInt(width) +5) + "px";
	
	subm.style.top = ((parseInt(depth)-1)*33) + "px";

    show(subid);
 }//end func sub menu

function activepage()
 {
    var urlof = window.location.href.toString();
    var pageof = urlof.split("/");
    pageof = pageof[parseInt(pageof.length)-1];
    if(pageof.indexOf("?")!="-1")
     {
        pageof = pageof.split("?");
        pageof = pageof[0];
     }//end if
    
    var obj = document.getElementById('RahaWebMainmenu');
    var fullcont = obj.innerHTML.replace(/"/g, "");
    var tmp = fullcont.indexOf(pageof);
    if(tmp!="-1")
     {
        funllcont = fullcont.substring(0, tmp).split(" id=");
        var cont = funllcont[parseInt(funllcont.length)-2].split(" ")[0];
        
        if(cont.substring(parseInt(cont.length)-3)=="sub")
        {
            cont = cont.substring(0, parseInt(cont.length)-7);
        }
        
        if(!isNaN(parseInt(cont.substring(parseInt(cont.length)-1))))
        {
            cont = cont.substring(0, parseInt(cont.length)-4);
        }
        //alert(cont+"\n"+isNaN(parseInt(cont.substring(parseInt(cont)-1)))+"\n"+parseInt(cont.substring(parseInt(cont)-1)));
        document.getElementById(cont).className = "menuactive";
        
     }//end if
 }//end func avtive page
