﻿function OpenImage(url, heigh, width)
{
    var defHeight = 300;
    var defWidth = 400;
    
    if( heigh > 0 )
        defHeight = heigh;
    
    if( width > 0 )
        defWidth = width;
        
    window.open( url, 'Página', 'titlebar=no, height = '+defHeight+' , width = ' + defWidth );
}

function ShowEditPhoto( photoId )
{
    window.open( 'EditPhoto.aspx?PhotoId=' +photoId, 'PhotoEditor', 'titlebar=no' );
}

function ShowEditSale( saleId )
{
    window.open( 'EditSale.aspx?SaleId=' +saleId, 'SaleEditor', 'titlebar=no' );
}

function ShowEditService( serviceId )
{
    window.open( 'EditService.aspx?ServiceId=' +serviceId, 'ServiceEditor', 'titlebar=no' );
}

function SaveCircuitPoints()
{
    var go = true;
    var ct = 0;
    var result = "";
    
    while(go)
    {
        var ctTemp = ct;
        
        if( ct < 10 )
            ctTemp = '0' + ct;
        
        var hd = document.getElementById("dtlPoints_ctl"+ctTemp+"_hdCircId");
        
        if(hd==null)
        {
            go = false;
        }
        else
        {
            var tp = document.getElementById("dtlPoints_ctl"+ctTemp+"_txtPoints");
            
            result += hd.value +";"+ tp.value + "|";
            ct = ct+1;
        }
    }
    
    var hr = document.getElementById("hdResult");
    hr.value = result;
}

function SavePilotInfo()
{
    var name = document.getElementById('txtName');
    var nick = document.getElementById('txtNick');
    var bike = document.getElementById('txtBike');
    var team = document.getElementById('txtTeam');
    
    var hdInfo = document.getElementById('hdInfo');
    hdInfo.value = name.value + '|' + nick.value + '|' + bike.value + '|' + team.value;
    
    
}

function SaveCalendar()
{

    var go = true;
    var ct = 0;
    var result = "";
    
    while(go)
    {
        var ctTemp = ct;
        
        if( ct < 10 )
            ctTemp = '0' + ct;
        
        var hd = document.getElementById("dtlCircuits_ctl"+ctTemp+"_hdCircuitId");
        
        if(hd==null)
        {
            go = false;
        }
        else
        {
            var tp = document.getElementById("dtlCircuits_ctl"+ctTemp+"_txtDate");
            
            result += hd.value +";"+ tp.value + "|";
            ct = ct+1;
        }
    }
    
    var hr = document.getElementById("hdResult");
    hr.value = result;
}

function SaveNewCircuit()
{
    var nc = document.getElementById("txtNewCircuit");
    var cc = document.getElementById("txtCircuitCountry");
    
    result = nc.value + ';' + cc.value;
    
    var hr = document.getElementById("hdResult");
    hr.value = result;
}
