//////////////////////////////////////////  
//
//
//	spyka Webmaster social bookmark script
//	(c) 2008 spyka Web Group
//  http://www.spyka.net
//
//	http://www.spyka.net/scripts/easy-social-bookmarks
//
//
//////////////////////////////////////////   
var sites = new Array();
//////////////////////////////////////////  
//
//			START EDITS HERE               
//
//////////////////////////////////////////   

//	html (or any other content) before each bookmark link. e.g. &nbsp; for space or <li> for start of list item
var html_before = '&nbsp;';

//	html (or any other content) after each bookmark link. e.g. &nbsp; for space or </li> to end list item
var html_after	= '&nbsp;';

//	imagepath to icons.	set to 0 to disable icons, e.g. var imagepath = '0';
var imagepath = '/images/_common/social/';


//	bookmarks: 
//				syntax: (be sure to increase x)
//				sites[x] = new Array(Bookmark URL, Bookmark name, Icon URL);
//
//				use {url} in bookmark URL to insert current url
//				use {title} in bookmark URL to insert current page title
//
sites[0] = new Array('http://www.facebook.com/sharer.php?u={url}', 'Facebook', imagepath+'facebook.gif');

sites[1] = new Array('http://twitter.com/home?status={url}', 'Twitter', imagepath+'twitter.gif');

//sites[2] = new Array('http://www.pusha.se/posta?url={url}&title={title}', 'Pusha', imagepath+'pusha.gif');

//sites[3] = new Array('http://del.icio.us/post?url={url}&title={title}', 'Del.icio.us', imagepath+'delicious.gif');

//sites[0] = new Array('http://digg.com/submit?phase=2&url={url}', 'Digg', imagepath+'digg.gif');
//sites[0] = new Array('http://reddit.com/submit?url={url}&title={title}', 'reddit', imagepath+'reddit.gif');
//sites[0] = new Array('http://furl.net/storeIt.jsp?t={title}&u={url}', 'Furl', imagepath+'furl.gif');
//sites[0] = new Array('http://www.stumbleupon.com/submit?url={url}', 'Stumble', imagepath+'stumble.gif');

//////////////////////////////////////////  
//
//			END EDITS HERE               
//
//////////////////////////////////////////   
function swgbookmarks()
{
	for(i = 0; i < sites.length; i++)
	{
		var g = sites[i];
		var u = g[0];
		u = u.replace('{url}', escape(window.location.href));
		u = u.replace('{title}', escape(encode_utf8(window.document.title)));
		var img = (imagepath == '0') ? '' : '<img src="'+g[2]+'" alt="'+g[1]+'" title="'+g[1]+'" />';
		var relativeUrl = '/share/' + g[1] +  window.location.pathname;
		var googleAnalyticsCall = "_gaq.push(['_trackPageview', '" + relativeUrl + "']);";
		var onClickCode = ' onClick="' + googleAnalyticsCall + '"';
		var k = '<a href="'+u+'"'+ onClickCode  + ' >'+img+g[1]+'</a>';
		//var k = '<a href="'+u+'">'+img+'</a>';
		window.document.write(html_before+k+html_after);		
	}
}



function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}







// dropdown select location change

function selsub(Url) {
  Url=document.subsites.sites[document.subsites.sites.selectedIndex].value;
  document.location = Url;
}

