//=================================================================================================
//	You can delete these three functions if not needed.
//-------------------------------------------------------------------------------------------------
function customBodyLoad( sender )
{
	new TDropDown("divLangs");
	new TDropDown("divRegions", "edtRegion");
	new TDropDown("divCheeses", "edtCheese");
	new TDropDown("divRecipeLangs");
}
//=================================================================================================
function handlePngs()
{
	var 
		arVersion = navigator.appVersion.split("MSIE"), 
		version   = parseFloat( arVersion[1] )
	
	if ( version >= 5.5 && version < 7.0 && document.body.filters )
	{
		for ( var i = 0; i < document.images.length; i++ )
		{
			var 
				img     = document.images[i], 
				imgName = img.src.toUpperCase();
			
			if ( imgName.substring( imgName.length - 3, imgName.length ) == "PNG")
			{
				var 
					imgID    = img.id        ? "id=\"" + img.id + "\" " : "", 
					imgClass = img.className ? "class=\"" + img.className + "\" " : "", 
					imgTitle = (img.title)   ? "title=\"" + img.title + "\" " : "title=\"" + img.alt + "\" ", 
					imgStyle = "display:inline-block;" + img.style.cssText;
				
				if ( img.align == "left") 
					imgStyle = "float:left;" + imgStyle;
				
				if (img.align == "right") 
					imgStyle = "float:right;" + imgStyle;
				
				if ( img.parentElement.href ) 
					imgStyle = "cursor:pointer;" + imgStyle;
				
				var
					width      = img.offsetWidth, 
					height     = img.offsetHeight, 
					strNewHTML = 
							"<span " + imgID + imgClass + imgTitle + " style=\"" + 
							"width:" + img.width + "px;" + 
							"height:" + img.height + "px;" + imgStyle + ";" + 
							"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + 
							"(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				
				i = i - 1;
			}
		}
	}
}
//-------------------------------------------------------------------------------------------------
	addEvent( window, "load", handlePngs );
//=================================================================================================
function customBodyResize( sender, size )
{
}
//=================================================================================================
function customBodyScroll( sender )
{
}
//=================================================================================================
function toggleVeg( sender )
{
	var
		veg = $("edtVegetarian"), 
		img = xFind( sender, "img");
	
	if ( img )
	{
		if ( veg.value == "0")
		{
			img.src   = "img/vegetarianChecked.gif";
			veg.value = "1";
		}
		else
		{
			img.src   = "img/vegetarianUnchecked.gif";
			veg.value = "0";
		}
	}
}
//=================================================================================================
TDropDown = function( ID, hidden )
{
	this.Class  = "TDropDown";
	this.div    = null; 
	this.hidden = hidden;
	this.input  = null;
	this.ID     = ID;
	this.timer  = null;
	
	if ( browser != browsers.IE )
		eval( ID + " = document.getElementById(\"" + ID + "\");");
	
	if ( document.getElementById( ID ) )
		eval( ID + ".dropdown = this;");
	//--------------------------------------------------------------------------
	this.hide  = function()
	{
		this.init();
		
		if ( this.div )
			this.div.style.display = "none";
	}
	//--------------------------------------------------------------------------
	this.init = function()
	{
		if ( !this.div )
		{
			this.div    = $( this.ID );
			this.hidden = $( this.hidden );
			this.input  = xFind( this.div.parentNode, "input");
			
			addEvent( window, "resize", this.ID + ".dropdown.position();");
		}
	}
	//--------------------------------------------------------------------------
	this.position = function()
	{
		var
			left = getLeft( this.div.parentNode ), 
			top  = getTop( this.div.parentNode ) + this.div.parentNode.offsetHeight;
		
		this.div.style.left = left + "px";
		this.div.style.top  = top  + "px";
	}
	//--------------------------------------------------------------------------
	this.select = function( ID, value )
	{
		if ( this.hidden )
			this.hidden.value = ID ? ID : "";
		
		if ( this.input )
			this.input.value = value ? value : "";
		
		this.hide();
	}
	//--------------------------------------------------------------------------
	this.show = function()
	{
		this.init();
		
		if ( this.div )
		{
			this.stopHide();
			this.position();
			
			this.div.style.display = "block";
		}
	}
	//--------------------------------------------------------------------------
	this.startHide = function()
	{
		this.timer = setTimeout( this.ID + ".dropdown.hide();", 250 );
	}
	//--------------------------------------------------------------------------
	this.stopHide  = function()
	{
		clearTimeout( this.timer );
	}
	//--------------------------------------------------------------------------
	this.toggle = function()
	{
		this.init();
		
		if ( this.div )
		{
			if ( this.div.style.display == "none")
				this.show();
			else
				this.hide();
		}
	}
}
//=================================================================================================