
//Показать - Скрыть объект. Пример: onclick="changeState('ID','block'); changeState('ID-2','none');"
function changeState (layerRef, state) {
var blockElement = document.getElementById (layerRef);
blockElement.style.display = state;
}

//AJAX POST на регистрацию
function send_register(){
$.post("/register/", { captcha: document.forms.register.captcha.value, user_name: document.forms.register.user_name.value,email: document.forms.register.email.value },
function(data){
document.getElementById('registerDialogcontent').innerHTML = data;
$(".capcha").html('<IMG align=\"right\" title=\"обновить картинку\" SRC=\"/captcha\" name=\"captcha\" onClick=\"getcapchaurl();\" style=\"margin-top: -15px; margin-right: 20px; cursor:pointer\">');    
});
}

//AJAX POST на восстановление пароля
function send_forgot(){
$.post("/forgot/", { captcha: document.forms.forgot.captcha.value, email: document.forms.forgot.email.value },
function(data){
document.getElementById('forgotDialogcontent').innerHTML = data;
$(".capcha").html('<IMG align=\"right\" title=\"обновить картинку\" SRC=\"/captcha\" name=\"captcha\" onClick=\"getcapchaurl();\" style=\"margin-top: -15px; margin-right: 20px; cursor:pointer\">');    
});
}

//CAPCHA modal reloading img
function getcapchaurl()
{
if (typeof(document.captcha.length) !== 'undefined')
{
for (var i = 0; i < document.captcha.length; i++)
{
document.captcha[i].src = '/captcha/?'+Math.random();
}
}
else
{
document.captcha.src = '/captcha/?'+Math.random();
}
}
