/******
 **
 ** Ajos1 - 2009/12/06 - Return Key Processing...
 ** Ajos1 - 2009/08/25 - AndOrArray system added...
 ** Ajos1 - 2008/03/08 - Time Checks...
 ** Ajos1 - 2007/04/15 - Date Functions...
 ** Ajos1 - 2006/08/15 - Links Sub-Tables Done!!
 ** Ajos1 - 2006/08/15 - Additions for popup forms...
 ** Ajos1 - 2006/02/18 - Additions for popup forms...
 ** Ajos1 - 2005/04/14 - Some more additions...
 ** Ajos1 - 2003/06/02 - Disco Bunny - An idea from Macs and casing problems
 **
 ** Ideas : http://www.klaban.torun.pl/help/jsref/select.htm
 ** Ideas : http://www.quirksmode.org/js/options.html
 ** Ideas : http://www.javaworld.com/javaworld/jw-06-1996/jw-06-javascript.html
 ** Ideas : http://www.sivamdesign.com/scripts/popups.html
 **
 ******/

var SubLstX;

///
/// Function
///
/// Last Modified: 08/01/2000 Bryan Bensing
///
function Chr(CharCode)
{
   return String.fromCharCode(CharCode);
}


///
/// Function
///
/// Last Modified: 08/01/2000 Bryan Bensing
///
function Right(String, Length)
{
   if (String == null)
      return (false);

   var dest = '';
   for (var i = (String.length - 1); i >= 0; i--) {
      dest = dest + String.charAt(i);
   }

   String = dest;
   String = String.substr(0, Length);
   dest = '';

   for (var i = (String.length - 1); i >= 0; i--) {
      dest = dest + String.charAt(i);
   }

   return dest;
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// Last Modified: 08/01/2000 Bryan Bensing
///
/// Some might say that array=Expression.split(Delimiter) is enough!
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function Split(Expression, Delimiter)
{
   var temp = Expression;
   var a, b = 0;
   var array = new Array();

   if (Delimiter.length == 0) {
      array[0] = Expression;
      return (array);
   }

   if (Expression.length == '') {
      array[0] = Expression;
      return (array);
   }

   Delimiter = Delimiter.charAt(0);

   for (var i = 0; i < Expression.length; i++) {
      a = temp.indexOf(Delimiter);
      if (a == -1) {
         array[i] = temp;
         break;
      } else {
         b = (b + a) + 1;
         var temp2 = temp.substring(0, a);
         array[i] = temp2;
         temp = Expression.substr(b, Expression.length - temp2.length);
      }
   }
   return (array);
}


///
/// Function
///
/// Last Updated: 2007/04/04
///
/// Some ideas from:
///   http://www.elated.com/articles/form-validation-with-javascript/
///
///  <fieldset> (Fieldset messes up CheckAllFields script... i.e. fields become undefined ?!)
///
///  var FormName     = document.frm_signup;
///  var FieldPrefix  = 'SignUp';
///  var FieldsArray  = ['Email', 'Name']
///
function CheckAllFields(FormName, FieldPrefix, FieldsArray, AltMesg)
{
   //
   // Try to give back some information on any silly errors....
   //
   // For colours to work... IE just needs "name"... Netscape needs "id"
   //
   var AddOnStr    = "";
   var AlertText   = "";
   var CheckIt     = 1;
   var ColourUse   = 0;
   var ColourVal   = "";
   var Focused     = 0;
   var UsedSoFar   = new Array()
   var NoChangeCol = 0;
   var SoFar       = 0;
   var tmpitem     = "";
   var TmpErrors   = 0;

   //
   // No FieldPrefix sent... so just lump out for the moment...
   //
   if (FieldPrefix == "") {
      return(true);
   }

   //
   //
   //
   var arraycnt    = FieldsArray.length;
   var FieldStart  = FieldPrefix + "_";

   //
   //
   //
   for (var i = 0; i < FormName.elements.length; i++) {
      TmpVar      = FormName.elements[i];
      MyStyle     = FormName.elements[i];
      AddOnStr    = "";
      ColourUse   = 0;
      Naughty     = 0;
      NoChangeCol = 0;
      RightO      = Right(TmpVar.name.toLowerCase(), 5);

      //
      // Only look at the fields with the correct starting sequence...
      //
      if (TmpVar.name.indexOf(FieldStart) > -1) {
         CheckIt = 1
         if (arraycnt >= 1) {
            CheckIt = 0
            for (var j = 0; j < arraycnt; j++) {
               AndOrArray = Split(FieldsArray[j], "@");
               tmpitem = FieldStart + AndOrArray[0];
               if (TmpVar.name == tmpitem) {
                  CheckIt = 1
               }
               tmpitem = FieldStart + AndOrArray[0] + "[]";
               if (TmpVar.name == tmpitem) {
                  CheckIt = 1
               }
            }
         }
         if (CheckIt == 1) {
            ColourUse = 2;
            switch (TmpVar.type) {
               case "checkbox":
               case "radio":
                  NoChangeCol = 1;
                  // Single items in here... not array... so we have to cycle
                  // through the whole sequence!!
                  Naughty = 1
                  for (var x = 0; x < FormName.elements.length; x++) {
                     if ((FormName.elements[x].type == TmpVar.type) && (FormName.elements[x].name == TmpVar.name)) {
                        if (FormName.elements[x].checked == true) {
                           Naughty = 0;
                        }
                     }
                  }
                  break;
               case "select-one":
                  if (TmpVar.selectedIndex < 0) {
                     Naughty = 1
                  }
                  break;
               case "file":
               case "password":
               case "text":
               case "textarea":
                  if (TmpVar.value == "" ) {
                     Naughty = 1
                  } else {
                     if (RightO == "email") {
                        if (!CheckIsEmail(TmpVar.value)) {
                           Naughty  = 1;
                           AddOnStr = " ( ** CORRECT Format ** )";
                        }
                     }
                  }
                  break;
               case "button":
               case "hidden":
               case "image":
               case "reset":
               case "select-multiple":
               case "submit":
                  break;
            }
            if (Naughty == 1) {
               //
               // This is needed to stop multiple radio/checkbox messages
               //
               FoundUsed = 0;
               for (x = 0; x < UsedSoFar.length; x++) {
                  if (UsedSoFar[x] == TmpVar.name) {
                     FoundUsed = 1;
                  }
               }
               //
               // If not reported before... now added to the report list...
               //
               if (FoundUsed == 0) {
                  SoFar++;
                  AlertText = AlertText + "     " + TmpVar.name + AddOnStr + "\n";
                  TmpErrors = TmpErrors + 1;
                  UsedSoFar[SoFar] = TmpVar.name;
                  ColourUse = 1;
                  if (Focused == 0) {
                     Focused = 1;
                     TmpVar.focus();
                  }
               }
            }
         }
         //
         // Colour to be printed... if a colour is to be used...
         //
         if (MyStyle) {
            switch (ColourUse) {
               case 0:
                  ColourVal = "#d0d0f0"; // Blue
                  break;
               case 1:
                  ColourVal = "#f0c0c0"; // Red
                  break;
               case 2:
                  ColourVal = "#c0f0c0"; // Green
                  break;
            }
            if (NoChangeCol != 1) {
               MyStyle.style.background = ColourVal;
            }
         }
      }
   }

   //
   // Print or not...
   //
   if (AlertText == "") {
      return(true);
   } else {
      if (AltMesg.length > 0) {
         alert(AltMesg);
      } else {
         alert("Please specify at least the following items :-\n\n" + AlertText);
      }
      return (false);
   }
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2007/08/06
///
/// Works IE/NetScape
/// NOTA BENE - Opera and Mozilla/Firefox have options to prevent window resize
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function FullScreen(ScreenMode)
{
   if (ScreenMode == 1) {
      //if (document.all || document.layers) {
         self.moveTo(0, 0);
         //self.resizeTo(window.screen.availWidth,   window.screen.availHeight);  // Avail
         self.resizeTo(window.screen.width,        window.screen.height);       // Widest
         self.focus();
      //}
   }
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2007/02/22
///
///
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function GullScreen()
{
   ///
   /// Put to top of screen
   ///
   if (self != top) top.location = self.location;

   ///
   /// Resize
   ///
   moveTo(0, 0);
   (navigator.userAgent.indexOf("MSIE")!=-1)?IE=true:IE=false;
   Ver = parseInt(navigator.appVersion);
   a = navigator.appName
   b = navigator.appVersion
   if (IE) {
      IE = Ver;
      resizeTo(screen.availWidth, screen.availHeight);
   } else {
      //resizeTo(((screen.availWidth - 10)), ((screen.availHeight - 10)));
      resizeTo(screen.availWidth, screen.availHeight);
      //ErrStr = "*** WARNING *** - Please note that this site was optimised for Microsoft Internet Explorer.  Some features may not appear correctly for browser: " + a + " (" + b + ") "
      //ErrStr = "*** WARNING *** "  + Chr(10) + Chr(10) + "Please note that this site was optimised for Microsoft Internet Explorer." + Chr(10) + Chr(10) + "Some features may not appear correctly for browser: " + Chr(10) + ">>> " + a + " (" + b + ") "
      //alert(ErrStr)
   }
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2007/12/03
///
/// Ideas from:  http://www.quirksmode.org/js/popup.html
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function AjosSubWind(WindoClose, IFrameMode, wwidth, wheight, WindName, LinkOid)
{
   if (WindoClose == 1) {
      //removelink();
   }

   if (typeof document.body.style.maxHeight != "undefined") {
      // IE 7, mozilla, safari, opera 9
      isIE7 = true;
   } else {
      // IE6, older browsers
      isIE7 = false;
   }

   if (isIE7 == true) {
      wheight = wheight + 20;
   }

   topPos  = 0;
   leftPos = 0;

   if (screen) {
      leftPos = screen.width;
      leftPos = (leftPos / 2);
      leftPos = leftPos - (wwidth / 2);
   }
   if (screen) {
      topPos = screen.height;
      topPos = (topPos / 2);
      topPos = topPos - (wheight / 2);
   }

   //
   // Read up the value from the main form and use it!
   //


   // Must be Single quotes for Opera to work!!
   if (IFrameMode == 0) {
      SubLstX = window.open(LinkOid, WindName, "width="+wwidth+",height="+wheight+",scrollbars=no,resizable=yes,left="+leftPos+",top="+topPos+"",false);
   } else {
      SubLstX = window.open("", WindName, "width="+wwidth+",height="+wheight+",left="+leftPos+",top="+topPos+",alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=0,status=0,titlebar=1,toolbar=0,z-lock=0",false);
      SubLstX.resizeTo(wwidth, wheight);
      SubLstX.focus();

      SubLstX.document.clear();
      SubLstX.document.write("<html>\n");
      SubLstX.document.write("<head>\n");
      SubLstX.document.write("<title>"+LinkOid+"</title>\n");
      SubLstX.document.write("</head>\n");
      SubLstX.document.write("<body topmargin=1 leftmargin=1>\n");
      SubLstX.document.write("<iframe scrolling=auto frameborder=0 width='100%' height='100%' src='"+LinkOid+"' name='"+WindName+"'></iframe>\n");
      SubLstX.document.write("</body>\n");
      SubLstX.document.write("</html>\n");
      SubLstX.document.close();
   }

   //return (false);
}


//
// http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
/*
 * This function will not return until (at least)
 * the specified number of milliseconds have passed.
 * It does a busy-wait loop.
 */
function pause(numberMillis)
{
   var now = new Date();
   var exitTime = now.getTime() + numberMillis;
   while (true) {
      now = new Date();
      if (now.getTime() > exitTime) {
         return;
      }
   }
}

///
/// Function
///
function push_value(RetFld, TmpStr)
{
   if (window.opener && !window.opener.closed) {
      //window.opener.document.forms[0].Field1.value = TmpStr;
      window.opener.document.forms[0][RetFld].value = TmpStr;
      window.opener.document.forms[0][RetFld].onchange(true);
   }
   window.close();
   return(true);
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/01/23
///
/// Function
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function removelink()
{
   if (SubLstX != undefined) {
      if (window.SubLstX && window.SubLstX.open && !window.SubLstX.closed) {
         SubLstX.document.clear();
         window.SubLstX.opener = null;
         window.SubLstX.close();
      }
   }
   //return true;
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/04/06
///
/// Function
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function Push_OptListValue_Or_SingleValue(RetFld, FrmNam, ActFld, SingleValue)
{
   ///
   /// Starting values...
   ///
   var CrashOut    = 0;
   var TmpStr      = '';
   var TmpExt      = '';
   var TmpStrArray = new Array();
   var TmpExtArray = new Array();

   ///
   ///
   ///
   //RetArray = Split(RetFld, ",");
   //ActArray = Split(ActFld, ",");

   ///
   ///
   ///
   ExtInf = "ignore_"+RetFld;

   ///
   /// Was there something chosen...
   ///
   if (ActFld.length > 0) {
      ///
      /// System FieldName
      ///
      FldNam = document.forms[FrmNam][ActFld];
      ///
      /// A hack need... in case FieldName is not MULTIPLE
      ///
      MaxLoop = 100;
      if (FldNam.multiple == false) {
         MaxLoop = 1;
      }
      ///
      ///
      ///
      while ((FldNam.selectedIndex != -1) && (CrashOut < MaxLoop)) {
         CrashOut = CrashOut + 1;
         TmpPos = FldNam.selectedIndex;
         TmpStr = FldNam.value;
         TmpExt = FldNam.options[TmpPos].text;
         if (MaxLoop > 1) {
            ///
            /// Only MULTIPLE can be changed...
            ///
            FldNam.options[TmpPos].selected = false;
         }
         ///
         /// Additional Array...
         ///
         TmpStrArray[TmpStrArray.length] = TmpStr;
         TmpExtArray[TmpExtArray.length] = TmpExt;
      }
   } else {
      switch (SingleValue) {
         case '':
         case 'NULL':
            TmpStr = SingleValue;
            TmpExt = "** Value Cleared **";
            break;
         default:
            TmpStr = SingleValue;
            TmpExt = SingleValue;
            break;
      }
   }

   ///
   /// Now try and return the result...
   ///
   if (window.opener && !window.opener.closed) {
      if (TmpStrArray.length <= 1) {
         window.opener.document.forms[0][RetFld].value = TmpStr;
         window.opener.document.forms[0][ExtInf].value = TmpExt;
      } else {
         window.opener.document.forms[0][RetFld].value = TmpStrArray;
         window.opener.document.forms[0][ExtInf].value = TmpExtArray;
      }
      window.opener.document.forms[0][RetFld].onchange(true);
   }

   ///
   ///
   ///
   window.close();
   return(true);
}

///
/// Function
///
function ConfirmInput(msgline1, msgline2)
{
   var tmpres1 = confirm(msgline1 + "\n" + msgline2);
   if (tmpres1) {
      var tmpres2 = confirm("ABSOLUTELY SURE?!");
      if (tmpres2) {
         return(true)
      } else {
         //alert("Most Marvo!");
         return(false)
      }
   } else {
      //alert("Marvo!");
      return(false)
   }
}


///
/// Function
///
/// Hmmmm and more Hmmmm - If link is a javascript location.href() the
/// referrer details are not sent through with the "href"!
///
function ConfirmLink(msgline1, msgline2, linkoid)
{
   var ReferOid = "";
   if (document.referrer) {
      if (document.referrer != "") {
         ReferOid = document.referrer;
      }
   }

   var tmpres1 = confirm(msgline1 + "\n" + msgline2);
   if (tmpres1) {
      var tmpres2 = confirm("ABSOLUTELY SURE??");
      if (tmpres2) {
         document.location.href = linkoid;
      } else {
         //alert("Most Marvo!");
      }
   } else {
      //alert("Marvo!");
   }
}


///
/// Function
///
function TickCheckSubmit(FormName)
{
   var contit = 0;
   for (var i = 0; i < FormName.elements.length; i++) {
      var TmpVar = FormName.elements[i];
      if ((TmpVar.type == "checkbox") && (TmpVar.name != 'sel_all_box')) {
         if (TmpVar.checked == true) {
            contit = contit + 1;
         }
      }
   }
   if (contit > 0) {
      var tmpres1 = confirm("Are you sure you want to do this?");
      if (tmpres1) {
         return(true)
      } else {
         return(false)
      }
   } else {
      alert("You have not selected any messages to work with?");
      return(false)
   }
}


///
/// Function
///
function TickSelectAll(FormName)
{
   for (var i = 0; i < FormName.elements.length; i++) {
      var TmpVar = FormName.elements[i];
      if ((TmpVar.type == "checkbox") && (TmpVar.name != 'sel_all_box')) {
         TmpVar.checked = FormName.sel_all_box.checked;
      }
   }
}

///
/// Based upon http://www.kent.police.uk/common/js/util.js
///
function stringReplace(originalString, findText, replaceText)
{
   var pos = 0;
   var len = findText.length;
   pos = originalString.indexOf(findText);
   while (pos != -1) {
      preString = originalString.substring(0, pos);
      postString = originalString.substring(pos + len, originalString.length);
      originalString = preString + replaceText + postString;
      pos = originalString.indexOf(findText);
   }
   return originalString;
}


///
/// Based upon http://www.kent.police.uk/common/js/util.js
///
function mailerto(obfAddress)
{
   obfAddress = stringReplace(obfAddress, '{at}',     '@');
   obfAddress = stringReplace(obfAddress, '{ato}',    '@');
   obfAddress = stringReplace(obfAddress, '{atoid}',  '@');
   obfAddress = stringReplace(obfAddress, '{dot}',    '.');
   obfAddress = stringReplace(obfAddress, '{doto}',   '.');
   obfAddress = stringReplace(obfAddress, '{dotoid}', '.');
   newWindow = window.open("mailto:" + obfAddress, "mailWindow", "toolbar=no, menubar=no, scrollbars=no");
}

///
/// 2007/01/12
/// http://www.codeproject.com/useritems/Immediate_Close__new_try_.asp
/// http://ajaxian.com/archives/detecting-ie7-in-javascript
///
function DoWindowClosure()
{
   if (typeof document.body.style.maxHeight != "undefined") {
      // IE 7, mozilla, safari, opera 9
      isIE7 = true;
   } else {
      // IE6, older browsers
      isIE7 = false;
   }

   if (isIE7 == true) {
      //
      // IE7
      //
      window.open('','_parent','');
      window.close();
   } else {
      //
      // IE6
      //
      window.opener=self;
      self.close();
   }
}


///
/// Taken from PHPMYADMIN... enables highlight and marking of rows in data tables
/// 2007/04/12 - Input and ammended by Ajos1... (Original author was excellent).
///
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

function CMT_PMA_markRowsInit()
{
    var BaseClass = "cmt_javascript_lined_tr";

    // for every table row ...
    var rows = document.getElementsByTagName('tr');
    for ( var i = 0; i < rows.length; i++ ) {
        // ... with the class 'cmt_javascript_lined_tr'
        if ( BaseClass != rows[i].className.substr(0,BaseClass.length) ) {
            continue;
        }
        // ... add event listeners ...
        // ... to highlight the row on mouseover ...
        if ( navigator.appName == 'Microsoft Internet Explorer' ) {
            // but only for IE, other browsers are handled by :hover in css
            rows[i].onmouseover = function() {
                this.className += ' hover';
            }
            rows[i].onmouseout = function() {
                this.className = this.className.replace( ' hover', '' );
            }
        }
        // Do not set click events if not wanted
        if (rows[i].className.search(/noclick/) != -1) {
            continue;
        }
        // ... and to mark the row on click ...
        rows[i].onmousedown = function() {
            var unique_id;

            if ( this.id.length > 0 ) {
                unique_id = this.id;
            } else {
                return;
            }

            if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
                this.className += ' cmt_javascript_lined_tr_MarkedRow';
            } else {
                this.className = this.className.replace(' cmt_javascript_lined_tr_MarkedRow', '');
            }

        }

    }
}


//
// OLD CODE
//
// Day = new MakeArraya(7);
// Day[0]="Sunday";
//
function MakeArraya(size)
{
   this.length = size;
   for (var i = 1; i <= size; i++) {
      this[i] = "";
   }
   return this;
}


///
/// More standard date rountine
/// Ajos1 - Yonks ago!!!
///
function ShowTimeDateFuture(FrmNam, ActFld, FutHours)
{
   var futuredate    = new Date();

   var expdate = futuredate.getTime()
   expdate += FutHours*3600*1000 //expires in 1 hour(milliseconds)
   futuredate.setTime(expdate)

   var year   = futuredate.getYear();
   var month  = futuredate.getMonth();
   var date   = futuredate.getDate();
   var day    = futuredate.getDay();
   var hour   = futuredate.getHours();
   var minute = futuredate.getMinutes();
   var second = futuredate.getSeconds();

   //
   // Month 0-11 goes to 1-12
   //
   month = month + 1;

   ///
   /// NetScape Fix!! - Ajos1 2000/06/11
   ///
   if (year < 500) {
      year = year + 1900;
   }

   var timeValue = "";

   if (hour < 10) {
      timeValue += "0";
   }
   timeValue += hour + ":";

   if (minute < 10) {
      timeValue += "0";
   }
   timeValue += minute + ":";

   if (second < 10) {
      timeValue += "0";
   }
   timeValue += second + " ";

   if (date < 10) {
      timeValue += "0";
   }
   timeValue += date + "/";

   if (month < 10) {
      timeValue += "0";
   }
   timeValue += month + "/";

   timeValue += year;

   if (ActFld.length > 0) {
      FldNam = document.forms[FrmNam][ActFld];
      FldNam.value ="a " + timeValue + "";
   } else {
      document.write("" + timeValue + "");
   }
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/10/20
///
/// More standard date rountine
/// Ajos1 - Yonks ago!!!
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function ShowDateTime(FrmNam, ActFld, ShortFormat, WithGreeting)
{
   ///
   /// Define some starting values...
   ///
   var now    = new Date();
   var year   = now.getYear();
   var month  = now.getMonth();
   var date   = now.getDate();
   var day    = now.getDay();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();

   var Day   = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
   var Month = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

   if (ShortFormat == 1) {
      var Day   = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
      var Month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
   }

   ///
   /// NetScape Fix!! - Ajos1 2000/06/11
   ///
   if (year < 500) {
      year = year + 1900;
   }

   ///
   /// Segment - greeting
   ///
   var greetsegment = "";
   if (WithGreeting == 1) {
      greetsegment="Good Evening!";
      if (hour < 18) greetsegment="Good Afternoon!";
      if (hour < 12) greetsegment="Good Morning!";
      if (hour <  6) greetsegment="Hello Night Owl!";
   }

   ///
   /// Segment - Date
   ///
   var datesegment = "";
   datesegment += (Day[day]) + ", ";
   datesegment += date + " "
   datesegment += (Month[month]) + " ";
   datesegment += year;

   ///
   /// Segment - Time
   ///
   var timesegment = "";
   if (hour < 10) {
      timesegment += "0";
   }
   timesegment += hour + ":";

   if (minute < 10) {
      timesegment += "0";
   }
   timesegment += minute + ":";

   if (second < 10) {
      timesegment += "0";
   }
   timesegment += second + "";

   ///
   /// Segment - The final string...
   ///
   var timeValue = "";
   if (WithGreeting == 1) {
      timeValue +=  greetsegment + " - It is ";
   }
   timeValue +=  datesegment + " " + timesegment;

   ///
   /// Return or Print...
   ///
   if (ActFld.length > 0) {
      document.forms[FrmNam][ActFld].value = timeValue;
   } else {
      document.write(timeValue);
   }
}


///
/// Function - Based upon Bryan Bensing, highly improved by Ajos1
///
/// alert(DateTimeDiff("20/07/2007 10:10:10", "20/07/2007 10:10:17", 0));
/// alert(DateTimeDiff("20/07/2007 10:10:10", "20/07/2007 10:10:17", 1));
///
function DateTimeDiff(Date1, Date2, TmpMode)
{
   date1 = new Date();
   date2 = new Date();

   date1temp = new Date(Date1);
   date2temp = new Date(Date2);

   origdiff = (date2temp.getTime() - date1temp.getTime());
   timediff = Math.abs(origdiff);

   weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
   timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

   days = Math.floor(timediff / (1000 * 60 * 60 * 24));
   timediff -= days * (1000 * 60 * 60 * 24);

   hours = Math.floor(timediff / (1000 * 60 * 60));
   timediff -= hours * (1000 * 60 * 60);

   mins = Math.floor(timediff / (1000 * 60));
   timediff -= mins * (1000 * 60);

   secs = Math.floor(timediff / 1000);
   timediff -= secs * 1000;

   if (TmpMode == 1) {
      MyRet = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds";
   } else {
      MyRet = (origdiff / 1000)
   }

   return (MyRet);
}


function ClearOnClick(FormField)
{
   var ValClear = document.forms[0][FormField];
   if (ValClear.value == "Enter_Search_Item_Here") {
      ValClear.value = "";
   }
}


///
/// Function
///
function poppy_photo(LinkOid) {
   wwidth = 482;
   wheight = 482;
   topPos = 0;
   leftPos = 0;
   if (screen) {
      leftPos = screen.width;
      leftPos = (leftPos / 2);
      leftPos = leftPos - (wwidth / 2);
      leftPos = leftPos - (wwidth / 2) + 300;
   }
   if (screen) {
      topPos = screen.height;
      topPos = (topPos / 2);
      topPos = topPos - (wheight / 2);
   }
   leftPos = 175;

   //SubLstR = window.open(LinkOid, "365photo", "width="+wwidth+",height="+wheight+",scrollbars=no,left="+leftPos+",top="+topPos+"");
   //SubLstR.focus();

   SubLstR = window.open("", "365photo", "width="+wwidth+",height="+wheight+",scrollbars=no,left="+leftPos+",top="+topPos+"");
   SubLstR.document.clear();
   SubLstR.document.write("<html>\n");
   SubLstR.document.write("<head>\n");
   SubLstR.document.write("<title>"+LinkOid+"</title>\n");
   SubLstR.document.write("<body topmargin=1 leftmargin=1>\n");
   SubLstR.document.write("<div align=\"center\">");
   SubLstR.document.write("<p><font size=-1>"+LinkOid+"</font></p>");
   SubLstR.document.write("<p><img src='"+LinkOid+"'></p>");
   SubLstR.document.write("</div>");
   SubLstR.document.write("</body>\n");
   SubLstR.document.write("</html>\n");
   SubLstR.document.close();
   SubLstR.focus();
   // return false;
}

//
// setTimeout('ajos_logouto()', 600000);
//
function ajos_logouto() {
   top.location="?pg=logout";
}

//
// Copyright (C) 2004, CodeHouse.com. All rights reserved.
// CodeHouse(TM) is a registered trademark.
// You can obtain this script at http://www.codehouse.com
//
function emailhide(name, domain, suffix, text)
{
   var address = name + "\u0040" + domain + "." + suffix;
   var url = "mailto:" + address;

   if ( ! text ) {
      text = address;
   }
   document.write("<a href=\"" + url + "\">" + text + "</a>");
}

//
// http://www.webdeveloper.com/forum/archive/index.php/t-52721.html
// Kor 01-03-2005, 11:17 AM
//
//
function disableAll()
{
   var el = document.forms[0].elements;
   for (var i = 0; i < el.length; i++) {
      el[i].setAttribute('disabled',true)
   }
}

//
// http://www.andyfowler.com/journal/2005/07/javascript-ucwords-replacement/
//
String.prototype.toProperCase = function()
{
     return this.toLowerCase().replace(/\w+/g,function(s){
          return s.charAt(0).toUpperCase() + s.substr(1);
     })
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2009/02/23
///
/// http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_ucwords/
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function othucwords(str)
{
   // http://kevin.vanzonneveld.net
   // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
   // +   improved by: Waldo Malqui Silva
   // +   bugfixed by: Onno Marsman
   // *     example 1: ucwords('kevin van zonneveld');
   // *     returns 1: 'Kevin Van Zonneveld'
   // *     example 2: ucwords('HELLO WORLD');
   // *     returns 2: 'HELLO WORLD'
   return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/04/12
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function FixTitleCase(FormName, FieldName, TitleType)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldName);

   ///
   /// This helps put the cursor at the end of the field...
   ///
   CurrentItem.focus();

   ///
   /// What Casing???
   ///
   switch (TitleType) {
      case 1:
         CurrentItem.value = CurrentItem.value.toUpperCase();
         break
      case 2:
         CurrentItem.value = CurrentItem.value.toLowerCase();
         break
      default:
         CurrentItem.value = CurrentItem.value.toProperCase();
         // CurrentItem.value = othucwords(CurrentItem.value);
         break
   }
   CurrentItem.onchange(true);
}


//
// Ajos1 2007/12/03 - http://www.javascripter.net/faq/browserw.htm
//
function ReportWindowSize()
{
   var winW = 630, winH = 460;
   var winB = "UnKnown";

   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         TBar = 16;
         winB = "netscape";
         winH = window.innerHeight;
         winW = window.innerWidth;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         TBar = 20;
         winB = "MicroSoft";
         winH = document.body.offsetHeight;
         winW = document.body.offsetWidth;
      }
   }

   alert("Window Mode = " + winB + "\n" + "Window width = " + winW + "\n" + "Window height = " + winH);
}


////////////////////////////////////////////////////////////////////////////
//
// http://javascript.about.com/library/blscreen2.htm
//
// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
//
////////////////////////////////////////////////////////////////////////////
function pageWidth()
{
   return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight()
{
   return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}
function posLeft()
{
   return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}
function posTop()
{
   return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}
function posRight()
{
   return posLeft()+pageWidth();
}
function posBottom()
{
   return posTop()+pageHeight();
}

///
/// Function
///
/// Ajos1 2008/01/07
///
function ClearTextField(FormName, FieldName)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldName);

   ///
   /// Set to BLANK...
   ///
   CurrentItem.value = "";
   CurrentItem.onchange(true);
}


///
/// TO CHECK AND MAKE MORE COMPLEX...
/// Function
///
/// http://www.quirksmode.org/js/mailcheck.html
/// We have to allow blank e-mails... pondering... as that is covered elsewhere...
///
function CheckIsEmail(Expression)
{
   if (Expression == "") {
      return(true);
   }

   var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   if (filter.test(Expression)) {
      return(true);
   } else {
     return(false);
   }
}

function isArray(testObject)
{
   alert(thisObject.name);
   return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}

function iaasArray(obj) {
   return obj.constructor == Array;
}

///
///
///
function AjosMesg(MesgStr)
{
   //alert(MesgStr)
   this.submit();
}


///
///
///
function XisArray(obj)
{
   return(typeof(obj.length)=="undefined")?false:true;
}
///
///
///
function aaisArray(obj)
{
   alert(obj.value);
   alert(obj.constructor.toString());
   if (obj.constructor.toString().indexOf("Array") == -1) {
      return false;
   } else {
      return true;
   }
}

///
///
///
function aaaisArray()
{
   alert(typeof arguments[0]);
   alert(typeof arguments[1]);
   alert(typeof arguments[2]);
   if (typeof arguments[0] == 'object') {
      var criterion = arguments[0].constructor.toString().match(/array/i);
      return (criterion != null);
   }
   return(false);
}


///
///
///
function AjosCheckRangeTime(timeBox)
{
   //
   // Take value...
   //
   timeval=timeBox.value

   //
   // Replace "." with ":" (TWICE)
   //
   timeval=timeval.replace(".", ":");
   timeval=timeval.replace(".", ":");

   //
   // Now split string on ":"
   //
   timearr=timeval.split(':')

   //
   // Test...
   //
   ErrorMod = 0;
   switch (timearr.length) {
      case 1:
         if (!/\d{1,2}/.test(timeval)) {
            ErrorMod = 1;
         }
         if (timearr[0] > 59) {
            ErrorMod = 1;
         }
         if (ErrorMod == 0) {
            timeBox.value = "00:00:" + timeval
         }
         break;
      case 2:
         if (!/\d{1,2}:\d{2}/.test(timeval)) {
            ErrorMod = 1;
         }
         if ((timearr[0] > 23) || (timearr[1] > 59)) {
            ErrorMod = 1;
         }
         if (ErrorMod == 0) {
            timeBox.value = "00:" + timeval
         }
         break;
      case 3:
         if (!/\d{1,2}:\d{2}:\d{2}/.test(timeval)) {
            ErrorMod = 1;
         }
         if ((timearr[0] > 23) || (timearr[1] > 59) || (timearr[2] > 59)) {
            ErrorMod = 1;
         }
         if (ErrorMod == 0) {
            timeBox.value = timeval
         }
         break;
      default:
         ErrorMod = 1;
         break;
   }

   //
   // Was there an error?
   //
   if (ErrorMod == 1) {
      alert('Invalid Time Format')
      timeBox.value = '00:00:00';
      timeBox.focus();
      return;
   }
}

///
/// Function
/// http://www.netlobo.com/off_left_div_hiding.html
/// http://www.netlobo.com/media/examples/offleftdivhide.html
/// This is screen-reader friendly.
///
/// <a href="javascript:toggleDivOL('toHide');" title="Hide the DIV">Hide/Show the DIV</a>
///
function toggleDivOL( elemID )
{
   var elem = document.getElementById( elemID );
   if (elem.style.position != 'absolute') {
      elem.style.position = 'absolute';
      elem.style.left     = '-4000px';
   } else {
      elem.style.position = 'relative';
      elem.style.left     = '0px';
   }
}


///
/// Function
/// http://www.netlobo.com/div_hiding.html
///
/// div#commentForm{  margin: 0px 20px 0px 20px;  display: none;}
/// <div id="commentForm"></div>
/// <a href="javascript:toggleLayer('commentForm');" title="Add a comment to this entry">Add a comment</a>
/// <input type="reset" name="reset" value="Cancel"onclick="javascript:toggleLayer('commentForm');" >
///
///
function toggleLayer( whichLayer )
{
   //
   // Define some variables...
   //
   var elem, vis;

   //
   // Initial/Basic Check...
   //
   if (document.getElementById) {
      // this is the way the standards work
      elem = document.getElementById( whichLayer );
   } else if( document.all ) {
      // this is the way old msie versions work
      elem = document.all[whichLayer];
   } else if( document.layers ) {
      // this is the way nn4 works
      elem = document.layers[whichLayer];
   }

   //
   // Get whatever mode we are now...
   //
   vis = elem.style; // if the style.display value is blank we try to figure it out here
   if (vis.display=='' && elem.offsetWidth!=undefined && elem.offsetHeight!=undefined) {
      vis.display = (elem.offsetWidth!=0 && elem.offsetHeight!=0) ? 'block':'none';
   }

   //
   //  Switch to other mode...
   //
   vis.display = (vis.display=='' || vis.display=='block') ? 'none':'block';
}

///
/// http://www.maani.us/charts/index.php?menu=IE_Click
/// http://www.macromediahelp.com/flash/flash_object_fix/
///
function override_activate_this(embedded_object)
{
   alert(embedded_object);
   document.write(embedded_object);
   document.write('\n');
}

///
/// Ajos1 2008/03/30
///
function ReportCharCount(FormName, FieldName, ReportName, MaxLen, TmpType)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldName);
   ReporttItem = ReadAFieldCode(ReportName);

   ///
   /// TmpType 0 = left
   /// TmpType 1 = used
   ///
   if (TmpType == 0) {
      RetVal = MaxLen - CurrentItem.value.length;
      TmpStr = "left";
   } else {
      RetVal = CurrentItem.value.length;
      TmpStr = "used";
   }

   ///
   ///
   ///
   ReporttItem.innerHTML = RetVal + " " + TmpStr;

   ///
   ///
   ///
   if (RetVal <= 0) {
      ReporttItem.style.color = "#eeeeee";
   } else {
      ReporttItem.style.color = "#111111";
   }
}

///
/// http://torchrelay.beijing2008.cn/en/journey/cities/n214036350.shtml
///
function doZoom(size){
   var o=document.getElementById("newsContent").className="fontSize"+size;
}

///
/// http://www.daniweb.com/forums/thread28365.html
///
function getItemHeight(FieldId)
{
   // mozHeight hack...
   moz             = document.getElementById&&!document.all;
   mozHeightOffset = 5;

   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldId);

   // Some form of hack... must be early...
   CurrentItem.style.height="auto";

   // Get the height...
   ourhght = (CurrentItem.offsetHeight + (moz?mozHeightOffset:0));

   // Return the result...
   return(ourhght);
}

