function onMaxValueLength(obj, max)
{
    return(obj.value.length <= max)
}

function ScrollTo(scrollY)
{
    ctl00_body.scrollTop = scrollY;
}

function OnlyNumChar(event) {
    var charCode = (event.which) ? event.which : event.keyCode;
    if( (charCode > 31 && (charCode < 48 || charCode > 57)) || (charCode == 13) ) {
        event.returnValue = false;
        return false;
    } else {
        event.returnValue = true;
        return true;
    }
}

function SetScroll()
{
    document.getElementById('ctl00_scrollY').value = ctl00_body.scrollTop;
}

function newWindowAlert(str)
{
/*    newWindow = window.open('','','width=200,height=30');
    var content = "<html><head><title>New message</title></head><body onload='window.moveTo(screen.width/2 - 200/2, screen.height/2 - 50/2); setTimeout(\"window.close()\",15)'>" + str + "</body></html>";
    newWindow.document.write(content);
    newWindow.moveTo(screen.width/2 - 200/2, screen.height/2 - 50/2);
    setTimeout('newWindow.close()',29000);*/
}

function DisableButton(id, enable)
{
    document.getElementById('ctl00_contentTartalom_' + id).disabled = (enable == 'true');
}

function DisableButtonIF(id, enable, id2)
{
    if(document.getElementById('ctl00_contentTartalom_' + id2).value != '')
        document.getElementById('ctl00_contentTartalom_' + id).disabled = (enable == 'true');
}

function ChangeNew(Type,Code,Emis,ECUs,YBeg,YEnd,Pwr,Cap,VID,VKey,MKey)
{
    document.getElementById('ctl00_contentTartalom_Type').value = Type;
    document.getElementById('ctl00_contentTartalom_Code').value = Code;
    document.getElementById('ctl00_contentTartalom_YBeg').value = (YBeg ? YBeg : "1900");
    document.getElementById('ctl00_contentTartalom_YEnd').value = (YEnd ? YEnd : "2090");
    document.getElementById('ctl00_contentTartalom_Pwr').value = Pwr;
    document.getElementById('ctl00_contentTartalom_Cap').value = Cap;
    document.getElementById('ctl00_contentTartalom_VID').value = VID;
    document.getElementById('ctl00_contentTartalom_Emis').value = Emis;
    document.getElementById('ctl00_contentTartalom_ECUs').value = ECUs;
    document.getElementById('ctl00_contentTartalom_VKey').value = VKey;
    document.getElementById('ctl00_contentTartalom_MKey').value = MKey;

    document.getElementById('ctl00_contentTartalom_tableDLList').style.display = 'inline';
    document.getElementById('ctl00_contentTartalom_Type0').innerText = Type;
    document.getElementById('ctl00_contentTartalom_Code0').innerText = Code;
    document.getElementById('ctl00_contentTartalom_Year0').innerText = YBeg+'-'+YEnd;
    document.getElementById('ctl00_contentTartalom_Pwr0').innerText = Pwr;
    document.getElementById('ctl00_contentTartalom_Cap0').innerText = Cap;
    document.getElementById('ctl00_contentTartalom_VID0').innerText = VID;
    document.getElementById('ctl00_contentTartalom_Emis0').innerText = Emis;
    document.getElementById('ctl00_contentTartalom_ECUs0').innerText = ECUs;
    document.getElementById('ctl00_contentTartalom_VKey0').innerText = VKey;
    document.getElementById('ctl00_contentTartalom_MKey0').innerText = MKey;
}

function ShowHide(id)
{
    if(document.getElementById('ctl00_contentTartalom_' + id).style.display == 'none')
        document.getElementById('ctl00_contentTartalom_' + id).style.display = 'inline'
    else
        document.getElementById('ctl00_contentTartalom_' + id).style.display = 'none'
}

function ValidateNewCall()
{
    // Évszám ellenőrzése
    var obj_year = document.getElementById('year_error'); 
    if(!ValidateYear()) 
    { 
        obj_year.style.color='red'; 
        document.getElementById('ctl00_contentTartalom_year').focus(); 
        return false;
    } 
    else 
    {
        obj_year.style.color='#ffffff';
    }; 
    
    // FrameNumber ellenőrzése
        var obj = document.getElementById('frame_error'); 
        var obj2 = document.getElementById('ctl00_contentTartalom_framenumbertext'); 
        if(obj) 
        { 
            if(obj2.value.length==17 || (obj2.value.length==0 && document.getElementById('ctl00_contentTartalom_ManufacIndex').value == ""))
            { 
                obj.style.color='#ffffff';
            } 
            else 
            {
                obj.style.color='red'; 
                obj.focus(); 
                return false;
            }
        } 
    
    document.getElementById('ctl00_contentTartalom_question').value=document.getElementById('ctl00_contentTartalom_question').value.replace('<', ' ');
    return true;
}

function ValidateYear()
{
    year = document.getElementById('ctl00_contentTartalom_year');
    YBeg = document.getElementById('ctl00_contentTartalom_YBeg');
    YEnd = document.getElementById('ctl00_contentTartalom_YEnd');
    
    if(YBeg.value == "" && YEnd.value == "") {
        if( (1900 < year.value && year.value < 2040) || year.value=="" )
            return true;
        else
            return false;
    } else {
        var beg = parseInt(YBeg.value);
        var end = parseInt(YEnd.value);
        if(beg > 20)       beg += 1900;
        else               beg += 2000;
        if(end > 20)       end += 1900;
        else               end += 2000;        
        
        if(beg <= year.value && year.value <= end)
            return true;
        else
            return false;
    }
}