		$(document).ready(function(){
		
		
			//Tabs  
			//$('#sub-content').AutoTabs(1, {fxFade: true});
			$('#sub-content').tabs({ selected: 0 });
			
			
			$('#profile_tabs').tabs({selected: 2, fx: { opacity: 'toggle' }});
			//$('#profile_tabs').AutoTabs(3, {fxFade: true});

			
			//Bigtarget
			$("ul.news_list li h4 a").bigTarget();
			$("#main_article h2 a").bigTarget();
			
			
			
			//Input value-clear
			$("input[name='articlesearchstring']").toggleVal();
			
			//Cycle
			$('.cycle_right').cycle({ 
			    fx:     'fade', 
			    timeout: 9999, 
			    delay:  -2000 
			});
			$('#front_slider').cycle({ 
			    fx:     'fade', 
			    timeout: 15000, 
			    delay:  -2000 
			});
			
			$('#webtv_slider').cycle({ 
			    fx:     'fade', 
			    timeout: 15000, 
			    delay:  -1000 
			});
			
			//Share slide
			$(".btn-slide").click(function(){
			    $(".share_article").slideToggle("fast");
			    $(this).toggleClass("active"); return false;
			});
			
			
			//Medlems_skjema_toggle_visibility
			 $("#skjema_toggle").toggle(
		      function () {  
				$("div#helsemedlem_skjema").slideDown("fast");
				$("#skjema_toggle").html("Skjul skjema");
				return false;
		      },
		      function () {
				$("div#helsemedlem_skjema").slideUp("fast"); 
		       	$("#skjema_toggle").html("Vis skjema");
		       	return false;
		      });
		      
		      
		    /*$("a#skjema_toggle").click(function() {
    				$('#helsemedlem_skjema').toggle();
    				return false;
			});*/
			
			
			
						
			
			
			/*
			$('#profile_accordion').accordion({ 
			    autoheight:false
			});*/
			
			/*jQuery('#profile_accordion').accordion({
			    autoheight: false
			});*/
			
			/*$("input[@name=Blir_vervet]").click(function() {
			if(this.value == 'Ja'){
				$('#manual').hide("fast");
			}
			else {
				$('#manual').show("fast"); 
			} */
			
			/*
			$("input[@name=blir_vervet]").bind('click', function() {
				$('#manual')[this.value==Ja?'show':'hide']('fast');
			}); 
			*/				
		
		});

if(document.addEventListener) document.addEventListener('DOMContentLoaded', cmxform, false);
function cmxform(){
  // Hide forms
  //$( 'form.cmxform' ).hide().end();
  
  // Processing
  $( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = null;
    this.appendChild( labelSpan );
  } ).end();
  
  // Show forms
  $( 'form.cmxform' ).show().end();
}


/*Login functions*/
	
            function toggleLostPassword() {
                if(document.getElementById('login-form-lostpassword-container').style.display == 'block') {
                    // if lostpassword is not visible, display it
                    document.getElementById('login-form-lostpassword-container').style.display = 'none';
                    document.getElementById('login-form-container').style.display = 'block';
                } else {
                    // lostpassword id visible, hide it
                    document.getElementById('login-form-lostpassword-container').style.display = 'block';
                    document.getElementById('login-form-container').style.display = 'none';
                }
            }
			
			function toggleChangePasswordForm() {
				if(document.getElementById('login-form-changepassword').style.display == 'block') {
					document.getElementById('login-form-changepassword').style.display = 'none';
					document.getElementById('login-form-changepassword-btn').style.display = 'block';
				} else {
					document.getElementById('login-form-changepassword').style.display = 'block';
					document.getElementById('login-form-changepassword-btn').style.display = 'none';
				}
			}
			function toggleChangeProfileForm() {
				if(document.getElementById('login-form-changeprofile').style.display == 'block') {
					document.getElementById('login-form-changeprofile').style.display = 'none';
					document.getElementById('login-form-changeprofile-btn').style.display = 'block';
				} else {
					document.getElementById('login-form-changeprofile').style.display = 'block';
					document.getElementById('login-form-changeprofile-btn').style.display = 'none';
				}
			}
			
			
//Validation
function Form1_Validator(theForm){

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page

// check to see if the field is blank
if (theForm.Fornavn.value == ""){
alert("Vennligst fyll inn fornavn");
theForm.Fornavn.focus();
return (false);
}

if (theForm.Etternavn.value == ""){
alert("Vennligst fyll inn etternavn");
theForm.Etternavn.focus();
return (false);
}



if (theForm.Personnr.value == ""){
alert("Vennligst fyll inn Fødsels-/Personnr");
theForm.Personnr.focus();
return (false);
}

// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.Personnr.value;
var allValid = true;
var allNum = "";
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Du kan bare skrive inn nummer i \"Fødsels-/Personnr\" feltet.");
theForm.Personnr.focus();
return (false);
}

if (theForm.Personnr.value.length != 11){
alert("Du har ikke skrevet inn korrekt personnummer, det består av 11 tegn");
theForm.Personnr.focus();
return (false);
}