///
/// Pass the width!!
///
function resizeIframe_FromInner(FieldId, iheight)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldId);

   // Get the height...
   newhght = (iheight + 8);

   // required for Moz bug, value can be "", null, or integer
   //x//CurrentItem.height = 1;

   // Set the height...
   CurrentItem.height = newhght;
}


///
/// http://www.huntingground.freeserve.co.uk/main/mainfram.htm?../webplus/iframes/iframe_resize.htm
///
/// This is not always accurate... because... the iframe may fire its own
/// onload= command before the iframe source is finished...
///
function resizeIframe_FromOuter(LeFrameId, LeFrameNm)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(LeFrameId);

   // Get the height...
   newhght = (window.frames[LeFrameNm].document.body.scrollHeight + 8);

   // required for Moz bug, value can be "", null, or integer
   CurrentItem.height = 1;

   // Set the height...
   CurrentItem.height = newhght;
}

///
///
///
function RewriteCallerValue(LeFieldId)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(LeFrameId);

   ///
   ///
   ///
   alert(CurrentItem.value);
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/05/04
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function ReadAFieldCode(FieldId)
{
   //
   //
   //
   var elem;

   //
   // Get the item ID...
   //
   if (document.getElementById) {
      //
      // this is the way the standards work
      //
      elem = document.getElementById(FieldId);
   } else if( document.all ) {
      //
      // this is the way old msie versions work
      //
      elem = document.all[FieldId];
      //elem = eval("document.all." + FieldId);
   } else if( document.layers ) {
      //
      // this is the way nn4 works
      //
      elem = document.layers[FieldId];
   }

   //
   //
   //
   return(elem);
}



