// FUNCTIONS //
var lstCache = new Array();

function LoadImage( strImage )
{
	var imgCache = new Image;

	imgCache.src = strImage;
	lstCache[lstCache.length] = imgCache;
}





var lstRollovers = new Array();

function CreateRollover( strRollover, imgObject )
{
	if (!imgObject)
		return( -1 );

	var imgOriginal = new Image;
	var imgRollover = new Image;

	imgOriginal.src = imgObject.src;
	imgRollover.src = strRollover;

	

	lstRollovers[lstRollovers.length] = new Array( imgOriginal, imgRollover, imgObject );

}



function Rollover( varImage )
{
	if (isNaN( varImage ))
	{
		for (indImage=0; indImage<lstRollovers.length; indImage++)
		{
			if (lstRollovers[indImage][2].name == varImage)
			{
				lstRollovers[indImage][2].src = lstRollovers[indImage][1].src;
				break;
			}
		}
	}
	else
		lstRollovers[varImage][2].src = lstRollovers[varImage][1].src;
}



function Rollout( varImage )
{
	if (isNaN( varImage ))
	{
		for (indImage=0; indImage<lstRollovers.length; indImage++)
		{
			if (lstRollovers[indImage][2].name == varImage)
			{
				lstRollovers[indImage][2].src = lstRollovers[indImage][0].src;
				break;
			}
		}
	}
	else
		lstRollovers[varImage][2].src = lstRollovers[varImage][0].src;
}





var wndLogin;

function OpenLogin( strLanguage )
{
	var intPositionX	= (screen.width / 2) - (300 / 2);
	var intPositionY	= (screen.height / 2) - (300 / 2);
	
	if (wndLogin && !wndLogin.closed)
		wndLogin.focus();
	else
		wndLogin = open( "popup/login.php3?language=" + strLanguage, "", "left=" + intPositionX + ",top=" + intPositionY + ",screenX=" + intPositionX + ",screenY=" + intPositionY + ",width=300,height=300" );
}





var wndSubscription;

function OpenSubscription( strLanguage )
{
	var intPositionX	= (screen.width / 2) - (600 / 2);
	var intPositionY	= (screen.height / 2) - (380 / 2);
	
	if (navigator.appName == "Netscape")
	{
		//alert(21312);
		//open( "subscribe.php3" );
		
		if (wndSubscription && !wndSubscription.closed)
			wndSubscription.close();
		
		wndSubscription = open( "subscribe.php3?language=" + strLanguage, "", "left=" + intPositionX + ",top=" + intPositionY + ",screenX=" + intPositionX + ",screenY=" + intPositionY + ",width=600,height=380" );
		wndSubscription.ResizeTo(600,380);
	}
	else
	{
		if (wndSubscription && !wndSubscription.closed)
			wndSubscription.focus();
		else
			wndSubscription = open( "subscribe.php3?language=" + strLanguage, "", "left=" + intPositionX + ",top=" + intPositionY + ",screenX=" + intPositionX + ",screenY=" + intPositionY + ",width=600,height=380" );
	}
}





var wndReminder;

function OpenReminder( strLanguage )
{
	var intPositionX	= (screen.width / 2) - (250 / 2);
	var intPositionY	= (screen.height / 2) - (215 / 2);	
	
	if (navigator.appName == "Netscape")
	{
		if (wndReminder && !wndReminder.closed)
			wndReminder.close();
		
		wndReminder = open( "reminder.php3?language=" + strLanguage, "", "left=" + intPositionX + ",top=" + intPositionY + ",screenX=" + intPositionX + ",screenY=" + intPositionY + ",width=250,height=215" );
		wndReminder.ResizeTo(250,215);
	}
	else
	{
		if (wndReminder && !wndReminder.closed)
			wndReminder.focus();
		else
			wndReminder = open( "reminder.php3?language=" + strLanguage, "", "left=" + intPositionX + ",top=" + intPositionY + ",screenX=" + intPositionX + ",screenY=" + intPositionY + ",width=250,height=215" );
	}
}





// CART LAYER //

var intCartLayerHeight;
var strCartLayerAnimation;

function ShowCartLayer()
{
	if (document.getElementById)
		pLayer = document.getElementById("layerCart");
	else if (document.all)
		pLayer = document.all["layerCart"];
	
	if (pLayer)
	{
		pLayer.style.visibility	= "visible";
		pLayer.style.height		= 1;
		intCartLayerHeight		= 1;
		strCartLayerAnimation	= "RollDown";
		
		setTimeout( "AnimateCartLayer()", 42 );
	}
}



function HideCartLayer()
{
	strCartLayerAnimation = "RollUp";
	setTimeout( "AnimateCartLayer()", 42 );
}



function AnimateCartLayer()
{
	if (document.getElementById)
		pLayer = document.getElementById("layerCart");
	else if (document.all)
		pLayer = document.all["layerCart"];
	
	switch (strCartLayerAnimation)
	{
		case "RollDown":
		{
			intCartLayerHeight += 10;
			
			if (intCartLayerHeight > 91)
			{
				intCartLayerHeight = 91;
				strCartLayerAnimation = "";
			}
			else
				setTimeout( "AnimateCartLayer()", 15 );
			
			break;
		}
		
		case "RollUp":
		{
			intCartLayerHeight -= 5;
			
			if (intCartLayerHeight < 1)
			{
				intCartLayerHeight						= 1;
				strCartLayerAnimation					= "";
				
				if (pLayer)
					pLayer.style.visibility = "hidden";
			}
			else
				setTimeout( "AnimateCartLayer()", 15 );
			
			break;
		}
	}
	
	pLayer.style.height = intCartLayerHeight;
}





// COUNTRY LAYER //

var intCountryLayerHeight;
var strCountryLayerAnimation;

function ShowCountryLayer()
{
	if (document.getElementById)
		pLayer = document.getElementById("layerCountry");
	else if (document.all)
		pLayer = document.all["layerCountry"];
	
	if (pLayer)
	{
		pLayer.style.visibility		= "visible";
		pLayer.style.height			= 1;
		intCountryLayerHeight		= 1;
		strCountryLayerAnimation	= "RollDown";
		
		setTimeout( "AnimateCountryLayer()", 15 );
	}
}



function HideCountryLayer()
{
	strCountryLayerAnimation = "RollUp";
	setTimeout( "AnimateCountryLayer()", 15 );
}



function AnimateCountryLayer()
{
	if (document.getElementById)
		pLayer = document.getElementById("layerCountry");
	else if (document.all)
		pLayer = document.all["layerCountry"];
	
	switch (strCountryLayerAnimation)
	{
		case "RollDown":
		{
			intCountryLayerHeight += 6;
			
			if (intCountryLayerHeight > 40)
			{
				intCountryLayerHeight		= 40;
				strCountryLayerAnimation	= "";
			}
			else
				setTimeout( "AnimateCountryLayer()", 15 );
			
			break;
		}
		
		case "RollUp":
		{
			intCountryLayerHeight -= 3;
			
			if (intCountryLayerHeight < 1)
			{
				intCountryLayerHeight		= 1;
				strCountryLayerAnimation	= "";
				
				if (pLayer)
					pLayer.style.visibility = "hidden";
			}
			else
				setTimeout( "AnimateCountryLayer()", 15 );
			
			break;
		}
	}
	
	pLayer.style.height = intCountryLayerHeight;
}





// EVENTS //

function CheckKeypress( objEvent, intKeyCode )
{
	if (navigator.appName == "Netscape")
	{
		if( objEvent.which == intKeyCode )
			return( true );
	}
	else
		if( event.keyCode == intKeyCode )
			return( true );
	
	return( false );
}
