// 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 = getSelectedCheckboxValue(document.forms['quizForm'].elements['question6']);
		 var answer7 = getSelectedRadioValue(document.forms['quizForm'].elements['question7']);	
		 var answer8 = getSelectedCheckboxValue(document.forms['quizForm'].elements['question8']);
		 	
		 	
		 	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 (answer7 == "false"){
       document.getElementById("error7").style.display="block";
       error = 1;
		 	}else {
		 		document.getElementById("error7").style.display="none";
		 	}
		 	
		 	if(error==1){
		 		return false;	
		 	}
		 	
		 	finalCount = Number(answer1)+Number(answer2)+Number(answer3)+Number(answer4)+Number(answer5)+Number(answer7)
		 	
		 	
  	for(var i = 0; i < answer6.length; i++){
  		finalCount = finalCount + Number(answer6[i])
  	 }
		 
		for(var i = 0; i < answer8.length; i++){
  		finalCount = finalCount + Number(answer8[i])
  	 }
		 

  document.forms['quizForm2'].elements['result'].value = finalCount
	document.forms['quizForm2'].submit();

	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 result= getParameter("result");

document.getElementById("result").innerHTML = "Du fick "+result+" po&auml;ng av 29 m&ouml;jliga";



} 

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);
         }
      }
   }
}
/*
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(formId).replyTo.value != null){
	
	email = document.getElementById(formId).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(formId).message.value != 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

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"; }
}
