front={};
front.lock = function(){
	wnd.onload = false;
	wnd.set_title('');
	wnd.set_content('Запрос выполняется');
	wnd.show();
}
front.unlock = function(){
	wnd.close();
}
function display() {document.getElementById("login").style.display="block";} function hide() {document.getElementById("login").style.display="none";}

front.f_display = function() {
	document.getElementById("form").style.display="block";
	document.getElementById("ask").style.display="none"
	document.getElementById("hide").style.display="block"
	return false;
} 
front.f_hide = function() {
	document.getElementById("form").style.display="none";  
	document.getElementById("ask").style.display="block"
	document.getElementById("hide").style.display="none"
	return false;
}
	


  //  news
front.news = {'server':false,'hash':0,'send_hash':false};
front.news.add_comment = function(){
  c = o.$('comment').value;
  
  if ( c=='' ){
    alert( front.LANG_NEWS_EMPTY_COMMENT);
    return false;
  }
  r = new request( front.news.server+'&act=ajax_add_comment');
	r.onrequest = function(){ 
		front.lock();
	}
	r.onload = function(r)
	{
		//front.reload(false);
		o.$('comment_list').innerHTML = r.comment_list;
		front.unlock();
	}
	r.error = function(e){
	  alert(e);
	  	front.unlock();
	}

	if ( front.news.hash==front.news.send_hash ){
	//  alert('Дубль');
	  return false;
	}

	r.send({'comment':c,'id':front.news.id,'hide_id':o.$('hide_id').checked,'page':front.news.page});	
	front.news.send_hash = front.news.hash;
	o.$('comment').value="";
	o.$('hide_id').checked=false;
}


  //  articles
front.articles = {'server':false,'hash':0,'send_hash':false};
front.articles.add_comment = function(){
  c = o.$('comment').value;
  
  if ( c=='' ){
    alert( front.LANG_ARTICLES_EMPTY_COMMENT);
    return false;
  }
  r = new request( front.articles.server+'&act=ajax_add_comment');
	r.onrequest = function(){ 
		front.lock();
	}
	r.onload = function(r)
	{
		//front.reload(false);
		o.$('comment_list').innerHTML = r.comment_list;
		front.unlock();
	}
	r.error = function(e){
	  alert(e);
	  	front.unlock();
	}

	if ( front.articles.hash==front.articles.send_hash ){
	  //alert('Дубль');
	  return false;
	}
	r.send({'comment':c,'id':front.articles.id,'hide_id':o.$('hide_id').checked,'page':front.articles.page});	
	front.articles.send_hash = front.articles.hash;
	o.$('comment').value="";
	o.$('hide_id').checked=false;
}

  //  mail
front.mail = {'server':false,'hash':0,'send_hash':false};
front.mail.add_comment = function(){
  c = o.$('comment').value;
  
  if ( c=='' ){
    alert( front.LANG_MAIL_EMPTY_COMMENT);
    return false;
  }
  r = new request( front.mail.server+'&act=ajax_add_comment');
	r.onrequest = function(){ 
		front.lock();
	}
	r.onload = function(r)
	{
		//front.reload(false);
		o.$('comment_list').innerHTML = r.comment_list;
		front.unlock();
	}
	r.error = function(e){
	  alert(e);
	  front.unlock();
	}

	if ( front.mail.hash==front.mail.send_hash ){
	  //alert('Дубль');
	  return false;
	}
	r.send({'comment':c,'id':front.mail.id,'hide_id':o.$('hide_id').checked,'page':front.mail.page});	
	front.mail.send_hash = front.mail.hash;
	o.$('comment').value="";
	o.$('hide_id').checked=false;
}

  //  mail
front.faq = {'server':false,'hash':0,'send_hash':false};
front.faq.error = function(e){
  
  o.$('error').innerHTML = e;
}
front.faq.add_msg = function(){

  title = o.$('title').value;
  if ( title=='' ){
    front.faq.error(front.LANG_FAQ_EMPTY_TITLE)
    return false;
  }
  
  msg = o.$('msg').value;
  if ( msg=='' ){
    front.faq.error(front.LANG_FAQ_EMPTY_MSG)
    return false;
  }
  
  r = new request( front.faq.server+'&act=ajax_add_faq');
	r.onrequest = function(){ 
	  
	  		o.$('ask').style.display="none";
	  if ( o.$('hide') ){
		  o.$('hide').style.display="none";
		}
		front.lock();
	}
	r.onload = function(r)
	{
		o.$('faq_form_end').style.display="block";
		if ( o.$('faq_form') ){
		  o.$('faq_form').style.display="none";
		}
		if ( o.$('form') ){
		  o.$('form').style.display="none";
		}
		
		front.unlock();
	}
	r.error = function(e){
	 front.faq.error(e);
	 front.unlock();
	}
  
	r.form( o.$('form_page') );
	//r.send({'msg':msg,'c_id':o.$('c_id').options[o.$('c_id').selectedIndex].value ,'title':title});	
}

front.faq.ini = function(){
  if ( o.$('display_form') ){o.$('display_form').onclick = front.f_display}
  if ( o.$('hide_form') ){ o.$('hide_form').onclick = front.f_hide; }
  if ( o.$('send_faq') ){ o.$('send_faq').onclick = front.faq.add_msg; }
  
}