var excludeUrls = Array(

		
		'http://www.novartisfoundation.org/',
		'http://www.novartis-venturefunds.com',
		'http://www.ADHDinfo.com',
		'http://www.buckleys.com',
		'http://www.clozaril.com',
		'http://www.combipatch.com',
		'http://www.cubicin.com',
		'http://www.estraderm.com',
		'http://www.exforge.com',
		'http://www.focalinxr.com',
		'http://www.gas-x.com',
		'http://www.lamisilk.com',
		'http://www.lescolxl.com',
		'http://www.maaloxus.com',
		'http://www.myfortic.com',
		'http://www.prodiem.ca',
		'http://www.proleukin.com',
		'http://www.tasigna.com',
		'http://www.tekturna.com',
		'http://www.theraflu.com',
		'http://www.thrive2quit.com',
		'http://www.transdermscop.com',
		'http://www.tyzeka.com',
		'http://tyzeka.com',
		'http://www.us.trileptal.com',
		'http://www.vivelledot.com',
		'http://www.voltaren.co.za',
		'http://www.zaditor.com',
		'http://cws.huginonline.com',
		'http://hugin.info',
		'http://www.hugin.info',
		'http://dominoext.novartis.com',
		'http://download.macromedia.com',
		'http://etrials.novartis.com',
		'http://gaia.world-television.com',
		'http://infra.novartis.com',
		'http://mfile.akamai.com',
		'http://nibr.novartis.com',
		'http://novcont05.eu.novartis.net',
		'http://qsm3.asp.quartal.com',
		'http://search.novartis.com',
		'http://services.choruscall.com',
		'http://streamstudio.unit.net',
		'http://streamstudio.world-television.com',
		'http://web.gnf.org',
		'http://www.acromegalyinfo.com',
		'http://www.adhdinfo.com',
		'http://www.ah.novartis.com',
		'http://www.ar.novartis.com',
		'http://www.at.novartis.com',
		'http://www.benefiber.com',
		'http://www.blt.ch',
		'http://www.chiron.com',
		'http://www.cibavision.com',
		'http://www.coartem.com',
		'http://www.comtan.com',
		'http://www.consumer-health.se.novartis.com',
		'http://www.consumerhealth.eg.novartis.com',
		'http://www.corporatecitizenship.novartis.com',
		'http://www.corporate-ir.net',
		'http://www.denavir.com',
		'http://www.deramaxx.novartis.us',
		'http://www.diovan.com',
		'http://www.diovan.info',
		'http://www.elidel.com',
		'http://www.enablex.com',
		'http://www.estradot.com',
		'http://www.excedrin.com',
		'http://www.exelon.com',
		'http://www.exjade.com',
		'http://www.famvir.com',
		'http://www.femara.com',
		'http://www.femarainfo.com',
		'http://www.fenistil.ch',
		'http://www.flea-info.com',
		'http://www.flycontrol.novartis.com',
		'http://www.fmi.ch',
		'http://www.foradil.com',
		'http://www.foradil.us',
		'http://www.fungalnailinfection.com',
		'http://www.gerber.com',
		'http://www.gleevec.com',
		'http://www.glivec.com',
		'http://www.global-hr.orientation.novartis.com',
		'http://www.habitrol.com',
		'http://www.hk.novartis.com',
		'http://www.hu.novartis.com',
		'http://www.id.novartis.com',
		'http://www.in.pharma.novartis.com',
		'http://www.international.myeczema.com',
		'http://www.jubilaeumsstiftung.novartis.com',
		'http://www.kerilotion.com',
		'http://www.lamisil.com',
		'http://www.lamisilat.com',
		'http://www.locations.novartis.com',
		'http://www.lotrel.com',
		'http://www.malariaandhealth.com',
		'http://www.mea.novartis.com',
		'http://www.miacalcin.com',
		'http://www.nibr.novartis.com',
		'http://www.nicotinell.com',
		'http://www.nightanddaycontacts.com',
		'http://www.nitd.novartis.com',
		'http://www.novartis-consumer-health.ch',
		'http://www.novartis-consumerhealth.de',
		'http://www.novartis-transplant.com',
		'http://www.novartis-vaccines.com',
		'http://www.novartis.at',
		'http://www.novartis.be',
		'http://www.novartis.ca',
		'http://www.novartis.ch',
		'http://www.novartis.co.jp',
		'http://www.novartis.co.kr',
		'http://www.novartis.co.uk',
		'http://www.novartis.com',
		'http://www.novartis.com.au',
		'http://www.novartis.com.br',
		'http://www.novartis.com.cn',
		'http://www.novartis.com.co',
		'http://www.novartis.com.mx',
		'http://www.novartis.com.tr',
		'http://www.novartis.cz',
		'http://www.novartis.de',
		'http://www.novartis.dk',
		'http://www.novartis.es',
		'http://www.novartis.fi',
		'http://www.novartis.fr',
		'http://www.novartis.gr',
		'http://www.novartis.is',
		'http://www.novartis.it',
		'http://www.novartis.nl',
		'http://www.novartis.no',
		'http://www.novartis.pl',
		'http://www.novartis.ru',
		'http://www.novartis.se',
		'http://www.novartisclinicaltrials.com',
		'http://www.novartisconsumerhealth.ca',
		'http://www.novartisconsumerhealth.es',
		'http://www.novartisconsumerhealth.nl',
		'http://www.novartisfound.org.uk',
		'http://www.novartisfoundation.com',
		'http://www.novartisoncology.com',
		'http://www.novartisophthalmics.com',
		'http://www.novartisvaccines.com',
		'http://www.o2optix.com',
		'http://www.pharma.us.novartis.com',
		'http://www.prexige.com',
		'http://www.rescula.com',
		'http://www.ritalin.com',
		'http://www.sandostatin.com',
		'http://www.sandoz.com',
		'http://www.stalevo.com',
		'http://www.starlix.com',
		'http://www.tbdots.com',
		'http://www.tiamutin.com',
		'http://www.triaminic.com',
		'http://www.trileptal.com',
		'http://www.us.cibavision.com',
		'http://www.us.novartis.com',
		'http://www.us.novartisoncology.com',
		'http://www.us.novartisophthalmics.com',
		'http://www.us.sandostatin.com',
		'http://www.us.zometa.com',
		'http://www.venturefund.novartis.com',
		'http://www.visudyne.com',
		'http://www.xolair.com',
		'http://www.zelmac.ch',
		'http://www.zelnorm.com',
		'http://www.zometa.com'
		  );

