var arr_header = [
	{high: "/images/homepage/header/high/header_clay.jpg", low:"/images/homepage/header/low/clay.jpg", bar:"/images/homepage/header/bar/colorbar_clay.gif", flash:"/images/homepage/header/flash/clay.swf"},
	{high: "/images/homepage/header/high/header_john.jpg", low:"/images/homepage/header/low/john.jpg", bar:"/images/homepage/header/bar/colorbar_john.gif", flash:"/images/homepage/header/flash/john.swf"},
	{high: "/images/homepage/header/high/header_ladonna.jpg", low:"/images/homepage/header/low/ladonna.jpg", bar:"/images/homepage/header/bar/colorbar_ladonna.gif", flash:"/images/homepage/header/flash/ladonna.swf"},
	{high: "/images/homepage/header/high/header_suzan.jpg", low:"/images/homepage/header/low/suzan.jpg", bar:"/images/homepage/header/bar/colorbar_susan.gif", flash:"/images/homepage/header/flash/suzan.swf"}
];
var seq_header = Math.floor(Math.random() * arr_header.length);

function getHeaderImageHigh () {
    return("<img src='" + arr_header[seq_header].high + "' border='0' alt='Novartis.com page header' usemap='#NovartisLink'>");
}

function getHeaderImageBar () {
    return("<img src='" + arr_header[seq_header].bar + "' border='0' alt=''>");
}

function getHeaderImageLow () {
    return("<img src='" + arr_header[seq_header].low + "' border='0' alt='' id='header_low'>");
}

function getFlashObject () {
    return("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0' WIDTH='195' HEIGHT='116'><PARAM NAME=movie VALUE='" + arr_header[seq_header].flash + "'><PARAM NAME=quality VALUE='high'><PARAM NAME=bgcolor VALUE='#ffffff'><EMBED src='" + arr_header[seq_header].flash + "' quality=high bgcolor='#ffffff' WIDTH='195' HEIGHT='116' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>");
}

