Menu = function(){
	this.timer = null;
	this.activeMenu;
	this.activeDropdown;
}

Menu.prototype.OpenMenu = function(menu, dropdownId, offsetX, offsetY, width){
	this.StopTimer();
	this.HideDropdown();

	this.activeMenu = menu;
	this.activeDropdown = this.FindDropdown(dropdownId);

	offsetX += this.getOffsetX(menu);
	offsetY += this.getOffsetY(menu);
	this.ShowDropdown(offsetX, offsetY, width);
}

Menu.prototype.FindDropdown = function(dropdownId){
	return document.getElementById(dropdownId);
}

Menu.prototype.ShowDropdown = function(offsetX, offsetY, width){
	if(this.activeDropdown != null){
		this.activeDropdown.style.top = offsetY + this.activeMenu.offsetHeight + 'px';
		this.activeDropdown.style.left = offsetX + 'px';
		this.activeDropdown.style.display = 'block';
		if (width != null)
			this.activeDropdown.style.width = width + 'px';
	}
}

Menu.prototype.HideDropdown = function(){
	if(this.activeDropdown != null){
		this.activeDropdown.style.display = 'none';
	}
}

Menu.prototype.StartTimer = function(){
	this.timer = setTimeout('hideDropdown()',1000);
}

Menu.prototype.StopTimer = function(){
	if(this.timer != null){
		clearTimeout(this.timer);
	}
}

Menu.prototype.getOffsetX = function(node){
	var offsetX = this.activeMenu.offsetLeft;
	var parentOffsetNode = node.offsetParent;
	while(parentOffsetNode != null){
		if(parentOffsetNode.offsetLeft != null){
			offsetX += parentOffsetNode.offsetLeft;
		}
		parentOffsetNode = parentOffsetNode.offsetParent
	}
	
	return offsetX;
}

Menu.prototype.getOffsetY = function(node){
	var offsetY = this.activeMenu.offsetTop;
	
	var parentOffsetNode = node.offsetParent;
	while(parentOffsetNode != null){
		if(parentOffsetNode.offsetTop != null){
			offsetY += parentOffsetNode.offsetTop;
		}
		parentOffsetNode = parentOffsetNode.offsetParent
	}
	
	return offsetY;
}

var oMenu = new Menu();

function openMenu(menu, dropdownId, offsetX, offsetY, width){
	oMenu.OpenMenu(menu, dropdownId, offsetX, offsetY, width);
}

function startTimer(){
	oMenu.StartTimer();
}

function stopTimer(){
	oMenu.StopTimer();
}

function hideDropdown(){
   oMenu.HideDropdown();
}

 
function showPicture1(sUrl, oEvent)
    {
        var oDiv = document.getElementById("divPicture");
        var oImg = document.getElementById("imgPicture");
        oImg.src = sUrl;
		
        oImg.onload = new Function("document.getElementById('divPicture').style.display='block';")
      //  oDiv.style.left = document.body.scrollLeft + oEvent.clientX  -100;
      // 	oDiv.style.top  = document.body.scrollTop  + oEvent.clientY   ;
	    return true;
    }
function showPicture2(sUrl, oEvent)
    {
        var oDiv = document.getElementById("divPicture");
        var oImg = document.getElementById("imgPicture");
        oImg.src = sUrl;
        oImg.onload = new Function("document.getElementById('divPicture').style.display='';")
       
	   // oDiv.style.left = document.body.scrollLeft + oEvent.clientX - (oImg.width  + 10) - 25;
       // oDiv.style.top  = document.body.scrollTop  + oEvent.clientY - (oImg.height + 10) / 2;
        return true;
    }
function hidePicture(oEvent)
    {
        var oDiv = document.getElementById("divPicture");
        oDiv.style.display = "none";
    }
	
function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/101
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML=insertimage(nextimageindex)
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
var tempobj2=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj2.style.visibility="hidden"
setTimeout("rotateimage()",pause)
}
}

function insertimage(i){
var tempcontainer=fadeimages[i][1]!=""? '<a href="'+fadeimages[i][1]+'" target="'+fadeimages[i][2]+'">' : ""
tempcontainer+='<img src="'+fadeimages[i][0]+'" border="0">'
tempcontainer=fadeimages[i][1]!=""? tempcontainer+'</a>' : tempcontainer
return tempcontainer
}

function rotateimage(){
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
tempobj.style.visibility="visible"
var temp='setInterval("fadepic()",150)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
}
else
document.images.defaultslide.src=fadeimages[curimageindex][0]
curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
}

function resetit(what){
curpos=10
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
if (crossobj.filters)
crossobj.filters.alpha.opacity=curpos
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=curpos/101
}

function startit(){
var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML=insertimage(curimageindex)
rotateimage()
}



