/* Copyright (c) 2007 Affno (Pvt) Ltd, . All rights reserved.

 This software is the confidential and proprietary information of        
 Affno  ("Confidential Information").  You shall not disclose such 
 Confidential Information and shall use it only in accordance with
 the terms of the license agreement you entered into with Affno.

Module Name		: ODLWEB1
File Name		: menu.js
Description		: Odel hover menu
Created By		: Bjorn de Lima
Created Date	: 12-April-2007
Modified By		: 
Modified Date	: 
Version			: 1.00.000

*/

var currentMenu = null;
var menuHideTimer = null;
var showTime = 300; // ms

function findPos(obj) {  // http://www.quirksmode.org/js/findpos.html#
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showMenu(str,obj){	
	//$E('.selectMenu').style.visibility = 'none';
	hideMenu();
	resetTimer();
	var off = 36;
	var pos = Array();
	pos = findPos(obj);
	obj2 = document.getElementById(str);
	obj.style.color="#FFbb00";
	
	obj2.style.display = "block";
	obj2.style.position = "absolute";
	obj2.style.Zindex = "1000";
	//var inv = new Fx.Style(str, 'opacity').set(0); 
	var fx = new Fx.Styles(str,{duration:240,transition: Fx.Transitions.linear} ); 
	fx.start({
			 'padding-top' : [0,10]
			 //,'opacity' : 1
			 });
	
	obj2.style.left = parseInt(pos[0]-33)+"px";
	obj2.style.top = parseInt(pos[1]+off)+"px";
	
	currentMenu = str;
	}

function showIt(obj){
	//alert('s');
	obj.style.display = 'block';
	}
	
function hideMenu(){	

	if (currentMenu){
	obj = document.getElementById(currentMenu);
	obj.style.display = "none";
	resetColor(currentMenu);
	//if ($E('.selectMenu')){
	//$E('.selectMenu').style.display = 'block';
	//}
	//var inv = new Fx.Style(currentMenu, 'padding-top').set(0); 
	
}
	
	}	

function resetColor(currentMenu){
	str = currentMenu.substr(3);
	obj = document.getElementById("link"+str);
	obj.style.color="#f0f0f0";
	}

function startTimer(){
	menuHideTimer = setTimeout("hideMenu()", showTime);
	}
	
function resetTimer(){
	if (menuHideTimer){
		clearTimeout(menuHideTimer);
	}
	menuHideTimer = null;	
	}
function flashWrite(file,width,height){
		document.write("<object type='application/x-shockwave-flash' data='"+file+"'  width='"+width+"' height='"+height+"'><param name='wmode' value='opaque' /><param name='movie' value='"+file+"' />ODEL - Shop online for fashion, Sri Lankan souvenirs, homeware, wedding needs and gifts</object>");	
	}
