/****************************************/
function verifFormRecherche()
{
	if (document.formRecherche.recherche.value=="")
	{
		alert("Specificera.");
		document.formRecherche.recherche.focus();
		return false;
	}
}
/****************************************/


/****************************************/
function verifFormRecherche2()
{
	if (document.formRecherche2.recherche.value=="")
	{
		alert("Specificera.");
		document.formRecherche2.recherche.focus();
		return false;
	}
}
/****************************************/



/****************************************/
function verifFormulaire()
{
Valider=true;
Valider=verifMail(newsletter.email,"Fel e-mailadress",Valider);	
return Valider;	
}
/****************************************/


/****************************************/
function verifMail(champ,message,Valider)
{
PasEncoreErreur=Valider;

	if (PasEncoreErreur) 
		{
		mail = champ.value;
		listemail=new Array;
		
		if(mail=="" || mail=="null" || mail.indexOf('@')==-1 || mail.indexOf(' ')>=0 )
			{
			alert(message);
			champ.select ();
			champ.focus ();
			PasEncoreErreur = false;
			}
		else
			{
			listemail=mail.split('@');

			if( (listemail[1].indexOf('.') <2) || (listemail[1].length<=listemail[1].indexOf('.')+2 ) || (listemail[0].length<1))
				{
				alert(message);
				champ.select ();
				champ.focus ();
				PasEncoreErreur = false;
				}
			} 		
		}
		if ( (!(/^[0-9A-Za-z.@\-_]+$/.test(champ.value))) && (PasEncoreErreur) )
			{alert('Fel adress');
			PasEncoreErreur = false;}
return PasEncoreErreur;
}
/****************************************/


/****************************************/
function verifChampText(champ, message)
{
	retour=true;
	if (champ.value=="")
	{
		alert(message);
		champ.focus();
		retour=false;
	}
	return retour;
}
/****************************************/


/****************************************/
function verifFormInscription()
{
Valider=true;
Valider=verifMail(formInscription.email,"Fel e-mailadress",Valider);	
if (Valider==true)
	Valider=verifChampText(document.formInscription.password, "Fel lösenord.");
if (Valider==true)
	Valider=verifChampText(document.formInscription.password2, "Du skrev fel lösenord.");
if ((Valider==true) && (document.formInscription.password.value != document.formInscription.password2.value))
	{
	alert("Konfirmationen stämmer inte överens med lösenordet.");
	Valider=false;
	}
if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<document.formInscription.titre.length ;i++ )
	{
		if ((document.formInscription.titre[i].checked==true)&&(titreCoche==false))
			titreCoche=true;
	}

	if (titreCoche==false)
		{	
			alert("Votre titre n\'est pas indiqué.");
			Valider=false;
		}
	}
if (Valider==true)
	Valider=verifChampText(document.formInscription.nom, "Fel förnamn.");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.prenom, "Fel efternamn.");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.societe, "Fel företag.");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.adresse, "Fel adress.");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.codepostal, "Del postnummer.");	
if (Valider==true)
	Valider=verifChampText(document.formInscription.ville, "Fel stad.");	
//pays
if (Valider==true)
	Valider=verifChampText(document.formInscription.telephone, "Fel telefonnummer.");	
if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<document.formInscription.profession.length ;i++ )
	{
		if ((document.formInscription.profession[i].checked==true)&&(titreCoche==false))
		{
			titreCoche=true;
			valCaseCochee=document.formInscription.profession[i].value;
		}
	}

	if ( (titreCoche==false) || (valCaseCochee==0 && document.formInscription.profautre=="") )
		{	
			alert("Fel yrke.");
			Valider=false;
		}
	}

return Valider;	
}

/****************************************/

