function CheckComm()
{    
    if ($('com_content').value=='' || $('com_content').value==0)
        {
            $('com_content').focus();
            return false;
        }
    if ($('img_sec').value=='' || $('img_sec').value==0)
        {
            $('img_sec').focus();
            return false;
        }
    return true;
}
function ChangeWeather(unixtime)
{
    var req = new JsHttpRequest();
    req.caching=true;
        req.onreadystatechange = function() {
        //alert(req.readyState);
            if (req.readyState == 4) {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        DoShowMsg(req.responseJS.msg);
                        onHide();
                        return false;
                    }
                   $('pogoda_day').innerHTML="<b>"+req.responseJS.pogoda_day+"</b>";
                   $('pogoda_night').innerHTML="<b>"+req.responseJS.pogoda_night+"</b>";
                   /*$('pogoda_temp').innerHTML=req.responseJS.pogoda_temp;*/
                   $('week').innerHTML=req.responseJS.week;
                   $('pogoda_date').innerHTML=req.responseJS.pogoda_date;
                   $('pogoda_data').innerHTML=req.responseJS.pogoda_data;
                   return;
                }
        }  
  //$('pogoda_data').innerHTML="<table class='week' cellspacing='1' cellpadding='0' width='100%'><tr><td align='center'><br/><img src='"+tpl_dir+"/images/ajax_loader.gif' width='32' height='32' align='absmiddle'>&nbsp;Идет загрузка...<br/>&nbsp;</td></tr></table>";  
  $('pogoda_data').innerHTML="<tr><td align='center' class='loader_"+loader_weather+"'><br/><img src='"+tpl_dir+"/images/ajax_loader_"+loader_weather+".gif' width='32' height='32' align='absmiddle'>&nbsp;Идет загрузка...<br/>&nbsp;</td></tr>";  
  req.open(null, script_self+'?mode=ajax&do=weather&unixtime='+unixtime, true);
  req.send();  
  //alert(script_self+'?mode=ajax&do=weather&unixtime='+unixtime);
}
function ShowRaiting(){
    if ($('raiting').style.display == "none") {
        $('raiting').style.display = "";
    }
    else {
        $('raiting').style.display="none";
    }
}
function VoteOver(select)
    {
        for(i=1;i<=5;i++)
        {
            if (select>=i)
            {
                $("star_"+i).src=tpl_dir+"/images/sun_a.jpg";
            }else
            {
               $("star_"+i).src=tpl_dir+"/images/sun.jpg";
            }
        }
    }
    function VoteOut()
    {
        var vote_rate=$("vote_rate").value;
        for(i=1;i<=5;i++)
        {
            if (vote_rate<i)
            {
                $("star_"+i).src=tpl_dir+"/images/sun.jpg";
            }else
            {
               $("star_"+i).src=tpl_dir+"/images/sun_a.jpg";
            }
        }
    }
function DoVote(id,num)
{
    if (num<1 && num>5)
    {
        return;
    }
    var req = new JsHttpRequest();
    req.onreadystatechange = function()
        {
            if (req.readyState == 4)
            {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        if (req.responseJS.msg!="" || req.responseJS.msg)
                        {
                            //DoShowMsg(req.responseJS.msg);
                            //onHide();
                            DoMsg(req.responseJS.msg,0,'msgInfo2');
                            onUnLoad();
                            return false;
                        }
                        return false;
                    }
                //onHide();
                //DoShowMsg(req.responseJS.msg,root_dir+'/member/dnevnik/');
                DoMsg(req.responseJS.msg,0,'msgInfo2');
                onUnLoad();
                $('raiting_suns').innerHTML=req.responseJS.raiting_suns;
                return true;
            }
        }

    //onShow();
    onLoad();
    req.open(null, script_self+'?mode=ajax&do=vote', true);
    req.send({'id':id,'num':num});
}
function Post2Mail(){
    if ($('post2mail').style.display == "none") {
        $('post2mail').style.display = "";
        $('post2mail_email').value="";
        $('img_sec').value="";
        $('img_sec_src').src+=Math.random(1000);
        $('post2mail_email').focus();
    }
    else {
        $('post2mail').style.display="none";
    }
}

function DoPost2Mail(){
 if ($('post2mail_email').value == "") {
    DoMsg("Вы не указали E-mail");
    return;
 }
 if ($('post2mail_img_sec').value == "") {
    DoMsg("Вы не ввели код");
    return;
 }
 if ($('post2mail_removeurl').value == "") {
    DoMsg("Не определена страница для отправки");
    return;
 }
 
var req = new JsHttpRequest();
    req.caching=true;
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        DoMsg(req.responseJS.msg);
                        onHide();
                        return;
                    }
                   
                   $('post2mail_email').value="";
                   $('post2mail_img_sec').value="";
                   $('post2mail_img_sec_src').src+=Math.random(1000);                    
                   if (Post2MailForm)
                   {
                    Post2MailForm.slideOut();                   
                   }else
                   {
                        $('post2mail').style.display="none";
                   }
                   $('post2mail').focus();
                   return;
                }
        }
  onShow();  
  req.open(null, script_self+'?mode=ajax&do=post2mail', true);
  req.send({'mail':$('post2mail_email').value,'img_sec':$('post2mail_img_sec').value,'url':$('post2mail_removeurl').value});
}
function DoSubscribe(){
if ($('subscribe_email').value == "") {
    $('subscribe_error').innerHTML='Вы не указали E-mail';
    return;
 }
$('subscribe_error').innerHTML=""; 
var req = new JsHttpRequest();
    req.caching=true;
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        $('subscribe_error').innerHTML=req.responseJS.msg;
                        return;
                    }
                   //$('post2mail').style.display="none";
                   $('subscribe_form').style.display="none";
                   return;
                }
        }
  req.open(null, script_self+'?mode=ajax&do=subscribe', true);
  req.send({'mail':$('subscribe_email').value});
}
function OutFromOrg(){
if (!confirm('Вы действительно хотите выйти из организации?'))
    { 
        return;
    }
var req = new JsHttpRequest();
    req.caching=true;
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        //$('subscribe_error').innerHTML=req.responseJS.msg;
                        onUnLoad();
                        return;
                    }
                   //$('subscribe_form').style.display="none";
                   onUnLoad();
                   top.location.href=root_dir+"/profile/";
                   return;
                }
        }
  onLoad();
  req.open(null, script_self+'?mode=ajax&do=outfromorg', true);
  req.send();
}
function DeletePrice(){
if (!confirm('Вы действительно хотите удалить прайс-лист организации?'))
    { 
        return;
    }
var req = new JsHttpRequest();
    req.caching=true;
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if ($('debug') && req.responseText)
                {
                    $('debug').value=req.responseText;
                }
                if (req.responseJS.error)
                    {
                        onUnLoad();
                        return;
                    }
                   onUnLoad(); 
                   top.location.href=root_dir+"/myorg/price/";
                   return;
                }
        }
  onLoad();
  req.open(null, script_self+'?mode=ajax&do=deleteprice', true);
  req.send();
}
function onLoad()
{
    $('ajax_loading').style.display="";
}
function onUnLoad()
{
    $('ajax_loading').style.display="none";
}

