/**************************************************************/
/*  Description : Functions for interacting with the database */
/*      Version : 1.00                                        */
/*       Author : Rob Rademeyer                               */
/*    Copyright : © Copyright 2003 by Insight Solutions       */
/* Date Written : 26/07/2003                                  */
/*    File Path : w:\php\functions_validate.php               */
/*     Platform : PHP                                         */
/*     Contains : valid_fields($array)                        */
/*                valid_email($email)                         */
/*                valid_pair($left, $right)                   */
/*                valid_length($string, $min, $max)           */
/*                valid_password($pass1, $pass2, $min, $max)  */
/*                build_field_name($field)                    */
/**************************************************************/

/*----------------------------------------------------------------------------*/
/* Get AND identfy the event object; note coding to cater for W3C compliant   */
/* browsers, AND for Internet Explorer...                                     */
/*----------------------------------------------------------------------------*/
function getTarget(x){
  x = x || window.event;
  return x.target || x.srcElement;
}

/*----------------------------------------------------------------------------*/
/* Get the name of the image that was clicked, add "_view" to the filename &  */
/* then create a new image src & load it into a popup window sized according  */
/* to the current size of the screen's resolution...                          */
/*----------------------------------------------------------------------------*/
function popupParent(vImage) {
  // Work out if it's the forward slash or the backward slash
  if (vImage.src.indexOf("\\")) {vSeparator = "\\"}
  if (vImage.src.indexOf("/"))  {vSeparator = "/"}

  // Strip off the file name at the end
  vFile = vImage.src.split(vSeparator);    //split it to an array
  vFile = vFile[ vFile.length -1 ];        //pick the LAST element (filename)

  // Strip off the first part of the filename, excluding the extension
  vFileName = vFile.split('.');            //split it to an array
  //vNewFile  = vFileName[0];              //pick the FIRST element (filename)
  //vNewExt   = vFileName[1];              //pick the LAST element

  // Build the new file name
  vFileNew = 'images' + vSeparator + vFileName[0] + '_view.' + vFileName[1];

  // Work out the orientation
  vOrientation = vImage.className.substring(vImage.className.length-1,vImage.className.length);

  vScreenWidth  = window.screen.width;
  vScreenHeight = window.screen.height;

  if (vOrientation == 'p') {
    // Can we accommodate a PORTRAIT image of at least 600 pixels HIGH
    if (vScreenHeight > 600 ) {
      vWidth  = 450;
      vHeight = 600;
    } else {
      vWidth  = vScreenWidth  * 90;
      vHeight = vScreenHeight * 90;
    }
  } else {
    // Can we accommodate a LANDSCAPE image of at least 800 pixels WIDE
    if (vScreenWidth > 800 ) {
      vWidth  = 800;
      vHeight = 600;
    } else {
      vWidth  = vScreenWidth  * 90;
      vHeight = vScreenHeight * 90;
    }
  }

  // Open the new window
  winNew = window.open(vFileNew,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=" + vWidth + ", height=" + vHeight);
  winNew.moveTo(10,10);
}