contactnov = new Array(
new Array("-- Choose a Product --","$$$$$"),
new Array("-- Product is not in the list --","Not listed Product"),
new Array("-- Product in development --","Product development"),
new Array("Acatak","Acatak"),
new Array("Actigall","Actigall"),
new Array("Adelphane-Esidrex","Adelphane-Esidrex"),
new Array("Alfacron","Alfacron"),
new Array("Anafranil","Anafranil"),
new Array("Angiscein","Angiscein"),
new Array("Anti\-Fly Program","Anti\-Fly Program"),
new Array("Anturan","Anturan"),
new Array("AOSept","AOSept"),
new Array("Apligraf","Apligraf"),
new Array("Apresoline","Apresoline"),
new Array("AquaSite","AquaSite"),
new Array("Aredia","Aredia"),
new Array("Aviva","Aviva"),
new Array("Benefiber","Benefiber"),
new Array("Brinerdin","Brinerdin"),
new Array("Butazolidin","Butazolidin"),
new Array("Cafergot","Cafergot"),
new Array("Cafergot\-PB","Cafergot\-PB"),
new Array("Calcium Sandoz","Calcium Sandoz"),
new Array("Capstar","Capstar"),
new Array("Cataflam","Cataflam"),
new Array("CIBA Pro 55","CIBA Pro 55"),
new Array("Cibacalcin","Cibacalcin"),
new Array("Cibacen","Cibacen"),
new Array("Cibadrex","Cibadrex"),
new Array("Cibasoft Standard","Cibasoft Standard"),
new Array("Cibasoft","Cibasoft"),
new Array("Clik","Clik"),
new Array("Clomicalm","Clomicalm"),
new Array("Clozaril","Clozaril"),
new Array("Co\-Diovan","Co\-Diovan"),
new Array("Coartem","Coartem"),
new Array("Combi\-Patch","Combi\-Patch"),
new Array("Compat","Compat"),
new Array("Comtan","Comtan"),
new Array("Corangin","Corangin"),
new Array("Cosumix Plus","Cosumix Plus"),
new Array("D.H.E. 54","D.H.E. 54"),
new Array("Demavir","Demavir"),
new Array("Deseril Retard","Deseril Retard"),
new Array("Deseril","Deseril"),
new Array("Desferal","Desferal"),
new Array("Dexacidin","Dexacidin"),
new Array("Dihydergot","Dihydergot"),
new Array("Diovan HCT","Diovan HCT"),
new Array("Diovan","Diovan"),
new Array("Econor","Econor"),
new Array("Eflone","Eflone"),
new Array("Egaten","Egaten"),
new Array("Endex","Endex"),
new Array("Entumin","Entumin"),
new Array("Esb3","Esb3"),
new Array("Esidrex","Esidrex"),
new Array("Estracomb TTS","Estracomb TTS"),
new Array("Estraderm MX","Estraderm MX"),
new Array("Estradot","Estradot"),
new Array("Estragest TTS","Estragest TTS"),
new Array("Estrapak","Estrapak"),
new Array("Ex\-Lax","Ex\-Lax"),
new Array("Exelon","Exelon"),
new Array("Eye\-Scrub","Eye\-Scrub"),
new Array("Famvir","Famvir"),
new Array("Fasimec","Fasimec"),
new Array("Fasinex","Fasinex"),
new Array("Femara","Femara"),
new Array("Fenistil","Fenistil"),
new Array("Fioricet","Fioricet"),
new Array("Fluor\-Op","Fluor\-Op"),
new Array("Focus 1\-2 Week","Focus 1\-2 Week"),
new Array("Focus DAILIES","Focus DAILIES"),
new Array("Focus Monthly","Focus Monthly"),
new Array("Focus NIGHT \& DAY","Focus NIGHT \& DAY"),
new Array("Focus Progressives","Focus Progressives"),
new Array("Focus Softcolors","Focus Softcolors"),
new Array("Focus Toric","Focus Toric"),
new Array("Foradil","Foradil"),
new Array("Fortekor","Fortekor"),
new Array("Gas X","Gas X"),
new Array("Gentacidin","Gentacidin"),
new Array("Gentamicin","Gentamicin"),
new Array("GenTeal","GenTeal"),
new Array("Gerber products","Gerber products"),
new Array("Gerlinea","Gerlinea"),
new Array("Gleevec","Gleevec"),
new Array("Glivec","Glivec"),
new Array("Gonisol","Gonisol"),
new Array("Habitrol","Habitrol"),
new Array("Hydergine","Hydergine"),
new Array("Hygroton","Hygroton"),
new Array("HypoTears Select","HypoTears Select"),
new Array("Illusions","Illusions"),
new Array("Impact","Impact"),
new Array("Importal","Importal"),
new Array("Inflamase","Inflamase"),
new Array("Insidon","Insidon"),
new Array("Interceptor","Interceptor"),
new Array("Isosource","Isosource"),
new Array("Lamisil AT Cream","Lamisil AT Cream"),
new Array("Lamisil","Lamisil"),
new Array("Lamprene","Lamprene"),
new Array("Larvadex","Larvadex"),
new Array("Lens Drops","Lens Drops"),
new Array("Lentaron","Lentaron"),
new Array("Leponex","Leponex"),
new Array("Leptilan","Leptilan"),
new Array("Lescol","Lescol"),
new Array("Leucomax","Leucomax"),
new Array("Lioresal","Lioresal"),
new Array("Litec","Litec"),
new Array("Logroton Retard","Logroton Retard"),
new Array("Lomir","Lomir"),
new Array("Lopatol","Lopatol"),
new Array("Lopresor","Lopresor"),
new Array("Lotensin HCT","Lotensin HCT"),
new Array("Lotensin","Lotensin"),
new Array("Lotrel","Lotrel"),
new Array("Ludiomil","Ludiomil"),
new Array("Maalox","Maalox"),
new Array("Mellaril S","Mellaril S"),
new Array("Mellaril","Mellaril"),
new Array("Melleril","Melleril"),
new Array("MemoryLens","MemoryLens"),
new Array("Methergin","Methergin"),
new Array("Metopirone","Metopirone"),
new Array("Miacalcin","Miacalcin"),
new Array("Miacalic","Miacalic"),
new Array("Migranal","Migranal"),
new Array("Modifast","Modifast"),
new Array("Mosegor","Mosegor"),
new Array("Navoban","Navoban"),
new Array("Neocidol","Neocidol"),
new Array("Neocitran","Neocitran"),
new Array("Neoporex","Neoporex"),
new Array("Neoral Oral","Neoral Oral"),
new Array("Neoral Soft Gelatine Capsules","Neoral Soft Gelatine Capsules"),
new Array("Neoral","Neoral"),
new Array("Nepresol","Nepresol"),
new Array("Nicotinell","Nicotinell"),
new Array("Nicotinell","Nicotinell"),
new Array("Nitroderm TTS","Nitroderm TTS"),
new Array("Norprolac","Norprolac"),
new Array("Novasource","Novasource"),
new Array("Noveril","Noveril"),
new Array("Oclea","Oclea"),
new Array("Ocupress","Ocupress"),
new Array("Orimeten","Orimeten"),
new Array("Orstanorm","Orstanorm"),
new Array("Otrivin","Otrivin"),
new Array("Otrivin","Otrivin"),
new Array("Ovaltine","Ovaltine"),
new Array("Ovomaltine","Ovomaltine"),
new Array("Parlodel","Parlodel"),
new Array("Pesoforma","Pesoforma"),
new Array("Phaco Blades","Phaco Blades"),
new Array("PMMA Lenses","PMMA Lenses"),
new Array("Program","Program"),
new Array("Pure Eyes","Pure Eyes"),
new Array("Quick Care","Quick Care"),
new Array("Reducol","Reducol"),
new Array("Regitin","Regitin"),
new Array("RESCULA","RESCULA"),
new Array("ReSource","ReSource"),
new Array("ReSource","ReSource"),
new Array("Riamet","Riamet"),
new Array("Ritalin SR","Ritalin SR"),
new Array("Ritalin","Ritalin"),
new Array("Sandimmun","Sandimmun"),
new Array("Sandimmune Injection","Sandimmune Injection"),
new Array("Sandimmune Oral Solution","Sandimmune Oral Solution"),
new Array("Sandimmune Soft Gelatine Capsules","Sandimmune Soft Gelatine Capsules"),
new Array("Sandoglobin","Sandoglobin"),
new Array("Sandoglobulin","Sandoglobulin"),
new Array("Sandomigran","Sandomigran"),
new Array("Sandonorm","Sandonorm"),
new Array("Sandostatin LAR Depot","Sandostatin LAR Depot"),
new Array("Sandostatin","Sandostatin"),
new Array("Sansert","Sansert"),
new Array("Sapphire Micorsurgical Knives","Sapphire Micorsurgical Knives"),
new Array("Savlon","Savlon"),
new Array("Savlon","Savlon"),
new Array("Scopoderm TTS","Scopoderm TTS"),
new Array("Sentinel","Sentinel"),
new Array("Ser\-Ap\-Es","Ser\-Ap\-Es"),
new Array("Serentil","Serentil"),
new Array("Simulect","Simulect"),
new Array("Sintrom","Sintrom"),
new Array("Sirdalud","Sirdalud"),
new Array("Slow\-K","Slow\-K"),
new Array("Snip","Snip"),
new Array("Softcon","Softcon"),
new Array("SoftWear Saline","SoftWear Saline"),
new Array("SOLO\-Care","SOLO\-Care"),
new Array("Spasmo\-Cibalgin","Spasmo\-Cibalgin"),
new Array("Spersallerg","Spersallerg"),
new Array("Starlix","Starlix"),
new Array("Symmetrel","Symmetrel"),
new Array("Synacthen","Synacthen"),
new Array("Syntocinon","Syntocinon"),
new Array("Tavist","Tavist"),
new Array("Tearisol","Tearisol"),
new Array("TearSaver","TearSaver"),
new Array("Tegretol XR","Tegretol XR"),
new Array("Tegretol","Tegretol"),
new Array("Tetracaine","Tetracaine"),
new Array("Tetramutin","Tetramutin"),
new Array("Theraflu","Theraflu"),
new Array("Tiamutin","Tiamutin"),
new Array("Tixy","Tixy"),
new Array("Tofranil","Tofranil"),
new Array("Torecan","Torecan"),
new Array("Torisoft","Torisoft"),
new Array("Transderm Nitro","Transderm Nitro"),
new Array("Transderm scop","Transderm scop"),
new Array("Trasicor","Trasicor"),
new Array("Trasitensin","Trasitensin"),
new Array("Trepress","Trepress"),
new Array("Triaminic","Triaminic"),
new Array("Trileptal","Trileptal"),
new Array("Vasocidin","Vasocidin"),
new Array("VasoClear","VasoClear"),
new Array("Venoruton","Venoruton"),
new Array("Vetrazin","Vetrazin"),
new Array("Viskaldix","Viskaldix"),
new Array("Visken","Visken"),
new Array("Visudyne","Visudyne"),
new Array("Vitravene","Vitravene"),
new Array("Vivelle","Vivelle"),
new Array("Vivelle\-Dot","Vivelle\-Dot"),
new Array("Voltaren","Voltaren"),
new Array("Zaditen","Zaditen")
);

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
  var i, j;
  var prompt;
  // empty existing items
  for (i = selectCtrl.options.length; i >= 0; i--) {
    selectCtrl.options[i] = null;
  }
  prompt = (itemArray != null) ? goodPrompt : badPrompt;
  if (prompt == null) {
    j = 0;
  }
  else {
    selectCtrl.options[0] = new Option(prompt);
    j = 1;
  }
  if (itemArray != null) {
  // add new items
    for (i = 0; i < itemArray.length; i++) {
      selectCtrl.options[j] = new Option(itemArray[i][0]);
      if (itemArray[i][1] != null) {
        selectCtrl.options[j].value = itemArray[i][1];
      }
      j++;
    }
    // select first item (prompt) for sub list
    selectCtrl.options[0].selected = true;
  }
}


