// Handle keypress event on the textbox
// Click certain button based on btnId.
function ClickButton(btnId, e)
{
	var key;
	
	if (window.event)
	{
		// IE
		key = event.keyCode;
	}
	else if (e.which)
	{
		// Netscape
		key = e.which;
	}
	else
	{
		// Other, no event
		return true;
	}
	
	if (key == 13)
	{			
		// cancel the default submit
		e.returnValue = false; 
		e.cancel = true; 
						
		var bt;
				
		// submit the form by programmatically clicking the specified button
		if (document.getElementById)
		{					
			bt = document.getElementById(btnId); 
		}
		else if (document.layers)
		{				
			bt = document.layers[btnId];
		}
		else if (document.all)
		{					
			bt = document.all[btnId];
		}
		
		bt.click();		
	}
}

var newWindow = '';

// Create pop up window
function PopItUp(url, width, height, name)
{				
	var windowFeatures = "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=0, width=" + width + "px, height=" + height + "px"				
	
	if (!newWindow.closed && newWindow.location) 
	{
		newWindow.location.href = url; 		
	} 
	else 
	{ 
		newWindow = window.open(url, name, windowFeatures); 			
		if (!newWindow.opener) newWindow.opener = self;				
	}
		
	if (newWindow == null || typeof(newWindow) == "undefined")
	{
		alert ("You can't see Item description windows because your web browser setting doesn't allow pop-up! \n Please allow pop-up for *.livingstone.com.au in order to see item description. \n\n To get more information about pop-up, please read Help topics on your web browser or email webmaster@livingstone.com.au.")
	}
	else
	{		
		if (window.focus)
		{				
			newWindow.focus();																	
		}
	}						
}

// Login in the main page
function LoginInMain(url)
{			
	if (!window.opener.closed)
	{			
		window.close();
		window.opener.location.href = url;
		window.opener.focus();	
		window.opener.moveTo(0,0);
		window.opener.resizeTo(screen.width,screen.height);		
	}
	else
	{		
		window.close();
		mainWindow = window.open(url);
		mainWindow.focus();	
		mainWindow.moveTo(0,0);
		mainWindow.resizeTo(screen.width,screen.height);		
	}	
}



