
;(function($) {

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
    return;
}

// global $ methods for blocking/unblocking the entire page
$.blockUI   = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// plugin method for blocking element content
$.fn.block = function(opts) {
    return this.each(function() {
        if ($.css(this,'position') == 'static')
            this.style.position = 'relative';
        if ($.browser.msie) 
            this.style.zoom = 1; // force 'hasLayout'
        install(this, opts);
    });
};

// plugin method for unblocking element content
$.fn.unblock = function(opts) {
    return this.each(function() {
        remove(this, opts);
    });
};

$.blockUI.version = 2.09; // 2nd generation blocking at no extra cost!

// override these in your code to change the default behavior and style
$.blockUI.defaults = {
    // message displayed when blocking (use null for no message)
    message:  '<h1>Please wait...</h1>',
    
    // styles for the message when blocking; if you wish to disable
    // these and use an external stylesheet then do this in your code:
    // $.blockUI.defaults.css = {};
    css: { 
        padding:        0,
        margin:         0,
        width:          '30%', 
        top:            '40%', 
        left:           '35%', 
        textAlign:      'center', 
        color:          '#000', 
        border:         '3px solid #aaa',
        backgroundColor:'#fff',
        cursor:         'wait'
    },
    
    // styles for the overlay
    overlayCSS:  { 
        backgroundColor:'#000', 
        opacity:        '0.6' 
    },
    
    // z-index for the blocking overlay
    baseZ: 1000,
    
    // set these to true to have the message automatically centered
    centerX: true, // <-- only effects element blocking (page block controlled via css above)
    centerY: true,
    
    // allow body element to be stetched in ie6; this makes blocking look better
    // on "short" pages.  disable if you wish to prevent changes to the body height
    allowBodyStretch: true,
    
    // be default blockUI will supress tab navigation from leaving blocking content;
    constrainTabKey: true,
    
    // fadeOut time in millis; set to 0 to disable fadeout on unblock
    fadeOut:  400,
    
    // if true, focus will be placed in the first available input field when
    // page blocking
    focusInput: true,
    
    // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
    applyPlatformOpacityRules: true,
    
    // callback method invoked when unblocking has completed; the callback is
    // passed the element that has been unblocked (which is the window object for page
    // blocks) and the options that were passed to the unblock call:
    //     onUnblock(element, options)
    onUnblock: null
};

// private data and functions follow...

var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
var pageBlock = null;
var pageBlockEls = [];

function install(el, opts) {
    var full = (el == window);
    var msg = opts && opts.message !== undefined ? opts.message : undefined;
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
    var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
    msg = msg === undefined ? opts.message : msg;

    // remove the current block (if there is one)
    if (full && pageBlock) 
        remove(window, {fadeOut:0}); 
    
    // if an existing element is being used as the blocking content then we capture
    // its current place in the DOM (and current display style) so we can restore
    // it when we unblock
    if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
        var node = msg.jquery ? msg[0] : msg;


        var data = {};
        $(el).data('blockUI.history', data);
        data.el = node;
        data.parent = node.parentNode;
        data.display = node.style.display;
        data.position = node.style.position;
        data.parent.removeChild(node);
    }
    
    var z = opts.baseZ;
    
    // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
    // layer1 is the iframe layer which is used to supress bleed through of underlying content
    // layer2 is the overlay layer which has opacity and a wait cursor
    // layer3 is the message content that is displayed while blocking
    
    var lyr1 = ($.browser.msie) ? $('<iframe class="blockUI" style="z-index:'+ z++ +';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;"></iframe>')
                                : $('<div class="blockUI" style="display:none"></div>');
    var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ z++ +';cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
    var lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';position:fixed"></div>')
                    : $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');

    // if we have a message, style it
    if (msg) 
        lyr3.css(css);

    // style the overlay
    if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform))) 
        lyr2.css(opts.overlayCSS);
    lyr2.css('position', full ? 'fixed' : 'absolute');
    
    // make iframe layer transparent in IE
    if ($.browser.msie) 
        lyr1.css('opacity','0.0');

    $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
    
    // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
    var expr = $.browser.msie && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
    if (ie6 || expr) {
        // give body 100% height
        if (full && opts.allowBodyStretch && $.boxModel)
            $('html,body').css('height','100%');

        // fix ie6 issue when blocked element has a border width
        if ((ie6 || !$.boxModel) && !full) {
            var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
            var fixT = t ? '(0 - '+t+')' : 0;
            var fixL = l ? '(0 - '+l+')' : 0;
        }

        // simulate fixed position
        $.each([lyr1,lyr2,lyr3], function(i,o) {
            var s = o[0].style;
            s.position = 'absolute';
            if (i < 2) {
                full ? s.setExpression('height','document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + "px"')
                     : s.setExpression('height','this.parentNode.offsetHeight + "px"');
                full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                     : s.setExpression('width','this.parentNode.offsetWidth + "px"');
                if (fixL) s.setExpression('left', fixL);
                if (fixT) s.setExpression('top', fixT);
            }
            else if (opts.centerY) {
                if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                s.marginTop = 0;
            }
        });
    }
    
    // show the message
    lyr3.append(msg).show();
    if (msg && (msg.jquery || msg.nodeType))
        $(msg).show();

    // bind key and mouse events
    bind(1, el, opts);
        
    if (full) {
        pageBlock = lyr3[0];
        pageBlockEls = $(':input:enabled:visible',pageBlock);
        if (opts.focusInput)
            setTimeout(focus, 20);
    }
    else
        center(lyr3[0], opts.centerX, opts.centerY);
};

