// JavaScript Document
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;