/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function SendTheForm(InID)
{
    document.getElementById(InID).submit();
}

function SetValue(InID,InValue)
{
    document.getElementById(InID).value = InValue;
}

function SetAction(InID,InValue)
{
    document.getElementById(InID).action = InValue;
}

function SetTarget(InID,InTarget)
{
    document.getElementById(InID).target = InTarget;
}


function EditMeasure(InObjectID,InConstrID,InMeasureID)
{
    window.open("MyConstruction.php?WhatShow=202&ObjectID="+InObjectID+"&ConstrID="+InConstrID+"&MeasureID="+InMeasureID,
                "EditMeasure",
                    "height=400,width=600,status=yes,toolbar=no,menubar=no,location=no,titlebar=no");
}

function SaveAndRefreshChanges()
{
    window.close();
    window.opener.location.reload();
}

function ResumeChanges(InStr)
{
    if(confirm(InStr))
    {
        SaveAndRefreshChanges();
    }
}

function CheckInputValues(InID,InMinValue,InMaxValue)
{
    if((document.getElementById(InID).value < InMinValue)||(InMaxValue < document.getElementById(InID).value))
    {
        alert('Введите значение от '+InMinValue+' до '+InMaxValue+'!');
        document.getElementById(InID).focus();
        return false;
    }
}

function AskConfirm(In_uo_Type)
{
    var AskMsgTypePart;
    var AskMsg = '';
    switch(In_uo_Type)
    {
        case 41:
            AskMsg = 'Присоединиться к проекту в качестве оператора?';
            break;
        case 42:
            AskMsg = 'Присоединиться к проекту в качестве контроллера?';
            break;
        case 43:
            AskMsg = 'Присоединиться к проекту в качестве управляющего?';
            break;
        case -40:
            AskMsg = 'Вы уверены, что хотите отменить свою заявку?';
            break;
    }

    var Answer = confirm(AskMsg);
    if(Answer)
    {
        SetValue('uo_Type',In_uo_Type);
        SendTheForm('TheForm');
    }
}

function OpenWindow(InPath,InW,InH)
{
    if (typeof InW == "undefined") InW = 500;
    if (typeof InH == "undefined") InH = 275;

    var ScreenWidth = screen.width;
    var ScreenHeight = screen.height;
    var WinWidth = InW;
    var WinHeight = InH;
    var LeftPos = (ScreenWidth-WinWidth)/2;
    var TopPos = (ScreenHeight-WinHeight)/2;
    var Params = 'channelmode=0,directories=0,location=0,';
    Params = Params+'left='+LeftPos+',top='+TopPos+',height='+WinHeight+',width='+WinWidth;
    Params = Params+',resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,menubar=1';
    window.open(InPath,'NewWindow',Params);
}

function ViewReportLink_Click(InObjID,InConID)
{
    var TmpPath = 'PrintReport.php?ConstrID='+InConID+'&ObjectID='+InObjID;
    OpenWindow(TmpPath);
}

function TimeBoardReportLink_Click()
{
    SetAction('TheForm', 'PrintReport.php');
    SetTarget('TheForm', '_blank');
    SetValue('WhatShow', '100');
    SendTheForm('TheForm');
    SetTarget('TheForm', '_self');
}

function TempPageReportLink_Click()
{
    SetAction('TheForm', 'PrintReport.php');
    SetTarget('TheForm', '_blank');
    SetValue('WhatShow', '200');
    SendTheForm('TheForm');
    SetTarget('TheForm', '_self');
}

function MenuHelpButton_Click(InContext,InWhatShow)
{
    var TmpPath = '/dokuwiki/doku.php?id='+InContext+'#'+InWhatShow;
    OpenWindow(TmpPath,900,550);
}

function MenuMailButton_Click(InContext,InWhatShow)
{
    var TmpPath = 'mail.php?Context='+InContext+'&WhatShow='+InWhatShow;
    OpenWindow(TmpPath,450,300);
}


function HideK()
{
    document.getElementById('K_text').style.visibility = 'hidden';
    document.getElementById('K_input').style.visibility = 'hidden';
    document.getElementById('K').disabled=true;
}
function ShowK()
{
    document.getElementById('K_text').style.visibility = 'visible';
    document.getElementById('K_input').style.visibility = 'visible';
    document.getElementById('K').disabled=false;
}
function FormworkType_Change_1()
{
    var FormworkType;
    FormworkType = document.getElementById('FormworkType').value;
    if(FormworkType == 6)
        ShowK();
    else
    {
        HideK();
    }
}

function ReportNumberLine_Click()
{
    SetValue('WhatShow','300');
    SetAction('TheForm','PrintReport.php');
    SetTarget('TheForm','_blank');
    SendTheForm('TheForm');
    SetTarget('TheForm','_self');
}

function PageButton_click(InVal)
{
    SetValue('WhatShow','800');
    SetValue('PageNum',InVal);
    SetAction('TheForm','MyObjects.php');
    SetTarget('TheForm','_self');
    SendTheForm('TheForm');
}

function CurStrListItem_Click(InID)
{
    SetValue('WhatShow','200');
    SetValue('ConstrID',InID);
    SetAction('TheForm','MyConstruction.php');
    SetTarget('TheForm', '_blank');
    SendTheForm('TheForm');
}

function DelConstr()
{
    var AskMsg = 'Вы уверены, что хотите удалить конструкцию?';
    var Answer = confirm(AskMsg);
    if(Answer)
    {
        SetValue('WhatShow','400');
        SetAction('TheForm','MyConstruction.php');
        SetTarget('TheForm', '_self');
        SendTheForm('TheForm');
    }
}

function FormworkType_Change(InTemp)
{
    if(document.getElementById('FormworkType').value == 1)
    {
        document.getElementById('TempExp').innerHTML='бетона';
        document.getElementById('mTempOpal1').name='mTempConc';
        document.getElementById('mTempOpal1').value=InTemp;
        for(i=2;i<=5;i++)
        {
            document.getElementById('mTempOpal'+i).style.visibility = 'hidden';
            document.getElementById('mTempOpal'+i).disabled=true;
        }
    }
    else
    {
        document.getElementById('TempExp').innerHTML='опалубки';
        document.getElementById('mTempOpal1').name='mTempOpal1';
        for(i=2;i<=5;i++)
        {
            document.getElementById('mTempOpal'+i).style.visibility = 'visible';
            document.getElementById('mTempOpal'+i).disabled=false;
        }
    }

}

function StopRelation_click(InFIO,InID)
{
    var AskMsg = 'Вы уверены, что хотите приостановить полномочия пользователя '+InFIO+'?';
    var Answer = confirm(AskMsg);
    if(Answer)
    {
        SetValue('WhatShow','703');
        SetValue('TheUser',InID);
        SendTheForm('TheForm');
    }
}

function ConstrListItem_click(InID)
{
    SetValue('WhatShow', '200');
    SetValue('ConstrID', InID);
    SendTheForm('TheForm');
}

function ObjectListItem_click(InWhatShow,InID)
{
    SetValue('WhatShow', InWhatShow);
    SetValue('ObjectID', InID);
    SendTheForm('TheForm');
}

function AddNewConstr_click()
{
    SetValue('WhatShow', '100');
    SendTheForm('TheForm');
}

function CoverFlag_Change()
{
    var CoverFlag;
    CoverFlag = document.getElementById('mCoverFlag').value;
    if(CoverFlag == 1)
        document.getElementById('mTempTepl').disabled=false;
    else
    {
        document.getElementById('mTempTepl').disabled=true;
    }
}
