function quote(x) {
	return "\"" + x + "\"";
	}
function addEvent( obj, type, fn )
{
//	alert("add "+type+" event to obj "+obj.nodeName+" :"+fn);
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		}
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}
function browserObj() {
	this.platform = ''
	this.isNav4 = false
	this.isNav6 = false
	this.isIE = false
	this.isIE4 = false
	this.isMajor = false
	this.isMinor = false
	if (navigator.appVersion.indexOf('Mac') != -1) {
		this.platform = "mac"
	} else {
		this.platform = "pc"
	}
	//var isNav4, isNav6, isIE4, isMajor, isMinor;
	if ((navigator.appName.indexOf('Netscape') != -1)) {
		if (navigator.appVersion.charAt(0) > "4") {
			this.isNav6 = true
			this.isMajor = true
		} else {
			this.isNav4 = true;
			this.isMinor = true
		}
	} else {
		this.isIE = true;
		uA = navigator.userAgent.toLowerCase()
		ind = uA.indexOf("msie")
		uA = uA.substr(ind, uA.length)
		ind = uA.indexOf(";")
		uA = parseFloat(uA.substr(0, ind).replace("msie", ""))
		if (uA >= 5) {
			this.isMajor = true
		} else {
			this.isIE4 = true;
			this.isMinor = true
		}
	}
}

var browser = new browserObj()

function getAbsolutePos (who) {
	x = 0, y = 0
	if (!browser.isNav4) {
		while (who.offsetParent != null) {
			x += who.offsetLeft
			y += who.offsetTop
			who = who.offsetParent
		}
		x += who.offsetLeft
		y += who.offsetTop
	} else {
		x = who.x
		y = who.y
	}
	point = new pointObj(x, y)
	return point
}
function pointObj(x, y) {
	this.x = x
	this.y = y
}
function confirm_del() {
	return confirm("Are you sure you want to delete?");
}
function setvisibilityatt(obj,val) {
	var theobj = $(obj);
	if (!theobj)
		theobj = window.parent.document.getElementById(obj);
	if (theobj) {
		theobj.style.visibility = val;
		}
}
function setvisible(obj) {
	setvisibilityatt(obj,"visible");
}
function setinvisible(obj) {
	setvisibilityatt(obj,"hidden");
}
function setdisplayatt(obj,att) {
    var theobj = document.getElementById(obj);
    if (!theobj)
    	theobj = window.parent.document.getElementById(obj);
    if (theobj) {
    	theobj.style.display = att;
    	}
}
function setdisplay(obj) {
	setdisplayatt(obj,"block");
}
function setdisplayon(obj) {
	setdisplayatt(obj,"block");
}
function setdisplayoff(obj) {
	setdisplayatt(obj,"none");
}
/*
function setdisplay(obj) {$(obj).show();}
function setdisplayon(obj) {$(obj).show();}
function setdisplayoff(obj) {$(obj).hide();}
*/
var newWindow;
var newWindowTitle;  // obsolete, get rid of it
var newWindowContent;  // this is obsolete. get rid of it
var newWindowHTML;
function newnewWindowOpen(url,params) {
	var openparm='';
	var windowName='window';
	if (params['width']) params['width'] += 32; else params['width'] = 600;
	if (params['height']) params['height'] += 96; else params['height'] = 600;
	if (!params['left']) params['left'] = screen.width - params['width'];
	if (!params['top']) params['top'] = 20;
	var c = '';
	for (inx in params) {
		switch (inx) {
		default:
			openparm += c + inx + '=' + params[inx];
			c = ',';
			break;
		case ("windowName"):
			windowName = params[inx];
			break;
		}
	}
	var win = window.open(url,windowName,openparm);
	win.resizeTo(params['width'],params['height']);
//	win.moveTo(params['left'],params['top']);
	win.focus();
	return win;
}
function newWindowFromHTML(html,params) {
	if (!newWindow || newWindow.closed) {
		newWindow = newnewWindowOpen("",params);
		newWindowHTML = html;
		setTimeout("newwriteNewWindow()",100);
	}
	else {
		newWindow.document.write(html);
		newWindow.document.close();
		newWindow.focus();
	}
 	return newWindow;
}
function newWindowFromContent(content,params) {
	var title = "Pop Up Window";
	if (params.windowTitle) {
		title = params.windowTitle;
		delete params.windowTitle;
	}
	html = "<html><head><title>" + title + "</title></head>\n" +
		   "<body>" +
		   "<h3>" + title + "</h3>\n" +
		   content +
		   "\n</body></html>";
	return newWindowFromHTML(html,params);
}
function newwriteNewWindow() {
	newWindow.document.write(newWindowHTML);
	newWindow.document.close();
	newWindow.focus();
}
function newwindowopen(url, windowname, width, height) {
	alert ("call on (old) newwindowopen in scripts.js. Fix me");
	var param = {width:width,height:height,windowname:windowname,
				 location:'no',menubar:'yes',status:'yes',toolbar:'yes',
				 scrollbars:'no',resizable:'yes'};
	newnewWindowOpen(url,paramy);
}
/*
 *  Obsolete
 */
