function addEvent(p_oObject, p_sEventName, p_oFunction){ 
	var mixResult = false;

	if( p_oObject.addEventListener ){ 
		p_oObject.addEventListener(p_sEventName, p_oFunction, false); 
		mixResult = true; 
	} else if( p_oObject.attachEvent ){ 
		mixResult = p_oObject.attachEvent("on"+p_sEventName, p_oFunction); 
	}

	return mixResult;
}

function oDropDown(p_oElement){
	this.m_nTimeout = 333;
	this.m_oTimeout = null;
	this.m_oParent = p_oElement;
	this.m_aChildList = this.m_oParent.getElementsByTagName('div');
	for(var nIndex = 0; nIndex < this.m_aChildList.length; nIndex++){
		this.m_aChildList[nIndex].onmouseover = this.showDropDown.bind(this);
		this.m_aChildList[nIndex].onmouseout = this.delayHide.bind(this);
		//this.m_aChildList[nIndex].onclick = function(){ return false; };
	}
}

oDropDown.prototype.delayHide = function(){
	this.m_oTimeout = setTimeout(this.hideDropDown.bind(this),this.m_nTimeout);
}

oDropDown.prototype.hideDropDown = function(){
	for(var nIndex = 0; nIndex < this.m_aChildList.length; nIndex++){
		if( this.m_aChildList[nIndex].className == 'child' ) this.m_aChildList[nIndex].style.display = 'none';
	}
}

oDropDown.prototype.showDropDown = function(){
	clearTimeout(this.m_oTimeout);
	this.m_oTimeout = null;	
	for(var nIndex = 0; nIndex < this.m_aChildList.length; nIndex++){
		if( this.m_aChildList[nIndex].className == 'child' ) this.m_aChildList[nIndex].style.display = 'block';
	}
}

function initPage(){
	var oParent = null;
	var aMenuItems = new Array(
		'menu_item_showreels',
		'menu_item_films'
	);
	var nMenuIndex = 0;

	for(nMenuIndex = 0; nMenuIndex < aMenuItems.length; nMenuIndex++){
		oParent = document.getElementById(aMenuItems[nMenuIndex]);
		if( oParent && oParent.getElementsByTagName ){
			new oDropDown(oParent);
		}
	}
}

addEvent(window,'load',initPage);

