// -------------------------------------------
// GENERAL JAVASCRIPT FUNCTIONS
// Robert Reinhard (Bukwild.com)
// 1.1.1 - 10/24/06
// -------------------------------------------

//open a centered popup
function popup(url,width,height,title,scrollbar,resizable,center) {
	
	//set defaults
	if (width == null) width = 600;
	if (height == null) height = 450;
	if (title == null) title = 'auto_popup';
	if (scrollbar == null) scrollbar = false;
	if (resizable == null) resizable = false;
	if (center == null) center = true;

	//set props
	scrollbar = scrollbar == true ? 'yes' : 'no';
	resizable = resizable == true ? 'yes' : 'no';
	winProperties = 'height='+height+',width='+width+',toolbar=no,location=no,scrollbars='+scrollbar+',titlebar=no,menubar=no,resizable='+resizable+',status=no';
	
	//open and move
	win = window.open(url,title, winProperties);
	if (!win) alert('Please disable your popup blocker to use this site.');
	else if (center) {
		if (self.screen) {
			sw = self.screen.width;
			sh = self.screen.height;
		} else return;
		win.moveTo((sw-width)/2,(sh-height)/2);
	}
	
}


//get element ref
function getElement(name){
	var dom = document.getElementById;
	var iex = document.all;
	var ns4 = document.layers;
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : ns4 ? eval(nest+"document."+name) : false;
	el.css = ns4 ? el : el.style;
	return el;
}

//swap the visiiblity of an element
var old_swap_vis_id = null;
function swapVis(id) {
	var el = getElement(id);
	if (old_swap_vis_id) old_swap_vis_id.css.display="none";
	el.css.display="";
	old_swap_vis_id = el;
}

//get browser size
function getWindowSize() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	return new Array(winW,winH);
}

//get a variable from the get
//courtesy of Ben
function getQueryVariable (variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}
