main_ph=0;
function next_ph()
    {
    main_ph=main_ph+1;
    marg=188*main_ph;
    document.getElementById('roll').style.marginLeft='-'+marg+'px';
    nav_check();
    }
function prev_ph()
    {
    main_ph=main_ph-1;
    marg=188*main_ph;
    document.getElementById('roll').style.marginLeft='-'+marg+'px';
    nav_check();
    }
function nav_check()
    {
    try{
    try{
        test=main_ph+5;
        document.getElementById('model_'+test).style;
        document.getElementById('arr').innerHTML='<a href="#" onClick="next_ph(); return false;"><img src="img/rarrow_act.gif" border="0" width="33" height="103" alt="->" title="->"></a>';    
    }
    catch(er){
        document.getElementById('arr').innerHTML='<img src="img/rarrow.gif" border="0" width="33" height="103" alt="->" title="->">';    
    }
    if(main_ph>0)
        {
        document.getElementById('arl').innerHTML='<a href="#" onClick="prev_ph(); return false;"><img src="img/larrow_act.gif" border="0" width="33" height="103" alt="<-" title="<-"></a>';
        }
    else
        {
        document.getElementById('arl').innerHTML='<img src="img/larrow.gif" border="0" width="33" height="103" alt="<-" title="<-">';
        }
    }
    catch(er){
    
    }        
    }
cur_type='all';
function show_type(t)
    {
    document.getElementById('type_'+cur_type).style.display='none';
    document.getElementById('type_'+t).style.display='';
    document.getElementById('nsel_'+cur_type).style.display='';
    document.getElementById('sel_'+cur_type).style.display='none'; 
    document.getElementById('nsel_'+t).style.display='none';
    document.getElementById('sel_'+t).style.display='';
    cur_type=t;
    }
function setTime(hour,minute,second)
    {
    h=hour;   //Москва
    m=minute;
    s=second; 
    showTime();
    }
function showTime() 
    { 
    s=s+1;
    if(s>=60)
        {
        s=0;
        m=m+1;
        }
    if(m>=60)
        {
        h=h+1;
        m=0;
        }
    h2=h+3;  //Барнаул
    if(h2>=24)
        {
        h2=h2-24;
        } 
    if (m<10)
        {
        minut="0"+m;
        }
    else
        {
        minut=m;
        }    
    document.getElementById("time_h").innerHTML=h2;
    document.getElementById("time_m").innerHTML=minut;
    timerId=setTimeout("showTime()",1000); 
    }
function createRequestObject() 
    {
    var request = null;
    try 
        {
        request=new ActiveXObject('Msxml2.XMLHTTP');
        }
    catch (e){}
    if(!request) 
        try 
            {
            request=new ActiveXObject('Microsoft.XMLHTTP');
            }
        catch (e){}
    if(!request)
        try 
            {
            request=new XMLHttpRequest();
            }
        catch (e){}
    return request;
    }
function serverRequest(request ,url, data, callback) 
    {
    if(!request) return false;
    request.onreadystatechange  = callback;
    request.open('POST', url, true);
    try{
        request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        }
    catch(err){}
    request.send(data);
    return true;
    }
function processReqChange()
    {
    if (req.readyState == 4)
        {
        if (req.status == 200)
            {
            if(req.responseText!='nonononono')
                {
                document.getElementById('opText').innerHTML=req.responseText;
                }
            else
                {
                alert('При обработке возникла ошибка. Операция не выполнена!');
                }
            }
        else
            {
            alert("Не удалось получить данные:\n" +req.statusText);
            }
        }
    }
function vote(vid)
    {
    var url = 'inc/voting_control.php';
    var post= 'vid='+vid;
    req = createRequestObject();
    serverRequest(req, url, post, processReqChange);
    }
    
t=0;
sh=0;
timerId='';
function getPosition(o)
    {
    var x=y=0;
    while(o)
        {
        x+=o.offsetLeft;
        y+=o.offsetTop;
        o=o.offsetParent;
        }
    return[x,y];
    }
ids='';
function show_sub_menu(id)
    {
    if(ids!=''&&ids!=id)
        {
        document.getElementById(ids).style.display='none';
        }
    clearTimeout(timerId);
    t=0;
    c=getPosition(document.getElementById(id+'_check'))
    x=c[0]
    y=c[1]
    document.getElementById(id).style.left=x-4;
    document.getElementById(id).style.top=y+14;
    document.getElementById(id).style.display='';
    sh=1;
    }
function hide_sub_menu(id)
    {
    ids=id;
    if(t==0)
        {
        timerId=setTimeout('hide_sub_menu_ex()',500);
        t=1;
        }
    sh=0;    
    }
function hide_sub_menu_ex()
    {
    if(sh==0&&t==1)
        {
        document.getElementById(ids).style.display='none';
        }
    t=0;
    }