function checkScore(){
			
		 var error = 0;
		 var finalCount = 0
		 var answer1 = getSelectedRadioValue(document.forms['quizForm'].elements['question1']);
		 var answer2 = getSelectedRadioValue(document.forms['quizForm'].elements['question2']);
		 var answer3 = getSelectedRadioValue(document.forms['quizForm'].elements['question3']);
		 var answer4 = getSelectedRadioValue(document.forms['quizForm'].elements['question4']);
		 var answer5 = getSelectedRadioValue(document.forms['quizForm'].elements['question5']);
		 var answer6 = getSelectedRadioValue(document.forms['quizForm'].elements['question6']);

		 	
		 	if (answer1 == "false"){
       document.getElementById("error1").style.display="block";
       error = 1;
		 	} else {
		 		document.getElementById("error1").style.display="none";
		 	}
		 	
		 	
		 	if (answer2 == "false"){
       document.getElementById("error2").style.display="block";
       error = 1;
		 	}else {
		 		document.getElementById("error2").style.display="none";
		 	}
		 	
		 	if (answer3 == "false"){
       document.getElementById("error3").style.display="block";
       error = 1;
		 	} 	else {
		 		document.getElementById("error3").style.display="none";
		 	}
		 	
		 	if (answer4 == "false"){
       document.getElementById("error4").style.display="block";
       error = 1;
		 	}	else {
		 		document.getElementById("error4").style.display="none";
		 	}
		 	
		 	if (answer5 == "false"){
       document.getElementById("error5").style.display="block";
       error = 1;
		 	}	else {
		 		document.getElementById("error5").style.display="none";
		 	}
		 	
		 	if (answer6 == "false"){
       document.getElementById("error6").style.display="block";
       error = 1;
		 	}else {
		 		document.getElementById("error6").style.display="none";
		 	}
		 	
		 	if(error==1){
		 		return false;	
		 	}
		 	
}
function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "false";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return true//buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return true//buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function


function printResult(){
var count = 0;	
var answer1= getParameter("question1");
var answer2= getParameter("question2");
var answer3= getParameter("question3");
var answer4= getParameter("question4");
var answer5= getParameter("question5");
var answer6= getParameter("question6");


if(answer1 == 1){
	count = count +1;
document.getElementById("question1").style.display="block";
}

if(answer2 == 1){
	count = count +1;
document.getElementById("question2").style.display="block";
}
if(answer3 == 1){
	count = count +1;
document.getElementById("question3").style.display="block";
}
if(answer4 == 1){
	count = count +1;
document.getElementById("question4").style.display="block";
}
if(answer5 == 1){
	count = count +1;
document.getElementById("question5").style.display="block";
}
if(answer6 == 1){
	count = count +1;
document.getElementById("question6").style.display="block";
}

//document.getElementById("result").innerHTML = "Du har svaret ja til "+count+" ud af 6 sp&oslash;rgsm&aring;l";
document.getElementById("result").innerHTML = "Du har svarat ja till "+count+" av 6 fr&aring;gor";



} 

