var s;

function ShowMap() {
		
	lpos = screen.availWidth / 2  - 410;
	tpos = screen.availHeight / 2 - 250;

		
	w = window.open( "/wp-content/themes/positive/map.html", "Map", "width=820,height=500,resizable=no,status=no,toolbar=no,menubar=no,left=" + lpos + ",top=" + tpos );
	window.w.focus();
	//if( window.event != null )
	try {
		window.event.returnValue = false;
	

	return false;
	}
	catch(err) {} 
}

function ShowProject(p_id) {
	pr_li = document.getElementById('pr_' + p_id);
	pr_link = document.getElementById('prl_' + p_id);
	pr_cont = document.getElementById('cont_' + p_id);
	button = document.getElementById('but_' + p_id);
	
	if (pr_cont.style.display == 'none') {
		
		pr_cont.style.display = 'block';
		button.className = 'btn_hide';
		
	}
	
	else {
		
		pr_cont.style.display = 'none';
		button.className = 'btn_show';
		
	}
}

function ShowRules() {
	submenu = document.getElementById('rules-submenu')
	
	if (submenu.style.display == 'none') {
		
		submenu.style.display = 'inline'	
	}
	
	else {
		submenu.style.display = 'none'
	}
}

function CheckFields(success) {

	var name = document.getElementById("posName").value;
	var contact = document.getElementById("posEmail").value;
	var mess = document.getElementById("posText").value;
	var error_txt = document.getElementById("error_txt");
	var sum = document.getElementById("summ");
	var hint;


if (name == "" || contact == "" || sum.value != s) {

	if (name == "") {
		hint = "Вы не ввели свое имя."
		error_txt.style.display = "block"
		error_txt.innerHTML = hint
		return false;
	}
	
	if (contact == "") {
		hint = "Вы не указали свой email."
		error_txt.style.display = "block"
		error_txt.innerHTML = hint
		return false;
	}
	
	if (sum.value != s) {
		hint = "Вы неправильно сложили числа."
		error_txt.style.display = "block"
		error_txt.innerHTML = hint
		return false;
	}
	
	//if (mess == "") { hint = "Вы не написали сообщение." }
	
}
else {
	
	ClearError()
	
	alert(success)
	
	document.getElementById("cForm").submit()

	return false;
	
}

}

function PrintNums() {
	x1 = Math.round(Math.random()*10); 
	x2 = Math.round(Math.random()*10); 
	s = x1 + x2; 
	document.write(x1+'+'+x2)
}