function buildNewWindow(title,content,height,width) {
	alert ("call on buildNewWindow in scripts.js. Fix me.");
	newWindowTitle = title;
	newWindowContent = content;
	if (!newWindow || newWindow.closed) {
		newWindow = window.open("","sub",
					"status,height="+height+",width="+width);
		setTimeout("writeNewWindow()",100);
	}
	else
		newWindow.focus();
	return newWindow;
}
/*
 *  Obsolete
 */
function writeNewWindow() {
	var page = "<html><head><title>" + newWindowTitle +
			   "</title></head>\n<body><h3>" + newWindowTitle +
			   "</h3>\n" + newWindowContent +
			   "\n</body></html>";
	newWindow.document.write(page);
	newWindow.document.close();
	newWindow.focus();
}
function debug(browser,platform) {
	alert ("Compatibility Mode: "+document.compatMode+
		   " Browser: "+browser+
		   " Platform: "+platform);
}
function setupGrid(gridType,gridInit) {
	var gridId = gridType+"grid";
	var obj = $(gridId);
	var getDataUrl="sendxml.php?type="+gridType+"&random="+(new Date()).valueOf();
	grid = new dhtmlXGridObject(obj);
	grid.setImagePath(gridInit.imagesdir);
	grid.setHeader(gridInit.label);
	grid.setInitWidths(gridInit.width);
	grid.setColAlign(gridInit.align)
	grid.setColTypes(gridInit.type);
	grid.setColSorting(gridInit.sort);
	var combos = gridInit.combos;
	for (var i=0,j=combos.length;i<j;i++) {
		var combo = combos[i];
		var combobox = grid.getCombo(combo.column);
		var values = combo.values;
		for (var k=0,l=values.length;k<l;k++) {
/*			var vals = values[k];
			combobox.put(vals[0],vals[1]);
*/
			combobox.put(values[k][0],values[k][1]);
			}
	}
	grid.enableLightMouseNavigation(true);
//	grid.setXMLAutoLoading(getDataUrl,30);
//	grid.enableAutoHeigth(true);
//	grid.enableBuffering(20);
	grid.setSkin("xp")
	grid.init();
	grid.loadXML(getDataUrl);
}
/*---------------------------
  Cycling of images
  ---------------------------*/
/*
 * This part has been put local to
 * City Club site
 *
localimages = new Array();
var image;
var loadcounter;
function changeShow(showName){
	select = document.getElementById("showselect");
	if (select)
		showName = select.value;
	getShow(showName);
}
function getShow(showName) {
	new Ajax.Request('ajaxrequest.php',
		{ method:'get',
		  parameters:{showselect:showName},
	      onSuccess:
	      	function(transport,json){
	            var resp = transport.responseText || "no response text";
//				alert ("ajax response: "+resp);
				imagelist = null;
	            var func = new Function ("return "+resp);
	            imagelist = func();
	            image = 0;
	            loadcounter = imagelist.length-1;
	            for (i=0; i<imagelist.length; i++) {
	            	localimages[i] = new Image();
	            	localimages[i].onload = imageCounter;
	            	localimages[i].src = imagelist[i];
	            	}
	            },
	      onFailure:
	      	function(){
	      		alert('Something went wrong...')
	      		}
	 	});
}
function startImageCycle(useFade) {
	if (useFade==1)
		setTimeout("imageFadeout()",9000);
	else
		setTimeout("changeImage(1)",9000);
}
function imageCounter() {
	loadcounter--;
	if (loadcounter == 0) {
		image = 0;
		changeImage(1);
//		setTimeout("changeImage(1)",0);
		}
}
var timeout;
function changeImage(reschedule) {
	var h = localimages[image].height;
	var w = localimages[image].width;
	var elem = document.getElementById("cycleimage");
	if (timeout) clearTimeout(timeout);
	elem.src = null;
	if (h>w) {
		elem.height = 300;
		elem.width = (300/h)*w;
		}
	else {
		elem.width = 300;
		elem.height = (300/w)*h;
		mt = (350-h)/2;
		elem.margin_top = mt;
	}
	elem.src = localimages[image].src;
	image = (image+1)%(localimages.length);
	if (reschedule==1) {
		timeout = setTimeout("changeImage(1)",9000);
		}
}
*/
/*
 *  The fadein/fadeout stuff looks hokey. Just changing the
 *  postcard looks a lot better, I think.
 *
 */
/*
 *  This stuff was part of OBGB site.
 *  It is included in the OBGB.js script
 *
var imageOpacity = 10;
function imageFadeout() {
	imageOpacity -= 1;
	document.getElementById("cycleimagediv").style.filter="Alpha(opacity="+(imageOpacity*10)+")";
	document.getElementById("cycleimagediv").style.opacity = (imageOpacity/10);
	if (imageOpacity <= 0) {
		changeImage(false);
		imageOpacity = 0;
		setTimeout("imageFadein()",150);
		return;
	}
	setTimeout("imageFadeout()",90);
}
function imageFadein() {
	imageOpacity += 1;
	document.getElementById("cycleimagediv").style.filter="Alpha(opacity="+(imageOpacity*10)+")";
	document.getElementById("cycleimagediv").style.opacity = (imageOpacity/10);
	if (imageOpacity >= 10) {
		imageOpacity = 10;
		setTimeout("imageFadeout()",10000);
		return;
	}
	setTimeout("imageFadein()",90);
}
*/