﻿/*-- color definitions --*/

/*var rowBgColor = '#ffffff';
var altRowBgColor = '#e5e5e5';
var orderColor = '#85bc85';
var orderRowBgColor = '#d2e6d2'; //calculateColorOverlay(orderColor, rowBgColor, 100);
var orderAltRowBgColor = '#c2d6c2'; //calculateColorOverlay(orderColor, altRowBgColor, 100);
var errorColor = '#ea2015';*/

function loadPage(url) {
    document.location = url;
}

function loadPageInNewWindow(url) {
    window.open(url);
}

var newsItemPath;
function openNewsItem(path, newsItemId) {
    newsItemPath = path;
    Adios.Site.Webservices.GetNewsItemDocumentLink(newsItemId, openNewsItemCompleted);
}

function openNewsItemCompleted(newsItemDocumentLink) {
    if (newsItemDocumentLink != null) openWindow(newsItemPath + newsItemDocumentLink);
}

function openWindow(link, width, height, location, menubar) {
    //-- set optional parameters
    if (width == undefined || width == null) width = 1000;
    if (height == undefined || height == null) height = 700;
    if (location != 0 && location != 1) location = 1;
    if (menubar != 0 && menubar != 1) menubar = 1;
    window.open(link, null, 'location=' + location + ',menubar=' + menubar + ',resizable=1,scrollbars=1,width=' + width + ',height=' + height);
}

function refreshBasketSummary(flashBasket) {
    if (flashBasket == undefined || flashBasket == true) flashBasketTotals();
    Adios.Site.Webservices.GetBasketSummary(refreshBasketSummaryCompleted);
}

function refreshBasketSummaryCompleted(result) {
    if (result.length == 5) {
        getJqueryObjectByServerControlId('lblBasketCount').html(result[0]);
        getJqueryObjectByServerControlId('lblBasketTotals').html(result[1]);
        getJqueryObjectByServerControlId('lblTransportCosts').html(result[2]).attr('title', result[3]).removeClass().addClass(result[4]);
    }
}

function flashBasketTotals() {
    $('#basket-totals').stop().css('background-color', '#eaeaea').animate({ backgroundColor: '#fff091' }, 'fast', function () {
        $('#basket-totals').animate({ backgroundColor: 'rgba(255, 240, 145, 0.0)' }, 2500);
    });
}

function printPage() {
    alert('Print function not implemented for this page.');
}

function sortGrid(element) {
    eval($(element).prev().attr('href').replace('javascript:',''));
}

function cancelClaimInProgress(key, keyExtra) {
    Adios.Site.Webservices.CancelClaimInProgress();
    removeMessage(key);
    
    removeMessage(keyExtra);
}

function toggleRowSelection(element) {
    var row = $(element).closest('tr');
    if (row.hasClass('selected')) row.removeClass('selected');
    else row.addClass('selected');
}

function removeHint(element) {
    if ($(element).hasClass('hint')) {
        if ($(element).attr('abbr') == undefined) {
            $(element).attr('abbr', $(element).val());
        }
        $(element).removeClass('hint').val('');
    }
}

function addHint(element) {
    if (!$(element).hasClass('hint') && element.value == '') {
        $(element).addClass('hint').val($(element).attr('abbr') != null && $(element).attr('abbr') != '' ? $(element).attr('abbr') : $(element).attr('title'));
    }
}

/*function needsRefresh() {
    var pValue = getCookie("historyLength");
    var cValue = window.history.length;
    alert(pValue + ' / ' + cValue);
    setCookie("historyLength", window.history.length);    
    return cValue <= pValue;
}*/