var defaultEmptyOK = false;

// CONSTANT STRING DECLARATIONS
// (grouped for ease of translation and localization)

// m is an abbreviation for "missing"

var mPrefix = "You did not enter a value into the \"";
var mSuffix = "\" item. This is a required item. Please enter it now.";

var iPrefix = "The item named \""
var iEmailSuffix = "\" must be a valid email address (like foo@bar.com). Please reenter it.";
var iAlphanumericSuffix = "\" must contain a valid alphanumeric string. Please reenter it.";
var iAlphabeticSuffix = "\" must contain a valid alphabetic string. Please reenter it.";
var iNumberSuffix = "\" must contain a valid number. Please reenter it.";
var iSelectPrefix = "You have not filled one of the required fields.  \nPlease select one of the options for the item named \"";
var iSelectSuffix = "\"";
var iRadioPrefix = "You have not filled one of the required fields.  \nPlease select one of the buttons for the item named \"";
var iRadioSuffix = "\"";
var iPhoneSuffix = "\" must be a valid 10 Digit Phone Number like 555-555-5555. Please reenter it.";

// regular expressions used for checking fields

// Email Address
// BOI, followed by one or more characters, followed by @,
// followed by one or more characters, followed by .,
// followed by one or more characters, followed by EOI.
//var reEmail = /^.+\@.+\..+$/
var reEmail = /.+/

