// JavaScript Document
var fontoptions = new Array();
var coloroptions = new Array();

fontoptions['Times New Roman'] = 'serif';
fontoptions['Courier'] = 'monospace';
fontoptions['Arial'] = 'sans-serif';
fontoptions['Trebuchet MS'] = 'sans-serif';
fontoptions['Tahoma'] = 'sans-serif';

coloroptions['E6E6E6'] = 'Valkoinen';
coloroptions['000000'] = 'Musta';
coloroptions['808080'] = 'Harmaa';
coloroptions['990000'] = 'Tumman punainen';
coloroptions['FF0000'] = 'Punainen';
coloroptions['800080'] = 'Violetti';
coloroptions['006400'] = 'Tumman vihreä';
coloroptions['008000'] = 'Vihreä';
coloroptions['808000'] = 'Oliivi';
coloroptions['FFCC00'] = 'Oranssi';
coloroptions['FFA500'] = 'Tumman oranssi';
coloroptions['000080'] = 'Tumman sininen';
coloroptions['0000FF'] = 'Sininen';
coloroptions['00FFFF'] = 'Cyan';


function build_font_selector() {
	
	for (key in fontoptions) {
		
		document.writeln('<option value="'+key+'" style="font-family: \''+key+'\', '+fontoptions[key]+';">'+key+'</option>');
		
	}
}

function build_color_selector() {
	
	for (key in coloroptions) {
		
		document.writeln('<option value="'+[key]+'" style="background: #'+key+';">'+coloroptions[key]+'</option>');
		
	}
}

function checkBox(boxid) {
	box = document.getElementById(boxid);
	
	if (box.checked == true) {
		return true;
	} else {
		box.checked = true;
		return true;
	}
}


function checkReplyBox(checkTitle, checkContent, checkReply) {
	if (checkTitle == true) {
		
		titleBox = document.getElementById('titleBox').value;
		if (titleBox.length < 1) {
			alert(msgstr2);
			return false;
		}
		
	}
	
	if (checkContent == true) {
		contentBox = document.getElementById('contentBox').value;
		if (contentBox.length < 1) {
			alert(msgstr3);
			return false;
		}
	}
	
	if (checkReply == true) {
		contentBox = document.getElementById('replyBox').value;
		if (contentBox.length < 1) {
			alert(msgstr4);
			return false;
		}
	}
	return true;
}

function checkFaqBox(checkQ, checkAnswer) {
	if (checkQ == true) {
		
		qBox = document.getElementById('qBox').value;
		if (qBox.length < 1) {
			alert(msgstr5);
			return false;
		}
		
	}
	
	if (checkAnswer == true) {
		answerBox = document.getElementById('answerBox').value;
		if (answerBox.length < 1) {
			alert(msgstr6);
			return false;
		}
	}
	
	return true;
}

function select_all(lastbox) {
	
	for (i=0; i<=lastbox; i++) {
		var box = document.getElementById(i);
		if (box.checked == true) {
			box.checked = false;
		} else {
			box.checked = true;
		}
	}
	
}


function toggle_box(boxid, toggleid) {
	
	box = document.getElementById(boxid);
	toggle = document.getElementById(toggleid);
	plus = document.createTextNode('+');
	minus = document.createTextNode('-');
	
	if (box.style.display == 'none') {
		
		for (i=0; i<=maxboxes; i++) {
			var otherbox = document.getElementById('box_'+i);
			var othertoggles = document.getElementById('toggle_'+i);
			//alert (otherbox + ' box_' + i);
			otherbox.style.display = 'none';
			if (toggleid != 'toggle_'+i) {
					
					othertoggles.src = '/images/l_plus.png';
					//othertoggles.innerHTML = '+';
				//othertoggles.replaceChild(plus, othertoggles.childNodes[0]);
			}
		}
		box.style.display = '';
		
		toggle.src = '/images/l_minus.png';
		//toggle.innerHTML = '-';
		//toggle.replaceChild(minus, toggle.childNodes[0]);
		
	} else {
		box.style.display = 'none';
		toggle.src = '/images/l_plus.png';
		//toggle.innerHTML = '+';
		//toggle.replaceChild(plus, toggle.childNodes[0]);
	}
	
}

function checkCookies() {
	
	var errorBox = document.getElementById('error');
	
	expires = new Date();
	document.cookie = "cookie_check=true; expires=" + expires.toGMTString() +  "; path=/";
	
	if (!document.cookie){
		er = document.createElement('div');
		txt = document.createTextNode(cookieMsg);
		er.appendChild(txt);
		er.style.position = 'absolute';
		er.style.top = '0';
		er.style.left = '0';
		er.style.width = '100%';
		er.style.background = '#C10000';
		er.style.color = '#ffffff';
		er.style.padding = '2px 0px 2px 5px';
		er.style.font = '11px "Arial", sans-serif';
		er.style.borderBottom = '1px solid #000';
		//er.style.setProperty('border-bottom', '1px solid #000', null);
		er.style.textAlign = 'left';
		document.body.appendChild(er);
		//errorBox.className = 'body_top';
		//errorBox.style.display = ''
		//errorBox.innerHTML = 'Cookies are not enabled in your browser. To be able to use this site, we ask you to switch them on.';
	}
	
}

window.onload = checkCookies;