if (theForm.Adresse.value == ""){
alert("Vennligst fyll inn adresse");
theForm.Adresse.focus();
return (false);
}


if (theForm.Postnummer.value == ""){
alert("Vennligst fyll inn postnummer");
theForm.Postnummer.focus();
return (false);
}

//Norsk postnummer
/*
if (theForm.Land.value == "Norge"){


	// only allow numbers to be entered
	var checkOK = "0123456789";
	var checkStr = theForm.Postnummer.value;
	var allValid = true;
	var allNum = "";
	
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length){
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
		}
		if (!allValid){
			alert("Du kan bare skrive inn nummer i postnummer feltet.");
			theForm.Postnummer.focus();
			return (false);
		}
	
	if (theForm.Postnummer.value.length != 4){
		alert("Du har ikke skrevet inn korrekt postnummer, det består av 4 tegn");
		theForm.Postnummer.focus();
		return (false);
	}

}
//Svensk postnummer
elseif (theForm.Land.value == "Sverige"){



	// only allow numbers to be entered
	var checkOK = "0123456789 ";
	var checkStr = theForm.Postnummer.value;
	var allValid = true;
	var allNum = "";
	
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length){
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
		}
		if (!allValid){
			alert("Du kan bare skrive inn nummer i postnummer feltet.");
			theForm.Postnummer.focus();
			return (false);
		}
	
	if (theForm.Postnummer.value.length != 6){
		alert("Du har ikke skrevet inn korrekt postnummer i Sverige, det består av 6 tegn (ex: 100 05)");
		theForm.Postnummer.focus();
		return (false);
	}



}*/









if (theForm.Sted.value == ""){
alert("Vennligst fyll inn poststed");
theForm.Sted.focus();
return (false);
}


if (theForm.Epost.value == ""){
alert("Vennligst fyll inn din private e-post adresse");
theForm.Epost.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Epost.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Din private e-post adresse er ikke gyldig. Den må inneholde \"@\" og \".\"");
theForm.Epost.focus();
return (false);
}









if (theForm.Arbeidsgiver.value == ""){
alert("Vennligst fyll inn arbeidsgiver");
theForm.Arbeidsgiver.focus();
return (false);
}


if (theForm.Stilling.value == ""){
alert("Vennligst fyll inn din stilling");
theForm.Stilling.focus();
return (false);
}

if (theForm.Epostjobb.value == ""){
alert("Vennligst fyll inn den e-post adressen du bruker i jobbsammenheng");
theForm.Epostjobb.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Epostjobb.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Din jobb e-post adresse er ikke gyldig. Den må inneholde \"@\" og \".\"");
theForm.Epostjobb.focus();
return (false);
}


}












/*Visma travel*/

function Visma_Travel_Validator(theForm){

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page


// check to see if the field is blank
if (theForm.Navn.value == ""){
alert("Vennligst fyll inn navn");
theForm.Navn.focus();
return (false);
}



if (theForm.Epost.value == ""){
alert("Vennligst fyll inn din e-post adresse");
theForm.Epost.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Epost.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid){
alert("Din e-post adresse er ikke gyldig. Den må inneholde \"@\" og \".\"");
theForm.Epost.focus();
return (false);
}



if (theForm.Kntnr.value == ""){
alert("Vennligst fyll inn kontonummer");
theForm.Navn.focus();
return (false);
}


// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.Kntnr.value;
var allValid = true;
var allNum = "";
for (i = 0;  i < checkStr.length;  i++){
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length){
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid){
alert("Du kan bare skrive inn nummer i kontonummer feltet.");
theForm.Kntnr.focus();
return (false);
}




}




/*Visma travel end*/







/*Bildekonk*/

function bildekonk_Validator(theForm){

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page


// check to see if the field is blank
if (theForm.Navn.value == ""){
alert("Vennligst fyll inn navn");
theForm.Navn.focus();
return (false);
}



if (theForm.Epost.value == ""){
alert("Vennligst fyll inn din e-post adresse");
theForm.Epost.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Epost.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid){
alert("Din e-post adresse er ikke gyldig. Den må inneholde \"@\" og \".\"");
theForm.Epost.focus();
return (false);
}



if (theForm.bilde.value == ""){
alert("Vennligst velg et bilde fra din datamaskin");
theForm.bilde.focus();
return (false);
}





}




/*Bildekonk end*/








