function check_quiz() {
	if (document.quiz_form.q_name.value.length < 1) {
		alert('Fyll i ditt namn!');
		window.scroll(0,0);
		return false;
	}
	document.quiz_form.submit();
}

function bookmarksite(title,url){
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	}
	else if(window.opera && window.print) {
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all) {
		window.external.AddFavorite(url, title);
	}
}

function find_sign(string, sign) {
	var return_result = false;
	for (i = 0; i < string.length; i++) {
		if (string.substr(i, 1) == sign) return_result = true;
	}
	return return_result;
}

function check_mail() {
	mail = document.mail_form.u_mail.value;
	if (mail.length > 6 && find_sign(mail, '.') && find_sign(mail, '@')) {
		document.mail_form.submit();
	}
	else {
		alert('Felaktig email');
	}
}

function nav_div(d_id) {
	if (document.getElementById(d_id).style.display == 'block') {
		document.getElementById(d_id).style.display = 'none';
	}
	else {
		document.getElementById(d_id).style.display = 'block';
	}
}

var alt_num = 3;

function add_alt() {
	if (alt_num < 7) {
		document.getElementById('da_' + alt_num).style.display ='block';	
		alt_num++;
	}
	else {
		alert('Du kan bara ha h\u00F6gst 6 alternativ!');	
	}
}

//Ta bort alternativ till en ny fråga
function ta_bort() {
	if (alt_num > 3) {
		var del_id = alt_num-1;
		document.getElementById('alt' + del_id).value = '';
		document.getElementById('right' + del_id).value = '0';
		document.getElementById('da_' + del_id).style.display = 'none';
		alt_num--;
	}
	else {
		alert('Du m\u00E5ste ha minst 2 alternativ!');
	}
}

//Till tema sidan
function c_q(qid, w, hex) {
	if (w == 'tx') {
		document.getElementById(qid).style.color = '#' + hex;	
	}
	else if (w == 'bo') {
		document.getElementById(qid).style.borderColor = '#' + hex;	
	}
	else {
		document.getElementById(qid).style.backgroundColor = '#' + hex;	
	}
}

//tar bort quiz
function check_del() {
	if (confirm('Helt s\u00E4kert att du vill ta bort denna quiz? Detta g\u00E5r inte att \u00E5ngra!')) {
		document.del_form.submit();	
	}
}