function checkAmount(obj)
{
	if (isNaN(obj.value) || obj.value < 1)
	{
		obj.value = 1;
	}
}

function openWindow(url, width, height, print)
{
	var w = null;
	w = window.open(url, '', 'width=' + width +',height=' + height + ',scrollbars=yes,resizable=yes');	
	w.focus();
	
	if(print == true) w.print();
}

function closeWindow(url)
{
	if (url) window.opener.location.href = url;
	window.opener.focus();
	window.close();
}

function validateMail(email)
{  
	if (email.match(/^[a-zA-Z0-9_\.-]{2,}@[a-zA-Z0-9-]{2,}\.([a-zA-Z0-9-]{1,}\.)*[a-zA-Z]{2,4}$/))
	{
		return true;
	}
	else
	{  
		return false;
	}
}

function closeWindowByKeyDown(keyEvent)
{
	if (!keyEvent)
	{
		keyEvent = window.event;
	}
	if (keyEvent.which)
	{
    	key = keyEvent.which;
 	}
 	else if (keyEvent.keyCode)
 	{
    	key = keyEvent.keyCode;
    }
    
    if (key == 88)
    {
    	closeWindow();
    }
}

function confirmCommand(message)
{
	return confirm(unescape(message));
}

function sendOrder(disablebuttons, sendstatus)
{	
	if (sendstatus == false) return false;

	if (disablebuttons)
	{
		for (var i = 0; i < disablebuttons.length; i++)
		{
			if (document.getElementById(disablebuttons[i]))
			{
				document.getElementById(disablebuttons[i]).style.visibility = 'hidden';
			}
		}	
	}
	
	viewportheight = (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight;
		
	x = Math.round((document.body.clientWidth / 2) -109);
	y = Math.round((viewportheight / 2));

	document.getElementById('waitbox').style.left = x + 'px';
	document.getElementById('waitbox').style.top = y + 'px';
	//nn
	document.getElementById('waitbox').left = x;
	document.getElementById('waitbox').top = y;
	//op
	if (navigator.userAgent.toLowerCase().indexOf('opera') != -1)
	{
		document.getElementById('waitbox').style.pixelLeft = x;
		document.getElementById('waitbox').style.pixelTop = y - document.body.scrollTop;
	}
	
	// show div
	document.getElementById('waitbox').style.visibility = 'visible';
	
	return true;
}

function centerLayer()
{
	document.getElementById('waitbox').style.width = screen.availWidth / 4;

	x = document.body.clientWidth / 2 - document.getElementById('waitbox').offsetWidth / 2 + document.body.scrollLeft;
	y = document.body.clientHeight / 2 - document.getElementById('waitbox').offsetHeight / 2 + document.body.scrollTop;

	document.getElementById('waitbox').style.position = 'absolute';
	document.getElementById('waitbox').style.left = x ;
	document.getElementById('waitbox').style.top = y ;

	setTimeout('centerLayer()', 100);
}

function toggle(toggleid, openimg, closeimg)
{
	if (toggleid[0] && document.getElementById(toggleid[0]))
	{
		if (document.getElementById(toggleid[0]).style.display == 'none') 
		{		
			document.getElementById(toggleid[0]).style.display = 'block';
			if (toggleid[1] && document.getElementById(toggleid[1]) && closeimg)
			{
				document.getElementById(toggleid[1]).src = closeimg;
			}
		}
		else 
		{   
			document.getElementById(toggleid[0]).style.display = 'none';
			if (toggleid[1] && document.getElementById(toggleid[1]) && openimg)
			{
				document.getElementById(toggleid[1]).src = openimg;
			}	
		}
	}
}

