/*
 * Noir Games Functions
 *
 *
 * Copyright (c) 2009-2010 Brent Neef
 *
 */



function submitForm(action){
//document.all.logForm.innerHTML = document.logForm.innerHTML + "<input type=hidden name=submit value='" + action +"'>";
document.logForm.doLogin.value='Login';
document.logForm.submit();
}


function showEffect(effectdesc,obj) {
	
	var popBox;
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version < 7))
  {
    return false;
  }
	var text =  '<table class=auctionpoptext>';
	text = text + '<tr><td colspan=2><font color=white><b>' + effectdesc + '</b></font></td><tr>';
	text = text + '</table>';
	
  popBox = document.createElement('div');
  popBox.id = 'popInfo';
  popBox.setAttribute('class','popInfo');
  popBox.innerHTML = text;
  //alert(text);
  obj.appendChild(popBox);
  
}


function hideEffect() {
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version < 7))
  {
    return false;
  }
	 var popBox;
   node = document.getElementById('popInfo');
   node.parentNode.removeChild(node);
}






function showPI(itemname,itemdesc,itemcolor,itemimg,attrate,reloadrate,attpower,acc,sell,minlevel,statreq,minstat,def,bonusname,bonuspct, dpr, obj) {
	
	var popBox;
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version < 7))
  {
    return false;
  }

	
	
	
	var text = '<table class=auctionpoptext>';
	text = text + '<tr><td colspan=2><font color=' + itemcolor + '><b>' + itemname + '</b></font></td><tr>';
	if (itemimg!='')
	{
		text = text + '<tr><td colspan=2><img width=125 src="' + itemimg + '"/></td><tr>';
	}
	text = text + '<tr><td colspan=2>' + itemdesc + '</td><tr>';
	if (attrate!='')
	{
		text = text + '<tr><td class=invi>Attack Rate</td><td class=invi>' + attrate + '</td></tr>';
	}
	if (reloadrate!='')
	{
		text = text + '<tr><td class=invi>Reload Rate</td><td class=invi>' + reloadrate + '</td></tr>';
	}
	if (dpr!='0')
	{
		text = text + '<tr><td class=invi>Damage Per Round</td><td class=invi>' + dpr + '</td></tr>';
	}
	if (attpower!='')
	{
		text = text + '<tr><td class=invi>Attack Power</td><td class=invi>' + attpower + '</td></tr>';
	}
	if (acc!='')
	{
		text = text + '<tr><td class=invi>Accuracy</td><td class=invi>' + acc + '</td></tr>';
	}
	if (def!='')
	{
		text = text + '<tr><td class=invi>Defense</td><td class=invi>' + def + '</td></tr>';
	}
	if (minlevel!='' && minlevel!='0')
	{
		text = text + '<tr><td class=invi>Required Level</td><td class=invi>' + minlevel + '</td></tr>';
	}
	if (statreq!='None' && statreq!='')
	{
		text = text + '<tr><td class=invi>Required ' + statreq + '</td><td class=invi>' + minstat + '</td></tr>';
	}
	if (bonusname != 'None')
	{
		text = text + '<tr><td class=invi><font color=gold>Bonus Stat</font></td><td class=invi><font color=gold>' + bonusname + ' ' + bonuspct + '%</font></td></tr>';
	}
	if (sell!='')
	{
		text = text + '<tr><td class=invi>Sell to Vendor</td><td class=invi>' + sell + '</td></tr>';
	}
	text = text + '</table>';
  popBox = document.createElement('div');
  popBox.id = 'popInfo';
  popBox.setAttribute('class','popInfo');
  popBox.innerHTML = text;
  obj.appendChild(popBox);
}





function hidePI() {
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ((browser=="Microsoft Internet Explorer") && (version < 7))
  {
    return false;
  }
	 var popBox;
   node = document.getElementById('popInfo');
   node.parentNode.removeChild(node);
}

function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		numberfield.value = '1';
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

for (i = 0;  i < checkStr.value.length;  i++)
{
ch = checkStr.value.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{	
alertsay = "Please enter only number quantity."
alert(alertsay);
return (false);
}

// set the minimum and maximum
var chkVal = allNum;
var prsVal = parseInt(allNum);
if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
{
alertsay = "Please enter a value betwen " + minval + " and " + maxval + ".";
alert(alertsay);
return (false);
}
}



<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}
// End -->

function ajaxFunction(phpPage,updateObjectName,objectType){
	var ajaxRequest;  // The variable that makes Ajax possible!
	var updateObject = document.getElementById(updateObjectName);
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if (objectType=='inner')
			{
	
				updateObject.innerHTML = ajaxRequest.responseText;
	
			}
			// Get the data from the server's response
		}	
	}
	ajaxRequest.open("GET", phpPage, true);
	
	ajaxRequest.send(null); 
	
	
}