// BOI, followed by one or more whitespace characters, followed by EOI.
var reWhitespace = /^\s+$/;

// Alphanumeric fields
// BOI, followed by one or more lower or uppercase English letters
// or digits, followed by EOI.
var reAlphanumeric = /^[0-9a-zA-Z.]+$/

// BOI, followed by one or more digits, followed by EOI.
var reInteger = /^[\d ]+$/

// BOI, followed by one or more lower or uppercase English letters,
// followed by EOI.
var reAlphabetic = /^[a-zA-Z ]+$/



// Check whether string s is empty.
function isEmpty(s) {
  return ((s == null) || (s.length == 0))
}


// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s) { 
  // Is s empty?
  return (isEmpty(s) || reWhitespace.test(s));
}

// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.
function warnEmpty (theField, s) {   
  theField.focus();
  alert(mPrefix + s + mSuffix);
  return false;
}


// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.
function warnInvalid (theField, s) {   
  theField.focus();
  theField.select();
  alert(s);
  return false;
}

function warnMustFill (theField, s) {
  theField.focus();
  alert(s);
  return false;
}

/* FUNCTIONS TO INTERACTIVELY CHECK VARIOUS FIELDS. */

// checkString (TEXTFIELD theField, STRING s, [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is not all whitespace.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkString (theField, s, emptyOK) {
  // Next line is needed on NN3 to avoid "undefined is not a number" error
  // in equality comparison below.
  if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (isEmpty(theField.value))) return true;
  if (isWhitespace(theField.value))
     return warnEmpty (theField, s);
  else return true;
}

// ********************** Email field testing ***************
// isEmail (STRING s [, BOOLEAN emptyOK])
//
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
function isEmail (s) {
  if (isEmpty(s))
    if (isEmail.arguments.length == 1) return defaultEmptyOK;
    else return (isEmail.arguments[1] == true);
    else {
      return reEmail.test(s)
    }
}

