/* java for pages at superbrawl only, not required on remote sites */

function act(actions,nspot) {
 rnm=Math.floor(Math.random()*900000); var rnms="&xsi=" + rnm; if (nspot == "") {nspot="Output";} spot=nspot;	actError='';
 if (actions.substring(0,4)=="form") {var fname=actions.substring(5); formstr=''; processForm(fname); 
 	var url=urlv11+"?"+formstr + rnms;
 }
 else if (actions.substring(0,3)=="sel") {var sa=actions.split(':'); var sn=sa[1]; var sv=document.getElementById(sn).value; var sa=sa[2]; var url=urlv11+"?"+sa+sv+rnms;}
 else {var url=urlv11+"?"+actions+rnms;}
 if (actError != 'Y') {
  if (typeof XMLHttpRequest != 'undefined') {fetch=new XMLHttpRequest();} try {fetch = ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {fetch=new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}} fetch.open("GET", url, true); fetch.onreadystatechange=doAct; fetch.send(null);
 }	
} 
function doAct () {if (fetch.readyState == 4) {document.getElementById(spot).innerHTML=fetch.responseText;}}
function processForm (fname) {
 str=''; formstr='';	f=document[fname]; var elem=f.elements; var felems=new Array();
 for(var i=0; i<elem.length; i++){
 	var fname=elem[i].name; var fval=elem[i].value; felems[fname]=fval;
 	if (fname == "fieldcheck") {var alerts=''; var fca=fval.split(",");
   for(var c=0; c<fca.length; c++) {
 	  var fci=fca[c]; var fcia=fci.split("="); var chkname=fcia[0]; 
 	  if (felems[chkname] == "") {actError='Y'; alerts+=fcia[1]+"\r";}
 	 }
 	 if (alerts != "") {alert(alerts);}
  }
	if (elem[i].type == "button") {continue;} if (fname == "fieldcheck") {continue;} 
	if ( ( (elem[i].type == "checkbox") || (elem[i].type == "radio") ) && elem[i].checked == false) {continue;}
	formstr+="&"+fname+"="+elem[i].value; // +"&et="+elem[i].type
 } 
}

 function chgLocation (actions,nspot) {
  if (document.superform.locOpts[1].checked) {document.getElementById("locacell").innerHTML='<input type="text" name="wlocation" value="yoursite.com (type here)" onclick="this.value=\'\'" class="acTinput" style="width:15.0em;" />'; actions+="-y";}
  else {document.getElementById("locacell").innerHTML='at your website'; actions+="-s";
 	 document.superform.elements.hostOpts[0].checked=false; document.getElementById("insCost").innerHTML='';
 	 document.superform.elements.hostOpts[1].checked=false; document.getElementById("dregCost").innerHTML='';
 	 document.superform.elements.hostOpts[2].checked=false; document.getElementById("hostCost").innerHTML='';
  }
  revSetup(); doAction(actions,nspot);
 }
 function chkInstall (actions,nspot) {
  if (document.superform.hostOpts[0].checked == false) {document.getElementById("insCost").innerHTML='\$0.00'; actions+="-n";}
  revSetup(); doAction(actions,nspot);
 }
 function chkDomain (actions,nspot) {
  if (document.superform.hostOpts[1].checked == false) {document.getElementById("dregCost").innerHTML=''; actions+="-n";}
  revSetup(); doAction(actions,nspot);
 }
 function chkHosting (actions,nspot) {
  if (document.superform.hostOpts[2].checked == false) {document.getElementById("hostCost").innerHTML=''; actions+="-n";}
  if (document.superform.hostOpts[2].checked) {document.superform.elements.locOpts[1].checked = true;}
  revSetup(); doAction(actions,nspot);
 }
 function chkCreative (actions,nspot) {
  if (document.superform.hostOpts[3].checked == false) {document.getElementById("creaCost").innerHTML=''; actions+="-n";}
  revSetup(); doAction(actions,nspot);
 }
 function capCalc (chg) {
 	var pv=document.superform.playerpricing.value.split(",");
 	var cap=document.superform.capacity.value; 	cap=cap*1 + chg*1;
 	document.superform.capacity.value=cap;
 	var incr=''; var ip=0; var tot=50; var excs=''; var basec='';
 	base=pv[0].split(":"); var basec=base[0]; var tot=base[1]*1; baseprice=tot.toFixed(0); var excs=cap - basec;
 	var content='<table align="center" class=acstable><tr><th colspan="2" class=th2>Player Pricing Details</td></tr><tr><td>first '+basec+' players</td><td align=right>\$' + baseprice+'</td></tr>';
 	if (excs>0) {
 	 for (var c=1; c<pv.length; c++) {
 	 	var pvs=pv[c].split(":");
 	 	if (excs > 0) {
 	 	 if (excs > pvs[0]) {incr=pvs[0];} else {incr=excs;}
 	 	 ip=incr * pvs[1]; ip=ip.toFixed(0); excs=excs - pvs[0]; tot=tot*1 + ip*1;
 	 	 content+='<tr><td>next '+incr+' players('+pvs[1]+'\@)</td><td align=right>\$' +  ip + '</td></tr>';
 	 	}
 	 }
 	}
 	tot=tot.toFixed(0);
 	content+='<tr><td></td><td align=right>\$'+tot+'</td></tr></table>';
 	document.getElementById("capCost").innerHTML="\$"+tot;
 	document.superform.capcostv.value=tot;
 	document.getElementById("legend").innerHTML=content;
 	revSetup();
 }
 
 function revSetup () {
 	var cost=document.superform.capcostv.value; cost=cost*1; var lprc=document.superform.locprc.value.split(":");
 	var locp=lprc[0]*1; locp=locp.toFixed(0);	var insp=lprc[1]*1; insp=insp.toFixed(0); var drgp=lprc[2]*1; drgp=drgp.toFixed(0);
  var hstp=lprc[3]*1; hstp=hstp.toFixed(0); var crep=lprc[4]*1; crep=crep.toFixed(0);

 	if (document.superform.hostOpts[2].checked) {
 	 cost=cost + hstp * 1; document.getElementById("hostCost").innerHTML='\$'+hstp;
 	 document.getElementById("dregCost").innerHTML='\$0.00';
 	 document.getElementById("insCost").innerHTML='\$0.00';
 	 document.getElementById("locCost1").innerHTML='';
 	 document.getElementById("locCost2").innerHTML='\$0.00';
 	}
 	else {
 	 if (document.superform.locOpts[1].checked) {cost=cost + locp * 1; document.getElementById("locCost2").innerHTML="\$" + locp; document.getElementById("locCost1").innerHTML='';}
   else {document.getElementById("locCost2").innerHTML=''; document.getElementById("locCost1").innerHTML='\$0.00';}
   if (document.superform.hostOpts[0].checked) {cost=cost + insp * 1; document.getElementById("insCost").innerHTML='\$'+insp;}
   if (document.superform.hostOpts[1].checked) {cost=cost + drgp * 1; document.getElementById("dregCost").innerHTML='\$'+drgp;}
  }
  if (document.superform.hostOpts[3].checked) {cost=cost + crep * 1; document.getElementById("creaCost").innerHTML='\$'+crep;}
  else {document.getElementById("creaCost").innerHTML='';}
 	cost=cost.toFixed(0); document.superform.total.value="\$"+cost;
 	
 }
 function chgCap (fname,tgt,chg){ 	f=document[fname];  var tgtv=f[tgt].value;  tgtv=tgtv*1 + chg*1; if (tgtv<0) {tgtv=0;}  f[tgt].value=tgtv; calcPrc();}
 function calcPrc () {
 	var price=25; var ptype=document.superform.ptype.value; 
 	if (ptype == "std") {var cap=document.superform.capacity.value; var xtrap=cap > 50 ? ((cap - 50) * 0.40):0; xtrap=xtrap.toFixed(0); price=xtrap*1 + price*1;}
 	else {
 	 var cap=document.superform.capacity.value; var xtrap=cap > 100 ? ((cap - 100) * 0.40):0; xtrap=xtrap.toFixed(0); price=xtrap*1 + price*1;
 	 if (document.superform.hosting[0].checked) {price=price*1 + 125;}
 	 else {price=price*1 + 40;
 	 	if (ptype == "web" && document.superform.domreg[0].checked) {price=price*1 + 20;}
 	  if (ptype == "web" && document.superform.install[0].checked) {price=price*1 + 20;}
 	  if (ptype == "cms" && document.superform.cmsconfig[0].checked) {price=price*1 + 35;}
 	 }}
 	if (price<25) {price=25;} document.superform.price.value=price;
 }
 function chgVal (fname,tgt,chg){ 	f=document[fname];  var tgtv=f[tgt].value;  tgtv=tgtv*1 + chg*1; if (tgtv<0) {tgtv=0;}  f[tgt].value=tgtv;}
 function setVal (fname,tgt,val){ 	f=document[fname];  f[tgt].value=val;}
 function setOU  (fname,game) {var gval="ougame"+game; var oul="oul"+game; f=document[fname]; var cv=f[gval].value; if (cv == "O") 			{var nv="U"; var nvt="Under";} else if (cv == "U") {var nv="X"; var nvt="clear";} else {var nv="O";  var nvt="Over";} f[gval].value=nv; document.getElementById(oul).innerHTML='<font color=red>'+nvt+'</font>';}
 function fixVal (fname,c1,c2){ 	f=document[fname]; f[c2].value=f[c1].value;; }
 function setOpt (actions,cell,fname,nspot){f=document[fname];  var cv=f[cell].value;  actions+=cv; doAction (actions,nspot);}
 function setSkn (fname,skn) {
 	f=document[fname]; var skinn="skinn";
 	var c="ext"+skn; var ext=f[c].value;
 	var c="des"+skn; var des=f[c].value;
 	
 	f[skinn].value=skn+":"+ext;
 	document.getElementById("sover").style.display='block';
 	document.getElementById("soverc").innerHTML=des;
 	
 }
 function ccLogin (cwa,cwp) {
 	document.getElementById("xdiv").innerHTML=''; document.getElementById("xdiv").style.display='none';
  var cv='wp='+cwa+'&password='+cwp;
  actions='ac=control&sa=admlogin&wp='+cwa+'&password='+cwp; doAction(actions,'content');
  // window.location.reload(); actions='ac=control&sa=console&wp='+cwa+'&password='+cwp; doAction(actions,'content');
 }