/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/05/26
///
/// Based upon http://www.dreamincode.net/code/snippet293.htm
///
/// getElementsByName is deprecated since i.e 4.0, it works only with
/// tags a,div,iframe ans dome other but not with p, input etc..
///
/// toLowerCase()
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function getElementsByName_iefix(tag, name, partial)
{
   var elem = document.getElementsByTagName(tag);
   var arr = new Array();
   iarr = 0;
   for (i = 0; i < elem.length; i++) {
      att = elem[i].getAttribute("name");
      if (att != null) {
         if (((partial == 0) && (att == name)) || ((partial == 1) && (att.indexOf(name) == 0))) {
            arr[iarr] = elem[i];
            iarr++;
         }
      }
   }
   return(arr);
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/05/26
///
/// Based upon http://www.webmasterworld.com/forum91/441.htm
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function AutoShowHideElements(tag, name, num, rehide)
{
   ///
   ///
   ///
   var ourelems = getElementsByName_iefix(tag, name, 1);

   ///
   ///
   ///
   fieldwant = name + num;

   ///
   ///
   ///
   for (i = 0; i < ourelems.length; i++) {
      ///
      ///
      ///
      att = ourelems[i].getAttribute("name");

      ///
      ///
      ///
      needtoshow = 0;
      if (att == fieldwant) {
         needtoshow = 1;
         if ((rehide == 1) && (ourelems[i].style.display == "block")) {
             needtoshow = 0;
         }
      }

      ///
      ///
      ///
      if (needtoshow == 1) {
         blkmode = "block";
         vismode = "visible";
      } else {
         blkmode = "none";
         vismode = "hidden";
      }

      ///
      /// Which to use?
      ///
      ourelems[i].style.display = blkmode;

      ///
      /// Which to use?
      ///
      if (document.getElementById) {
         // DOM3 = IE5, NS6
         ourelems[i].style.visibility         = vismode;
      } else  if (document.layers) {
         // Netscape 4
         document.layers[ourelems[i]].display = vismode;
      } else {
         // IE 4
         document.all.ourelems[i].visibility  = vismode;
      }
   }
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/05/26
///
/// Ajos1_SetAValue...
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function Ajos1_SetAValue( whichlayer, myvalue)
{
   //
   //
   //
   alert(myvalue);
   alert(myvalue);
   alert(myvalue);
   alert(myvalue);
    if (document.getElementById) {
       // DOM3 = IE5, NS6
       // this is the way the standards work
       document.getElementByName( whichLayer ).value = myvalue;
    } else if( document.all ) {
       // IE 4
       // this is the way old msie versions work
       document.all[whichLayer].value = myvalue;
    } else if( document.layers ) {
       // Netscape 4
       // this is the way nn4 works
       document.layers[whichLayer].value = myvalue;
    }
   alert(myvalue);
}


///
/// The Independent Feedback Prize Draw
///
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns5 = false;
if (navigator.appVersion.substring(0,1) == "5" && navigator.appName == "Netscape") {
   var ns5 = true;
}


///
/// The Independent Feedback Prize Draw
///
function show(id)
{
   if (ns4) {
      document.layers[id].display = "block";
   } else if (ie4) {
      document.all[id].style.display = "block";
   } else if (ns5) {
     document.getElementById(id).style.display = "block";
   }
}


///
/// The Independent Feedback Prize Draw
///
function verifyEmail(str)
{
   var reg = /^[a-z0-9_.-]*@{1}(([a-z0-9]+)([a-z0-9.-]+))\.([a-z]{2,4})$/i;
   var found = reg.test(str);
   return found;
}


///
/// The Independent Feedback Prize Draw
///
function verifyNumeric(strInput)
{
   if (strInput != '') {
      if (!strInput.match(/[^0-9]/)) {
         return true;
      }
   }
   return false;
}


///
/// The Independent Feedback Prize Draw
///
function verifyBirthDate(strBirthday,strBirthmonth,strBirthyear)
{
   if (strBirthday != '' && strBirthmonth != '' && strBirthyear != '') {
      var isBissex = (strBirthyear%400 == 0 ) || (( strBirthyear%4 == 0 ) && ( strBirthyear%100 != 0 ));
      return ((strBirthday=='31' && (strBirthmonth=='02' || strBirthmonth=='04' || strBirthmonth=='06' || strBirthmonth=='09' || strBirthmonth=='11')) || (strBirthday=='30' && strBirthmonth=='02') || (strBirthday=='29' && strBirthmonth=='02' && !isBissex)) ? false : true;
   }
   return false;
}


///
/// The Independent Feedback Prize Draw
///
function validateFormFields()
{
   var errorMsg = '';
   var form = document.registration;

   var salutation = form.salutation.value;
   if ( form.salutation.selectedIndex == 0 ) {
      errorMsg +='      * Title \n';
   }
   var firstname = form.firstname.value;
   if ( firstname.substring(0,1) == ' ' || firstname.length < 1 || firstname.length > 50 ) {
      errorMsg +='      * Name \n';
   }
   var lastname = form.lastname.value;
   if ( lastname.substring(0,1) == ' ' || lastname.length < 1 || lastname.length > 50 ) {
      errorMsg +='      * Surname \n';
   }
   if ( !verifyBirthDate(birthday,birthmonth,birthyear) ){
      errorMsg +='      * Birthdate \n';
      }
      var zipcode = form.zipcode.value;
      if ( zipcode.substring(0,1) == ' ' || zipcode.length < 1 || zipcode.length > 10 ) {
        errorMsg +='      * Postcode \n';
      }
      if ( !form.terms.checked ) {
        errorMsg +='      * Terms&Conditions \n';
      }
      var email = form.email.value;
      if ( !verifyEmail(email ) || email.length < 6 || email.length > 132 ) {
        errorMsg +='      * EMail address \n';
       }
      var var4 = form.var4.value;
      if ( !verifyEmail(var4 ) || var4.length < 6 || var4.length > 132 ) {
        errorMsg +='      * Confirmation E-Mail address \n';
       }
      if (errorMsg != '') {
        errorMsg = 'Following fields are not correct:\n\n'+errorMsg;
        alert(errorMsg);
        return false;
      }
      else {
        show('LayerLoading');
        document.getElementById("ndssend").disabled = true;
        return true;
      }
    }

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/12/12
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function Ajos1_Random_Int(TopRange)
{
   RetVal = parseInt(TopRange * Math.random(1));
   return(RetVal);
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2009/01/29
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function BeepBeep(TmpStr)
{
   alert("Beep " + TmpStr + " Beep");
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2009/03/30
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function ShowImgPreview(TmpStr, FieldId)
{
   //alert("Beep " + TmpStr + " Beep " + FieldId + " Beep");
   if ( TmpStr == "-blank-out-entry-" ) {
      TmpStr = "/ajosweb/images/website/no_image.jpg";
   }
   document.getElementById(FieldId).src    = TmpStr;
   document.getElementById(FieldId).height = 40;
}

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2009/12/06
/// http://stackoverflow.com/questions/382171/use-javascript-to-change-which-submit-is-activated-on-enter-key-press
/// <input type="text" name="something" value="blah"     onkeydown="return processKey(event)" />
/// <input type=submit name="desired" value="Save Earth" style="display: none"/>...<input type=submit name="something_else" value="Destroy Earth" />...<input id="foobar" type=submit name="desired" value="Save Earth" />
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function processKey(e)
{
   if (null == e) {
      e = window.event;
   }
   if (e.keyCode == 13)  {
      document.getElementById("foobar").click();
      return false;
   }
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2010/03/15
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function UnderScoreToSpace(FormName, FieldName)
{
   ///
   /// Read A Field Name/Id/Code...
   ///
   CurrentItem = ReadAFieldCode(FieldName);

   ///
   /// This helps put the cursor at the end of the field...
   ///
   CurrentItem.focus();

   ///
   /// What action
   ///
   CurrentItem.value = CurrentItem.value.replace(/_/ig, " ");
   CurrentItem.onchange(true);
}


