function open_new_window(url) {new_window = window.open(url,'content_window','toolbar=0,menubar=0,resizable=0,dependent=0,status=0,scrollbars=1,width=600,height=600,left=25,top=25');}
function open_large_image(url) {new_window = window.open(url,'large_image_window','toolbar=0,menubar=0,resizable=0,dependent=0,status=0,scrollbars=0,width=700,height=350,left=25,top=25');}
function rollover(imgid, newsrc) {var img = document.getElementById(imgid); img.src=newsrc;}
function confirmDelete() {
  var agree = confirm("Are you sure you wish to delete this entry?");
  if(agree) { return true; } else { return false; }
}
function confirmEdit() {
  var agree = confirm("Are you sure you wish to edit this entry?");
  if(agree) { return true; } else { return false; }
}
function isEmpty(s) { return ((s == null) || (s.length == 0)); }
function isNotEmpty(s) { return ((s != null) || (s.length > 0)); }
function isNumeric(s) {
  for (i = 0; i < s.length; i++) {
    c = s.charAt(i);
    if (((c < "0") || (c > "9"))) return false;
  }
  return true;
}

function changeClass(id, newClass) {
  //alert("Changing class of "+id+" to "+newClass);
  object = document.getElementById(id);
  object.className = newClass;
}
function valEmail(field) {
  var str = field.value;
  if (str.length==0) { field.className=""; return true; }
  if (emailIsValid(str)) { field.className=""; return true; }
  else { field.className="error"; return false; }
}
function emailIsValid(str) {
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
    //alert("Invalid E-mail ID")
    return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    //alert("Invalid E-mail ID")
    return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
     //alert("Invalid E-mail ID")
     return false
  }
   if (str.indexOf(at,(lat+1))!=-1){
     //alert("Invalid E-mail ID")
     return false
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
     //alert("Invalid E-mail ID")
     return false
   }
   if (str.indexOf(dot,(lat+2))==-1){
     //alert("Invalid E-mail ID")
     return false
   }
   if (str.indexOf(" ")!=-1){
     //alert("Invalid E-mail ID")
     return false
   }
  return true         
}
function valZip(field) {
  var str = field.value;
  if (str.length==0) {return true;}
  str = str.replace(new RegExp("-","g"),"");
  if (str.length==5) { field.value=str; field.className=""; return true; }
  else { field.className="error"; return false; }
}
function zipIsValid(str) {
  var i;
  var c;
  if (str.length != 5) {return false;}
  for (i = 0; i < str.length; i++) {
    c = str.charAt(i);
    if (((c < "0") || (c > "9"))) return false;
  }
  return true;
}
function valPhone(field) {
  var str = field.value;
  if (str.length==0) {return true;}
  str = str.replace(new RegExp(" ","g"),"");
  str = str.replace(/\(/g,"");
  str = str.replace(/\)/g,"");
  str = str.replace(new RegExp("-","g"),"");
  if (str.length==10) { str=str.substr(0,3)+"-"+str.substr(3,3)+"-"+str.substr(6,4); field.value=str; field.className=""; return true; }
  else { field.className="error"; return false; }
}
function phoneIsValid(str) {
  var i;
  var c;
  str = str.replace(new RegExp("-","g"),"");
  if (str.length != 10) {return false;}
  for (i = 0; i < str.length; i++) {
    c = str.charAt(i);
    if (((c < "0") || (c > "9"))) return false;
  }
  return true;
}
function valTimestamp(field) {
  var str = field.value;
  var yyyy = "";
  var mm = "";
  var dd = "";
  if (str.length == 8) {
    yyyy = str.substr(0,4);
    mm = str.substr(4,2);
    dd = str.substr(6,2);
  }
  else if (str.length == 10) {
    if ((str.charAt(2) < "0" || str.charAt(2) > "9") && (str.charAt(5) < "0" || str.charAt(5) > "9")) {
      mm = str.substr(0,2);
      dd = str.substr(3,2);
      yyyy = str.substr(6,4);
    } else if ((str.charAt(4) < "0" || str.charAt(4) > "9") && (str.charAt(7) < "0" || str.charAt(7) > "9")) {
      yyyy = str.substr(0,4);
      mm = str.substr(5,2);
      dd = str.substr(8,2);
    } else {field.className = "error"; return false;}
  }
  else {field.className = "error"; return false;}
  if (isNumeric(yyyy) && isNumeric(mm) && isNumeric(dd)) {
    field.value = mm+"-"+dd+"-"+yyyy;
    field.className = "";
    return true;
  } else {field.className = "error"; return false;}
}
function timestampIsValid(str) {
  if (isNumeric(str.substr(0,2)) && isNumeric(str.substr(3,2)) && isNumeric(str.substr(6,4))) {return true;} else {return false;}
}

PositionX = 100;
PositionY = 100;
defaultWidth  = 640;
defaultHeight = 500;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isOP=(navigator.appName=="Opera")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optOP='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isOP){imgWin=window.open('about:blank','',optOP);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{background-color:#FFFFFF;margin:0px;}</style>');
writeln('<sc'+'ript>');
writeln('var isNN,isOP,isIE;');
writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');
writeln('isOP=(navigator.appName=="Opera")?1:0;');
writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');
writeln('if (isIE){');
writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');
writeln('if (isNN){');       
writeln('window.innerWidth=document.images["theimage"].width;');
writeln('window.innerHeight=document.images["theimage"].height;}');
writeln('if (isOP){');       
writeln('window.innerWidth=document.images["theimage"].width;');
writeln('window.innerHeight=document.images["theimage"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');
writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor="#000000" scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="theimage" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