function getParameter(name) {
   var url = window.location.href;
   var paramsStart = url.indexOf("?");

   if(paramsStart != -1){

      var paramString = url.substr(paramsStart + 1);
      var tokenStart = paramString.indexOf(name);

      if(tokenStart != -1){

         paramToEnd = paramString.substr(tokenStart + name.length + 1);
         var delimiterPos = paramToEnd.indexOf("&");

         if(delimiterPos == -1){
            return paramToEnd;
         }
         else {
            return paramToEnd.substr(0, delimiterPos);
         }
      }
   }
}

function tbTest_focus(e,o){
if(!o.firstTime){
	o.firstTime=true
	o.defaultText = o.value;
	o.value=""

	return
	}

	if(o.value == "" ){
		o.value = o.defaultText;
		o.firstTime = false
	}
	
}

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

/*
Instructions.
All elements that are required must contain id="Req" or required="true".
Please use required="true", as the other is left for backwards compatibility purposes only.
Please also set a caption attribute with the field's caption for use in error messages.

The form that is to be validated must have the same id as the variable 'formId'

Besides the simple "not empty" validation, there are other, more complex and powerful validation types available. 
See below for details.
@author Tom Andresen,www.daman.dk,tom@daman.dk
Version 2.0 28/09/2009 
*/

	//----Don't touch------
	var jFormId = "validateForm"; // id of the form
	// ----Error message lookup table----
	// Note that %c in error messages will be replaced with the field's caption.
	var errorMessages = { 
	dk : { mandatoryError : "Du skal udfylde feltet %c, tak.",
				 emailFormatError : "Din mailadresse er ikke korrekt, pr\370v venligst igen.", 
				 lengthError : "Teksten er for lang, den kan maksimalt v\346re 950 tegn.", 
				 numMaxError : "Du kan ikke bestille flere end det maksimale antal.", 
				 numMinError : "Du kan ikke bestille mindre end det minimale antal.", 
				 zipCodeError : "Postnummeret er ikke korrekt.", 
				 mustAcceptError : "Du skal acceptere betingelserne for anvendelse.", 
				 numInvalidError : "Du skal skrive et tal.",
				 maxLength : "950"},
	en : { mandatoryError : "Please fill the field %c.",
				 emailFormatError : "The entered e-mail address is invalid, please try again.", 
				 lengthError : "The text is too long, it has a maximum length of 950 characters.", 
				 numMaxError : "You cannot order more than the maximum number.", 
				 numMinError : "You cannot order less than the minimal number.", 
				 zipCodeError : "The Zip code is incorrect.", 
				 mustAcceptError : "You must accept the terms and condition for use of this website.", 
				 numInvalidError : "You must write a number.",
				 maxLength : "950"},
	se : { mandatoryError : "Du m\345ste fylla i f\344ltet %c, tack", 
				 emailFormatError : "Din e-mail adress \344r inte korrekt, v\344nligen f\366rs\366k igen", 
				 lengthError : "Meddelandet \344r f\366r l\345ngt, max antal tecken \344r 950", 
				 numMaxError : "Du kan inte best\344lla mer \344n det maximala antalet", 
				 numMinError : "Du kan inte best\344lla mindre \344n det minsta antalet", 
				 zipCodeError : "Postnumret \344r felaktig", 
				 mustAcceptError : "Du m\366ste godk\344nna villkoren f\366r anv\344ndning", 
				 numInvalidError : "Du m\366ste skriva ett tal",
				 maxLength : "950"},
	no : { mandatoryError : "test", 
				 emailFormatError : "email", 
				 lengthError : "", 
				 numMaxError : "", 
				 numMinError : "", 
				 zipCodeError : "", 
				 mustAcceptError : "",
				 numInvalidError : "", 
				 maxLength : "950"},
	fi : { mandatoryError : "Kaikki *merkatut kent\344t on t\344ytett\344v\344", 
				 emailFormatError : "S\344hk\344postiosoitteesi on v\344\344r\344, yst\344v\344llisesti yrit\344 uudestaan", 
				 lengthError : "Teksti on liian pitk\344, maksimipituus on 950 merkki\344", 
				 numMaxError : "", 
				 numMinError : "", 
				 zipCodeError : "", 
				 mustAcceptError : "",
				 numInvalidError : "", 
				 maxLength : "950"}
};
	// ---------------------------------
function error(errorMessage, fieldId, fieldCaption)
{
	this.fieldCaption = fieldCaption;
	this.fieldId = fieldId;
	this.errorMessage = errorMessage.replace(/%c/, fieldCaption);
}

