try {
document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}
var lightwindow = Class.create();	
lightwindow.prototype = {
element : null,
contentToFetch : null,
windowActive : false,
dataEffects : [],
dimensions : {
cruft : null,
container : null,
viewport : {
height : null,
width : null,
offsetTop : null,
offsetLeft : null
}
},
pagePosition : {
x : 0,
y : 0
},
pageDimensions : {
width : null,
height : null
},
resizeTo : {
height : null,
heightPercent : null,
width : null,
widthPercent : null,
fixedTop : null,
fixedLeft : null
},
scrollbarOffset : 18,
navigationObservers : {
previous : null,
next : null
},
containerChange : {
height : 0,
width : 0
},
initialize : function(options) {
this.options = Object.extend({
resizeSpeed : 10,
contentOffset : {
height : 20,
width : 20
},
dimensions : {
page : {height : 250, width : 250},
inline : {height : 250, width : 250},
external : {height : 250, width : 250},
titleHeight : 25
},
classNames : {	
standard : 'lightwindow',
action : 'lightwindow_action'
},
fileTypes : {
page : ['htm', 'html', 'php', 'php5', 'phtml', 'thtml']
},
mimeTypes : {
pdf : 'application/pdf',
swf	: 'application/x-shockwave-flash'		
},	
classids : {
swf : 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
},
codebases : {
swf : 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'
},	
viewportPadding : 10,
EOLASFix : 'swf,wmv,fla,flv',
overlay : {
opacity : 0.7,
image : '/img/black.png',
presetImage : '/img/black-70.png'
},
skin : 	{
main : 	'<div id="lightwindow_container" >'+
'<div id="lightwindow_title_bar" >'+
'<div id="lightwindow_title_bar_inner" >'+
'<span id="lightwindow_title_bar_title"></span>'+
'<a id="lightwindow_title_bar_close_link" >stäng</a>'+
'</div>'+
'</div>'+
'<div id="lightwindow_stage" >'+
'<div id="lightwindow_contents" >'+
'</div>'+
'</div>'+
'</div>',	
loading : 	'<div id="lightwindow_loading" >'+
'<img src="/img/ajax-loading.gif" alt="loading" />'+
'<span>Laddar utrop..</span>'+
'<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
'</div>',
iframe : 	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
'<html xmlns="http://www.w3.org/1999/xhtml">'+
'<body>'+
'{body_replace}'+
'</body>'+
'</html>'
},
hideFlash : false,
showTitleBar : true,
animationHandler : false,
navigationHandler : false,
transitionHandler : false,
finalAnimationHandler : false,
galleryAnimationHandler : false,
showGalleryCount : true
}, options || {});
this.duration = ((11-this.options.resizeSpeed)*0.15);
this._setupLinks();
this._getScroll();
this._getPageDimensions();
this._browserDimensions();
this._addLightWindowMarkup(false);
this._setupDimensions(); 
},
activate : function(e, link){		
this._clearWindowContents(true);		
this._addLoadingWindowMarkup();
this._setupWindowElements(link);
this._getScroll();
this._browserDimensions();
this._setupDimensions();
this._displayLightWindow('block', 'hidden');
this._setStatus(true);
this._prepareIE(true);
this._loadWindow();
},
deactivate : function(){
this.windowActive = false;
this.animating = false;
this.element = null;
this._displayLightWindow('none', 'visible');
this._clearWindowContents(false);
var queue = Effect.Queues.get('lightwindowAnimation').each(function(e){e.cancel();});
this._prepareIE(false);
this._setupDimensions();	
},
createWindow : function(element, attributes) {
this._processLink($(element));
},
activateWindow : function(options) {
this.element = Object.extend({
href : null,
title : null,
author : null,
caption : null,
rel : null,
top : null,
left : null,
type : null,
showImages : null,
height : null,
width : null,
loadingAnimation : null,
iframeEmbed : null,
form : null
}, options || {});
this.contentToFetch = this.element.href;
this.windowType = this.element.type ? this.element.type : this._fileType(this.element.href);	
this._clearWindowContents(true);
this._addLoadingWindowMarkup();
this._getScroll();
this._browserDimensions();
this._setupDimensions();
this._displayLightWindow('block', 'hidden');
this._setStatus(true);
this._prepareIE(true);
this._loadWindow();
},
_setupLinks : function() {
var links = $$('.'+this.options.classNames.standard);
links.each(function(link) {
this._processLink(link);
}.bind(this));	
},
_processLink : function(link) {
var url = link.getAttribute('href');
if (url.indexOf('?') > -1) {
url = url.substring(0, url.indexOf('?'));
}
var container = url.substring(url.indexOf('#')+1);
if($(container)) {
$(container).setStyle({
display : 'none'
});
}
Event.observe(link, 'click', this.activate.bindAsEventListener(this, link), false);
link.onclick = function() {return false;};		
},
_setupActions : function() {
var links = $$('#lightwindow_container .'+this.options.classNames.action);
links.each(function(link) {
Event.observe(link, 'click', this[link.getAttribute('rel')].bindAsEventListener(this, link), false);
link.onclick = function() {return false;};
}.bind(this));
},
_addLightWindowMarkup : function(rebuild) {
var overlay = Element.extend(document.createElement('div'));
overlay.setAttribute('id', 'lightwindow_overlay');		
if (Prototype.Browser.Gecko) {
overlay.setStyle({
backgroundImage: 'url('+this.options.overlay.presetImage+')',
backgroundRepeat: 'repeat',
height: this.pageDimensions.height+'px'
});			
} else {
overlay.setStyle({
opacity: this.options.overlay.opacity,
backgroundImage: 'url('+this.options.overlay.image+')',
backgroundRepeat: 'repeat',
height: this.pageDimensions.height+'px'
});
}
var lw = document.createElement('div');
lw.setAttribute('id', 'lightwindow');
lw.innerHTML = this.options.skin.main;
var body = document.getElementsByTagName('body')[0];
body.appendChild(overlay);
body.appendChild(lw);	
if ($('lightwindow_title_bar_close_link')) {
Event.observe('lightwindow_title_bar_close_link', 'click', this.deactivate.bindAsEventListener(this));
$('lightwindow_title_bar_close_link').onclick = function() {return false;};
}
if (Prototype.Browser.IE) {
Event.observe(document, 'mousewheel', this._stopScrolling.bindAsEventListener(this), false);
} else {
Event.observe(window, 'DOMMouseScroll', this._stopScrolling.bindAsEventListener(this), false);
}	
Event.observe(overlay, 'click', this.deactivate.bindAsEventListener(this), false);
overlay.onclick = function() {return false;};
},
_addLoadingWindowMarkup : function() {
$('lightwindow_contents').innerHTML += this.options.skin.loading;
},
_setupWindowElements : function(link) {
this.element = link;
this.element.params = null ? '' : link.getAttribute('params');
this.contentToFetch = this.element.href;
this.windowType = this._getParameter('lw_t') ? this._getParameter('lw_t') : this._fileType(this.contentToFetch);	
},
_clearWindowContents : function(contents) {
if ($('lightwindow_iframe')) {
Element.remove($('lightwindow_iframe'));
}
if (contents) {
$('lightwindow_contents').innerHTML = '';
$('lightwindow_contents').setStyle({
overflow: 'hidden'
});		
}
this.resizeTo.height = null;
this.resizeTo.width = null;
},
_setStatus : function(status) {
this.animating = status;
if (status) {
Element.show('lightwindow_loading');
}
if (!(/MSIE 6./i.test(navigator.userAgent))) {
this._fixedWindow(status);
}
},
_fixedWindow : function(status) {
if (status) {
if (this.windowActive) {
this._getScroll();
$('lightwindow').setStyle({
position: 'absolute',
top: parseFloat($('lightwindow').getStyle('top'))+this.pagePosition.y+'px',
left: parseFloat($('lightwindow').getStyle('left'))+this.pagePosition.x+'px'
});		
} else {
$('lightwindow').setStyle({
position: 'absolute'
});						
}
} else {
if (this.windowActive) {
this._getScroll();
$('lightwindow').setStyle({
position: 'fixed',
top: parseFloat($('lightwindow').getStyle('top'))-this.pagePosition.y+'px',
left: parseFloat($('lightwindow').getStyle('left'))-this.pagePosition.x+'px'
});		
} else {
if ($('lightwindow_iframe')) {
this._browserDimensions();
}
$('lightwindow').setStyle({
position: 'fixed',
top: (parseFloat(this._getParameter('lightwindow_top')) ? parseFloat(this._getParameter('lightwindow_top'))+'px' : this.dimensions.viewport.height/2+'px'),
left: (parseFloat(this._getParameter('lightwindow_left')) ? parseFloat(this._getParameter('lightwindow_left'))+'px' : this.dimensions.viewport.width/2+'px')
});
}
}
},
_prepareIE : function(setup) {
if (Prototype.Browser.IE) {
var height, overflowX, overflowY;
if (setup) { 
var height = '100%';
} else {
var height = 'auto';
}
var body = document.getElementsByTagName('body')[0];
var html = document.getElementsByTagName('html')[0];
html.style.height = body.style.height = height;
}
},
_stopScrolling : function(e) {
if (this.animating) {
if (e.preventDefault) {
e.preventDefault();
}
e.returnValue = false;		
}
},
_getScroll : function(){
if(typeof(window.pageYOffset) == 'number') {
this.pagePosition.x = window.pageXOffset;
this.pagePosition.y = window.pageYOffset;
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
this.pagePosition.x = document.body.scrollLeft;
this.pagePosition.y = document.body.scrollTop;
} else if(document.documentElement) {
this.pagePosition.x = document.documentElement.scrollLeft;
this.pagePosition.y = document.documentElement.scrollTop;
}
},
_setScroll : function(x, y) {
document.documentElement.scrollLeft = x; 
document.documentElement.scrollTop = y; 
},
_getPageDimensions : function() {
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){ 
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { 
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {	
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { 
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { 
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}	
if(yScroll < windowHeight){
this.pageDimensions.height = windowHeight;
} else { 
this.pageDimensions.height = yScroll;
}
if(xScroll < windowWidth){	
this.pageDimensions.width = windowWidth;
} else {
this.pageDimensions.width = xScroll;
}
},
_displayLightWindow : function(display, visibility) {
$('lightwindow_overlay').style.display = $('lightwindow').style.display = $('lightwindow_container').style.display = display;	
$('lightwindow_overlay').style.visibility = $('lightwindow').style.visibility = $('lightwindow_container').style.visibility = visibility;
},
_setupDimensions : function() {
var originalHeight, originalWidth;
switch (this.windowType) {
case 'page' :
originalHeight = this.options.dimensions.page.height;
originalWidth = this.options.dimensions.page.width;
break;
case 'external' : 
originalHeight = this.options.dimensions.external.height;
originalWidth = this.options.dimensions.external.width;
break;
case 'inline' :
originalHeight = this.options.dimensions.inline.height;
originalWidth = this.options.dimensions.inline.width;
break;
default :
originalHeight = this.options.dimensions.page.height;
originalWidth = this.options.dimensions.page.width;
break;
}
var offsetHeight = this._getParameter('lightwindow_top') ? parseFloat(this._getParameter('lightwindow_top'))+this.pagePosition.y : this.dimensions.viewport.height/2+this.pagePosition.y;
var offsetWidth = this._getParameter('lightwindow_left') ? parseFloat(this._getParameter('lightwindow_left'))+this.pagePosition.x : this.dimensions.viewport.width/2+this.pagePosition.x;
$('lightwindow').setStyle({
top: offsetHeight+'px',
left: offsetWidth+'px'
});
$('lightwindow_container').setStyle({
height: originalHeight+'px',
width: originalWidth+'px',
left: -(originalWidth/2)+'px',
top: -(originalHeight/2)+'px'
});
$('lightwindow_contents').setStyle({
height: originalHeight+'px',
width: originalWidth+'px'
});
},
_fileType : function(url) {
if (url.indexOf('#') > -1 && (document.domain == this._getDomain(url))) return 'inline';		
if (url.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
var type = 'unknown';
var page = new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$", "i");
if (document.domain != this._getDomain(url)) type = 'external';
if (type == 'external') return type;
if (page.test(url) || url.substr((url.length-1), url.length) == '/') type = 'page';
return type;
},
_fileExtension : function(url) {
if (url.indexOf('?') > -1) {
url = url.substring(0, url.indexOf('?'));
}
var extenstion = '';
for (var x = (url.length-1); x > -1; x--) {
if (url.charAt(x) == '.') {
return extenstion;
}
extenstion = url.charAt(x)+extenstion;
}
},
_getDomain : function(url) {    
var leadSlashes = url.indexOf('//');
var domainStart = leadSlashes+2;
var withoutResource = url.substring(domainStart, url.length);
var nextSlash = withoutResource.indexOf('/');
var domain = withoutResource.substring(0, nextSlash);
if (domain.indexOf(':') > -1){
var portColon = domain.indexOf(':');
domain = domain.substring(0, portColon);
}
return domain;
},
_getParameter : function(parameter, parameters) {
if (!this.element) return false;
if (parameter == 'lightwindow_top' && this.element.top) {
return unescape(this.element.top);
} else if (parameter == 'lightwindow_left' && this.element.left) {
return unescape(this.element.left);
} else if (parameter == 'lw_t' && this.element.type) {
return unescape(this.element.type);
} else if (parameter == 'lightwindow_show_images' && this.element.showImages) {
return unescape(this.element.showImages);
} else if (parameter == 'lw_h' && this.element.height) {
return unescape(this.element.height);
} else if (parameter == 'lw_w' && this.element.width) {
return unescape(this.element.width);
} else if (parameter == 'lightwindow_loading_animation' && this.element.loadingAnimation) {
return unescape(this.element.loadingAnimation);
} else if (parameter == 'lightwindow_iframe_embed' && this.element.iframeEmbed) {
return unescape(this.element.iframeEmbed);
} else if (parameter == 'lightwindow_form' && this.element.form) {
return unescape(this.element.form);
} else {
if (!parameters) {
if (this.element.params) parameters = this.element.params;
else return;
}
var value;
var parameterArray = parameters.split(',');
var compareString = parameter+'=';
var compareLength = compareString.length;
for (var i = 0; i < parameterArray.length; i++) {
if (parameterArray[i].substr(0, compareLength) == compareString) {
var currentParameter = parameterArray[i].split('=');
value = currentParameter[1];
break;
}
}
if (!value) return false;
else return unescape(value);
}
},
_browserDimensions : function() {
if (Prototype.Browser.IE) {
this.dimensions.viewport.height = document.documentElement.clientHeight;
this.dimensions.viewport.width = document.documentElement.clientWidth;   
} else {
this.dimensions.viewport.height = window.innerHeight;
this.dimensions.viewport.width = document.width || document.body.offsetWidth;
}
},
_getScrollerWidth : function() {
var scrollDiv = Element.extend(document.createElement('div'));
scrollDiv.setAttribute('id', 'lightwindow_scroll_div');
scrollDiv.setStyle({
position: 'absolute',
top: '-10000px',
left: '-10000px',
width: '100px',
height: '100px',
overflow: 'hidden'
});
var contentDiv = Element.extend(document.createElement('div'));
contentDiv.setAttribute('id', 'lightwindow_content_scroll_div');
contentDiv.setStyle({
width: '100%',
height: '200px'
});
scrollDiv.appendChild(contentDiv);
var body = document.getElementsByTagName('body')[0];
body.appendChild(scrollDiv);
var noScroll = $('lightwindow_content_scroll_div').offsetWidth;
scrollDiv.style.overflow = 'auto';
var withScroll = $('lightwindow_content_scroll_div').offsetWidth;
Element.remove($('lightwindow_scroll_div'));
this.scrollbarOffset = noScroll-withScroll;
},
_addParamToObject : function(name, value, object, id) {
var param = document.createElement('param');
param.setAttribute('value', value);
param.setAttribute('name', name);
if (id) {
param.setAttribute('id', id);
}
object.appendChild(param);
return object;
},
_outerHTML : function(object) {
if (Prototype.Browser.IE) {
return object.outerHTML;
} else {
var clone = object.cloneNode(true);
var cloneDiv = document.createElement('div');
cloneDiv.appendChild(clone);
return cloneDiv.innerHTML;
}
},
_convertToMarkup : function(object, closeTag) {
var markup = this._outerHTML(object).replace('</'+closeTag+'>', '');
if (Prototype.Browser.IE) {
for (var i = 0; i < object.childNodes.length; i++){
markup += this._outerHTML(object.childNodes[i]);
}
markup += '</'+closeTag+'>';
}
return markup;
},
_appendObject : function(object, closeTag, appendTo) {
if (Prototype.Browser.IE) {
appendTo.innerHTML += this._convertToMarkup(object, closeTag);
if (this.options.EOLASFix.indexOf(this._fileType(this.element.href)) > -1) {
var objectElements = document.getElementsByTagName('object');
for (var i = 0; i < objectElements.length; i++) {
if (objectElements[i].getAttribute("data")) objectElements[i].removeAttribute('data');
objectElements[i].outerHTML = objectElements[i].outerHTML;
objectElements[i].style.visibility = "visible";
}
}
} else {
appendTo.appendChild(object);	
}	
},
_appendIframe : function(scroll) {
var iframe = document.createElement('iframe');
iframe.setAttribute('id', 'lightwindow_iframe');
iframe.setAttribute('name', 'lightwindow_iframe');
iframe.setAttribute('src', 'about:blank');
iframe.setAttribute('height', '100%');
iframe.setAttribute('width', '100%');
iframe.setAttribute('frameborder', '0');
iframe.setAttribute('marginwidth', '0');
iframe.setAttribute('marginheight', '0');
iframe.setAttribute('scrolling', scroll);	

this._appendObject(iframe, 'iframe', $('lightwindow_contents'));
},
_writeToIframe : function(content) {
var template = this.options.skin.iframe;
template = template.replace('{body_replace}', content); 
if ($('lightwindow_iframe').contentWindow){
$('lightwindow_iframe').contentWindow.document.open();
$('lightwindow_iframe').contentWindow.document.write(template);
$('lightwindow_iframe').contentWindow.document.close();
} else {
$('lightwindow_iframe').contentDocument.open();
$('lightwindow_iframe').contentDocument.write(template);
$('lightwindow_iframe').contentDocument.close();
}
},
_loadWindow : function() {
switch (this.windowType) {
case 'external' :		
this._appendIframe('auto');
this.resizeTo.height = this.dimensions.viewport.height;
this.resizeTo.width = this.dimensions.viewport.width;	
this._processWindow();
break;
case 'page' :	
var newAJAX = new Ajax.Request(
this.contentToFetch, {
method: 'get', 
parameters: '', 
onComplete: function(response) {
$('lightwindow_contents').innerHTML += response.responseText;
this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
this._processWindow();
}.bind(this)
}
);
break;
case 'inline' : 
var content = this.contentToFetch;
if (content.indexOf('?') > -1) {
content = content.substring(0, content.indexOf('?'));
}
content = content.substring(content.indexOf('#')+1);
new Insertion.Top($('lightwindow_contents'), $(content).innerHTML);
this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);		
this._processWindow();
break;
default : 
throw("Page Type could not be determined, please amend this lightwindow URL "+this.contentToFetch);
break;
}
},
_resizeWindowToFit : function() {
if (this.resizeTo.height+this.dimensions.cruft.height > this.dimensions.viewport.height) {
var heightRatio = this.resizeTo.height/this.resizeTo.width;
this.resizeTo.height = this.dimensions.viewport.height-this.dimensions.cruft.height-(2*this.options.viewportPadding);
if (this.windowType == 'image') {
this.resizeTo.width = this.resizeTo.height/heightRatio;
$('lightwindow_data_slide_inner').setStyle({
width: this.resizeTo.width+'px'
});			
}
} 
if (this.resizeTo.width+this.dimensions.cruft.width > this.dimensions.viewport.width) {
var widthRatio = this.resizeTo.width/this.resizeTo.height;
this.resizeTo.width = this.dimensions.viewport.width-2*this.dimensions.cruft.width-(2*this.options.viewportPadding);
if (this.windowType == 'image') {
this.resizeTo.height = this.resizeTo.width/widthRatio;
$('lightwindow_data_slide_inner').setStyle({
height: this.resizeTo.height+'px'
});
}
}
},
_presetWindowSize : function() {
if (this._getParameter('lw_h')) {
this.resizeTo.height = parseFloat(this._getParameter('lw_h'));
}
if (this._getParameter('lw_w')) {
this.resizeTo.width = parseFloat(this._getParameter('lw_w'));
}
},
_processWindow : function() {
this.dimensions.dataEffects = [];
$('lightwindow_title_bar_title').innerHTML = '';
var originalContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
$('lightwindow_container').setStyle({
height: 'auto',
width: $('lightwindow_container').getWidth()+this.options.contentOffset.width-(this.windowActive ? this.options.contentOffset.width : 0)+'px'
});
var newContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
this.containerChange = {height: originalContainerDimensions.height-newContainerDimensions.height, width: originalContainerDimensions.width-newContainerDimensions.width};
this.dimensions.container = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
this.dimensions.cruft = {height: this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.options.contentOffset.height, width: this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.options.contentOffset.width};
this._presetWindowSize();
this._resizeWindowToFit();
if (!this.windowActive) {
$('lightwindow_container').setStyle({
left: -(this.dimensions.container.width/2)+'px',
top: -(this.dimensions.container.height/2)+'px'
});
}
$('lightwindow_container').setStyle({
height: this.dimensions.container.height+'px',
width: this.dimensions.container.width+'px'
});
this._displayLightWindow('block', 'visible');
this._animateLightWindow();
},
_animateLightWindow : function() {
if (this.options.animationHandler) {
this.options.animationHandler().bind(this);
} else {
this._defaultAnimationHandler();
}
},
_handleNavigation : function(display) {
if (this.options.navigationHandler) {
this.options.navigationHandler().bind(this, display);
} else {
}
},
_handleTransition : function() {
if (this.options.transitionHandler) {
this.options.transitionHandler().bind(this);
} else {
this._defaultTransitionHandler();
}
},
//
//  Handle the finish of the window animation
// 
_handleFinalWindowAnimation : function(delay) {
if (this.options.finalAnimationHandler) {
this.options.finalAnimationHandler().bind(this, delay);
} else {
this._defaultfinalWindowAnimationHandler(delay);
}		
},
_defaultAnimationHandler : function() {	
if (this.element.caption || this.element.author) {
$('lightwindow_data_slide').setStyle({
display: 'none',
width: 'auto'
});
this.dimensions.dataEffects.push(
new Effect.SlideDown('lightwindow_data_slide', {sync: true}),
new Effect.Appear('lightwindow_data_slide', {sync: true, from: 0.0, to: 1.0})
);
}
$('lightwindow_title_bar_inner').setStyle({
height: '0px',
marginTop: this.options.dimensions.titleHeight+'px'
});
this.dimensions.dataEffects.push(
new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: this.options.dimensions.titleHeight+'px', marginTop: '0px'}}),
new Effect.Appear('lightwindow_title_bar_inner', {sync: true, from: 0.0, to: 1.0})
);		
var resized = false;
var ratio = this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.resizeTo.width+this.options.contentOffset.width;
if (ratio != $('lightwindow_container').getWidth()) {
new Effect.Parallel([
new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.width/$('lightwindow_contents').getWidth()), {scaleFrom: 100*($('lightwindow_contents').getWidth()/($('lightwindow_contents').getWidth()+(this.options.contentOffset.width))), sync: true,  scaleY: false, scaleContent: false}),
new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.width)), {sync: true, scaleY: false, scaleFromCenter: true, scaleContent: false})
], {
duration: this.duration, 
delay: 0.25,
queue: {position: 'end', scope: 'lightwindowAnimation'}
}
);		
}
ratio = this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.resizeTo.height+this.options.contentOffset.height;
if (ratio != $('lightwindow_container').getHeight()) {
new Effect.Parallel([
new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.height/$('lightwindow_contents').getHeight()), {scaleFrom: 100*($('lightwindow_contents').getHeight()/($('lightwindow_contents').getHeight()+(this.options.contentOffset.height))), sync: true, scaleX: false, scaleContent: false}),
new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.height)), {sync: true, scaleX: false, scaleFromCenter: true, scaleContent: false})
], {
duration: this.duration, 
afterFinish: function() {				
if (this.dimensions.dataEffects.length > 0) {
new Effect.Parallel(this.dimensions.dataEffects, {
duration: this.duration,
afterFinish: function() {
this._finishWindow();
}.bind(this),
queue: {position: 'end', scope: 'lightwindowAnimation'} 
}
);
}
}.bind(this), 
queue: {position: 'end', scope: 'lightwindowAnimation'} 
}
);
resized = true;
}
if (!resized && this.dimensions.dataEffects.length > 0) {	
new Effect.Parallel(this.dimensions.dataEffects, {
duration: this.duration,
beforeStart: function() {
if (this.containerChange.height != 0 || this.containerChange.width != 0) {
new Effect.MoveBy('lightwindow_container', this.containerChange.height, this.containerChange.width, {transition: Effect.Transitions.sinoidal});
}
}.bind(this),			
afterFinish: function() {
this._finishWindow();
}.bind(this),
queue: {position: 'end', scope: 'lightwindowAnimation'} 
}
);
}			
},
_defaultfinalWindowAnimationHandler : function(delay) {
if (this._getParameter('lightwindow_loading_animation')) {	
Element.hide('lightwindow_loading');
this._setStatus(false);
} else {
Effect.Fade('lightwindow_loading', {
duration: 0.75,
delay: 1.0, 
afterFinish: function() {
if (this.windowType != 'external') {
$('lightwindow_contents').setStyle({
overflow: 'auto'
});
}
this._setStatus(false);
}.bind(this),
queue: {position: 'end', scope: 'lightwindowAnimation'}
});
}
},
_defaultTransitionHandler : function() {
this.dimensions.dataEffects = [];
if ($('lightwindow_data_slide').getStyle('display') != 'none') {
this.dimensions.dataEffects.push(
new Effect.SlideUp('lightwindow_data_slide', {sync: true}),
new Effect.Fade('lightwindow_data_slide', {sync: true, from: 1.0, to: 0.0})
);
}
this.dimensions.dataEffects.push(
new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: '0px', marginTop: this.options.dimensions.titleHeight+'px'}}),
new Effect.Fade('lightwindow_title_bar_inner', {sync: true, from: 1.0, to: 0.0})
);
new Effect.Parallel(this.dimensions.dataEffects, {
duration: this.duration,
afterFinish: function() {
this._loadWindow();
}.bind(this),
queue: {position: 'end', scope: 'lightwindowAnimation'} 
}
);	
},
_finishWindow : function() {
if (this.windowType == 'external') {
$('lightwindow_iframe').setAttribute('src', this.element.href);
this._handleFinalWindowAnimation(1);	
} else {
this._handleFinalWindowAnimation(0);
}
this._setupActions();
}
}
Event.observe(window, 'load', lightwindowInit, false);
var myLightWindow = null;
function lightwindowInit() {
myLightWindow = new lightwindow();
}
