var cont;
var i_param;
var current_ph;
var array_ph = new Array();
var from;
var to;
var timerId;
var timerIdv;
var intervalIds;
var intervalIdb;
var idsw;
var cur_spec=1;
var all_spec;
var cur_banner=1;
var all_banners;
var IE='\v'=='v';
var ua = navigator.userAgent.toLowerCase();
var direction=1;
function change_c(o,n,a)
    {
    for(i=1;i<=a;i++)
        {
        id='info_'+i;
        if(i==n)
            {
            document.getElementById(id).style.display='';
            }
        else
            {
            document.getElementById(id).style.display='none';
            }
        }
    if(IE || ua.indexOf("gecko") !=-1)
        {
        marg=37*(n-1);
        }
    else
        {
        marg=35*(n-1);
        }
    o.parentNode.style.marginTop='-'+marg+'px';
    }

function show_note(obj)
    {
    c1=obj.parentNode.childNodes.length;
    for(i=0;i<c1;i++)
        {
        if(obj.parentNode.childNodes[i].id=='info')
            {
            h=parseInt(obj.parentNode.childNodes[i].offsetHeight)
            }
        }
    obj.parentNode.style.height=h+'px';
    obj.parentNode.style.overflow='visible';
    obj.style.display='none';
    c=obj.parentNode.childNodes.length;
    for(i=0;i<c;i++)
        {
        if(obj.parentNode.childNodes[i].id=='min')
            {
            obj.parentNode.childNodes[i].style.display='';
            }
        }
    }
function hide_note(obj)
    {
    obj.parentNode.style.height='23px';
    obj.parentNode.style.overflow='hidden';
    obj.style.display='none';
    c=obj.parentNode.childNodes.length;
    for(i=0;i<c;i++)
        {
        if(obj.parentNode.childNodes[i].id=='max')
            {
            obj.parentNode.childNodes[i].style.display='';
            }
        }
    }

function moveDown()
    {
    cur_h=document.getElementById('model_block').offsetHeight;
    cur_m=parseInt(document.getElementById('model_block').style.marginTop) || 0;
    sum=cur_m+cur_h-50;
    if(sum>=200)
        {
        document.getElementById('model_block').style.marginTop=cur_m-50+'px';
        }
    }
function moveUp()
    {
    cur_m=parseInt(document.getElementById('model_block').style.marginTop) || 0;
    if(cur_m<0)
        {
        document.getElementById('model_block').style.marginTop=cur_m+50+'px';
        }
    }

function showsmenu(id)
    {
    document.getElementById(id).style.display='block';
    }

function hidesmenu(id)
    {
    document.getElementById(id).style.display='none';
    }

function showvsmenu(id,sm,classid)
    {
    try
        {
        document.getElementById(sm).className=classid;
        }
    catch(er){}
    try
        {
        document.getElementById(id).style.display='block';
        }
    catch(e){}
    }

function changeClass(id,classid)
    {
    document.getElementById(id).className=classid;
    }

function change_spec(num)
    {
    all_spec=num;
    intervalIds=setInterval('auto_spec()',5000);
    }

function auto_spec()
    {
    idsw='spec_block';
    if((cur_spec+1)<=all_spec && direction==1)
        {
        cur_spec=cur_spec+1;
        num=(cur_spec-1)*-280;
        cur_marg=parseInt(document.getElementById(idsw).style.marginLeft);
        from=cur_marg;
        to=num;
        if(cur_spec==all_spec)
        	{
        	direction=0;
        	}
        timerId=setInterval('shift_left()',20);
        }
    else if((cur_spec-1)>0)
        {
        cur_spec=cur_spec-1;
        num=(cur_spec-1)*-280;
        cur_marg=parseInt(document.getElementById(idsw).style.marginLeft);
        from=cur_marg;
        to=num;
        if(cur_spec==1)
        	{
        	direction=1;
        	}
        timerId=setInterval('shift_right()',20);
        }
    else
        {
        clearInterval(intervalIds);
        }
    }

function change_banners(num)
    {
    all_banners=num;
    intervalIdb=setInterval('auto_banner()',5000);
    }