//Validation
function Genericform_Validator(theForm){

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page

// check to see if the field is blank
if (theForm.Medlemsnummer.value == ""){
alert("Vennligst fyll inn medlemsnummer");
theForm.Medlemsnummer.focus();
return (false);
}

// check to see if the field is blank
if (theForm.Navn.value == ""){
alert("Vennligst fyll inn navn");
theForm.Navn.focus();
return (false);
}



// check to see if the field is blank
if (theForm.Adresse.value == ""){
alert("Vennligst fyll inn adresse");
theForm.Adresse.focus();
return (false);
}




if (theForm.Postnummer.value == ""){
alert("Vennligst fyll inn postnummer");
theForm.Postnummer.focus();
return (false);
}
// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.Postnummer.value;
var allValid = true;
var allNum = "";
for (i = 0;  i < checkStr.length;  i++){
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length){
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid){
alert("Du kan bare skrive inn nummer i postnummer feltet.");
theForm.Postnummer.focus();
return (false);
}

/*if (theForm.Postnummer.value.length != 5){
alert("Du har ikke skrevet inn korrekt postnummer, det består av 4 eller 5 tegn");
theForm.Postnummer.focus();
return (false);
}*/



if (theForm.Sted.value == ""){
alert("Vennligst fyll inn poststed");
theForm.Sted.focus();
return (false);
}


if (theForm.Epost.value == ""){
alert("Vennligst fyll inn din e-post adresse");
theForm.Epost.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Epost.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid){
alert("Din e-post adresse er ikke gyldig. Den må inneholde \"@\" og \".\"");
theForm.Epost.focus();
return (false);
}


}









//Add more fields dynamically.
function addField(area,field,limit) {
	if(!document.getElementById) return; //Prevent older browsers from getting any further.
	var field_area = document.getElementById(area);
	var all_inputs = field_area.getElementsByTagName("input"); //Get all the input fields in the given area.
	//Find the count of the last element of the list. It will be in the format '<field><number>'. If the 
	//		field given in the argument is 'friend_' the last id will be 'friend_4'.
	var last_item = all_inputs.length - 1;
	var last = all_inputs[last_item].id;
	var count = Number(last.split("_")[1]) + 1;
	
	//If the maximum number of elements have been reached, exit the function.
	//		If the given limit is lower than 0, infinite number of fields can be created.
	if(count > limit && limit > 0) return;
 	
	if(document.createElement) { //W3C Dom method.
		var li = document.createElement("li");
		
		var label = document.createElement("label");
		label.innerHTML = "Dokument "+(count)+"";
		label.id = field+count;
		li.appendChild(label);
		
		
		var input = document.createElement("input");
		input.id = field+count;
		input.name = field+count;
		input.type = "file"; //Type of field - can be any valid input type like text,file,checkbox etc.
		li.appendChild(input);
		field_area.appendChild(li);
	} else { //Older Method
		field_area.innerHTML += "<li><label for='"+(field+count)+"'>"+(field+count)+"</label><input name='"+(field+count)+"' id='"+(field+count)+"' type='file'></li>";
	}
}

count = 1;
function createExtraElement(area,field,limit){
	if(!document.getElementById) return; //Prevent older browsers from getting any further.
		
		var field_area = document.getElementById(area);
		count += 1;
		var template = "<fieldset><legend>Representasjon "+(count)+"</legend><ol><li><label for=\"Rep"+(count)+"_Medlemsnummer\">Medlemsnummer: <em>*</em></label> <input class=\"text\" id=\"Rep"+(count)+"_Medlemsnummer\" name=\"Rep"+(count)+"_Medlemsnummer\" value=\"\" type=\"text\"></li><li><label for=\"Rep"+(count)+"_Navn\">Navn: <em>*</em></label> <input class=\"text\" id=\"Rep"+(count)+"_Navn\" name=\"Rep"+(count)+"_Navn\" value=\"\" type=\"text\"></li><li><label for=\"Rep"+(count)+"_Adresse\">Adresse: <em>*</em></label> <input class=\"text\" id=\"Rep"+(count)+"_Adresse\" name=\"Rep"+(count)+"_Adresse\" value=\"\" type=\"text\"></li><li><label for=\"Rep"+(count)+"_Postnummer\">Postnr./sted: <em>*</em></label> <input class=\"text short\" id=\"Rep"+(count)+"_Postnummer\" name=\"Rep"+(count)+"_Postnummer\" value=\"\" type=\"text\"> <input class=\"text medium\" id=\"Rep"+(count)+"_Sted\" name=\"Rep"+(count)+"_Sted\" value=\"\" type=\"text\"></li><li><label for=\"Rep"+(count)+"_epost\">E-post privat: <em>*</em></label> <input class=\"text\" id=\"Rep"+(count)+"_epost\" name=\"Rep"+(count)+"_epost\" value=\"\" type=\"text\"></li><li><label for=\"Rep"+(count)+"_Tillitsverv\">Tillitsverv i styret: <em>&nbsp;</em></label> <input class=\"text\" id=\"Rep"+(count)+"_Tillitsverv\" name=\"Rep"+(count)+"_Tillitsverv\" value=\"\" type=\"text\"></li><li><fieldset><legend>Ønsker overnatting? <em>*</em></legend><label><input name=\"Rep"+(count)+"_overnatting\" value=\"Ja\" checked=\"checked\" type=\"radio\"> Ja</label><label><input name=\"Rep"+(count)+"_overnatting\" value=\"Nei\" type=\"radio\"> Nei</label></fieldset></li></ol></fieldset>";
		
		
		if(document.createElement) { //W3C Dom method.
			field_area.innerHTML += (template);
		} else { //Older Method
			field_area.innerHTML += (template);
		}
	}




	
	