// Browser Detection
if ((document.all)&&(document.getElementById)) ie = true; else ie = false;

// Menu MouseOver (All Browsers)
function Menu_Over(e,color) 
{
	if(ie) e = event.srcElement; else e = e.target;

	if(e.getAttribute("Default") == null)
	{
		e.setAttribute("oldBGColor", e.style.backgroundColor);
		e.setAttribute("oldColor", e.style.color);
		e.style.backgroundColor = color;
		e.style.color = "#ffffff";
		e.style.cursor = "pointer";
	}
	else
	{
		e.style.cursor = "default";
	}
}	

//Menu MouseOut (All Browsers)
function Menu_Out(e)
{   	
	if(ie) e = event.srcElement; else e = e.target;	
	
	if(e.getAttribute("Default") == null)
	{		
		e.style.backgroundColor	= e.getAttribute("oldBGColor");
		e.style.color = e.getAttribute("oldColor");
	}
}

//Menu MouseOut (All Browsers)
function Menu_Click(url)
{
	window.location = url;
}

// Menu Default (All Browsers)
function Menu_Default(e) 
{
	document.getElementById(e).setAttribute("Default", true);	
	document.getElementById(e).style.borderBottomColor = "#f5f5f5";
	document.getElementById(e).style.backgroundColor = "#e5e5e5";
	document.getElementById(e).style.color = "#000000";
}	

// Ref MouseOver (All Browsers)
function Ref_Over(e,ref) 
{
	if(ie) e = event.srcElement; else e = e.target;
	
	obj = document.getElementById("product");
	obj.style.display = "inline";
	obj.src = "interface/images/content_ref_" + ref + ".jpg";
}	

// ShowList Variables
var List = new Array();
var ListItem = 0;
var ListLimit = 0;

// ShowList Init (All Browsers)
function ShowList(obj,limit) 
{
	for(i = 1;i <= limit; i++)
		List[i] = obj + i;

	ListLimit = limit;
	DisplayList();
}

// Automated List Display (All Browsers)
function DisplayList()
{
	try	{ document.getElementById(List[ListItem]).style.visibility = "visible"; } catch(e){};
	ListItem = ListItem + 1;	
	
	if (ListItem <= ListLimit)
		setTimeout("DisplayList()", 1000);
}


// Product Viewer (All Browsers)
function Preview_Click(type)
{
	var url = "preview.aspx?type=" + type;
	
	var wSize =	600;
	var hSize =	455;	
	var TopPos = ((window.screen.availHeight- hSize) / 2 );	
	var LeftPos = ((window.screen.availWidth - wSize) / 2 );
	
	window.open(url, "preview", "width=" + wSize + ", height=" + hSize + ", top=" + TopPos + ", left=" + LeftPos + ", menubar=no, location=no, resizable=no, status=no, scrollbars=no");
}

// Preview MouseOver View (All Browsers)
function Preview_Over(e)
{
	if(ie) e = event.srcElement; else e = e.target;	
	
	if(e.tagName == "TD")
		e = e.firstChild;
	
	e.parentNode.style.cursor	= "pointer";
	e.parentNode.style.textDecoration	= "underline";	
	e.style.borderColor	= "#ffffff";	
}

// Preview MouseOut View (All Browsers)
function Preview_Out(e)
{
	if(ie) e = event.srcElement; else e = e.target;	
	
	if(e.tagName == "TD")
		e = e.firstChild;
		
	e.parentNode.style.cursor	= "";
	e.parentNode.style.textDecoration	= "";	
	e.style.borderColor	= "";
}

// Product Viewer (All Browsers)
function Thumb_Click(type,id)
{
	window.location = "?type=" + type + "&id=" + id;
}

// Thumb MouseOver View (All Browsers)
function Thumb_Over(e)
{
	if(ie) e = event.srcElement; else e = e.target;	
	
	e.style.borderBottomColor = "#2D88B0";
}

// Thumb MouseOut View (All Browsers)
function Thumb_Out(e)
{
	if(ie) e = event.srcElement; else e = e.target;	
	
	e.style.borderBottomColor = "";
}

// Slide Show Variables
var Pic = new Array();
var preLoad = new Array();
var nextSlide = 0;
var source;

// Automated SlideShow (IE Full - Mozilla Limited)
function Slide_Show(type,id,max)
{
	source = document.getElementById(type+"Preview");

	for(i = 0; i <= max; i++)
	{
		j = i + 1;
		Pic[i] = "interface/images/" + type + "_" + j + ".jpg";		
	}
	
	for (i = 0; i < max; i++)
	{
		preLoad[i] = new Image();
		preLoad[i].src = Pic[i];
	}		
	
	if(id)
		nextSlide = id - 1;
	
	Play_Slide_Show();	
}

function Play_Slide_Show()
{
	if (document.all)
	{
		source.style.filter = "blendTrans(duration=1)";
		source.filters.blendTrans.Apply();
	}
	
	source.src = preLoad[nextSlide].src;
	
	if (document.all)
	{
		source.filters.blendTrans.Play()
	}
	
	nextSlide = nextSlide + 1;
	
	if (nextSlide > max-1)
		nextSlide = 0;			
	
	setTimeout('Play_Slide_Show()', 4000);
}

//Form Field Check (All Browsers)
function FormCheck(e)
{
	if(ie) e = event.srcElement; else e = e.target;	
	
	if(e.value != "")
	{
		if(e.getAttribute("error") != null)
			e.style.backgroundColor = "#ffffdd";
		else
			e.style.backgroundColor = "#f2f2f2";
	}
	else
	{
		e.style.backgroundColor = "";
	}
}

//Form Reload (All Browsers)
function FormReload()
{
	for(i = 0; i < Decopak.length; i++)			
	{
		if(Decopak.elements[i].value != "")
		{
			if(Decopak.elements[i].type == "text" || Decopak.elements[i].type == "textarea")
				Decopak.elements[i].style.backgroundColor = "#f2f2f2";
				
			if(Decopak.elements[i].getAttribute("error") != null )
				Decopak.elements[i].style.backgroundColor = "#ffffdd";
		}
	}
}


//Form Submit (All Browsers)
function FormSubmit(error)
{
	var errors = error + "\n\n";
	var valid = true;	
	
	for(i = 0; i < Decopak.length; i++)			
	{
		if(Decopak.elements[i].getAttribute("error") != null)
		{
			if(Decopak.elements[i].value == "")
			{
				errors += "> " + Decopak.elements[i].getAttribute("error") + "\n";
				valid = false;
			}
		}
	}
	
	if(valid)
	{
		return true;
	}
	else
	{
		alert(errors);	
		return false;
	}
}