/**
-- code created by RPGoutfitter.com
-- RPGoutfitter ©2004-2007
**/
function isDefined(varCheck)
{ return (typeof(window[varCheck])!="undefined"); }
function submitButtonFix(oForm){
	if(document.all||document.getElementById){
		for (i=0;i<oForm.length;i++){var elObj=oForm.elements[i];if(elObj.type.toLowerCase()=="submit"||elObj.type.toLowerCase()=="button"||elObj.type.toLowerCase()=="reset") elObj.disabled=true}}}
function submitOnce(oForm){
	if(! isDefined('_submit')){_submit=1;submitButtonFix(oForm);return true;}
	else {return false;}}
function doSubmit(oForm){
	if(! isDefined('_submit')){_submit=1;submitButtonFix(oForm);oForm.submit();}}
function setOpacity(sEl,val){
	oEl=document.getElementById(sEl);
	if(oEl){oEl.style.opacity = val/10;
	oEl.style.filter = 'alpha(opacity=' + val*10 + ')';}}
function togBox(cName){
  var obj = document.getElementById(cName);
  if(obj.style.display == 'none' || obj.style.display == ''){showBox(obj);}
  else{hideBox(obj);}}
function togNav(cName){
  var obj = document.getElementById(cName);
  var obj2 = document.getElementById(cName+'h');
  if(obj.style.display == 'none'){obj2.className='section expanded';showBox(obj);}
  else{obj2.className='section';hideBox(obj);}}
function showBox(oName){oName.style.display='block';}

function hideBox(oName){oName.style.display='none';}
function addAttributeName(node) {if(node.type&&!(node.className&&node.className.indexOf(node.type)>=0)) {node.className = node.type;}}
function togCell(cName){
  var obj = document.getElementById(cName);
  if(obj.style.display == 'none' || obj.style.display == ''){showCell(obj);}
  else{hideCell(obj);}}
function showCell(oName){
  dispType = (oName.tagName.toLowerCase()=='tr') ? 'table-row':'table-cell';
  try{oName.style.display=dispType;}
  catch(e){oName.style.display = 'block';}}
function hideCell(oName){oName.style.display='none';}
function parseQueryString(q){
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q){
		for(var i=0; i < this.q.split("&").length; i++)
		{this.keyValuePairs[i] = this.q.split("&")[i]; }}
	this.getKeyValuePairs = function() { return this.keyValuePairs;}
	this.getValue = function(s){
		for(var j=0; j < this.keyValuePairs.length; j++){
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];} return false;}
	this.getParameters = function(){
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++)
		{a[j] = this.keyValuePairs[j].split("=")[0];} return a;}
	this.getLength = function() { return this.keyValuePairs.length;}}
function getQueryString(key){
	if(! isDefined('_urlVarAS'))
	{ _urlVarAS = new parseQueryString(window.location.search); }
	return unescape(_urlVarAS.getValue(key));}
function popWin(_pHndl,_url,_w,_h) {
	_props='toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0';
	if(_w){_props+=',width='+_w;}
	if(_h){_props+=',height='+_h;}
	if(navigator.appName == "Microsoft Internet Explorer") {
	_x = window.screen.availWidth;_y=document.body.offsetHeight;}
	else {_x=window.outerWidth;_y=window.outerHeight;}
	_x=(_x-_w)/2;_y=(_y-_h)/2;
	if(_x){_props+=',left='+_x;}
	if(_y){_props+=',top='+_y;}
	_win=window.open(_url,_pHndl,_props);
	if(window.focus){_win.focus()}}
function invertChecked(oForm){
	for (i=0;i<oForm.length;i++){
		if(oForm.elements[i].type.toLowerCase()=="checkbox"){
			oForm.elements[i].checked=!oForm.elements[i].checked;}}}
function unChecked(oForm){
	for (i=0;i<oForm.length;i++){
		if(oForm.elements[i].type.toLowerCase()=="checkbox"){
			oForm.elements[i].checked=0;}}}
function selectRange(oForm){
	var x1=0; var x2=0;
	for (i=0;i<oForm.length;i++){
		if( (oForm.elements[i].type.toLowerCase()=="checkbox") && oForm.elements[i].checked ){
			if(x1==0) x1=i;
			else if(x2==0) x2=i; }}
	for (i=x1;i<x2;i++){
		if( (oForm.elements[i].type.toLowerCase()=="checkbox"))
			oForm.elements[i].checked=1;}}
function ajaxSubmit(oForm) {
	var target = oForm;
	if (!target) return;
	if (target.ajaxIsActive) return;
	ajaxButton = target.elements['submitbutton'];
	ajaxButton.disabled = true;
	var xmlhttp =  new XMLHttpRequest();
	xmlhttp.open('POST','/WoW-GM/data.cfm?ajax=1',true);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) {ajaxResponse(xmlhttp.responseXML, target);} else target.submit();}
		else if(xmlhttp.readyState==3) ajaxButton.value = ':saving:';
		else if(xmlhttp.readyState==2) ajaxButton.value = ':'+ajaxButton.value+':';
		else if(xmlhttp.readyState==1) ajaxButton.value = ':'+ajaxButton.value+':';
		else if(xmlhttp.readyState==0) ajaxButton.value = ':'+ajaxButton.value+':';}
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send(ajaxSubmitString(target));
	target.ajaxIsActive = true;}
function ajaxSubmitString(target) { var fieldvals; for (var i=0;i<target.elements.length;i++) {fieldvals += target.elements[i].name + '=' + target.elements[i].value+'&';} return fieldvals;}
function ajaxResponse(responseXML, target) {
	setTimeout("ajaxRestore(ajaxButton);",5000);
	target.elements['submitbutton'].value = ':: saved ::';
	target.ajaxIsActive = false;}
function ajaxRestore(oButton) {oButton.value='save';oButton.disabled=false;}
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);}}
	return (arrReturnElements)}
function toggleImage(oImg,bState,sColor) {
	sColor == null ? sColor = '#CDCDCD' : 0;
	oImg.style.backgroundColor = bState ? sColor : '';}