// remove the block
function remove(el, opts) {
    var full = el == window;
    var data = $(el).data('blockUI.history');
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    bind(0, el, opts); // unbind events
    var els = full ? $('body').children().filter('.blockUI') : $('.blockUI', el);
    
    if (full) 
        pageBlock = pageBlockEls = null;

    if (opts.fadeOut) {
        els.fadeOut(opts.fadeOut);
        setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
    }
    else
        reset(els, data, opts, el);
};

// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
    els.each(function(i,o) {
        // remove via DOM calls so we don't lose event handlers
        if (this.parentNode) 
            this.parentNode.removeChild(this);
    });
    if (data && data.el) {
        data.el.style.display = data.display;
        data.el.style.position = data.position;
        data.parent.appendChild(data.el);
        $(data.el).removeData('blockUI.history');
    }
    if (typeof opts.onUnblock == 'function')
        opts.onUnblock(el,opts);
};

// bind/unbind the handler
function bind(b, el, opts) {
    var full = el == window, $el = $(el);
    
    // don't bother unbinding if there is nothing to unbind
    if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) 
        return;
    if (!full) 
        $el.data('blockUI.isBlocked', b);
        
    // bind anchors and inputs for mouse and key events
    var events = 'mousedown mouseup keydown keypress click';
    b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

// former impl...
//    var $e = $('a,:input');
//    b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
};

// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
    // allow tab navigation (conditionally)
    if (e.keyCode && e.keyCode == 9) {
        if (pageBlock && e.data.constrainTabKey) {
            var els = pageBlockEls;
            var fwd = !e.shiftKey && e.target == els[els.length-1];
            var back = e.shiftKey && e.target == els[0];
            if (fwd || back) {
                setTimeout(function(){focus(back)},10);
                return false;
            }
        }
    }
    // allow events within the message content
    if ($(e.target).parents('div.blockMsg').length > 0)
        return true;
        
    // allow events for content that is not being blocked
    return $(e.target).parents().children().filter('div.blockUI').length == 0;
};

function focus(back) {
    if (!pageBlockEls) 
        return;
    var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
    if (e) 
        e.focus();
};

function center(el, x, y) {
    var p = el.parentNode, s = el.style;
    var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
    var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
    if (x) s.left = l > 0 ? (l+'px') : '0';
    if (y) s.top  = t > 0 ? (t+'px') : '0';
};

function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};

})(jQuery);


