function checkForm(frm) {
	for (var i=0;i<frm.length;i++) {
		current = frm.elements[i];
		if(current.name.indexOf("_req") > -1) {
			if(current.value.replace(/^\s+|\s+$/, '') == "" && current.type=="text") {
					alert("You need to enter text in all required fields.");
					return false;
			}
			if(current.value.replace(/^\s+|\s+$/, '') == "" && current.type=="password") {
				alert("You need to enter text in all password fields.");
				return false;
			}
			if(current.value == "#" && current.type != "text") {
				alert("You have to make a selection in all drop down menus.");
				return false;
			}
			if(current.value.replace(/^\s+|\s+$/, '') == "" && current.type=="textarea") {
				alert("You need to enter text in all required text areas.");
				return false;
			}
			if(current.name == "human_req") {
				if(current.checked != true) {
					alert("You have not checked the spam verification box. Please do so and try again.");
					return false;
				}
			}
		}
	}
	return true;
}

function selectLink(whichID) { 
	var links = document.getElementsByTagName('a'); 
	for(var i=0;i<links.length;i++) { 
		if(links[i].className != null && links[i].className == 'selectedlink') {
			links[i].className = 'notselectedlink';
		}
	} 
	document.getElementById(whichID).className ='selectedlink'; 
} 

function switchLanguage(target) {  
	if (!document.getElementsByTagName) return;    
	var thisPage = location.href;  
	if(target == "en") {
		if(thisPage.indexOf("index-bg.htm") != -1) {
			location.href = "index-en.htm";
		}
		else if(thisPage.indexOf("index.htm") != -1) {
			location.href = "index-en.htm";
		}
		else if(thisPage.indexOf("index-en.htm") != -1) {
			// do nothing
		}
		else if(thisPage.indexOf("-bg.htm") != -1) {
			location.href = thisPage.substring(0, thisPage.indexOf("-bg.htm")) + ".htm";
		}
		else if(thisPage.indexOf("-bg.php") != -1) {
			location.href = thisPage.substring(0, thisPage.indexOf("-bg.php")) + ".php";
		}
		else if(thisPage.indexOf(".php") != -1) {
			location.href = thisPage.substring(0, thisPage.indexOf(".php")) + ".php";
		}
		else if(thisPage.indexOf(".htm") == -1) {
			location.href = "index-en.htm";
		}
	}
	if(target == "bg") {
		if(thisPage.indexOf("index-bg.htm") != -1) {
			// do nothing
		}
		else if(thisPage.indexOf("index-en.htm") != -1) {
			location.href = "index-bg.htm";
		}
		else if(thisPage.indexOf("-bg.htm") != -1) {
			// do nothing
		}
		else if(thisPage.indexOf("-bg.php") != -1) {
			// do nothing
		}
		else if(thisPage.indexOf(".htm") != -1) {
			location.href = thisPage.substring(0, thisPage.indexOf(".htm")) + "-bg.htm";
		}
		else if(thisPage.indexOf(".php") != -1) {
			location.href = thisPage.substring(0, thisPage.indexOf(".php")) + "-bg.php";
		}
		else if(thisPage.indexOf(".htm") == -1) {
			location.href = "index.htm";
		}
	}
} 

function openViewUserWin(userid) {
	win = window.open("inc.viewUser.php?uid=" + userid, "userwin", "location=0,status=0,menubar=0,toolbar=0,scrollbars=1,resizable=1,width=450,height=450");
	win.focus();
}

function checkreunionform(frm) {
	if(frm.q1_1.checked != true) {
		if(frm.q1_2.checked != true) {
			alert("Трябва да изберете поне една възможност от въпрос 1.");
			return false;
		}
	}
	if(frm.q1_1.checked == true) {
		if(frm.q2_1.checked != true) {
			if(frm.q2_2.checked != true) {
				alert("Трябва да изберете поне една възможност от въпрос 2.");
				return false;
			}
		}
	}
	if(frm.fullname.value.replace(/^\s+|\s+$/, '') == "") {
		alert("Трябва да посочите името си.");
				return false;
	}
	return true;
}