function pSetup (ptype) {
 document.getElementById("stab").className=ptype;
 document.getElementById("quote").className=ptype;
 document.getElementById("pcap").className=ptype;
 
 if 			(ptype == "web") {document.getElementById("webinfo").style.display='block'; document.getElementById("stdinfo").style.display='none'; document.getElementById("cmsinfo").style.display='none';}
 else if 	(ptype == "std") {document.getElementById("stdinfo").style.display='block'; document.getElementById("webinfo").style.display='none'; document.getElementById("cmsinfo").style.display='none';}
 else if 	(ptype == "cms") {document.getElementById("cmsinfo").style.display='block'; document.getElementById("stdinfo").style.display='none'; document.getElementById("webinfo").style.display='none';} 	
 document.superform.ptype.value=ptype;
 calcPrc();
}
function pSrch (nspot) {
 	var ps=document.superform.psearch.value; ps=ps.toLowerCase(); 
 	// var filter=new Array('foot','ball');  for(var i=0; i<filter.length; i++) {var ps=ps.replace(filter[i],"");}	
 	actions='ac=poolFind&sa=search&psearch='+ps; 
 	doAction(actions,nspot);
 }  
function slider (a_init, a_tpl) {this.f_setValue=f_sliderSetValue;	this.f_getPos=f_sliderGetPos;	if (!window.A_SLIDERS) {window.A_SLIDERS = [];}	this.n_id = window.A_SLIDERS.length; window.A_SLIDERS[this.n_id]=this; var s_key; if (a_tpl) {for (s_key in a_tpl) {this[s_key]=a_tpl[s_key];}}	for (s_key in a_init)	{this[s_key] = a_init[s_key];}this.n_pix2value = this.n_pathLength / (this.n_maxValue - this.n_minValue);	if (this.n_value == null) {this.n_value = this.n_minValue;}	document.write('<div style="width:' + this.n_controlWidth + 'px;height:' + this.n_controlHeight + 'px;border:0; background-image:url(' + this.s_imgControl + ')" id="sl' + this.n_id + 'base">'+'<img src="' + this.s_imgSlider + '" width="' + this.n_sliderWidth + '" height="' + this.n_sliderHeight + '" border="0" style="position:relative;left:' + this.n_pathLeft + 'px;top:' + this.n_pathTop + 'px;z-index:' + this.n_zIndex + ';cursor:pointer;visibility:hidden;" name="sl' + this.n_id + 'slider" id="sl' + this.n_id + 'slider" onmousedown="return f_sliderMouseDown(' + this.n_id + ')"/></div>'); this.e_base   = get_element('sl' + this.n_id + 'base');	this.e_slider = get_element('sl' + this.n_id + 'slider');	if (document.onmousemove != f_sliderMouseMove) {window.f_savedMouseMove = document.onmousemove;	document.onmousemove = f_sliderMouseMove;}	if (document.onmouseup != f_sliderMouseUp) {window.f_savedMouseUp = document.onmouseup;	document.onmouseup = f_sliderMouseUp;}	var e_input = this.s_form == null	? get_element(this.s_name): document.forms[this.s_form]	? document.forms[this.s_form].elements[this.s_name]	: null;	this.f_setValue(e_input && e_input.value != '' ? e_input.value : null, 1);this.e_slider.style.visibility = 'visible';}
function f_sliderSetValue (n_value, b_noInputCheck) {if (n_value == null)n_value = this.n_value == null ? this.n_minValue : this.n_value;if (isNaN(n_value))	return false;	if (this.n_step)n_value = Math.round((n_value - this.n_minValue) / this.n_step) * this.n_step + this.n_minValue;if (n_value % 1)n_value = Math.round(n_value * 1e5) / 1e5;if (n_value < this.n_minValue)n_value = this.n_minValue;if (n_value > this.n_maxValue)n_value = this.n_maxValue;this.n_value = n_value;	if (this.b_vertical)this.e_slider.style.top  = (this.n_pathTop + this.n_pathLength - Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';else this.e_slider.style.left = (this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';var e_input;if (this.s_form == null) {e_input = get_element(this.s_name);	if (!e_input)	return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the input with ID='" + this.s_name + "'.");}	else {var e_form = document.forms[this.s_form];	if (!e_form)return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the form with NAME='" + this.s_form + "'.");e_input = e_form.elements[this.s_name];	if (!e_input)	return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the input with NAME='" + this.s_name + "'.");	}	e_input.value = n_value;}
function f_sliderGetPos (b_vertical, b_base) {var n_pos = 0,s_coord = (b_vertical ? 'Top' : 'Left');var o_elem = o_elem2 = b_base ? this.e_base : this.e_slider;while (o_elem) {n_pos += o_elem["offset" + s_coord];o_elem = o_elem.offsetParent;}	o_elem = o_elem2;	var n_offset;while (o_elem.tagName != "BODY") {n_offset = o_elem["scroll" + s_coord];if (n_offset)	n_pos -= o_elem["scroll" + s_coord];o_elem = o_elem.parentNode;	}	return n_pos;}
function f_sliderMouseDown (n_id) {window.n_activeSliderId = n_id;	return false;}
function f_sliderMouseUp (e_event, b_watching) {if (window.n_activeSliderId != null) {var o_slider = window.A_SLIDERS[window.n_activeSliderId];o_slider.f_setValue(o_slider.n_minValue + (o_slider.b_vertical?(o_slider.n_pathLength - parseInt(o_slider.e_slider.style.top) + o_slider.n_pathTop):(parseInt(o_slider.e_slider.style.left) - o_slider.n_pathLeft)) / o_slider.n_pix2value);if (b_watching)	return;	window.n_activeSliderId = null;}	if (window.f_savedMouseUp)return window.f_savedMouseUp(e_event);}
function f_sliderMouseMove (e_event) {if (!e_event && window.event) e_event = window.event;	if (e_event) {window.n_mouseX = e_event.clientX + f_scrollLeft();window.n_mouseY = e_event.clientY + f_scrollTop();	}if (window.n_activeSliderId != null) {var o_slider = window.A_SLIDERS[window.n_activeSliderId];	var n_pxOffset;if (o_slider.b_vertical) {var n_sliderTop = window.n_mouseY - o_slider.n_sliderHeight / 2 - o_slider.f_getPos(1, 1) - 3;if (n_sliderTop < o_slider.n_pathTop)	n_sliderTop = o_slider.n_pathTop;	var n_pxMax = o_slider.n_pathTop + o_slider.n_pathLength;	if (n_sliderTop > n_pxMax)n_sliderTop = n_pxMax;o_slider.e_slider.style.top = n_sliderTop + 'px';	n_pxOffset = o_slider.n_pathLength - n_sliderTop + o_slider.n_pathTop;}	else {var n_sliderLeft = window.n_mouseX - o_slider.n_sliderWidth / 2 - o_slider.f_getPos(0, 1) - 3;if (n_sliderLeft < o_slider.n_pathLeft)	n_sliderLeft = o_slider.n_pathLeft;	var n_pxMax = o_slider.n_pathLeft + o_slider.n_pathLength;if (n_sliderLeft > n_pxMax)	n_sliderLeft = n_pxMax;	o_slider.e_slider.style.left = n_sliderLeft + 'px';n_pxOffset = n_sliderLeft - o_slider.n_pathLeft;}	if (o_slider.b_watch) f_sliderMouseUp(e_event, 1);	return false;}	if (window.f_savedMouseMove) return window.f_savedMouseMove(e_event);}
function f_scrollLeft() {return f_filterResults (window.pageXOffset ? window.pageXOffset : 0,document.documentElement ? document.documentElement.scrollLeft : 0,document.body ? document.body.scrollLeft : 0);}
function f_scrollTop() {return f_filterResults (window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0	);}
function f_filterResults(n_win, n_docel, n_body) {var n_result = n_win ? n_win : 0;	if (n_docel && (!n_result || (n_result > n_docel)))	n_result = n_docel;	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;}
function f_sliderError (n_id, s_message) {alert("Slider #" + n_id + " Error:\n" + s_message);	window.n_activeSliderId = null;}

function fixPhase (fname,field) {
 var f=document[fname]; var field2=f[field].value; 
 field2=field2.replace(/:/g, "-"); field2=field2.replace(/,/g, "-"); field2=field2.replace(/\|/g, "-");
 f[field].value=field2;
}

