function turnOn(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "on.src");
  }
}
function turnOff(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "off.src");
  }
}

function openResizeWin(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable,dependent,width=800,height=500,left=25,top=25");
  window.opener = top
}

function openWin(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=no, resizable=no,dependent,width=450,height=250,left=25,top=25");
  window.opener = top
}
function overview(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes, resizable=yes,dependent,width=1280,height=768,left=0,top=0");
  window.opener = top
  myform.target = name
}

function openeCheckWin(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=no, resizable=no,dependent,width=750,height=325,left=150,top=150");
  window.opener = top
}
function Clipboard(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=yes,dependent,width=250,height=600,left=400,top=45");
  window.opener = top
}
function SelectRef(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=yes,dependent,width=700,height=225,left=400,top=45");
  window.opener = top
}

function SelectVol(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=no,dependent,width=600,height=225,left=400,top=45");
  window.opener = top
}
function SelectEvent(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=yes,dependent,width=700,height=500,left=400,top=45");
  window.opener = top
}
function SelectVenue(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=no,dependent,width=700,height=225,left=400,top=45");
  window.opener = top
}
function BalanceSchedule(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=yes, resizable=no,dependent,width=450,height=700,left=400,top=45");
  window.opener = top
}

function SelectGameTime(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=no, resizable=no,dependent,width=275,height=200,left=400,top=450");
  window.opener = top
}
function SelectGame(url, name) {

  popupWin = window.open(url, name, "menubar=no,toolbar=no,location=no,directories=no,status,scrollbars=no, resizable=no,dependent,width=275,height=200,left=400,top=450");
  window.opener = top
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function isBlank(s){
var len=s.length
var i
for(i=0;i<len;++i){
if(s.charAt(i)!=" ") return false
}
return true
}

function validate(fieldName,fieldValue){
//alert(fieldName+" "+fieldValue);

if(isBlank(fieldValue)){
	alert(fieldName+" is required.")
	return false
	}
return true
}


function isPictureExt(string) {
if (string.search(/\.(jpg|gif)$/i) == -1)	// not valid ext
	return (false);
return(true)
}


function validateNumber(fieldName,fieldValue){
if(!isNumber(fieldValue)){
	alert(fieldName+" must be a number.")
	return false
	}
return true
}

function validateEmail(fieldName,fieldValue){
if(!isEmail(fieldValue)){
	alert(fieldName+" must be a valid email address.")
	return false
	}
return true
}

function validatePhone34(fieldName,fieldValue1,fieldValue2){
if(!isPhone3(fieldValue1) || !isPhone4(fieldValue2)){
	alert(fieldName+" is not a valid phone number.")
	return false
	}
return true
}


function validatePhone7(fieldName,fieldValue){
if(!isPhone7(fieldValue)){
	alert(fieldName+" must be a valid phone number in the form\nxxx-xxxx")
	return false
	}
return true
}



// support functions

function isNumber(string){
	if (string.search(/^\d+$/g) != -1)	// at least one digit
		return (true);
	else
		return(false);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isPhone7(string) {
    if (string.search(/^\d\d\d\-\d\d\d\d$/) != -1) 
         return true; 
     else
         return false;
}

function isPhone3(string) {
    if (string.search(/^\d\d\d$/) != -1) 
         return true; 
     else
         return false;
}

function isPhone4(string) {
    if (string.search(/^\d\d\d\d$/) != -1) 
         return true; 
     else
         return false;
}

function checkTextAreaSize(name,txtarea,maxsize) {
	z =	txtarea.value.length;
	if (z>maxsize) {
		alert("The "+ name +" field is limited to "+ maxsize +" characters, and the current size is "+ z +" characters.");
		return(false);
	}
	return(true);
}


