function updateCapcha() {
	var img = $('imk');
	var src = img.src;
	src = src.replace(/&nc=[0-9]+/g, '');
	img.src = src + '&nc=' + (new Date).getTime();
	
}


function getCity() {
	
	if (!$('regionSelect').value) {
		$('cit').innerHTML = '<option value="">Не выбрано</oprion>';
		$('cit').disabled = true;
	} else {
		$('cit').disabled = true;
		var self = this;
		
		var options = {
			method: 'POST',
			parameters: { idRegion: $('regionSelect').value}, 
			
			onComplete: function(transport) {
					
					$('cit').innerHTML = transport.responseText;
					$('cit').disabled = false;
				}
			};
				
			new Ajax.Request(self_url, options);		 
	}		
	
}

function checkDiv(id, name_class) {
	if ($(id).style.display == 'none') {
		if (name_class) {
			$A($$('div.'+name_class)).each(function(div) { 	
				div.style.display = 'none';	
			});
		}	
		$(id).style.display = 'block';
	} else {
		$(id).style.display = 'none';
	}
}

function checkErrorSearch(id) {
	if (!$(id).value) {
		alert('Не заполнена строка поиска.');
		return false;
	} 
	if ($(id).value.length < 2) {
		alert('Строка поиска меньше 2 символов.');
		return false;
	}
	
	return true;
}


function checkEmail(email) {
	if(!email) return email;
	if(!email.match(/^[\w\.\-]+@[\w\.\-]+\.[a-zA-Z]{2,}$/i, "")) return false;
	return true;
}


function checkFeedbackForm(){
	var required = {
		"name"	:	"Вы не ввели Ваше ФИО",
		"email"	:	"Вы не ввели Ваш E-mail",
		"msg"	:	"Вы не ввели сообщение"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkFeedbackFormEn(){
	var required = {
		"name"	:	"You haven't entered yours name",
		"email"	:	"You haven't entered your E-mail",
		"msg"	:	"You haven't entered the message"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkEditUserEn(){
	var required = {
		"lname"		:	"You haven't entered yours name",
		"lemail"	:	"You haven't entered your E-mail"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkEditUser(){
	var required = {
		"lname"		:	"Вы не ввели Ваше ФИО",
		"lemail"	:	"Вы не ввели Ваш E-mail"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkOt1En(){
	var required = {
		"resume"	:	"You haven't chosen file from the resume"
		
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkOt1(){
	var required = {
		"resume"	:	"Вы не выбрали файл с резюме"
		
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkOt2(){
	var required = {
		"name"	:	"Вы не ввели Ваше ФИО",
		"email"	:	"Вы не ввели Ваш E-mail",
		"phone"	:	"Вы не ввели Ваш телефон"		
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkOt2En(){
	var required = {
		"name"	:	"You haven't entered yours name",
		"email"	:	"You haven't entered your E-mail",
		"phone"	:	"You haven't entered yours phone"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkLegalRegFormEn(){
	var required = {
		"lname"		:	"You haven't entered yours name",
		"lemail"	:	"You haven't entered your E-mail",
		"lpassword"	:	"You haven't entered the password",
		"lpassword_rep"	:	"You haven't entered password acknowledgement"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkLegalRegForm(){
	var required = {
		"lname"		:	"Вы не ввели Ваше ФИО",
		"lemail"	:	"Вы не ввели Ваш E-mail",
		"lpassword"	:	"Вы не ввели пароль",
		"lpassword_rep"	:	"Вы не ввели подтверждение пароля"
	};
	
	for (var i in required) {
		var el = document.getElementById(i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkPasswordFormEn(form){
	var required = {
		"current_password"		:	"You haven't entered the current password",
		"password"				:	"You haven't entered the new password",
		"password_r"			:	"You haven't entered the new password (repeatedly)"
	};
	
	for (var i in required) {
		var el = eval('form.' + i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function checkPasswordForm(form){
	var required = {
		"current_password"		:	"Вы не ввели текущий пароль",
		"password"				:	"Вы не ввели новый пароль",
		"password_r"			:	"Вы не ввели новый пароль (повторно)"
	};
	
	for (var i in required) {
		var el = eval('form.' + i);
		if (!el.value) {
			alert(required[i]);
			el.focus();
			return false;
		}
	}
	return true;
}

function mapRussian() {
    brouser = getBrouser();
	switch (brouser) {
	    case 'OP': dTop = 0; dLeft = 0; break;
		case 'CH': dTop = 0; dLeft = 0; break;
		default : dTop = 0; dLeft = 0; break;
	}
    	
	
	/*table[class="city"]*/
	$A($$('table.city')).each(function(div) { 
			width = div.getWidth()/2;
			//alert(div.style.left.replace("px", ""));
			leftT = div.style.left.replace("px", "");
			topT = div.style.top.replace("px", "");
			if ($('cit'+div.id)) {
				p1 = 5;
				p2 = 50;
				
				lt = parseInt(leftT) - parseInt(p1);
				pt = parseInt(topT) + parseInt(p2);
				
				$('cit'+div.id).style.left = lt + "px";
				$('cit'+div.id).style.top = pt + "px";
			}	
			//alert(top);
			//alert(width);
			height = 27;
			leftT = leftT - width + dLeft;
			topT = topT - height + dTop;
			//alert(top);
			div.style.left = leftT+"px";
			div.style.top = topT+"px";
			
			
	});
}

function addNewDiv(id) {
	var new_div = document.createElement('div');
	new_div.innerHTML = $('pr_'+id).innerHTML;
	$(id).appendChild(new_div);
}

function opWind(url) {
	window.open(url, "wind1", "width=800,height=600,resizable=no,scrollbars=no,menubar=no");
}

function opWind2(url) {
	window.open(url, "wind1", "width=850,height=800,resizable=no,scrollbars=yes,menubar=no");
}

function addOtklik() {
	$('pust').innerHTML = '';
	$('nonePust').style.display = 'block';
}

function getBrouser() {
	if(strpos(navigator.userAgent, 'Firefox')) return 'FF';
	if(strpos(navigator.userAgent, 'MSIE')) return 'IE';
	if(strpos(' '+navigator.userAgent, 'Opera')) return 'OP';
	if(strpos(navigator.userAgent, 'Chrome')) return 'CH';
	
	return 'FF';
	//B=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':'Op';
	//return B;
}

function strpos( haystack, needle, offset){    // Find position of first occurrence of a string
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var i = haystack.indexOf( needle, offset ); // returns -1
    return i >= 0 ? i : false;
}