// dropdown select location change

function selsub(Url) {
  Url=document.subsites.sites[document.subsites.sites.selectedIndex].value;
  document.location = Url;
}

var excludeUrls = Array(
		'http://www.atopiskeksem.no/',
		'http://www.benefiber.no/',
		'http://www.femar.no/',
		'http://www.novartis.no/',
		'http://www.glivec.no/',
		'http://www.lamisil.no/',
		'http://www.lucentis.no/',
		'http://www.novartisnutrition.no/',
		'http://www.otrivin.no/',
		'http://www.torreoyne.no/',
		'http://www.xolair.no/',
		'http://www.nicotinell.no/',
		'http://www.locations.novartis.com/',
		'http://www.novartis.com/careers/job-search/brassring/',
		'http://www.novartis.com/about-novartis/company-history/',
		'http://www.zometa.no/'
		
);



/*
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

//referersite checking
function checkRefererSite(){
	var url = document.location.href;		
	var curSite = url.substring(url.lastIndexOf("/")+1);
	
	if (curSite == 'informasjon.shtml'){ 
				
				if (document.referrer != ''){
				
				var liste = document.getElementById('liste');
				var referer = document.referrer;
				var site = referer.substring(referer.lastIndexOf("/")+1);
				
				switch (site)
				{
				case "benefiber.shtml":
				  
				  liste.selectedIndex=1;
				  break;
				  case "eurax.shtml":
				  liste.selectedIndex=2;
				  break;
				  case "otrivin.shtml":
				  liste.selectedIndex=7;
				  break;
				  case "spersallerg.shtml":
				  liste.selectedIndex=8;
				  break;
				  case "spersallerg_sporsmal.shtml":
				  liste.selectedIndex=8;
				  break;
				  case "vectavir.shtml":
				  liste.selectedIndex=9;
				  break;
				  case "voltarol.shtml":
				  liste.selectedIndex=11;
				  break;
				  case "zaditen.shtml":
				  liste.selectedIndex=12;
				  
				  break;
				  case "zaditen_sporsmal.shtml":
				  liste.selectedIndex=12;
				  break;	  		
				case "aclasta.shtml":
				  liste.selectedIndex=14;
				  break;
			  case "certican.shtml":
			  liste.selectedIndex=18;
			  break;
				case "cubicin.shtml":
				  liste.selectedIndex=19;
				  break;
				case "diovan.shtml":
				  liste.selectedIndex=21;
				  break;
				case "diovan_comp.shtml":
				  liste.selectedIndex=22;
				  break;
				case "emselex.shtml":
				  liste.selectedIndex=24;
				  break;
				case "exforge.shtml":
				  liste.selectedIndex=30;
				  break;
				case "exjade.shtml":
				  liste.selectedIndex=31;
				  break;
				case "glivec.shtml":
				  liste.selectedIndex=35;
				  break;
				case "lucentis.shtml":
				  liste.selectedIndex=42;
				  break;
				case "myfortic.shtml":
				  liste.selectedIndex=44;
				  break;
				case "rasilez.shtml":
				  liste.selectedIndex=46;
				  break;
				  case "sandimmun_neoral.shtml ":
				  liste.selectedIndex=50;
				  break;
				case "sebivo.shtml":
				  liste.selectedIndex=53;
				  break;
				case "simulect.shtml":
				  liste.selectedIndex=55;
				  break;
				case "tasigna.shtml":
				  liste.selectedIndex=58;
				  break;
				case "tobi.shtml":
				  liste.selectedIndex=60;
				  break;
			  case "xolair.shtml":
				  liste.selectedIndex=66;
				  break;
				  
				  
				default:
				  liste.selectedIndex=0;
				}
			}
	}
	
}

function checkIcroForm(form){
	if(document.studielege.lastName.value==""){
      alert("Etternavn skal fylles ut");
      document.studielege.lastName.select();
      document.studielege.lastName.focus();
      return false;
    }
	if(document.studielege.firstName.value==""){
      alert("Fornavn skal fylles ut");
      document.studielege.firstName.select();
      document.studielege.firstName.focus();
      return false;
    }
    if(document.studielege.phoneNumber.value==""){
      alert("Telefon skal fylles ut");
      document.studielege.phoneNumber.select();
      document.studielege.phoneNumber.focus();
      return false;
    }
    if(document.studielege.requestorPostalCode.value==""){
      alert("Postnummer skal fylles ut");
      document.studielege.requestorPostalCode.select();
      document.studielege.requestorPostalCode.focus();
      return false;
    }
	   if(document.studielege.requestorCity.value==""){
      alert("Poststed skal fylles ut");
      document.studielege.requestorCity.select();
      document.studielege.requestorCity.focus();
      return false;
    }
  	return true;
}

// OPEN BROWSER WINDOW
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