// isAlphanumeric (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is English letters
// (A .. Z, a..z) and numbers only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.
function isAlphanumeric (s) {
  var i;

  if (isEmpty(s))
     if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
     else return (isAlphanumeric.arguments[1] == true);

  else {
     return reAlphanumeric.test(s)
  }
}


// isInteger (STRING s [, BOOLEAN emptyOK])
//
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true),
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true
function isInteger (s) {
  var i;

  if (isEmpty(s))
     if (isInteger.arguments.length == 1) return defaultEmptyOK;
     else return (isInteger.arguments[1] == true);

  return reInteger.test(s)
}

// isAlphabetic (STRING s [, BOOLEAN emptyOK])
//
// Returns true if string s is English letters
// (A .. Z, a .. z, 0 .. 9) only.
//
function isAlphabetic (s) {
  var i;

  if (isEmpty(s))
     if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
     else return (isAlphabetic.arguments[1] == true);

  else {
     return reAlphabetic.test(s)
  }
}

// checkEmail (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid Email.
//
function checkEmail (theField, message, emptyOK) {
  if (checkEmail.arguments.length == 2) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (isEmpty(theField.value))) return true;
  else if (!isEmail(theField.value, false))
     return warnInvalid (theField, message);
  else return true;
}

// check alphanumeric (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid alphanumeric string.
//
function checkAlphanumeric (theField, message, emptyOK)
{   if (checkAlphanumeric.arguments.length == 2) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isAlphanumeric(theField.value))
       return warnInvalid (theField, message);
    else return true;
}

// checkAlphabetic (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid alphabetic string.
//
function checkAlphabetic (theField, message, emptyOK) {
  if (checkAlphabetic.arguments.length == 2) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (isEmpty(theField.value))) return true;
  else if (!isAlphabetic(theField.value))
     return warnInvalid (theField, message);
  else return true;
}

// checkNumber (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid number string.
//
function checkNumber (theField, message, emptyOK) {
  if (checkNumber.arguments.length == 2) emptyOK = defaultEmptyOK;
  if ((emptyOK == true) && (isEmpty(theField.value))) return true;
  else if (!isInteger(theField.value))
     return warnInvalid (theField, message);
  else return true;
}

// checkRequiredSelect (SelectField theField)
//
// Check that option theField.value is filled by user
//
function checkRequiredSelect(theField, message) {
  if (theField.options[theField.options.selectedIndex].value == "$$$$$")    
   return warnMustFill(theField, message);
  else return true;
}

function checkRequiredRadio(theField, message) {
  if (!theField.checked)
    return warnMustFill(theField, message);
  else return true;
}

// check form element values before submitting
// if all fields look good return true so that the form can be submitted
function CheckForm(theForm, fes) {
  // first check that all "required" fields are filled
  for (i = 0; i < theForm.elements.length; i++) {
    if (typeof(fes[theForm.elements[i].name]) == "undefined") {
      continue;
    }
    if (fes[theForm.elements[i].name].required == 1) {
      if (fes[theForm.elements[i].name].type == "text") {
//	    if (!checkString(theForm.elements[i],
//	                     theForm.elements[i].name, false))
        if (!checkString(theForm.elements[i], fes[theForm.elements[i].name].desc, false))
	  return false;
        } else if (fes[theForm.elements[i].name].type == "select") {
	  if (!checkRequiredSelect(theForm.elements[i], iSelectPrefix + fes[theForm.elements[i].name].desc+iSelectSuffix)) return false;
	} else if (fes[theForm.elements[i].name].type == "radio") {
          var radiochecked = theForm.elements[i].checked;
	  var radioname = theForm.elements[i].name;
	  var j = i+1;
          while (j < theForm.elements.length) {
	    if (theForm.elements[j].type == "radio" &&
	        theForm.elements[j].name == radioname) {
              if (!radiochecked) radiochecked = theForm.elements[j].checked;
	        j++;
	      } else
	        break;	// reached end of radio button sequence
	    }
	    if (!radiochecked)
	      return warnMustFill(theForm.elements[i], iRadioPrefix + fes[theForm.elements[i].name].desc+iRadioSuffix);
	    i = j  - 1;
	}
     }
  }

  // now check the contents of all fields that require tests
  for (i = 0; i < theForm.elements.length; i++) {
    if (typeof(fes[theForm.elements[i].name]) == "undefined") {
      continue;
    }
    if (fes[theForm.elements[i].name].ctype == "Alphabetic") {
      if (!checkAlphabetic(theForm.elements[i],
	  iPrefix + fes[theForm.elements[i].name].desc + iAlphabeticSuffix,
	  (fes[theForm.elements[i].name].required == 1) ? false : true))
        return false;
    } else if (fes[theForm.elements[i].name].ctype == "Alphanumeric") {
        if (!checkAlphanumeric(theForm.elements[i],
	    iPrefix + fes[theForm.elements[i].name].desc + iAlphanumericSuffix,
	    (fes[theForm.elements[i].name].required == 1) ? false : true))
          return false;
    } else if (fes[theForm.elements[i].name].ctype == "Number") {
        if (!checkNumber(theForm.elements[i],
	    iPrefix + fes[theForm.elements[i].name].desc + iNumberSuffix,
	    (fes[theForm.elements[i].name].required == 1) ? false : true))
	  return false;
    } else if (fes[theForm.elements[i].name].ctype == "Email") {
        if (!checkEmail(theForm.elements[i],
	    iPrefix + fes[theForm.elements[i].name].desc +
	    iEmailSuffix,(fes[theForm.elements[i].name].required == 1) ? false : true))
	  return false;
    } else if (fes[theForm.elements[i].name].ctype == "None") {

    }
  }

    //theForm.submitTime.value=new Date();;
    return true;
}

