﻿function sessionExpired(path)
{
    switch(path)
    {
        case 'public':
            window.location='logout.aspx';
            break;
        case 'private':
            window.location='../logout.aspx';
            break;
        case 'order':
            window.location = '../../logout.aspx';
            break;
    }
    alert('You have been logged out due to inactivity');
}

function centerDialog(dialogID, overlayID, animate) {

    if (animate = 'undefined') animate = true;

    $(overlayID).setStyle('position', 'absolute');
    $(overlayID).setStyle('display', 'block');
    $(overlayID).setStyle('width', (document.body.clientWidth));
    if (BrowserDetect.browser == 'Explorer') {
        $(overlayID).setStyle('height', document.documentElement.clientHeight);
    }
    else {
        $(overlayID).setStyle('height', ((window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight));
    }
    if (BrowserDetect.browser == 'Explorer') {
        $(overlayID).setStyle('top', document.body.scrollTop);
    }
    else {
        $(overlayID).setStyle('top', window.getScrollTop());
    }
    $(overlayID).setStyle('left', 0);

    $(dialogID).setStyle('position', 'absolute');
    $(dialogID).setStyle('display', 'block');
    $(dialogID).setStyle('left', ((document.body.clientWidth) / 2) - ($(dialogID).getStyle('width').replace('px', '') / 2));
    if (BrowserDetect.browser == 'Explorer') {
        $(dialogID).setStyle('top', document.body.scrollTop + (document.documentElement.clientHeight / 2) - ($(dialogID).getStyle('height').replace('px', '') / 2));
    }
    else {
        $(dialogID).setStyle('top', window.getScrollTop() + (((window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight) / 2) - ($(dialogID).getStyle('height').replace('px', '') / 2));
    }
    
    if (animate) {
        $(overlayID).fx = $(overlayID).effect('opacity', { duration: 500 }).start(.6);
        $(dialogID).fx = $(dialogID).effect('opacity', { duration: 500 }).start(1);
    }
    else {
        $(overlayID).setStyle('opacity', .6);
        $(dialogID).setStyle('opacity', 1);
    }
}

function trim(str)
{
    return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}


