var x, y;
$(function() {
$().mouseover(function(e){
      x = e.pageX;
      y = e.pageY;
   }); 
$("a#menu-call").mouseover(function() { setTimeout("rollDown()",500); });
$("a#menu-call").mouseout(function() { setTimeout("rollUp()",500); });

$("a#menu-gallery-call").mouseover(function() { setTimeout("galleryRollDown()",500); });
$("a#menu-gallery-call").mouseout(function() { setTimeout("galleryRollUp()",500); });

$("ul#menu").hover( function() {},
  function() { $("ul#menu").animate({opacity:1.0},1125).slideUp(375); return false;
  });
  
$("ul#gallery-menu").hover( function() {},
  function() { $("ul#gallery-menu").animate({opacity:1.0},1125).slideUp(375); return false;
  });
  
  
})

function rollDown(){
	left = findPos(document.getElementById("menu-call"));
	if(y>=111 && y <=133 && x>=left && x<=left+110){
		$("ul#menu").animate({height:"show",opacity:"show"},"slow"); 
		return false;
	}
}
function rollUp(){
	left = findPos(document.getElementById("menu-call"));
	menuHeight = document.getElementById("menu").offsetHeight;
        if(y>=111 && y <=133+menuHeight && x>=left && x<=left+170){
                return false;
        }
	$("ul#menu").animate({opacity:1.0},1125).slideUp(375);
}
function galleryRollDown(){
	left = findPos(document.getElementById("menu-gallery-call"));
	if(y>=111 && y <=133 && x>=left && x<=left+110){
		$("ul#gallery-menu").animate({height:"show",opacity:"show"},"slow"); 
		return false;
	}
}
function galleryRollUp(){
	left = findPos(document.getElementById("menu-gallery-call"));
	menuHeight = document.getElementById("gallery-menu").offsetHeight;
        if(y>=111 && y <=133+menuHeight && x>=left && x<=left+170){
                return false;
        }
	$("ul#gallery-menu").animate({opacity:1.0},1125).slideUp(375);
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	return curleft;
        }
}

