﻿/***************************\
* Greybox popup integration *
\***************************/
var GB_ROOT_DIR = '/js/greybox/';
var curID = '';

function CloseGB()
{
    GB_hide();
}

function CloseGBandPost()
{
    GB_hide();

    // based on which button was clicked
    if (curID == '')
        alert('Unknown error. Please try again.');
    else
        causePostback(curID);
}

function CloseGBandRedirect(url)
{
    if (window.top.location != window.location)
        GB_hide();

    window.location = url;

    return false;
}

function causePostback(id)
{
    eval(document.getElementById(id).href);
}

function gb_BuildLaunch(g,w,h)
{
		w = w == undefined ? 800 : w;
		h = h == undefined ? 500 : h;
		return gb_FrontEndLaunch(g.title,g.getAttribute('href'),w,h);
}

function gb_FrontEndLaunch(title, url, width, height) {
	// check for width and height
	width = width == undefined ? 800 : width;
	height = height == undefined ? 500 : height;
	// scroll the window to the top of the page
	scroll(0, 0);
	// get the browser width
	var iWidth = document.body.clientWidth - 20;
	// set the GB window to use that width
	GB_show(title, url, height, width);
	// return false
	return false;

}

function gb_FrontEndLaunchNoHeight(title, url, width) {
    // check for width
    width = width == undefined ? 800 : width;
    // scroll the window to the top of the page
    scroll(0, 0);
    // get the browser width
    var iWidth = document.body.clientWidth - 20;
    var iHeight = $(window).height() - 20;
    if (iHeight > 683) iHeight = 683;
    // set the GB window to use that width
    GB_show(title, url, iHeight, width);
    // return false
    return false;

}
