function dropDown()
{
	dojo.query('.subMenu').style("display", "none");
    dojo.query('#menu ul ul li:has(ul)')
        .connect('onmouseenter', function(){
        	dojo.addClass(this, "selected");
        	dojo.query('ul:first', this).style("display", "block");
        })
        .connect('onmouseleave', function(){
        	dojo.query('ul:first', this).style("display", "none");
        	dojo.removeClass(this, "selected");
        });
}

function Lamoraposa_ModelLoad()
{
	var images = document.getElementsByTagName("img");
	for(var i=0; i<images.length; i++)
	{
		var parent = images[i].parentNode;
		var tag = parent.tagName;
		
		if(images[i].id == "modellImage")
		{
			Lamoraposa_ModelStart();
		}
		else if(tag == "A" && images[i].className == "modellthumb")
		{
			dojo.connect(parent, "onmouseenter", Lamariposa_Over);
			dojo.connect(parent, "onmouseleave", Lamariposa_Out);
		}
	}
}

function Lamariposa_Over()
{
	this.firstChild.style.opacity = "1";
}

function Lamariposa_Out()
{
	if(this.firstChild.name != "active")
		this.firstChild.style.opacity = "0.5";
}

function Lamariposa_ThumbFade()
{
	var images = document.getElementsByTagName("img");
	for(var i=0; i<images.length; i++)
	{
		if(images[i].className == "modellthumb")
		{
			var image = images[i];
			var parent = image.parentNode;
			var tag = parent.tagName;
			
			if(tag == "A")
			{
				image.name = "";
				image.style.opacity = "0.5";
				parent.style.borderColor = "#eeeeee";
			}
		}
	}
}

function Lamoraposa_ModelStart()
{
	var image = dojo.fadeIn({node: "showmodellcontainer", duration: 500 });
	image.play();
}

function Lamoraposa_Slideshow(thumbId, imageId, src, margin)
{
	var link = dojo.byId(thumbId).parentNode;
	var image = dojo.byId(thumbId);
	
	Lamariposa_ThumbFade();
	
	Hook_Image_Swap(imageId, src, margin);
	
	link.style.borderColor = "#cfc8e7";
	image.style.opacity = "1";
	image.name = "active";
	
	return false;
}

function Hook_Image_Swap(imageId, src, margin)
{
	var a = dojo.byId(imageId);
	
	var image = new Image();
	image.src = src;
	
	a.src = src;
	a.style.marginTop = margin + "px";
	
	return false;
}

function Hook_Image_Slideshow(imgarray, divid, fadeIn, fadeOut, delay, width, height)
{
	// Require
	dojo.require("dojo._base.fx");
	fadeIn = parseInt(fadeIn);
	fadeOut = parseInt(fadeOut);
	delay = parseInt(delay);
	
	// The div
	var divNode = dojo.byId(divid);
	divNode.innerHTML = "";
	
	// The img
	var imgNode = document.createElement("img");
	var imgId = "hook_slideshow_img";
	imgNode.id = imgId;
	imgNode.style.opacity = "0";
	imgNode.src = imgarray[0];
	
	// Width and height
	if(height > 0)
		imgNode.height = height;
	if(width > 0)
		imgNode.width = width;
	
	divNode.appendChild(imgNode);
	
	// Fadeing
	var In = dojo.fadeIn({node: imgId, duration:fadeIn });
	dojo.connect(In,"onEnd",function(){ 
		setTimeout(function(){ Hook_Image_Slideshow_Create(imgarray, imgId, 0, fadeIn, fadeOut, delay) }, delay);
	});
	In.play();
}

function Hook_Image_Slideshow_Create(imgarray, imgId, next, fadeIn, fadeOut, delay)
{
	// Fadeing out
	var Out = dojo.fadeOut({node: imgId, duration:fadeOut });
	dojo.connect(Out,"onEnd",function(){
		
		// Finding the next
		var amount = imgarray.length;
		next++;
		next = (next >= amount) ? 0 : next;
		
		// Waiting
		setTimeout(function(){
			// Changing the image
			dojo.byId(imgId).src = imgarray[next];

			// Fading In again
			var In = dojo.fadeIn({node: imgId, duration:fadeIn });
			dojo.connect(In,"onEnd",function(){ 
				setTimeout(function(){ Hook_Image_Slideshow_Create(imgarray, imgId, next, fadeIn, fadeOut, delay) }, delay);
			});
			In.play();
		}, 300);
	});
	Out.play();
}

function Hook_Calendar(id, month, year, test)
{
	ajaxresponse("/api/ajax?type=calendar&month=" + month + "&year=" + year, id, true);
	return false;
}


















