function changeVisibility (objectID, newVisibility) {
	var styleObject = getStyleObject(objectID);
	if (styleObject) {
		styleObject.visibility = newVisibility;
		return true;
	} else {
		return false;
	}
} // changeVisibility

function getStyleObject (objectId) {
	// cross-browser function to get an object's style object given its id
  if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
		return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
		return document.all(objectId).style;
  } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
  } else {
		return false;
  }
} // getStyleObject

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];
	}
}

function numbersonly (myfield, e, dec) {
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	   
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	   return true;
	
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}

//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 browser size
//http://www.quirksmode.org/viewport/compatibility.html
function getWindowSize() {
	var x,y;
	
	// all except Explorer
	if (self.innerHeight) {
		x = self.innerWidth;
		y = self.innerHeight;
	// Explorer 6 Strict Mode
	} else if (document.documentElement && document.documentElement.clientHeight) {
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	// other Explorers
	} else if (document.body) {
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return new Array(x,y);
}

function readmore (id) {
	if (id == 1) {
		$$('td.waymore','th.waymore').each(function(s){
			s.show();
		});
		$('readmore1').hide();
		$('readmore2').show();
	} else if (id == 0) {
		$$('td.waymore','th.waymore').each(function(s){
			s.hide();
		});
		$('readmore1').show();
		$('readmore2').hide();
	}
}

// DYNAMIC RESIZING OF FLASH MOVIES DONE USING THIS:
// http://hossgifford.com/downloads.htm
// I did make some changes to it though
function resizeSWF(id,nWidth,nHeight) {
	if (nWidth == null || !nWidth) nWidth = '';
	if (nHeight == null || !nHeight) nHeight = '';
	nWidth = nWidth.toString();
	nHeight = nHeight.toString();
	if (nWidth.length > 0) {
		if (nWidth.substr(nWidth.length-2) != 'px' && nWidth.substr(nWidth.length-1) != '%') nWidth += "px";
		document.getElementById(id).style.width = nWidth;
		document.getElementById(id+'_div').style.width = nWidth;
	}
	if (nHeight.length > 0) {
		if (nHeight.substr(nHeight.length-2) != 'px' && nHeight.substr(nHeight.length-1) != '%') nHeight += "px";
		document.getElementById(id).style.height = nHeight;
		document.getElementById(id+'_div').style.height = nHeight;
	}
}

//stop 100% flash movie from shrinking below a certain size
function swfSizeMin(swf_id,min_w,min_h) {

	//set it up to update
	window.onresize = function() {
		swfSizeMin(swf_id,min_w,min_h)
	}
	
	//get window size
	var sizes = getWindowSize();
	var win_w = sizes[0];
	var win_h = sizes[1];

	//figure out what to set flash size to
	if (win_w < min_w) var w = min_w;
	else var w = "100%";
	if (win_h < min_h) var h = min_h;
	else var h = "100%";

	//set the size
	resizeSWF(swf_id,w,h);

}

function toggleDisplay(obj_id){ // Toggles display of certain syled elements
	if (document.getElementById){
		var obj = document.getElementById(obj_id);
		if (obj.style.display == '' || obj.style.display == 'none'){
			var state = 'block';
		} else {
			var state = 'none';
		}
		obj.style.display = state;
	}
}

function setDisplayOff(obj_id){ // Toggles display of certain syled elements
	if (document.getElementById){
		var obj = document.getElementById(obj_id);
		var state = 'none';
		obj.style.display = state;
	}
}

function setDisplayOn(obj_id){ // Toggles display of certain syled elements
	if (document.getElementById){
		var obj = document.getElementById(obj_id);
		var state = 'inline';
		obj.style.display = state;
	}
}

function open_player() {
	newWindow = window.open("http://suretone.com/player.php","player","scrollbars=1,menubar=0,toolbar=0,location=0,status=0");
}
