//
// Change city text by city
//
function ChangeCityTextByCity(objCity, objCityText, language)
{
    var i = 0;
    var num = objCity.options.length;
    
    if ("" === objCity.value)
    {
        objCityText.value = "";
        return;
    }
    
    for (i = 0; i < num; i += 1)
    {
        if (objCity.options[i].selected)
        {
            switch (language)
            {
            case 0:
                objCityText.value = objCity.options[i].text.substring(1);
                return;
                
            case 1:
                objCityText.value = objCity.options[i].text;
                return;
            }
        }
    }
}

//
// Change city by city text
//
function ChangeCityByCityText(objCityText, objCity, language)
{
    var i = 0;
    var num = objCity.options.length;
    
    if ("" === objCityText.value)
    {
        objCity.value = "";
        return;
    }
    
    var localCityText = objCityText.value;
    if (1 === language)
    {
        localCityText = objCityText.value.toLowerCase();
    }

    var tempValue = "";
    for (i = 0; i < num; i += 1)
    {
        switch (language)
        {
        case 0:
            tempValue = objCity.options[i].text.substring(1);
            break;
            
        case 1:
            tempValue = objCity.options[i].text.toLowerCase();
            break;
        }
        if (localCityText === tempValue)
        {
            objCity.options[i].selected = true;
            return;
        }
    }
}

//
// Increase date
//
function IncreaseDate(date)
{
    var nDayArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var cDateArray = date.split("-");
    
    var year = parseInt(cDateArray[0], 10);
    var month = parseInt(cDateArray[1], 10);
    var day = parseInt(cDateArray[2], 10);
    
    if (((0 === (year % 4)) && ((year % 100) !== 0)) || (0 === (year % 400)))
    {
        nDayArray[1] = 29;
    }
    
    if (day < nDayArray[month - 1])
    {
        day += 1;
    }
    else
    {
        day = 1;
        if (month < 12)
        {
            month += 1;
        }
        else
        {
            month = 1;
            year += 1;
        }
    }
    
    return year + "-" + month + "-" + day;
}

//
// Decrease date
//
function DecreaseDate(date)
{
}

//
// Get absolute control position
//
function GetAbsolutePos(obj)
{
    var position = new Object();
    var tempobj = obj;
    
    position.x = 0;
    position.y = 0;
    
    while ((tempobj != null) && (tempobj != document.body))
    {
        position.x += tempobj.offsetLeft + tempobj.clientLeft;
        position.y += tempobj.offsetTop + tempobj.clientTop;
        tempobj = tempobj.offsetParent;
    }
    
    return position;
}

