// #Preload Images for RollUP
var menu_aboutcompany_passive = new Image; menu_aboutcompany_passive.src = "/_Images/menu_aboutcompany.gif";
var menu_aboutcompany_active = new Image; menu_aboutcompany_active.src = "/_Images/menu_aboutcompany_active.gif";

var menu_services_passive = new Image; menu_services_passive.src = "/_Images/menu_services.gif";
var menu_services_active = new Image; menu_services_active.src = "/_Images/menu_services_active.gif";

var menu_clients_passive = new Image; menu_clients_passive.src = "/_Images/menu_clients.gif";
var menu_clients_active = new Image; menu_clients_active.src = "/_Images/menu_clients_active.gif";

var menu_contacts_passive = new Image; menu_contacts_passive.src = "/_Images/menu_contacts.gif";
var menu_contacts_active = new Image; menu_contacts_active.src = "/_Images/menu_contacts_active.gif";

var menu_equipment_passive = new Image; menu_equipment_passive.src = "/_Images/menu_equipment.gif";
var menu_equipment_active = new Image; menu_equipment_active.src = "/_Images/menu_equipment_active.gif";

var menu_news_passive = new Image; menu_news_passive.src = "/_Images/menu_news.gif";
var menu_news_active = new Image; menu_news_active.src = "/_Images/menu_news_active.gif";

var menu_partners_passive = new Image; menu_partners_passive.src = "/_Images/menu_partners.gif";
var menu_partners_active = new Image; menu_partners_active.src = "/_Images/menu_partners_active.gif";

var sidebillet_arrow_W = new Image; sidebillet_arrow_W.src = "/_Images/sidebillet_configurator_open.gif";
var sidebillet_arrow_E = new Image; sidebillet_arrow_E.src = "/_Images/sidebillet_configurator_close.gif";

function whyBro(varID)
{
    if (document.all){return document.all[varID];}
    else if (document.getElementById){return document.getElementById(varID);}
}

// #Function
function changepic(nameRec,srcRec)
{
    document.images[nameRec].src = eval(srcRec + ".src");
}

function switchSelect()
{

    if (document.forms["changeEquipment"].elements["material"].value == 1)
    {
        document.forms["changeEquipment"].elements["PvcAmount"].disabled = true;
        document.forms["changeEquipment"].elements["PvcAmount"].style.backgroundColor = "#D1D7E2";
        document.forms["changeEquipment"].elements["AlProgram"].disabled = false;
        document.forms["changeEquipment"].elements["AlProgram"].style.backgroundColor = "";
    }

    if(document.forms["changeEquipment"].elements["material"].value == 2)
    {
        document.forms["changeEquipment"].elements["AlProgram"].disabled = true;
        document.forms["changeEquipment"].elements["AlProgram"].style.backgroundColor = "#D1D7E2";
        document.forms["changeEquipment"].elements["PvcAmount"].disabled = false;
        document.forms["changeEquipment"].elements["PvcAmount"].style.backgroundColor = "";
    }
}

var lastCellID = "";
var lastLinkID = "";
function serviceCellLinkList(cellID,linkID)
{
    if (lastCellID){whyBro(lastCellID).style.backgroundColor = "";}
    whyBro(cellID).style.backgroundColor = "#F9F9F9";
    if (lastLinkID){whyBro(lastLinkID).className= "linklistconsumables";}
    whyBro(linkID).className = "lnklstcnsmblsHere";
    lastCellID = cellID;
    lastLinkID = linkID;

}

var flagSlideCondition = "";
var lastFlagSlideCondition = "";
var tmpdivSlider,tmphowpixslide;
function slideEar(divSlider,howpixslide,flagSlideCondition)
{//alert(lastFlagSlideCondition);
    tmpdivSlider = divSlider;
    tmphowpixslide = howpixslide;
    if (flagSlideCondition && flagSlideCondition == 'slideOFF')
    {
        //whyBro(divSlider).style.left = 0 - howpixslide;
        moveSlideW();
        changepic('sidebillet_arrow','sidebillet_arrow_E');
        lastFlagSlideCondition = flagSlideCondition;
    }
    else if (flagSlideCondition && flagSlideCondition == 'slideON')
    {
        //whyBro(divSlider).style.left = howpixslide - howpixslide;
        moveSlideE();
        changepic('sidebillet_arrow','sidebillet_arrow_W');
        lastFlagSlideCondition = flagSlideCondition;
    }
    else if (!flagSlideCondition && lastFlagSlideCondition == 'slideON')
    {
        //whyBro(divSlider).style.left = 0 - howpixslide;
        moveSlideW();
        changepic('sidebillet_arrow','sidebillet_arrow_E');
        flagSlideCondition = "slideOFF";
        lastFlagSlideCondition = flagSlideCondition;
    }
    else if (!flagSlideCondition && lastFlagSlideCondition == 'slideOFF')
    {
        //whyBro(divSlider).style.left = howpixslide - howpixslide;
        moveSlideE();
        changepic('sidebillet_arrow','sidebillet_arrow_W');
        flagSlideCondition = "slideON";
        lastFlagSlideCondition = flagSlideCondition;
    }
}

function moveSlideW()//плавное скольжение :) Аргументы у этой функции ДОЛЖНЫ отсутствовать! Иначе не работает таймоут.
{
    if(parseInt(whyBro(tmpdivSlider).style.left.slice(0,-2)) > -tmphowpixslide)
    {
        whyBro(tmpdivSlider).style.left = (parseInt(whyBro(tmpdivSlider).style.left.slice(0,-2)) - 3);
        window.setTimeout(moveSlideW,20);
    }
}
function moveSlideE()//плавное скольжение :)Аргументы у этой функции ДОЛЖНЫ отсутствовать! Иначе не работает таймоут.
{
    if(parseInt(whyBro(tmpdivSlider).style.left.slice(0,-2)) < tmphowpixslide - tmphowpixslide)
    {
        whyBro(tmpdivSlider).style.left = (parseInt(whyBro(tmpdivSlider).style.left.slice(0,-2)) + 3);
        window.setTimeout(moveSlideE,20);
    }
}



function isEmpty(str) {
    for(var i = 0; i < str.length; i++) {
        if(" " != str.charAt(i)) return false;
    }

    return true;
}



function checkQuestForm(f) {
    var error_str       = "";
    var return_value    = false;

    if(isEmpty(f.elements["UserName"].value)) {
        error_str = "Пожалуйста заполните поле 'Ваше имя'";
    } else if(isEmpty(f.elements["UserMail"].value)) {
        error_str = "Пожалуйста заполните поле 'E-mail'";
    } else if(isEmpty(f.elements["UserQuestion"].value)) {
        error_str = "Пожалуйста заполните поле 'Вопрос'";
    } else {
        return_value = true;
    }

    if(error_str != "") {
        alert(error_str);
    }

    return return_value;
}



function openPopupConfigurator() {
    var mat_id      = document.forms["changeEquipment"].elements["material"].value;
    var program_id  = document.forms["changeEquipment"].elements["AlProgram"].value;
    var amount_id   = document.forms["changeEquipment"].elements["PvcAmount"].value;

    winConf = window.open("/popup_configurator.php?mat_id=" + mat_id + "&program_id=" + program_id + "&amount_id=" + amount_id,"winConfigurator","width=720,height=820");
    //winConf = eval('window.open("/popup_bigphoto.php?mat_id=' + mat_id + '", "newBigPhotoW", "width=' + 720 + ',height=' + 820 + '")');
    //winConf.focus();
}