jQuery.extend({
    //dims the screen
    dimScreen: function(speed, opacity, callback) {
        if(jQuery('#__dimScreen').size() > 0) {
			if(typeof callback == 'function') callback();
			return;
		}
        
        if(typeof speed == 'function') {
            callback = speed;
            speed = null;
        }

        if(typeof opacity == 'function') {
            callback = opacity;
            opacity = null;
        }

        if(speed < 1) {
            var placeholder = opacity;
            opacity = speed;
            speed = placeholder;
        }
        
        if(opacity >= 1) {
            var placeholder = speed;
            speed = opacity;
            opacity = placeholder;
        }
		
        speed = (speed > 0) ? speed : 500;
        opacity = (opacity > 0) ? opacity : 0.5;
        return jQuery('<div></div>').attr({
                id: '__dimScreen'
                ,fade_opacity: opacity
                ,speed: speed
            }).css({
            background: '#000'
            ,height: $(document).height() + 'px'
            ,left: '0px'
            ,opacity: 0
            ,position: 'absolute'
            ,top: '0px'
            ,width: $(document).width() + 'px'
            ,zIndex: 999
        }).appendTo(document.body).fadeTo(speed, opacity, callback);
    },
    
    //stops current dimming of the screen
    dimScreenStop: function(callback) {
        var x = jQuery('#__dimScreen');
        var opacity = x.attr('fade_opacity');
        var speed = x.attr('speed');
        x.fadeOut(speed, function() {
            x.remove();
            if(typeof callback == 'function') callback();
        });
    }
});
jQuery.fn.center = function() {
        // Always return each...
        return this.each(function() {
                var t = jQuery(this);

                // Set position to other than 'static' so element shrink-wraps and width/height is calculated properly
                t.css({position: 'absolute'});

                // Why are there no jQuery.fn.outerWidth/Height:s?
                var w = t.width(); 
                var h = t.height();
                var lrPadding = parseInt(t.css('paddingLeft'), 10) + parseInt(t.css('paddingRight'), 10);
                var lrBorder = parseInt(t.css('borderLeftWidth'), 10) + parseInt(t.css('borderRightWidth'), 10);
                var tbPadding = parseInt(t.css('paddingTop'), 10) + parseInt(t.css('paddingBottom'), 10); 
                var tbBorder = parseInt(t.css('borderTopWidth'), 10) + parseInt(t.css('borderBottomWidth'), 10);
				if (isNaN(tbBorder)) tbBorder = 0;
				if (isNaN(lrBorder)) lrBorder = 0;
                var leftMargin = (w + lrPadding + lrBorder) / 2;
                var topMargin = ($(window).height()-(h + tbPadding + tbBorder)) / 2;
				var top = $(window).scrollTop();
                t.css({ 
                        left: '50%', 
                        top: '', 
                        marginLeft: '-' +leftMargin +'px', 
                        marginTop: (top) +'px',
                        zIndex: '1001'
                });

                /* Use this code if you care about IE<7, this requires the dimensions plug-in tho
                // Calculate left and top pos values
                var leftPos = (jQuery(window).width() - jQuery(this).outerWidth()) / 2 + jQuery(window).scrollLeft(), 
                        topPos = (jQuery(window).height() - jQuery(this).outerHeight()) / 2 + jQuery(window).scrollTop();

                // Make sure element is not out of bounds
                leftPos = (leftPos < 0) ? 0 : leftPos;
                topPos = (topPos < 0) ? 0 : topPos;

                jQuery(this).css({left: leftPos +'px', top: topPos +'px', zIndex: '1000'});
                */
        });
};

(function($){
	
$.dimensions = {
	version: '1.2'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){
	
	// innerHeight and innerWidth
	$.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};
	
	// outerHeight and outerWidth
	$.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;
		
		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
		
		options = $.extend({ margin: false }, options || {});
		
		var val = this.is(':visible') ? 
				this[0]['offset' + name] : 
				num( this, name.toLowerCase() )
					+ num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
					+ num(this, 'padding' + torl) + num(this, 'padding' + borr);
		
		return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
	};
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
	$.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;
		
		return val != undefined ?
		
			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo( 
						name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : $(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :
			
			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
					$.boxModel && document.documentElement[ 'scroll' + name ] ||
					document.body[ 'scroll' + name ] :
				this[0][ 'scroll' + name ];
	};
});

