function is_IE()
{
	return navigator.appName == 'Microsoft Internet Explorer';
}

function is_Moz()
{
	return navigator.appName == 'Netscape';
}

function manageMoveToEvents()
{
	window.location.href = "events.php";
}


function do_ticket_form_click_A(obj)
{
	strCode = obj.value;
	strCode = strCode.toUpperCase();
	
	if (strCode.length == 5) {
		//
		// if the first char is d then its a discount card
		// submit the info
		//
		if(strCode.charAt(0) == 'D')
			document.getElementById('frmProcessticket').submit();
			
		document.getElementById('codeB').focus();
	}
}

function do_ticket_form_click_B(obj)
{
	if ((obj.value.length == 3) && (document.getElementById('codeA').value.length == 5))
		document.getElementById('frmProcessticket').submit();
}

function do_card_form_click_A(obj)
{
	if (obj.value.length == 5)
		document.getElementById('frmProcessCard').submit();
}

function do_keypress(evt)
{
	while (true) {
		if (evt.which) {
			i = evt.which;
			break;
		}
	
		if (evt.keyCode) {
			i = evt.keyCode;
			break;
		}
		
		return true;
	}
	
	if (i == 45)
		return false;
	else
		return true;
}

function clear_barcodes()
{
	document.getElementById('codeA').value = '';
	document.getElementById('codeB').value = '';
}

function edit_product(obj,a)
{	
	bEnabled = (obj.checked);
	
	for (i = 0; i < a.length; i++) {
		var el = document.getElementById(a[i]);
		
		if (el) {
			el.disabled = !bEnabled;
			toggle_background_color(el, !bEnabled);
		}
	}
}

function toggle_background_color(obj, state)
{
	if(!state)
		obj.style.backgroundColor = '#ffffff';
	else
		obj.style.backgroundColor = '#dddddd';
}


function get_absolute_element_position(obj)
{
	var x = 0;
	var y = 0;

	while (obj) {
		x += obj.offsetLeft;
		y += obj.offsetTop;
		//window.alert(obj.offsetX);
		obj = obj.offsetParent;
	}

	a = new Array();
	a[0] = x;
	a[1] = y;
	return a;
}

function get_relative_event_position(evt,obj)
{
	//
	// mozilla/konquerer
	//
	if (evt.pageX) {
		a = get_absolute_element_position(obj);
		return new Array(evt.pageX-a[0],evt.pageY-a[1]);
	}
	
	//
	// IE
	//
	return new Array(evt.offsetX,evt.offsetY);
}	

function money_to_string(iPence)
{
	/*switch(c)
	{		
	case "USD":				
		n = ((iPence/100) + 0.001) + '';
		return '$; ' + n.substring(0, n.indexOf('.') + 3);				
		break;			
	case "EUR":				
		n = ((iPence/100) + 0.001) + '';
		return '€; ' + n.substring(0, n.indexOf('.') + 3);				
		break;
	default: */
		n = ((iPence/100) + 0.001) + '';
		return '&pound; ' + n.substring(0, n.indexOf('.') + 3);
	//}
}

function dollars_to_string(iPence)
{
	/*switch(c)
	{		
	case "USD":				
		n = ((iPence/100) + 0.001) + '';
		return '$; ' + n.substring(0, n.indexOf('.') + 3);				
		break;			
	case "EUR":				
		n = ((iPence/100) + 0.001) + '';
		return '€; ' + n.substring(0, n.indexOf('.') + 3);				
		break;
	default: */
		n = ((iPence/100) + 0.001) + '';
		return '$ ' + Math.round(n*100)/100;
	//}
}

function euros_to_string(iPence)
{
	/*switch(c)
	{		
	case "USD":				
		n = ((iPence/100) + 0.001) + '';
		return '$; ' + n.substring(0, n.indexOf('.') + 3);				
		break;			
	case "EUR":				
		n = ((iPence/100) + 0.001) + '';
		return '€; ' + n.substring(0, n.indexOf('.') + 3);				
		break;
	default: */
		n = ((iPence/100) + 0.001) + '';
		return '€  ' + Math.round(n*100)/100;
		//return '€ ' + n.substring(0, n.indexOf('.') + 3);
	//}
}