//Funksjon for hide/display-toggle
function toggledisplay(first, second, third) {
	if (document.getElementById(first).style.display=='none') {
		document.getElementById(first).style.display='block';
	}
	else if (document.getElementById(first).style.display=='block' || document.getElementById(first).style.display=='inline') {
		document.getElementById(first).style.display='none';
	}
	
	if (second) {
		if (document.getElementById(second).style.display=='block' || document.getElementById(second).style.display=='inline') {
			document.getElementById(second).style.display='none'; 
		}
		else if  (document.getElementById(second).style.display=='none') {
			  document.getElementById(second).style.display='block';
		}
	}
	if (third) {
		if (document.getElementById(third).style.display=='block' || document.getElementById(third).style.display=='inline') {
			document.getElementById(third).style.display='none'; 
		}
		else if  (document.getElementById(third).style.display=='none') {
			  document.getElementById(third).style.display='block';
		}
	}
} 


//Funksjon for innsetting av smilies
function addSmiley(smiley) {
	textbox = document.getElementById("text");
	textbox.value += smiley;	
}

//Funkajon for henting av AJAX-artikler
function page(hash, art) {
	window.location.hash = hash;
	var hash = document.location.href.split("#")[1];
	//var hash = window.location.hash;
	if (hash != null) {
		ajaxPage(hash,art);
	}

}

// Funksjon for å bytte link i dynamisk meny
function menu_fx(obj_link) {
	var t = obj_link.parentNode.parentNode;
	var l = t.getElementsByTagName('a');
	for(var i = 0; i < l.length; i++) {
		l.item(i).className = null;
	}
	obj_link.className = 'current';
}

//Funksjon for å disable/enable objekter
function disenable(dis,ena) {
	document.getElementById(dis).style.backgroundColor = "silver";
	document.getElementById(dis).disabled = true;
	document.getElementById(ena).style.backgroundColor = "white";
	document.getElementById(ena).disabled = false;
}


//Funksjon for å vise passordstyrke

function passwordStrength(password){

        var desc = new Array();
        	desc[0] = "Fort kort";
        	desc[1] = "Fort kort";
        	desc[2] = "Fremdeles for kort :)";
        	desc[3] = "Kommer seg";
        	desc[4] = "Bra nok";
        	desc[5] = "Kjempemessig";
        	desc[6] = "Blue Skies!";
	
 		var score = 0;
		
        //Points for password lenght       
		if (password.length > 0) {
			document.getElementById('passwordDesc').style.color='red';
		}
        if (password.length > 1) {
			document.getElementById('passwordDesc').style.color='red';
			score++;
		}
        if (password.length > 2) {
			document.getElementById('passwordDesc').style.color='red';
			score++;
		}
        if (password.length > 3) {
			document.getElementById('passwordDesc').style.color='#CC9900';
			score++;
		}
        if (password.length > 4) {
			document.getElementById('passwordDesc').style.color='#00CC00';
			score++;
		}
        if (password.length > 5) {
			document.getElementById('passwordDesc').style.color='#00CC00';
			score++;
		}
        if (password.length > 6) {
			document.getElementById('passwordDesc').style.color='blue';
			score++;
		}
		
        //if password has both lower and uppercase characters give 1 point      
        // if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
		
        //if password has at least one number give 1 point
        //if (password.match(/\d+/)) score++;

        //if password has at least one special caracther give 1 point
        //if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;

        //if password bigger than 12 give another 1 point
        //if (password.length > 12) score++;
        document.getElementById("passwordDesc").innerHTML = desc[score];
}