$.fn.extend({
	position: function() {
		var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
		
		if (elem) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();
			
			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();
			
			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');
			
			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');
			
			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}
		
		return results;
	},
	
	offsetParent: function() {
		var offsetParent = this[0].offsetParent;
		while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return $(offsetParent);
	}
});

function num(el, prop) {
	return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);/*
  Popup code. Based on Lightbox JS by Lokesh Dhakar.
  License agreement included below.
*/

/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
*/


/*
  Popup code. Based on Lightbox JS by Lokesh Dhakar.
  License agreement included below.
*/

/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
*/


//
// lightboxGetPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function helpCall(title,content) {
  body = "<table width=730><tr><td align=center class=txt_common>"+content+"</td></tr></table>";
  lightboxInit();
  lightboxShow(730, [title, "closebutton", ""], body, "", "", "", "", "");
  return false;
}

function showImage(title,img) {
	 body = '<table width=300><tr><td align=center class=txt_common><img id="overlayimg" src="'+img+'" border="0" /></td></tr></table>';
     lightboxInit();
     lightboxShow(450, [title, "closebutton", ""], body, "", "", "", "", "");
     return false;
}


function lightboxGetPageSize() {
  
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
  return arrayPageSize;

}



//
// lightboxGetPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function lightboxGetPageScroll() {

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function resize(obj){  
	var frame = obj;
	var htmlheight = document.body.parentNode.scrollheight;  
	var windowheight = window.innerheight;  
	if ( htmlheight < windowheight ) { document.body.style.height = windowheight + "px"; frame.style.height = windowheight + "px"; }  
	else { document.body.style.height = htmlheight + "px"; frame.style.height = htmlheight + "px"; }  
} 

