﻿var myCommentUniqueID = "";
function Comment(myUniqueID, a) { 
myCommentUniqueID = myUniqueID; 
returnUrl = window.location; 
Enable(document.getElementById('divComment_' + myCommentUniqueID)); 
changeObjectVisibility('commentPosted_' + myUniqueID, 'hidden'); 
changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'hidden'); 
changeObjectVisibility('commentRegister_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('commentRegMSG_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('divVerify_' + myCommentUniqueID, 'hidden');
if (a != 0) { changeObjectVisibility('divComment_' + myUniqueID, 'visible'); } 
else { changeObjectVisibility('divComment_' + myUniqueID, 'hidden'); } 
}
var gRel = "";
function PostComment(rel) { 
gRel = rel;
Disable(document.getElementById('divComment_' + myCommentUniqueID));
if (ivA != "False") { 
var loader=new net.ContentLoader(uncache(baseDomain + '/postcomment/?rel=' + rel + '&txt=' + encodeURIComponent(document.getElementById('comment_' + myCommentUniqueID).value)), onComment);
} else {
//login form
 changeObjectVisibility('divComment_' + myCommentUniqueID, 'hidden');
 changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'visible');
 }
}
function onComment() {
Enable(document.getElementById('divComment_' + myCommentUniqueID)); document.getElementById('comment_' + myCommentUniqueID).value = ""; changeObjectVisibility('divComment_' + myCommentUniqueID, 'hidden'); changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'hidden'); changeObjectVisibility('commentPosted_' + myCommentUniqueID, 'visible'); document.getElementById('charsleft').innerHTML = "2000";
var t=setTimeout("refresh()", 3000);
}
function refresh() { window.location = window.location; }
function CommentLogin() {
var txtUser = document.getElementById("txtEmail_" + myCommentUniqueID).value; var txtPassword = document.getElementById("txtPass_" + myCommentUniqueID).value;if ((txtUser.length >= 2) && (txtPassword.length >= 2)) {
//show authentication process message
changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('commentAuthProcess_' + myCommentUniqueID, 'visible');
var loader=new net.ContentLoader(uncache(baseDomain + '/authenticate/?u=' + encodeURIComponent(txtUser) + '&p=' + encodeURIComponent(txtPassword)), doAuthComment);}
 }
function doAuthComment(){
var r = this.req.responseText;
if (r != 'no_auth') { 
//authenticated
changeObjectVisibility('commentAuthProcess_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'hidden');
ivA = true;
PostComment(gRel);
} else {
changeObjectVisibility('commentAuthProcess_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'visible');
alert('Введены неверные имя пользователя или пароль.');
 }
 }
 
function CommentRegister() { 
changeObjectVisibility('commentLogin_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('commentRegister_' + myCommentUniqueID, 'visible');
document.getElementById('txtEmailReg_' + myCommentUniqueID).focus();
}

function CommentRegisterProceed() { 
msg = document.getElementById('commentRegMSG_' + myCommentUniqueID);
changeObjectVisibility('commentRegMSG_' + myCommentUniqueID, 'visible');
msg.innerHTML = '<span style="color:green">Сохраняем данные регистрации, пожалуйста подождите...</span>';
var url = baseDomain + '/register/?e=' + encodeURIComponent(document.getElementById('txtEmailReg_' + myCommentUniqueID).value) + '&p=' + encodeURIComponent(document.getElementById('txtPassReg_' + myCommentUniqueID).value) + '&g=' + encodeURIComponent(document.getElementById('ddlGenderReg_' + myCommentUniqueID).value) + '&a=' + encodeURIComponent(document.getElementById('txtAgeReg_' + myCommentUniqueID).value) + '&fn=' + encodeURIComponent(document.getElementById('txtFirstName_' + myCommentUniqueID).value) + '&ln=' + encodeURIComponent(document.getElementById('txtLastName_' + myCommentUniqueID).value);
var loader=new net.ContentLoader(uncache(url), onRegistration);
}

function onRegistration() {
var r = this.req.responseText;
msg = document.getElementById('commentRegMSG_' + myCommentUniqueID);
msg.innerHTML = r;
if (r == 'OK.1') { 
//Registration success
changeObjectVisibility('commentRegister_' + myCommentUniqueID, 'hidden');
changeObjectVisibility('divVerify_' + myCommentUniqueID, 'visible');
}
 }
 
function Activate() { 
msg = document.getElementById('divActivateMSG_' + myCommentUniqueID);
changeObjectVisibility('divActivateMSG_' + myCommentUniqueID, 'visible');
msg.innerHTML = '<span style="color:green">Активизируем Ваш доступ...</span>';

var url = baseDomain + '/register/?acc=' + encodeURIComponent(document.getElementById('txtConfirmationCode_' + myCommentUniqueID).value);
var loader=new net.ContentLoader(uncache(url), onActivation);
}

function onActivation() { 
var r = this.req.responseText;
msg = document.getElementById('divActivateMSG_' + myCommentUniqueID);
msg.innerHTML = r;
if (r == 'OK.2') { 
//Activation success
ivA = "True";
changeObjectVisibility('divVerify_' + myCommentUniqueID, 'hidden');
PostComment(gRel);
}
}
