/*
* Smoothbox v20080623 by Boris Popoff (http://gueschla.com)
* To be used with mootools 1.2
*
* Based on Cody Lindley's Thickbox, MIT License
*
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
// on page load call TBEX_init
window.addEvent('domready', TBEX_init);
// prevent javascript error before the content has loaded
TBEX_WIDTH = 0;
TBEX_HEIGHT = 0;
var TBEX_doneOnce = 0;
var TBEX_closeCallback = null;
// add smoothbox to href elements that have a class of .smoothbox
function TBEX_init(){
$$("a.smoothboxex").each(function(el){el.onclick=TBEX_bind});
}
function TBEX_bind(event){
var event = new Event(event);
// stop default behaviour
event.preventDefault();
// remove click border
this.blur();
// get caption: either title or name attribute
var caption = this.title || this.name || "";
// get rel attribute for image groups
var group = this.rel || false;
// display the box for the elements href
TBEX_show(caption, this.href, group);
this.onclick = TBEX_bind;
return false;
}
// called when the user clicks on a smoothbox link
function TBEX_show(caption, url, rel, loading, disable_close, close_callback) {
// set default closing mechanism
if(!disable_close) { disable_close = 0; }
// set close callback
if(close_callback) {
TBEX_closeCallback = close_callback;
} else {
TBEX_closeCallback = null;
}
// create iframe, overlay and box if non-existent
if (!$("TBEX_overlay")) {
new Element('div').setProperty('id', 'TBEX_overlay').inject(document.body);
$('TBEX_overlay').setOpacity(0.6);
}
if (!$("TBEX_window")) {
new Element('div').setProperty('id', 'TBEX_window').inject(document.body);
$('TBEX_window').setOpacity(0);
}
else
{
$('TBEX_window').dispose();
// SEMODS also kill TB
if($('TB_window')) {
$('TB_window').dispose();
}
new Element('div').setProperty('id', 'TBEX_window').inject(document.body);
$('TBEX_window').setOpacity(0);
}
if (!$("TBEX_load")) {
new Element('div').setProperty('id', 'TBEX_load').inject(document.body);
$('TBEX_load').innerHTML = "
";
}
//$('TBEX_load').show();
$('TBEX_load').setStyle('display','block');
//document.getElementByID('TBEX_load').style.display = "";
if(disable_close == 0) { $("TBEX_overlay").onclick=TBEX_remove; } else { $("TBEX_overlay").onclick = ''; }
//window.onscroll = TBEX_position;
// check if a query string is involved
var baseURL = url.match(/(.+)?/)[1] || url;
// CODE TO SHOW IFRAME
var queryString = url.match(/\?(.+)/)[1];
var params = TBEX_parseQuery(queryString);
// autosize - fullscreen
if(!params['width'] || !params['height']) {
// TBEX_HEIGHT = (document.all?document.body.parentNode.clientHeight:window.innerHeight) - 20;
TBEX_HEIGHT = (document.all?document.documentElement.clientHeight:window.innerHeight) - 40;
TBEX_WIDTH = (document.all?document.body.clientWidth:window.innerWidth) - 40;
} else {
TBEX_WIDTH = (params['width'] * 1) + 30;
TBEX_HEIGHT = (params['height'] * 1) + 40;
}
var ajaxContentW = TBEX_WIDTH - 30, ajaxContentH = TBEX_HEIGHT - 45;
if (url.indexOf('TBEX_iframe') != -1) {
urlNoQuery = url.split('TBEX_');
$("TBEX_window").innerHTML += "