//
// lightboxShow()
// Preloads images. Pleaces new image in lightbox then centers and displays.
//
function lightboxShow(width, title, content, overlay, delParam, prefix, closeButtonCSS, closeButtonOnClick) {

  var useTitle       = true;
  var titleAlign     = "center";
  var useCloseButton = false;
  var useCloseAction = false;
  while (typeof title == "object") {
    for(i=1 ; i<title.length ; i++) {
      if (typeof title[i] == "string") {
        if (title[i] == "notitle")
          useTitle       = false;
        if (title[i] == "lefttitle")
          titleAlign     = "left";
        if (title[i] == "closebutton")
          useCloseButton = true;
        if (title[i] == "closeaction")
          useCloseAction = true;
      }
    }
    title = title[0];
  }

  if (typeof(overlay) == 'undefined' || overlay == '')
    overlay = 'overlay';
  if (typeof(delParam) == 'undefined')
    delParam = '';
  if (typeof(prefix) == 'undefined')
    prefix = '';
  if (typeof(closeButtonCSS) == 'undefined' || closeButtonCSS == '')
    closeButtonCSS = 'lightboxCloseButton';
  if (typeof(closeButtonOnClick) == 'undefined')
    closeButtonOnClick = '';
  closeButtonOnClick = prefix+'lightboxHide();'+closeButtonOnClick+'return false;';

  if (!overlay) // Default to overlay if not set
    overlay = 'overlay';
	var objOverlay = document.getElementById(overlay);
	var objLightbox = document.getElementById('lightbox');
	var objLightboxContent = document.getElementById('lightboxContent');

	var arrayPageSize = lightboxGetPageSize();
	var arrayPageScroll = lightboxGetPageScroll();

	// set height of overlay to take up whole page
	if (objOverlay) {
    objOverlay.style.width = (arrayPageSize[0] + '');
    objOverlay.style.height = (arrayPageSize[1] + 'px');
    objOverlay.style.display = 'block';
  }

	if (objLightbox) {
    objLightbox.style.width = (width + '');
    objLightbox.style.display = 'block';
	 objLightbox.style.top = arrayPageScroll[1] + 'px';
  }

	if (objLightboxContent) {
	  var titleDiv = '';
    if(useTitle)
      titleDiv = '<div id=' + prefix + 'lightboxTitle class=' + prefix + 'lightboxTitle>'+title+'</div>';

    if (typeof str_close_lightbox == "undefined")
      var str_close_button = 'CLOSE ';
    else
      var str_close_button = str_close_lightbox + ' ';
    
    if (typeof str_close_window_tooltip == "undefined")
      var str_close_button_tooltip = 'Close Window';
    else
      var str_close_button_tooltip = str_close_window_tooltip;
    
    var closeButtonDiv = "";
    if (useCloseButton) {
      var closeButtonDiv = '<div class=\"' + closeButtonCSS +'\" id=' + prefix + 'lightboxCloseButton onClick=\"'+ closeButtonOnClick +'\"><img width=1 height=1 src=images/break.gif></div>';

    }

    var contentDiv     = '<div>'+content+'</div>';
    var contentTable = '<table style="border:2px solid #fff" align="center" border=0 cellspacing=0 cellpadding=0>' +
	  										'<tr>' +
	  										 '<td class=bgnone style="padding:7px;" valign=top>' +
	  										   titleDiv +
	  										 '</td>' +
	  										 '<td class=bgnone align=right valign=top>' + 
	  										  '<table border=0 cellspacing=0 cellpadding=0>' +
	  										   '<tr>' +
	  										    '<td class=bgnone valign=top>' +
	  										      delParam +
	  										    '</td>' +
	  										    '<td class=bgnone width=10>' +
	  										    '</td>' +
	  										    '<td style="padding:7px;" class=bgnone valign=top>' +
	  										      closeButtonDiv +
	  										    '</td>' +
	  										   '</tr>' +
	  										  '</table>' +
	  										 '</td>' +
	  										'</tr>' +
	  									  '<tr>' +
	  										 '<td class=bgnone colspan=3>' +
	  										   contentDiv +
	  										 '</td>' +
	  										'</tr>' +
	  									 '</table>';
    objLightboxContent.innerHTML = '<table border=0 cellspacing=3 cellpadding=3>'+

                                   '  <tr>'+

                                   '    <td colspan=1 class=' + prefix + 'lightboxCenter>'+contentTable+'</td>'+

                                   '  </tr>'+
                                 
                                   '</table>';
  }



  // center lightbox
	if (objLightbox) {
    var lightboxWidth = objLightbox.offsetWidth;
    var lightboxHeight = objLightbox.offsetHeight;
    var lightboxLeft = ((arrayPageSize[0] - lightboxWidth) / 2);
    var lightboxTop = arrayPageScroll[1] + 90;
	var imgWidth = 0;

    objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
    objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
  }
   //preload images
   if( img = document.getElementById("overlayimg")) {
	    var imgPreloader = new Image();
        imgPreloader.onload = (function(){
            lightboxLeft = ((arrayPageSize[0] - imgPreloader.width) / 2);
   			objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
			img.src = imgPreloader.src;
        });
        imgPreloader.src = img.src;
		img.src = 'http://bradstone.ee.mic5.mikare.ee/images/ajax-loader.gif';
   }
  // Update the overlay height as the lightbox might have increased the overall page height.
  arrayPageSize = lightboxGetPageSize();
	if (objOverlay) {
    objOverlay.style.width = (arrayPageSize[0] + '');
    objOverlay.style.height = (arrayPageSize[1] + '');
  }

  // Hide select boxes as they will 'peek' through the image in IE
  selects = document.getElementsByTagName("select");
  for (i = 0; i != selects.length; i++) {
    if (selects[i].zIndex < 100) {
      selects[i].style.visibility = "hidden";
    }
  }

}


//
// lightboxHide()
//
function lightboxHide() {

  // get objects
  var objOverlay = document.getElementById('overlay');
  var objLightbox = document.getElementById('lightbox');
	var objLightboxContent = document.getElementById('lightboxContent');

  // hide lightbox and overlay
	if (objOverlay)
    objOverlay.style.display = 'none';
	if (objLightbox)
    objLightbox.style.display = 'none';

  // Remove content from lightbox
	if (objLightboxContent)
    objLightboxContent.innerHTML = '';

  // make select boxes visible
  selects = document.getElementsByTagName("select");
  for (i = 0; i != selects.length; i++)
    selects[i].style.visibility = "visible";

}