function auto_banner()
    {
    if((cur_banner+1)<=all_banners)
        {
        cur_banner=cur_banner+1;
        num=(cur_banner-1)*-280;
        cur_marg=parseInt(document.getElementById('banners_block').style.marginLeft);
        from2=cur_marg;
        to2=num;
        timerIdb=setInterval('shift_leftb()',20);
        }
    else if((cur_banner-1)>0)
        {
        cur_banner=cur_banner-1;
        num=(cur_banner-1)*-280;
        cur_marg=parseInt(document.getElementById('banners_block').style.marginLeft);
        from2=cur_marg;
        to2=num;
        timerIdb=setInterval('shift_rightb()',20);
        }
    else
        {
        clearInterval(intervalIdb);
        }
    }

function shift_leftb()
    {
    from2=from2-20;
    if(from2<to2)
        {
        from2=to2;
        clearInterval(timerIdb);
        }
    document.getElementById('banners_block').style.marginLeft=from+'px';
    }

function shift_rightb()
    {
    from2=from2+20;
    if(from2>to2)
        {
        from2=to2;
        clearInterval(timerIdb);
        }
    document.getElementById('banners_block').style.marginLeft=from+'px';
    }

function switchc(id,num)
    {
    cur_spec=num;
    idsw=id;
    num=(num-1)*-280;
    cur_marg=parseInt(document.getElementById(id).style.marginLeft);
    from=cur_marg;
    to=num;
    clearInterval(intervalIds);
    clearInterval(intervalIdb)
    if(from>to)
        {
        timerId=setInterval('shift_left()',20);
        }
    else
        {
        timerId=setInterval('shift_right()',20);
        }
    return false;
    }

function shift_left()
    {
    from=from-20;
    if(from<to)
        {
        from=to;
        clearInterval(timerId);
        }
    document.getElementById(idsw).style.marginLeft=from+'px';
    }

function shift_right()
    {
    from=from+20;
    if(from>to)
        {
        from=to;
        clearInterval(timerId);
        }
    document.getElementById(idsw).style.marginLeft=from+'px';
    }

function s_open()
    {
    var st=document.getElementById(cont).style;
    st.overflow='hidden';
    st.width=0;
    i_param++
    st.width=i_param+'px';
    if(i_param<200)
        setTimeout('s_open()',5);
    else
        st.overflow='';
    }

function hidevsmenu(id,sm,classid)
    {
        document.getElementById(sm).className=classid;
    try
        {
        document.getElementById(id).style.display='none';
        }
    catch(e){}
    }

function getPosition(o)
    {
    var x=y=0;
    while(o)
        {
        x+=o.offsetLeft;
        y+=o.offsetTop;
        o=o.offsetParent;
        }
    return[x,y];
    }
function setshadow(id)
    {
    obj=document.getElementById(id);
    pos=getPosition(obj);
    document.getElementById('shadowel').style.left=pos[0]+'px';
    document.getElementById('shadowel').style.top=pos[1]+'px';
	}
function changePhoto(ph,ph2,ide)
    {
    document.getElementById('photoM').src=ph;
    document.getElementById('photoMlink').href=ph2;
    current_ph=ide;
    }
function prev_photo()
    {
    if(current_ph<=1)
        {
        current_ph=(array_ph.length-1);
        }
    else
        {
        current_ph=current_ph-1;
        }
    ph=array_ph[current_ph];
    document.getElementById('photoM').src=ph[0];
    document.getElementById('photoMlink').href=ph[1];
    setshadow('el'+current_ph);
    }
function next_photo()
    {
    if(current_ph>=(array_ph.length-1))
        {
        current_ph=1;
        }
    else
        {
        current_ph=parseInt(current_ph)+1;
        }
    ph=array_ph[current_ph];
    document.getElementById('photoM').src=ph[0];
    document.getElementById('photoMlink').href=ph[1];
    setshadow('el'+current_ph);
    }
function change_color(ph)
    {
    document.getElementById('photoM').src=ph;
    }
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';
    re=/^[0-9]{1,}$/;
    if(re.test(vid))
        {
        var post= 'vid='+vid;
        req = createRequestObject();
        serverRequest(req, url, post, processReqChange);
        }
    }