function formelement(req, typ, contentt, flddesc) {
  this.required = req;  	       // is this a required item?
  this.ctype = contentt;
        			       // is content numeric, alphabetic etc.
        			       // applies only to text item fields
        			       // possible values are "Alphabetic", "Number",
        			       //	"Alphanumeric", "Email", "None"
  this.type = typ;		       // what is the type of this item
        			       // "text", "select", "radio"
  this.desc = flddesc;  	       // descriptive string for item
  return this;
}


function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
  field.value = field.value.substring(0, maxlimit);
  // otherwise, update 'characters left' counter
  else
  countfield.value = maxlimit - field.value.length;
}

function textChecker(field, countfield, maxlimit) {
  if (field.value.length != maxlimit) // if too short...extend it!
  {
    field.value = field.value.substring(0, maxlimit);
    alert("Invalid Phone Number Please Re-enter a standard 10 Digit Number WITHOUT DASHES");
  }

  // otherwise, update 'characters left' counter
  else
  countfield.value = maxlimit - field.value.length;
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}


/*
Instructions.
Alle elements that are required must contain 'id="Req"'
The form that is to be validated must have the same id as the variable 'formId'
@author Timmi,www.daman.dk,timmi@daman.dk
Version 1.2 17/11/2008 
*/

	//----Don't touch------
	var formId = "validateForm"; //id of the form
	 //array for holding passwords
	//----------------------
	
function validering(){
	
	var mandatoryError = document.getElementById("mandatoryError").value+"<br>";
	var emailFormatError = document.getElementById("emailFormatError").value+"<br>";
	var lengthError = document.getElementById("lengthError").value+"<br>";
	var maxLength = document.getElementById("maxLength").value;

	
	//local variables
	var count = 0;
	var error= 0;
	var errorMan = 0;
	var passArr = new Array();
	var errorMsg ="";
	

	// get all elements in the form
	var elem = document.getElementById(formId).elements;
	for(var i = 0; i < elem.length; i++){
		
		//check if element is mandatory
		if (elem[i].id == "Req"){
				//check if element is empty
				if (elem[i].value.length != 0){ 
					//element is not empty, do nothing	
				} else {
					//element is empty, set error
					errorMan = 1;
					error = 1;

				}
	} //end if req
}	
	
	//email validation
if(document.getElementById("replyTo") != null){
	
	email = document.getElementById("replyTo").value;
	
	apos=email.indexOf("@");
	dotpos=email.lastIndexOf(".");
	if (apos<1||dotpos-apos<2){
		error=1;
		errorMsg += emailFormatError;
  	}
}

//Check if message is null
if(document.getElementById("message") != null){
		if(document.getElementById(formId).message.value.length > maxLength){
	errorMsg += lengthError;
	error = 1;
	}
}


	if (error == 1){
		//form was filled incorrectly
		if (errorMan == 1){
			errorMsg += mandatoryError;
	}
		document.getElementById("valMsg").innerHTML = "<p>"+errorMsg+"</p>";
		document.getElementById("valMsg").style.display="block";
		return false;
	} else {
		//form was filled correctly
		return true;
	} //end error=1
}//end function