//
// lightboxSetPos()
//
function lightboxSetPos(x, y) {

	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');

	if (objLightbox) {
    objLightbox.style.left = (x < 0) ? "0px" : x + "px";
    objLightbox.style.top = (y < 0) ? "0px" : y + "px";
  }

  // Update the overlay height as the lightbox might have increased the overall page height.
  arrayPageSize = lightboxGetPageSize();
	if (objOverlay) {
    objOverlay.style.width = (arrayPageSize[0] + '');
    objOverlay.style.height = (arrayPageSize[1] + '');
  }

}


//
// lightboxSetPosX()
//
function lightboxSetPosX(x) {

	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');

	if (objLightbox)
    objLightbox.style.left = (x < 0) ? "0px" : x + "px";

  // Update the overlay height as the lightbox might have increased the overall page height.
  arrayPageSize = lightboxGetPageSize();
	if (objOverlay) {
    objOverlay.style.width = (arrayPageSize[0] + '');
    objOverlay.style.height = (arrayPageSize[1] + '');
  }

}


//
// lightboxSetPosY()
//
function lightboxSetPosY(y) {

	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');

  y = adjustTopForAffiliates(y);

	if (objLightbox)
    objLightbox.style.top = (y < 0) ? "0px" : y + "px";

  // Update the overlay height as the lightbox might have increased the overall page height.
  arrayPageSize = lightboxGetPageSize();
	if (objOverlay) {
    objOverlay.style.width = (arrayPageSize[0] + '');
    objOverlay.style.height = (arrayPageSize[1] + '');
  }

}


//
// lightboxSetPosRelativeMouse()
//
function lightboxSetPosRelativeMouse(x, y) {
  lightboxSetPos(mx + x, my + y);

}


//
// lightboxInit()
// Adds the following to the top of the body:
// <div id="overlay"></div>
// <div id="lightbox">
//   <div id="lightboxContent"></div>
// </div>
//
function lightboxInit() {

	var objBody = document.getElementsByTagName("body").item(0);
	
  if (!document.getElementById("overlay")) {
    // create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
    var objOverlay = document.createElement("div");
    objOverlay.setAttribute('id','overlay');
    //objOverlay.onclick = function () { lightboxHide(); return false; }
    objOverlay.style.display = 'none';
    objOverlay.style.position = 'absolute';
    objOverlay.style.top = '0';
    objOverlay.style.left = '0';
    objOverlay.style.zIndex = '900';
    objBody.insertBefore(objOverlay, objBody.firstChild);
	}

  if (!document.getElementById("lightbox")) {
    // create lightbox div, same note about styles as above
    var objLightbox = document.createElement("div");
    objLightbox.setAttribute('id','lightbox');
    objLightbox.style.display = 'none';
    objLightbox.style.position = 'absolute';
    objLightbox.style.zIndex = '1000';	
    objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	}
	
  if (!document.getElementById("lightboxContent")) {
    // create lightbox content div
    var objLightboxContent = document.createElement("div");
    objLightboxContent.setAttribute('id','lightboxContent');
    objLightboxContent.style.position = 'static';
    objLightboxContent.style.zIndex = '2';
    objLightboxContent.style.display = 'block';
    objLightbox.appendChild(objLightboxContent);
  }
	
}

function showLicenceAgreement(width, btnId, agreeAction, disagreeAction) {
  var disagreeBtn = createJSBtn(btnId+"_disagree", disagreeAction, "Disagree");
  var agreeBtn = createJSBtn(btnId+"_agree", agreeAction, "Agree", "account");
  
  var contentTest = "<table cellspacing=15 cellpadding=0 border=0>";
  contentTest += "<tr><td colspan=2>"+licenceText+"</td></tr><tr>";
  contentTest += "<td width='50%' align=center>"+disagreeBtn+"</td>";
  contentTest += "<td width='50%' align=center>"+agreeBtn+"</td></tr></table>";
  
	lightboxInit();
	lightboxShow(500,licenceTitle,contentTest);
}

function adjustTopForAffiliates(y) {
	var contentDiv = document.getElementById('contentDiv');

  if (contentDiv && contentDiv.offsetTop > 100)
    y = contentDiv.offsetTop - 100 + y;
  return y;
}

