function saleTickets(returnObj) {
	//alert(returnObj['src'])
	document.getElementById('tixwise').innerHTML = "<A href='#' onclick=hideLayer('tixwise')><IMG src='/graphics/icon_x.gif' style='border:0px'></A>"+
	returnObj['src']
	showLayer('tixwise')

}
function updateBackImage(obj,image) {
	obj.style.backgroundImage="url('"+image+"')"
}

/**
*
*	divName String - a div name from top
*	innerText String - the text to show
*	closeButton Boolean - default is false, if true will show 'x' to enable manual closing of layer.
*	colorClass String - default is 'remarks'.
*	closeTime Int - miliseconds to hide. 0 is the default meaning do not close automatically.
*	zIndex Int - default is not to change the layers z-index, anything else is setting it.
*	posX Int - default is 200 adding offset of main_div of 229
*	posY Int - default is 200 adding offset of main_div of 165
*
**/
function qms3ShowLayer(divName,innerText,closeButton, colorClass,closeTime,zIndex,posX,posY) {
	closeButton = (closeButton == null || closeButton == '')? false : true
	colorClass = (colorClass == null || colorClass == '')? "remarks" : colorClass
	closeTime = (closeTime == null)? 0 : closeTime
	posX = (posX == null)? 200  : posX
	posY = (posY == null)? 200 : posY
	var L = top.document.getElementById(divName);

	L.className = colorClass
	var innerStr = (closeButton) ? "<A href='#' onclick=hideLayer('"+divName+"')><IMG src='/qms3/graphics/icon_x.gif' style='border:0px'></A>": ''
	L.innerHTML = innerStr + innerText
	showLayer(divName)
	moveLayer(divName,posX+229,posY+165)
	if(closeTime > 0) {
		var close = setTimeout('hideLayer(\''+divName+'\')',closeTime)
	}
	if(zIndex != null && zIndex != '') {
		L.style.zIndex = zIndex
	}

}


function XHR() {

	this.startWaiting = function() {
		startHourglass();
	}
	this.stopWaiting  = function() {
		stopHourglass();
	}

	try {
		// Opera 8.0+, Firefox, Safari
		this.xhr = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			this.xhr = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (othermicrosoft) {
			try {
				this.xhr = new ActiveXObject('Microsoft.XMLHTTP');
			} catch (failed) {
				this.xhr = false;
			}
		}
	}
}

function newPage(actionPath, varsString, callBackFunc, callBackFuncParams, silentMode, sendMethod) {
	top.location.href='main.php?'+varsString
}
function sendRequest(actionPath, varsString, callBackFunc, callBackFuncParams, silentMode, sendMethod) {

	var xhrObj = new XHR();
	xhrObj.silentMode = (silentMode == undefined) ? false : silentMode ;
	if (!xhrObj.xhr) {
		if ( !xhrObj.silentMode ) {
			alert('Error initializing XMLHttpRequest object!');
		}
		xhrObj.xhr = null;
		xhrObj = null;
		return false;
	}
	xhrObj.timeOutTimer = '';
	this.timeOutLimit = 30 * 1000;

	if(sendMethod == undefined) sendMethod = 'POST';

	if (sendMethod.toLowerCase() == 'get') {
		xhrObj.xhr.open('GET', actionPath + '?' + varsString, true);
		varsString = 'null';
	}else{
		xhrObj.xhr.open('POST', actionPath, true);
	}

	xhrObj.xhr.onreadystatechange = function() {
		siteResponse(xhrObj, callBackFunc, callBackFuncParams);
	};
	xhrObj.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
	xhrObj.xhr.send(varsString);
	if ( !xhrObj.silentMode ) {
		xhrObj.startWaiting();
		xhrObj.timeOutTimer = setTimeout( function(){
			xhrObj.xhr.abort();
			xhrObj.stopWaiting();
			alert('Error : 408 - Request Timeout')
		}, this.timeOutLimit);
	}else{
		xhrObj.timeOutTimer = setTimeout( function(){
			xhrObj.xhr.abort()
			}, this.timeOutLimit);
	}
	return true;
}


function siteResponse(xhrObj, callBackFunc, callBackFuncParams) {
	if (xhrObj.xhr.readyState == 4) {
		if ( !xhrObj.silentMode ) {
			clearTimeout(xhrObj.timeOutTimer);
			xhrObj.stopWaiting();
		}
		if (xhrObj.xhr.status == 200) {
			if(xhrObj.xhr.responseText) {
				var content = eval( "(" + xhrObj.xhr.responseText + ")" );
				if ( callBackFuncParams == '' ) {
					eval( callBackFunc + '( content )' );
				}else{
					eval( callBackFunc + '( content, callBackFuncParams )' );
				}
			}
		} else if ( xhrObj.xhr.status && !xhrObj.silentMode ) {
			alert('Error : ' + xhrObj.xhr.status + ' - ' + xhrObj.xhr.statusText );
		}
	}
}


function startHourglass() {
	//	alert(top.name);
	//	QMS3.document.getElementById('waiting').style.visibility='visible';
	if(top.name=='MS3') {
		top.document.getElementById('waiting').style.visibility='visible';
	}else{
		opener.top.document.getElementById('waiting').style.visibility='visible';
	}
	document.body.style.cursor ='wait';
}

function stopHourglass() {
	if(top.name=='MS3') {
		top.document.getElementById('waiting').style.visibility='hidden';
	}else{
		opener.top.document.getElementById('waiting').style.visibility='hidden';
	}
	document.body.style.cursor = "default";
}


var nn4 = (document.layers) ? true : false;
var dom = (document.getElementById ) ? true : false;
var ie = (document.all&& !dom) ? true : false;


function browser(id){
	if(nn4) {
		var path = document.layers[id];
	}else if(ie) {
		var path = document.all[id];
	}else {
		var path = document.getElementById(id);
	}
	return path ; //return the path to the css layer depending on which browser is looking at the page
}

function hideLayer(id){
	jQuery('#'+id).hide(400)
}

function showLayer(id) {
	jQuery('#'+id).css('visibility','visible')
	jQuery('#'+id).show(400);
}

function moveLayer(id,x,y) {
	//alert(x+'/'+y);
	var layer = browser(id) ;// get browser specific path to block element
	if(nn4){
		layer.top=y;
		layer.left=x;
	}else{
		layer.style.top=y;
		layer.style.left=x;
	}
}



/************************************************************************
list is an array of "text|value" used in ItemSwitch
*************************************************************************/
function makeSelect(list,theSelect){
	if(list.length!=0){
		s=list.sort();
		theSelect.length=s.length;
		for (var loop=0; loop < s.length; loop++)
		{
			var name_id=s[loop].split('|');
			theSelect.options[loop].text=name_id[0];
			theSelect.options[loop].value=name_id[1];
		}
	}else{
		theSelect.length=0;
	}
}


// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
	var nameq = name + "=";
	var c_ar = document.cookie.split(';');
	for (var i=0; i<c_ar.length; i++) {
		var c = c_ar[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
	}
	return null;
}

