/**
 * A base library for Shadowbox used as a standalone (without another base
 * library/adapter combination).
 *
 * This file is part of Shadowbox.
 *
 * Shadowbox is an online media viewer application that supports all of the
 * web's most popular media publishing formats. Shadowbox is written entirely
 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
 * authors can showcase a wide assortment of media in all major browsers without
 * navigating users away from the linking page.
 *
 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
 * Noncommercial-Share Alike license. This means that it is absolutely free
 * for personal, noncommercial use provided that you 1) make attribution to the
 * author and 2) release any derivative work under the same or a similar
 * license.
 *
 * If you wish to use Shadowbox for commercial purposes, licensing information
 * can be found at http://mjijackson.com/shadowbox/.
 *
 * @author      Michael J. I. Jackson <mjijackson@gmail.com>
 * @copyright   2007-2008 Michael J. I. Jackson
 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/
 * @version     SVN: $Id: shadowbox-base.js 103 2008-06-27 06:19:21Z mjijackson $
 */

// create the Shadowbox object first
var Shadowbox={};Shadowbox.lib=function(){var styleCache={};var camelRe=/(-[a-z])/gi;var camelFn=function(m,a){return a.charAt(1).toUpperCase()};var toCamel=function(style){var camel;if(!(camel=styleCache[style])){camel=styleCache[style]=style.replace(camelRe,camelFn)}return camel};var view=document.defaultView;var alphaRe=/alpha\([^\)]*\)/gi;var setOpacity=function(el,opacity){var s=el.style;if(window.ActiveXObject){s.zoom=1;s.filter=(s.filter||'').replace(alphaRe,'')+(opacity==1?'':' alpha(opacity='+(opacity*100)+')')}else{s.opacity=opacity}};return{adapter:'standalone',getStyle:function(){return view&&view.getComputedStyle?function(el,style){var v,cs,camel;if(style=='float')style='cssFloat';if(v=el.style[style])return v;if(cs=view.getComputedStyle(el,'')){return cs[toCamel(style)]}return null}:function(el,style){var v,cs,camel;if(style=='opacity'){if(typeof el.style.filter=='string'){var m=el.style.filter.match(/alpha\(opacity=(.+)\)/i);if(m){var fv=parseFloat(m[1]);if(!isNaN(fv))return(fv?fv/100:0)}}return 1}else if(style=='float'){style='styleFloat'}var camel=toCamel(style);if(v=el.style[camel])return v;if(cs=el.currentStyle)return cs[camel];return null}}(),setStyle:function(el,style,value){if(typeof style=='string'){var camel=toCamel(style);if(camel=='opacity'){setOpacity(el,value)}else{el.style[camel]=value}}else{for(var s in style){this.setStyle(el,s,style[s])}}},get:function(el){return typeof el=='string'?document.getElementById(el):el},remove:function(el){el.parentNode.removeChild(el)},getTarget:function(e){var t=e.target?e.target:e.srcElement;return t.nodeType==3?t.parentNode:t},getPageXY:function(e){var x=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var y=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));return[x,y]},preventDefault:function(e){if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}},keyCode:function(e){return e.which?e.which:e.keyCode},addEvent:function(el,name,handler){if(el.addEventListener){el.addEventListener(name,handler,false)}else if(el.attachEvent){el.attachEvent('on'+name,handler)}},removeEvent:function(el,name,handler){if(el.removeEventListener){el.removeEventListener(name,handler,false)}else if(el.detachEvent){el.detachEvent('on'+name,handler)}},append:function(el,html){if(el.insertAdjacentHTML){el.insertAdjacentHTML('BeforeEnd',html)}else if(el.lastChild){var range=el.ownerDocument.createRange();range.setStartAfter(el.lastChild);var frag=range.createContextualFragment(html);el.appendChild(frag)}else{el.innerHTML=html}}}}();