/****************************************/
function verifFormMembre(nomForm)
{
	//alert(nomForm.name);

Valider=true;
Valider=verifMail(nomForm.email,"Fel e-mailadress.",Valider);	

if (nomForm.name=="formInscription")
{
	if (Valider==true )
		Valider=verifChampText(nomForm.password, "Fel lösenord.");
	if (Valider==true)
		Valider=verifChampText(nomForm.password2, "Fel konfirmation av lösenordet.");
}

if (nomForm.name!="formQuestions")
{
	if ((Valider==true) && (nomForm.password.value != nomForm.password2.value))
		{
		alert("Konfirmationen stämmer inte överens med lösenordet.");
		Valider=false;
		}
}

if ((Valider==true))
	{ 
	titreCoche=false;
	for (i=0;i<nomForm.titre.length ;i++ )
	{
		if ((nomForm.titre[i].checked==true)&&(titreCoche==false))
			titreCoche=true;
	}

	if (titreCoche==false)
		{	
			alert("Merci de préciser votre civilité.");
			Valider=false;
		}
	}
	
if (Valider==true)
	Valider=verifChampText(nomForm.nom, "Fel förnamn.");	
if (Valider==true)
	Valider=verifChampText(nomForm.prenom, "Fel efternamn.");	
if (Valider==true)
	Valider=verifChampText(nomForm.societe, "Fel företg.");	
if (Valider==true)
	Valider=verifChampText(nomForm.adresse, "Fel adress.");	
if (Valider==true)
	Valider=verifChampText(nomForm.codepostal, "Fel postnummer.");	
if (Valider==true)
	Valider=verifChampText(nomForm.ville, "Fel stad.");	
//pays
if (Valider==true)
	Valider=verifChampText(nomForm.telephone, "Fel telefonnummer.");	

if ((Valider==true))
{ 
	if (nomForm.profession[nomForm.profession.selectedIndex].value=="")
		{	
			alert("Du har inte valt något yrke.");
			Valider=false;
		}
}

if (nomForm.name=="formQuestions")
{
	demandeCoche=false;
	for (i=0;i<nomForm.demande.length ;i++ )
	{
		if ((nomForm.demande[i].checked==true)&&(demandeCoche==false))
		{
			demandeCoche=true;
			valCaseCochee=nomForm.demande[i].value;
		}
	}

	if (demandeCoche==false)
		{	
			alert("Du har inte valt fråga.");
			Valider=false;
		}
	else
		{
		switch(valCaseCochee)
			{
			case "doc":
				//if (nomForm.doc.selectedIndex==-1)
				//documents.forms[0].elements['var[]']; 
				if (nomForm.elements['doc[]'].selectedIndex==-1)

				{ Valider=false; alert("Ingen broschyr är vald.");}
				break;
			case "dis":
				if (nomForm.dis[nomForm.dis.selectedIndex].value=="")
				{ Valider=false; alert("Inget område är valt.");}
				break;
			case "pri":
				if (nomForm.pri1[nomForm.pri1.selectedIndex].value=="")
				{ Valider=false; alert("Ingen produkt är vald.");}
				if (nomForm.pri1s.value=="")
				{ Valider=false; alert("Ingen yta har angetts.");}
				break;
			}
		}
	
}
return Valider;	
}

/****************************************/
function afficheSouhaitContact(val)
{
	document.getElementById("chambre").style.display='none';
	document.getElementById("restaurant").style.display='none';
	document.getElementById("cours").style.display='none';
	if (val=="restaurant"||val=="chambre"||val=="cours")
	{
		document.getElementById(val).style.display='';
	}
}

/**** QUESTIONS ****/
tabnomsId=new Array("Broschyrer", "Teknisk fr&aring;ga", "Priser", "Kontakt", "&Aring;terf&uml;rs&auml;ljare","&Ouml;vriga fr&aring;gor");
function afficheId(nomId)
{	
	//alert(tabnomsId.length);
	for (i=0; i<tabnomsId.length; i++ )
	{ 
		if (document.getElementById("details"+tabnomsId[i]))
			document.getElementById("details"+tabnomsId[i]).style.display='none';	
		//alert(tabnomsId[i]);
	}
	if (document.getElementById(nomId))
		document.getElementById(nomId).style.display='';
}

function detailsKontakt()
{
	if (formQuestions.detailsKontakt_select.options[formQuestions.detailsKontakt_select.selectedIndex].value=="")
	{
		document.getElementById("detailsKontakt_autre").style.display='';
	}
	else
		document.getElementById("detailsKontakt_autre").style.display='none';

}


/****************************************/
function verifSondageQuestion(nomForm, numQuestion, numElement, Valider)
{
	if (eval('nomForm.q'+numQuestion+'['+numElement+'].checked==true') && eval('nomForm.q'+numQuestion+'commentaire.value==""') && Valider==true)
	{
		alert("Merci de préciser votre réponse ā la question n°"+numQuestion);
		eval('nomForm.q'+numQuestion+'commentaire.select()');
		eval('nomForm.q'+numQuestion+'commentaire.focus()');
		Valider=false;
	}
	return Valider;
}

/****************************************/

