// Copyright (C) 2006 Hartland Institute / EGN Productions
// Author: Kevin H. Patterson
// Contact: kevpatt _AT_ khptech.com
// Description: Provides a slide-in DHTML popup when a new item is added to the cart

var PUP = null;

function Scale( Val, Min, Max ) {
	if( Val < Min ) return 0;
	if( Val > Max ) return 1;
	return (Val - Min) / (Max - Min);
}

function RenderPopUp() {
	var t = new Date();
	var e = (t.getTime() - PUP.StartTime) / 1000;
	if( PUP.Cycle == 0 ) {
		if( PUP.RenderMode == 1 )
			PUP.style.position = "absolute";
		else
			PUP.style.position = "fixed";
		PUP.style.top = "0px";
		PUP.style.right = "-" + (PUP.Width + 1) + "px";
		PUP.style.display = "block";
	}
	if( e < 1 )
		PUP.style.right = "-" + Math.round( PUP.Width * (1 - Scale( e, 0, 1 )) ) + "px";
	else
		PUP.style.right = "0px";
	if( e >= 4 && e < 5 ) {
		if( PUP.RenderMode == 1 )
			PUP.style.filter = "alpha(opacity=" + (100 * (1 - Scale( e, 4, 5 ))) + ");";
		else
			PUP.style.opacity = 1 - Scale( e, 4, 5 );
	}
	if( e >= 5 )
		PUP.style.display = "none";
	PUP.Cycle++;
	if( e <= 5 ) setTimeout( "RenderPopUp()", 33 );
}

function DisplayPopUp( ElementID ) {	
	PUP = document.getElementById( ElementID );
	if( PUP ) {	
		PUP.RenderMode = 0;
		if( navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" ) {
			var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
			if( rslt != null && Number( rslt[1] ) >= 5.0 && Number( rslt[1] ) < 7.0 )
				PUP.RenderMode = 1;
		}
	
		var t = new Date();
		PUP.Cycle = 0;
		PUP.StartTime = t.getTime();
		PUP.Width = PUP.offsetWidth;
		RenderPopUp();
	}
}