function check_post_comment_form() {



if (document.getElementById('firstname').disabled == false && document.getElementById('firstname').value == "") {
alert('Пожалуйста, введите Ваше имя');
document.getElementById('firstname').focus();
return false;
}
if (document.getElementById('firstname').disabled == true && document.getElementById('cm_login')) {

if (document.getElementById('cm_login').value == "") {
alert('Пожалуйста, введите Ваш логин');
document.getElementById('cm_login').focus();
return false;
}

if (document.getElementById('cm_password').value == "") {
alert('Пожалуйста, введите Ваш пароль');
document.getElementById('cm_password').focus();
return false;
}

}


if (document.getElementById('comment_text').value == "") {
alert('Пожалуйста, напишите текст комментария');
document.getElementById('comment_text').focus();
return false;
}

document.getElementById('comment_submit').disabled=true;
document.getElementById('comment_submit').value="Загрузка...";
xajax_post_comment(xajax.getFormValues('post_comment_form'),1);

}

function check_send_feedback_form(type) {

if (type=='ban'){
var contact=document.getElementById('contact_fbi');
var text=document.getElementById('text_fbi');
var sbm=document.getElementById('submit_fbi');
var xjx_arg='send_feedback_form';
var xjx_type=0;
} else {
var contact=document.getElementById('contact_fbi_p');
var text=document.getElementById('text_fbi_p');
var sbm=document.getElementById('submit_fbi_p');
var xjx_arg='send_feedback_form_page';
var xjx_type=1;
}

if (contact.value == "" || contact.value == "контактная информация") {
alert('Пожалуйста, укажите контактную информацию');
contact.focus();
return false;
}

if (text.value == "") {
alert('Пожалуйста, напишите текст сообщения');
text.focus();
return false;
}

sbm.disabled=true;
sbm.value="Загрузка...";

xajax_send_feedback(xajax.getFormValues(xjx_arg),xjx_type,1);

}


function swap_photo(news_id, file, folder_var){
document.getElementById('b_photo').src="/news" + folder_var + "/" + news_id + "/photos/" + file;
return false;
}


function writeCookie(name, value, expires, path, domain, secure) {
document.cookie =
name +"=" + escape(value) +
((expires) ? "; expires="  + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
}

function top_line_hide(id){document.getElementById('tl' + id).style.display="none";
var d1 = new Date();
var d2 = d1.getTime() + (365*24*60*60*1000);
d1.setTime(d2);
writeCookie('hide_tl' + id,'1',d1,'\/');
return false;
}

function swap_fbi(type){
if (type=='ban'){
var contact=document.getElementById('contact_fbi');
}  else {var contact=document.getElementById('contact_fbi_p');
}

if (contact.value == "контактная информация"){contact.value="";contact.style.color="#000";
}

else if (contact.value == ""){
contact.value="контактная информация";
contact.style.color="#ccc";
}

}

function swap_srch(){
var b_input = document.getElementById('top_search_inp');
var b_submit = document.getElementById('top_search_sbm');

if (b_input.value == "поиск по сайту"){b_input.value="";
b_input.style.background="#fff";
b_input.style.color="#000";
b_submit.style.backgroundPosition="bottom";
}

else if (b_input.value == ""){
b_input.value="поиск по сайту";
b_input.style.background="#e3e9f5";
b_input.style.color="#a6a6a6";
b_submit.style.backgroundPosition="top";
}

}

function show_loginform(){

var tr1 = document.getElementById('logintr1');
var tr2 = document.getElementById('logintr2');
var firstname =  document.getElementById('firstname');

if (tr1.style.display == 'none'){tr1.style.display='';
tr2.style.display='';
firstname.disabled='true';
} else {tr1.style.display='none';
tr2.style.display='none';
firstname.disabled='';
}

}

function show_anonymform(param){var input = document.getElementById('firstname');
var name = document.getElementById('comments_auth_user');
var link = document.getElementById('comments_auth_user_link');
var anonym = document.getElementById('comments_auth_user_anonym');

if (input.style.display == 'none' && param==1) {input.style.display='';
name.style.color='#c0c0c0';
name.style.textDecoration='line-through';
link.style.display='none';
input.disabled=false;
anonym.value=1;
} else  {
input.style.display='none';
name.style.color='#000';
name.style.textDecoration='none';
link.style.display='';
input.disabled=true;
anonym.value=0;
}

}