function verifSondage(nomForm)
{

Valider=true;

// Questions
for (y=1;y<12;y++)
{

	if (Valider==true && y!=5 && y!=3 && y<9)
	{ 

		questionOK=false;
		longueurRep=eval('nomForm.q'+y+'.length');

		for (i=0;i<longueurRep;i++)
		{
			if (eval('nomForm.q'+y+'['+i+'].checked')==true && questionOK==false)
				questionOK=true;
		}


		// Question non cochée
		if (questionOK==false)
		{	
			alert("Merci de répondre ā la question n°"+y);
			Valider=false;
		}
		// Question cochée, tout ok ?
		else
		{
			switch(y)
			{
				case 1:
				Valider=verifSondageQuestion(nomForm, 1, 4, Valider);
					break;
				case 3:
				Valider=verifSondageQuestion(nomForm, 3, 6, Valider);
					break;
				case 4:
				Valider=verifSondageQuestion(nomForm, 4, 1, Valider);
					break;
				case 6:
				Valider=verifSondageQuestion(nomForm, 6, 3, Valider);
					break;
				case 7:
				Valider=verifSondageQuestion(nomForm, 7, 3, Valider);
					break;
				case 8:
				Valider=verifSondageQuestion(nomForm, 8, 3, Valider);
					break;				
			}
		}
	}
	
}

if (nomForm.q5.value=='' && Valider==true)
{
	alert("Vänligen specifiera fråga nr.5");
	nomForm.q5.select ();
	nomForm.q5.focus ();
	Valider=false;
}

if (nomForm.q9.selectedIndex==0 && Valider==true)
{
	alert("Vänligen specifiera fråga nr.9");
	Valider=false;
}

if (nomForm.q10.value=='' && Valider==true)
{
	alert("Vänligen specifiera fråga nr.10");
	nomForm.q10.select ();
	nomForm.q10.focus ();
	Valider=false;
}

Valider=verifMail(nomForm.email,"Fel e-mailadress",Valider);	

return Valider;	
}

/****************REQUIRED************************/


function checkrequired(which) {
  var pass=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,8)=="required") {
       if (((tempobj.type=="text"||tempobj.type=="textarea")&&
          tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          tempobj.selectedIndex==0)) {
        pass=false;
        break;
      }
    }
  }
  if (!pass) {
    shortFieldName=tempobj.name.substring(8,30).toUpperCase();
    alert("Du måste fylla i följande fält: "+shortFieldName);
    return false;
  } else {
  return true;
  }
  
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function checklength(bildinfo)
{
	if(bildinfo.length > 10)
		{alert("Du skrev för många tecken.");return false;}
		
		else{alert("Nu skrev du nåt.");return true;}
	}

function validate_form ( )
{
	valid = true;

        if ( document.form1.requirednamn.value == "" )
        {
                alert ( "Du måste fylla i namn." );
                valid = false;
        }
		
		
		 if ( document.form1.requiredefternamn.value == "" )
        {
                alert ( "Du måste fylla i efternamn." );
                valid = false;
        }
		
		 if ( document.form1.requiredadress.value == "" )
        {
                alert ( "Du måste fylla i adress." );
                valid = false;
        }
		
		if ( document.form1.requiredpostnummer.value == "" )
        {
                alert ( "Du måste fylla i postnummer." );
                valid = false;
        }
		
		if ( document.form1.requiredstad.value == "" )
        {
                alert ( "Du måste fylla i stad." );
                valid = false;
        }
		
		    	
		if ( document.form1.requiredtelefon.value == "" )
        {
                alert ( "Du måste fylla i telefonnummer." );
                valid = false;
        }
		
		if ( document.form1.requiredemail.value == "" )
        {
                alert ( "Du måste fylla i e-mailadress." );
                valid = false;
        }
		
		if ( document.form1.file.value == "" )
        {
                alert ( "Du måste ladda upp en bild." );
                valid = false;
        }
		
			   
        if ( document.form1.villkor.checked == false )
        {
                alert ( "Du måste godkänna tävlingsvillkoren." );
                valid = false;
        }
		
		
        return valid;
}
	
/****************TÄVLINGSVILLKOR************************/

		function toggleCrosssection(whichLayer){
			if (document.getElementById){
				var style2 = document.getElementById(whichLayer).style;
				style2.display = style2.display? "":"block";
			}else if (document.all){
				var style2 = document.all[whichLayer].style;
				style2.display = style2.display? "":"block";
		
		}else if (document.layers){
				var style2 = document.layers[whichLayer].style;
				style2.display = style2.display? "":"block";		
			}
		}
		
		
		function switchColor(element,thisId){
			var menu = document.getElementsByTagName('a');
			for (var i=0; i < menu.length; i++){
				if (menu[i].parentNode.className == "tavling"){
					menu[i].style.color='#000';
				}
			}
			
			for(i=1;i<=1;i++){
				document.getElementById("tavling"+i).style.display = 'none';
			}
			document.getElementById("tavling"+thisId).style.display = 'block';
			element.style.color='#000';
		}	
	
function toggleLayer(whichLayer){
	if (document.getElementById){
		for (i = 1; i < 2; i++){document.getElementById('subtoplevel'+i).style.display="none";}	
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}else if (document.all){
		for (i = 1; i < 2; i++){document.all['subtoplevel'+i].style.display="none";}
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}else if (document.layers){
		for (i = 1; i < 2; i++){document.layers['subtoplevel'+i].style.display="none";}
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}


