window.onresize = reDo;
function reDo(){ window.location=window.location }

function popup(url,detWidth,detHeight) {
	leftPos = 40
	topPos = 40
	detWidth += 20
	detHeight += 20
	if (screen) {
		leftPos = screen.width * .1
		topPos = screen.height * .1
			}
	detWindow = window.open(url,detWidth+"x"+detHeight,'width='+detWidth+',height='+detHeight+',left='+leftPos+',top='+topPos+',toolbar,location,scrollbars,resizable,status')
	detWindow.focus()
}

// thanks Bill Dortch <bdortch@hidaho.com>   hidaho_cookies.js

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
//
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function checkVote(theForm) {
    var why = "";
    for (i=0, n=theForm.a.length; i<n; i++) {
        if (theForm.a[i].checked) {
            var checkvalue = theForm.a[i].value;
            break;
        } 
    }
    why += checkRadio(checkvalue);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
// exactly one radio button is chosen
}

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please indicate your choice on this question by selecting YES or NO.\n";
    }
return error;
}

// <body onload="initCount('x',250,'y','');">
// <textarea name="comments" cols="50" rows="2" id="x" onkeyup="return taCount('x','y');"></textarea><br>
// <small>You have <span id="y" class="bold">?</span> characters remaining</small>

var maxLen,errMsg;invChars=/[<>:\/="']/;  //global default settings
function initCount(ident,maxChars,displayId,chkStr){ // init settings
  taObj=document.getElementById(ident);maxLen=maxChars;
  errMsg="Sorry! Text entry stopped at limit of "+maxLen+" characters.";
  if(chkStr!==""){invChars=chkStr;}
  if(chkStr.toLowerCase()==="nocheck"){invChars="";}
  if(displayId.toLowerCase()==="noshow"){return;}
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=maxLen-taObj.value.length;
}
function taCount(ident,displayId){
  taObj=document.getElementById(ident);
  taLength=taObj.value.length; // look at current length
  if (taLength>maxLen){ // clip characters
    taObj.value=taObj.value.substring(0,maxLen);alert(errMsg);}
  taLength=taObj.value.length;oldLength=0;
  while (oldLength<taLength){ //validate characters
    tChar=taObj.value.charAt(oldLength);
    if ((invChars!=="")&&(invChars.test(tChar))){
       alert('Invalid char['+tChar+'] Letters, numbers or hyphens only.');
       tStr=taObj.value; tail=tStr.substring(oldLength+1);
       taObj.value=tStr.substring(0,oldLength)+tail;taLength--;
       }else{oldLength++;}
  }
  if (displayId.toLowerCase()==="noshow"){return;}
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=(maxLen-taObj.value.length);
}
function verify(id,p2){ //check for single digit values only
if (p2){ //clear request
  for (idx=0;idx<99;idx++){
    if (!document.getElementById(id+idx)){return false;}
    document.getElementById(id+idx).value="";}
  return false;}
for (idx=0;idx<99;idx++){ //if field is blank,set focus to it
   if (!document.getElementById(id+idx)){
   alert('Form has been sent!'); return true;}
   obj=document.getElementById(id+idx);temp=obj.value;
   if (isNaN(parseInt(temp,10))){
      alert('Entry must contain exactly one digit!');
      obj.value="";obj.focus();return false;}
   }
alert('Form has been sent!'); return true;}
function isHex(entry){
validChar='0123456789ABCDEF'; // characters allowed in hex
strlen=entry.length;   // how long is test string
if(strlen<1){alert('Enter Something!');return false;}
entry=entry.toUpperCase();   // lowercase characters?
// Now scan string for illegal characters
for (i=0;i<strlen;i++){
    if(validChar.indexOf(entry.charAt(i))<0){
       alert('Entry must be in hexadecimal format!');return false;}
    } // end scan loop
alert('ok!');return true;}

function isit(id,expectedval){
inputval=document.getElementById(id).value;
if(inputval!==expectedval){alert('You must enter the word '+expectedval);
   }else{alert('ok!');}
}

// Form Validation Script 
// Revision 2 - Ryan Peters (ryanp@ihtmlmerchant.com)
// BIG rewrite - Michael Slavin (michael@thewebster.com)
// form onSubmit="return validInfo(this)"
// <script language="JavaScript" type="text/javascript" src="appvalidate.js"></script>

var neededFields = new makeAnArray('realname', 'email');

var neededDesc = new makeAnArray('your name','your email');

function makeAnArray() {
        this.length = makeAnArray.arguments.length;
        for (var i = 0; this.length > i; i++) {
          	this[i+1] = makeAnArray.arguments[i]
          	}	
	}

function validInfo(obj) {
	var errMsg = '';

	if (isMailAddress(obj)) {
	
		for (var l = 1; neededFields.length > l-1; l ++) {
			if ((obj.elements[neededFields[l]].value == '') ||
				(obj.elements[neededFields[l]].value == ' ')) {
				errMsg = errMsg + 'You didn\'t enter ' + neededDesc[l] + '\n';
				}
			}
		if (errMsg != '') {
			errMsg = 'Sorry, we can\'t process this form because:\n\n' + errMsg;
			alert(errMsg);
			return false;
		} else {
			return true;
		}
	}else {
			return false;
		}
	return true;
}

function isMailAddress(obj) {
	invalidChars = " /|\\\"':;,";
	email = obj.elements['email'].value;
//	if (obj.elements['email'].value != obj.elements['email2'].value) {
//		alert("Your email entries did not match.");
//		obj.elements['email'].focus();
//		obj.elements['email'].select();
//		return false; 
//	}
	if ( ! email) { alert("Sorry, I couldn't make out any email address you're wanting to use."); return false; }
	for (i=0; i<invalidChars.length; i++) { badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) { alert("Sorry, we cannot accept an email containing the character \"" + badChar + "\""); return false; }	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) { alert("Sorry, your email address must contain an \"@\""); return false; }
	if (email.indexOf("@",atPos+1) != -1) { alert("Sorry, your email address must contain only one \"@\""); return false; }
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) { alert("Sorry, a valid email address contains a dot after the \"@\""); return false; } 
	if (periodPos+3 > email.length) { alert("Sorry, a valid email address contains a TLD type (e.g. com, net, org) after the dot"); return false; } 
	return true;
}

function confirmDelete()	{
	var agree=confirm("Are you sure you want to delete this item?");
	if (agree)
		return true ;
	else
		return false ;
	}