// This function will look up the specified error type in the specified
// language, but overrides in the local document will be used.
function getErrorMessage(type, language)
{
	if (document.getElementById(type) != null && document.getElementById(type).value != null)
	{
		return document.getElementById(type).value+"<br/>"; 
	}
	else if (errorMessages[language] != null && errorMessages[language][type] != null)
	{
		return errorMessages[language][type]+"<br/>";
	}
	else
	{
		return null;
	}
}

function test()
{
	alert(getErrorMessage('lengthError', 'dk'));
}

//
// Validates the form with the ID specified in the variable formId. 
// Fields where id="req" or required="true" are checked for not being null. 
// More advanced validation is done using the validation types:
// 
// valtype="num" - validates as number (incl. decimal numbers), optional min and
// max tresholds.
// valtype="email" - validates an e-mail address (makes sure
// there is a @ and a . after the @).
// valtype="true" - validates that a checkbox is checked.
// valtype="zipcode" - validates that the zipcode consists of a number of integers. That number is set using the ziplength attribute.
// valtype="groupmax" - validates that all fields of a specific group
// (default if none specified with the group attribute). Use the max attribute
// on the first element in a group to set the max length.
function validate(language)
{
	var lang = language !== null && language !== "" ? language : "dk";
	
	var mandatoryError = getErrorMessage("mandatoryError", lang);
	var emailFormatError = getErrorMessage("emailFormatError", lang);
	var lengthError = getErrorMessage("lengthError", lang);
	var numMaxError = getErrorMessage("numMaxError", lang);
	var numMinError = getErrorMessage("numMinError", lang);
	var zipCodeError = getErrorMessage("zipCodeError", lang);
	var mustAcceptError = getErrorMessage("mustAcceptError", lang);
	var numInvalidError = getErrorMessage("numInvalidError", lang);
	var maxLength = getErrorMessage("maxLength", lang);

	
	// local variables
	var errorArray = [];
	var supplementaryLength = 0;
	var groupArray = [];
	

	// get all elements in the form
	var elem = document.getElementById(jFormId).elements;
	for(var currentElementIndex = 0; currentElementIndex < elem.length; currentElementIndex++)
	{
		// check if element is mandatory
		if (elem[currentElementIndex].id.toLowerCase() == "req" || (elem[currentElementIndex].getAttribute("required") != null && elem[currentElementIndex].getAttribute("required").toLowerCase() == "true"))
		{
			// check if element is empty
			if (elem[currentElementIndex].value.length != 0)
			{ 
				// element is not empty, do nothing
			}
			else
			{
				// element is empty, set error
				errorArray[errorArray.length] = new error(mandatoryError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
			}
		}// end if req
		// Validate groupmax
		if (elem[currentElementIndex].getAttribute("valtype") != null && elem[currentElementIndex].getAttribute("valtype").toLowerCase() == "groupmax")
		{
			var groupName = elem[currentElementIndex].getAttribute("group") != null ? elem[currentElementIndex].getAttribute("group").toLowerCase() : "default";
			if (groupArray[groupName] == null)
			{
				groupArray[groupName] = [];
				groupArray[groupName].count = 0;
				groupArray[groupName].max = -1;
				groupArray[groupName].valid = true;
				
				if (elem[currentElementIndex].getAttribute("max") != null && isInteger(elem[currentElementIndex].getAttribute("max")) )
				{
					groupArray[groupName].max = elem[currentElementIndex].getAttribute("max");
				}
			}
			if (elem[currentElementIndex].value != null && elem[currentElementIndex].value != "")
			{
				groupArray[groupName].count += elem[currentElementIndex].value.length;
				if (groupArray[groupName].max != -1 && parseFloat(groupArray[groupName].count) > parseFloat(groupArray[groupName].max) && groupArray[groupName].valid == true)
				{
					errorArray[errorArray.length] = new error(lengthError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
					groupArray[groupName].valid = false;
				}
			}
		}
		//
		
		// If the element is supplementary, count up towards the 1000 char total
		// limit
		if (elem[currentElementIndex].name != null & elem[currentElementIndex].name.toLowerCase() == "supplementary")
		{
			if (elem[currentElementIndex].value != null && elem[currentElementIndex].value.length != 0)
			{
				supplementaryLength += elem[currentElementIndex].value.length;
			}
		}
		// Validate numeric input
		if (elem[currentElementIndex].getAttribute("valtype") != null && elem[currentElementIndex].getAttribute("valtype").toLowerCase() == "num")
		{
			if (isNumeric(elem[currentElementIndex].value))
			{
				if (elem[currentElementIndex].getAttribute("max") != null && isNumeric(elem[currentElementIndex].getAttribute("max")))
				{
					if (parseFloat(elem[currentElementIndex].value) > parseFloat(elem[currentElementIndex].getAttribute("max")))
					{
						errorArray[errorArray.length] = new error(numMaxError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
					}
				}
				if (elem[currentElementIndex].getAttribute("min") != null && isNumeric(elem[currentElementIndex].getAttribute("min")))
				{
					if (parseFloat(elem[currentElementIndex].value) < parseFloat(elem[currentElementIndex].getAttribute("min")))
					{
						errorArray[errorArray.length] = new error(numMinError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
					}
				}
			}
			else if (elem[currentElementIndex].value != null && elem[currentElementIndex].value != "")
			{
				errorArray[errorArray.length] = new error(numInvalidError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
			}
				
		}
		// Validate postal code input
		if (elem[currentElementIndex].getAttribute("valtype") != null && elem[currentElementIndex].getAttribute("valtype").toLowerCase() == "zipcode")
		{
			if (elem[currentElementIndex].value == null || !isInteger(elem[currentElementIndex].value))
			{
				errorArray[errorArray.length] = new error(zipCodeError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
			}
			if (elem[currentElementIndex].getAttribute("ziplength") != null && isInteger(elem[currentElementIndex].getAttribute("ziplength")))
			{
				if (elem[currentElementIndex].value.length != elem[currentElementIndex].getAttribute("ziplength"))
				{
					errorArray[errorArray.length] = new error(zipCodeError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
				}
			}
		}
		// email validation
		if(elem[currentElementIndex].getAttribute("valtype") != null && elem[currentElementIndex].getAttribute("valtype").toLowerCase() == "email")
		{
			if (elem[currentElementIndex].value != null && !isEmail(elem[currentElementIndex].value))
			{
				errorArray[errorArray.length] = new error(emailFormatError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
		  }
		}
		// Validate that input is true
		if (elem[currentElementIndex].getAttribute("valtype") != null && elem[currentElementIndex].getAttribute("valtype").toLowerCase() == "true")
		{
			if (elem[currentElementIndex].type != null && elem[currentElementIndex].type == "checkbox")
			{
				if(!elem[currentElementIndex].checked)
				{
					errorArray[errorArray.length] = new error(mustAcceptError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
				}
			}
		}
	} 
	// Check if message is null
	if(document.getElementById("message") != null)
	{
		if(document.getElementById(jFormId).message.value.length > maxLength)
		{
			errorArray[errorArray.length] = new error(lengthError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
		}
	}
	// Do the final count of supplementary fields, and add an error if it is
	// above 1000
	if (supplementaryLength > 1000)
	{
		errorArray[errorArray.length] = new error(lengthError, elem[currentElementIndex].id, elem[currentElementIndex].getAttribute("caption"));
	}
	//
	if (errorArray.length > 0)
	{
		// form was filled incorrectly
		var errorMsg = "";
		for (var i = 0; i < errorArray.length; i++)
		{
			errorMsg += errorArray[i].errorMessage;
		}
		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

function validering()
{
	return validate();
}

function validering(language)
{
	return validate(language);
}

// Tests if the parameter is a number
function isNumeric(sText)
{
  var validChars = "0123456789.";
  var isNumber=true;
  var theChar;
  for (var i = 0; i < sText.length && isNumber == true; i++) 
  { 
   	theChar = sText.charAt(i); 
    if (validChars.indexOf(theChar) == -1) 
    {
    	isNumber = false;
  	}
  }
	return isNumber; 
}

// Tests if the parameter is an integer
function isInteger(sText)
{
  var validChars = "0123456789";
  var isNumber=true;
  var theChar;

  for (var i = 0; i < sText.length && isNumber == true; i++) 
  { 
   	theChar = sText.charAt(i); 
    if (validChars.indexOf(theChar) == -1) 
    {
    	isNumber = false;
  	}
  }
	return isNumber; 
}

// Uses a regular expression to test if the parameter is a valid e-mail address
// (assumes that all TLDs are between 2 and 4 characters long)
function isEmail(sText)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (reg.test(sText) == false)
	{
		return false;
  }
  return true;
}
