var popup_menu_current = false
var last_tab_id = 'tab_8'

function popup_menu_on(oid, sobj)
{
    oid = String(oid)
    if (oid.length == 1) {
        if (oid == popup_menu_current) return
        toggle_popup_menu(popup_menu_current, false)
    }
    toggle_popup_menu(oid, true)
    if (oid.length == 1) {
        popup_menu_current = oid
    }
    if (sobj) {
        popup_obj = document.getElementById('popup_menu_'+oid)
        if (popup_obj) {
            var last_tab = document.getElementById(last_tab_id)
            if (findPosX(sobj) + popup_obj.clientWidth > findPosX(last_tab) + last_tab.clientWidth) {
                xpos = findPosX(last_tab) + last_tab.parentNode.clientWidth - popup_obj.clientWidth
            } else {
                xpos = findPosX(sobj)
            }
            document.getElementById('popup_menu_'+oid).style.left = xpos + 'px'
        }
        toggle_video_controls(false)
    }
}

function toggle_video_controls(s)
{
    var vc = document.getElementById('video_container_1')
    if (v = vc.getElementsByTagName("VIDEO")) {
        if (s) {
            v[0].setAttribute("controls", "controls")
        } else {
            v[0].removeAttribute("controls")
        }
    }
}

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 popup_menu_off(oid)
{
    oid = String(oid)
    toggle_popup_menu(oid, false)
    popup_menu_current = false
    toggle_video_controls(true)
}

function toggle_popup_menu(oid, s)
{
    if (o = document.getElementById('popup_menu_'+oid)) {
        o.style.display = s ? 'block' : 'none'
    }
}

function place_alpha_layer(o, lid)
{
    elts = o.coords.split(',')
    document.getElementById(lid).style.top = (elts[1]) + 'px'
    document.getElementById(lid).style.height = (elts[3]-elts[1]) + 'px'
}


		/*********************************************************************
		 * No onMouseOut event if the mouse pointer hovers a child element 
		 * *** Please do not remove this header. ***
		 * This code is working on my IE7, IE6, FireFox, Opera and Safari
		 * 
		 * Usage: 
		 * <div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');"> 
		 *		So many childs 
		 *	</div>
		 *
		 * @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		
		**/
		function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}
		function fixOnMouseOut(element, event, JavaScript_code) {
			var current_mouse_target = null;
			if( event.toElement ) {				
				current_mouse_target 			 = event.toElement;
			} else if( event.relatedTarget ) {				
				current_mouse_target 			 = event.relatedTarget;
			}
			if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
				eval(JavaScript_code);
			}
		}
		/*********************************************************************/



function menu_cell_over(w, i)
{
   w = w.getElementsByTagName("A")[0]
   w.style.background = "url('img/b"+(i+1)+"_over.png')"
}

function menu_cell_out(w, i)
{
   w = w.getElementsByTagName("A")[0]
   w.style.background = "url('img/b"+(i+1)+".png')"
}

