function popUp(page,PWidth,PHeight,id) {
 eval("village"+id+"=window.open('"+page+"','gallery','toolbar=0,scrollbars=0,location=0,status=0,menubars=0,resizable=0,width="+PWidth+",height="+PHeight+"')")
eval("village"+id+".window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2))")
}

function howTo(page,PWidth,PHeight,id) {
 eval("icght"+id+"=window.open('"+page+"','howto','toolbar=0,scrollbars=0,location=0,status=0,menubars=0,resizable=0,width="+PWidth+",height="+PHeight+"')")
eval("icght"+id+".window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2))")
}


if (document.images) {
  var book1 = new Image(); book1.src = "images-new/book-btn-off.jpg";
  var book2 = new Image(); book2.src = "images-new/book-btn-on.jpg";

  var workshops1 = new Image(); workshops1.src = "images-new/workshops-btn-off.jpg";
  var workshops2 = new Image(); workshops2.src = "images-new/workshops-btn-on.jpg";

  var resources1 = new Image(); resources1.src = "images-new/resources-btn-off.jpg";
  var resources2 = new Image(); resources2.src = "images-new/resources-btn-on.jpg";

  var visit1 = new Image(); visit1.src = "images-new/visit-btn-off.jpg";
  var visit2 = new Image(); visit2.src = "images-new/visit-btn-on.jpg";

  var gallery1 = new Image(); gallery1.src = "images-new/gallery-btn-off.jpg";
  var gallery2 = new Image(); gallery2.src = "images-new/gallery-btn-on.jpg";

  var blog1 = new Image(); blog1.src = "images-new/blog-btn-off.jpg";
  var blog2 = new Image(); blog2.src = "images-new/blog-btn-on.jpg";
  
  var ebook1 = new Image(); ebook1.src = "images-new/ebook-btn-off.jpg";
  var ebook2 = new Image(); ebook2.src = "images-new/ebook-btn-on.jpg";

  var paperback1 = new Image(); paperback1.src = "images-new/paperback-btn-off.jpg";
  var paperback2 = new Image(); paperback2.src = "images-new/paperback-btn-on.jpg";


}


function turnOn(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "2.src");
  }
}

function turnOff(imageName) {
  if (document.images) {
    document[imageName].src = eval(imageName + "1.src");
  }
}



function ParseUSNumber(PhoneNumberInitialString)
  {
    var FmtStr="";
    var index = 0;
    var LimitCheck;

    LimitCheck = PhoneNumberInitialString.length;
    while (index != LimitCheck)
      {
        if (isNaN(parseInt(PhoneNumberInitialString.charAt(index))))
          { }
        else
          { FmtStr = FmtStr + PhoneNumberInitialString.charAt(index); }
        index = index + 1;
      }
    if (FmtStr.length == 10)
      {
        FmtStr = "(" + FmtStr.substring(0,3) + ") " + FmtStr.substring(3,6) + "-" + FmtStr.substring(6,10);
      }
    return FmtStr;
  }


function placeFocus() {
 if (document.forms.length > 0) {
  var field = document.forms[0];
  for (i = 0; i < field.length; i++) {
   if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
    document.forms[0].elements[i].focus();
    break;
   }
  }
 }
}

function isValid() {
 var emailaddr=document.forms[0].email.value;
 if (emailaddr.indexOf(' ')==-1 
      && 0<emailaddr.indexOf('@')
      && emailaddr.indexOf('@')+1 < emailaddr.length
 ) return true;
 else alert ('Invalid email address!')
 return false;
}
