
// JAVASCRIPT JE CASE-SENSITIVE!

 var month = new Array;
 
 var tz = -60;  // Central European Standard (Winter) Time = GMT + 1 hour
 var msie = navigator.userAgent.indexOf("MSIE");
 var frmSize = 21;
 var now = new Date();
 var nowL = new Date();
 var TZL = nowL.getTimezoneOffset(); // = what browser thinks is TZ; but
        // MS IE version 3 gives wrong sign of TZ
    // MSIE 4.0b2 shifts TZ by -1 hour

 // This piece of js code should give the Central European time anywhere on Earth
 // To adapt to another time zone adjust the value of variable tz,
 //   and modify the daylight/standard time switching if necessary

 if(msie > -1) {
    if(navigator.userAgent.substring(msie+5,msie+6) <= 3) TZL *= -1;
    else if(navigator.userAgent.indexOf("4.0b2") > -1) TZL += 60;
 }
 now.setTime(nowL.getTime() + (TZL - tz) * 60000);
        // Summer/Winter Time switching: last Sunday of March at 2am WT
        //                  last Sunday of October at 3 am ST (2 am WT)
 var H = now.getHours() + now.getMinutes()/60 + now.getSeconds()/3600;
 var M = now.getMonth();
 var d = now.getDate();
 var D = now.getDay();
 if((M>2 ||
     (M==2 && (D==0 && d>24 && H>2 || D==1 && d>25 || D==2 && d>26 ||
               D==3 && d>27 || D==4 && d>28 || D==5 && d>29 || D==6 && d==31)
     )) &&
    (M<9 ||
     (M==9 && (d<25 || D==0 && d>24 && H<2 || D==1 && d<26 || D==2 && d<27 ||
               D==3 && d<28 || D==4 && d<29 || D==5 && d<30 || D==6 && d<31)
     ))) tz = tz - 60;  // Daytime Saving Time - Letní čas
 var offset = (TZL - tz) * 60000;   

var ti, tiOld, delay = 950;

var lpjsBgMidi;
var lpjsLoaded = false;
var lpjsWriteEnabled = true;
var lpjsHostDir='a';

var himd = "";
var hims = new Array();

function himdir (dir)
{
		if (document.images) himd = dir+'/';
}

function him (name, ext)
{
	if (document.images)
	{
		hims[name] = new Image ();
		hims[name].src = himd+name+'.'+ext;
		hims[name+'_hover'] = new Image ();
		hims[name+'_hover'].src = himd+name+'_hover.'+ext;
	}
}

function himf (imagename,objectsrc)
{
	if (document.images) document.images[imagename].src = hims[objectsrc].src;
}

function lpjsForm (f, e)
{
	var form = document.getElementById (f);
	
	if (!form) return form;
	
// if (form[0].elements) window.alert ("Invalid form "+f);
	
	if (e) return form[e];	
	else return form;
}

function lpjsDoubleClickup ()
{
	window.scrollTo (0,0);
}

function lpjsAddBookmark (url, title, errorstr)
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else // if(window.opera && window.print) 
		{ // Opera Hotlist
		window.alert (errorstr); }
 }

function lpjsOpenEmailWindow (address)
{
	var mywin = window.open (address, 'email','width=600,height=400,scrollbars=yes,resizable=yes,menubar=0');
	if (mywin) mywin.focus (); 
}

function lpjsMMMSingle (url)
{
	var iMyWidth;
	var iMyHeight;
	var width=600;
	var height=400;
	
	if (url.href) url = url.href;
	// gets top and left positions based on user's resolution so hint window is centered.
	iMyWidth = (window.screen.width/2) - (width/2 + 10); // half the screen width minus half the new window width (plus 5 pixel borders).
	iMyHeight = (window.screen.height/2) - (height/2 + 50); // half the screen height minus half the new window height (plus title and status bars).
	iMyWidth = window.screen.width - width - 50;
	iMyHeight = window.screen.height - height - 77;
	var winPopup = window.open(url,'poselstvi',"width="+width+",height="+height+",scrollbars=yes,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight); // menubar=yes,toolbar=no,
	if (winPopup) winPopup.focus();		
}

// http://www.jakpsatweb.cz/javascript/window.open.html

function lpjsPopup (myurl, width, height)
{
	if (width == 0)
	{
		width = window.screen.width - 50;
		if (width > 790)
			width = 790; 
	}
	if (height == 0)
	{
		height = window.screen.height - 200;
	}
	var left = (window.screen.width/2) - (width/2 + 10); // half the screen width minus half the new window width (plus 5 pixel borders).
	var top = (window.screen.height/2) - (height/2 + 100);

	var popupWin = window.open (myurl,'popupwin',"width="+width+",height="+height+",scrollbars=yes,resizable=yes,location=yes,directories=no,status=yes,copyhistory=no,menubar=1,toolbar=1,top="+top+",left="+left);
	if (popupWin) popupWin.focus();
}


function lpjsSetFindDate ()
{
	var f = lpjsForm ('f-find');
	if (f)
	{
		var state = !f.checkDate.checked;
	
		f.fromDay.disabled = state;
		f.fromMonth.disabled = state;
		f.fromYear.disabled = state;
		f.toDay.disabled = state;
		f.toMonth.disabled = state;
		f.toYear.disabled = state;
	}
}

function _lpjsInitFindDate ()
{
	if (lpjsForm ('f-find', 'fromDay')) lpjsSetFindDate ();
}


function lpjsSetHomePage (page, url, errstr)
{
	if (document.all && !window.opera)
	{
		page.style.behavior='url(#default#homepage)';
		page.setHomePage(url);
	}
	else window.alert (errstr);
}

function lpjsClickReturn ()
{
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName;
	if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
		return true; // dont follow link
	else return false; // dont follow link
}


function lpjsInitText ()
{

}


function _lpjsMPrint ()
{
	window.print ();
}


function lpjsInitPrintOnDemand ()
{

}

function lpjsInitPrintStart ()
{
	_lpjsMPrint ();	
}

function lpjsInitIm ()
{
// document.ondblclick=window.print;
}

function lpjsInitIndex ()
{
	
}

function lpjsInitEmail ()
{
	
}

function lpjsInitPda ()
{
	lpjsInitPrint ();	
}


function lpjsItemFocus (id)
{
	var e = document.getElementById (id);
	if (e) e.focus ();
	return e;
}

function lpjsItemSelect (id)
{
	var e = document.getElementById (id);
	if (e)
	{
		e.focus ();
		e.select ();
	}
	return e;
}



function lpjsItemClear (id)
{
	var e = document.getElementById (id);
	if (e)
	{
		e.focus (); 
		e.select ();
		e.value = '';
	}
	return e;
}


function lpjsItemClean (id)
{
	var e = document.getElementById (id); 
	if (e)
	{
		e.value = '';
	}
	return e;	
}


function lpjsItemSet (id, val)
{
	var e = document.getElementById (id);
	if (e)
	{
		e.value = val;
	}
	return e;	
}


function lpjsItemIns (id, s)
{
	var e = document.getElementById (id); 
	if (e)
	{
		e.focus ();
		e.value += s;
	}
	return e;
}

function lpjsHideLayer (number, number2)
{
    e = lpjsItemSet ("code", number + number2);
	e.parentNode.style.position = "absolute";
	e.parentNode.style.left = "-9999px";
	e.tabIndex = "-1";
}


var _lpjsArselEnabledDisabled = false;
var _lpjsNumChecked = 0;
var _lpjsNumTotal = 0;


function _lpjsArSelEnableDisableButton (f,e,c)
{
	var element = lpjsForm (f, e);
	if (element) element.disabled = c;
}


function _lpjsEnableDisableArSel (f, c)
{
	if (_lpjsArselEnabledDisabled != c)
	{
		_lpjsArSelEnableDisableButton (f, 'arSelPrint', c);
		_lpjsArSelEnableDisableButton (f, 'arSelDisplay', c);
		_lpjsArselEnabledDisabled = c;
	}
}


function _lpjsArSelSetup (f, total, count)
{
	_lpjsNumChecked = count; 
	// window.status = _lpjsNumChecked;
	_lpjsEnableDisableArSel (f, !count);
}

function lpjsArSelSetup (f, e, total)
{
	var form = lpjsForm (f);
		_lpjsNumChecked = 0;
	_lpjsNumTotal = total;	
	for (i = 0; i < total; i++)
	{
		if (form[e+'['+i+']'].checked)
			_lpjsNumChecked++;
	}
	// window.status = _lpjsNumChecked;
	_lpjsEnableDisableArSel (f, !_lpjsNumChecked);
}

 
function lpjsArSelSetAll (f, e, total)
{
	var form = lpjsForm (f);
	for (i = 0; i < total; i++)
	{
		form[e+'['+i+']'].checked = true;
	}
	_lpjsArSelSetup (f, total, total);
}


function lpjsArSelClearAll (f, e, total)
{
	var form = lpjsForm (f);
	for (i = 0; i < total; i++)
	{
		form[e+'['+i+']'].checked = false;
	}
	_lpjsArSelSetup (f, total, 0);	
}

function lpjsArSelDetCheckbox (f,e)
{
	var element = lpjsForm (f,e);
	if(element.checked)
	{
		_lpjsNumChecked++;
	}
	else
		_lpjsNumChecked--;
	
	// window.status = _lpjsNumChecked;
	
	_lpjsEnableDisableArSel (f, _lpjsNumChecked <= 0);
}


/*
function votecheck()
{
	with (document.voteForm)
	{
		if (votefor.value != "")
		{ 
			window.alert("Please pick a subject.");
			window.alert (votefor.value);			
			return false;
		}
		else
		{
			return true;
		}
	}
}
*/

function lpjsRandomPopup (path, sid)
{
	var element = lpjsForm ('f-rM', 'count');
	if (sid) sid = '&' +sid; else sid = "";
	if (element)
	{
		url = path + 'message?count=' + element.value + sid;
		lpjsMMMSingle (url);
	}
}


function lpjsSubmitDisable (form)
{    
	var e = lpjsForm (form, 'vote');
	if (e)
	{
		e.disabled = true;	
		e.enabled = false;	
	}
	else window.alert (form);
}

function lpjsSubmitEnable (form)
{   
	var e = lpjsForm (form, 'vote');
	if (e)
	{
		e.disabled = false;	
		e.enabled = true;	
	}
	else window.alert (form);
}


function _lpjsIsEmail (s)
{	
	if (s.indexOf("@") < 1 || s.indexOf("@") != s.lastIndexOf("@") || s.lastIndexOf(".") < s.lastIndexOf("@")+2  || s.lastIndexOf(".") > (s.length-3) || s.lastIndexOf(".") < (s.length-5)) return false;
	else return true;
}

function lpjsWriteIE (s, s2)
{
	if (document.all && !window.opera && lpjsWriteEnabled) document.write (s);
	else if (s2) document.write (s2);	
}


function lpjsWriteDivText(id, text)
{
	var e = document.getElementById (id);
	if (e) 
	{
		e.innerHTML = text;
		// e.text = '';
// window.alert(text);
	}
}


function lpjsWrite (s, id)
{
	if (lpjsWriteEnabled)	
	{
		if (id) lpjsWriteDivText(id, s);
		else document.write (s);
	}
}

var _lpjsValidateBeginStr;
var _lpjsValidateStr="";
var _lpjsValidateForm="";

function lpjsValidateBegin (form, beginstr)
{
	_lpjsValidateForm = form;
	_lpjsValidateBeginStr = beginstr;
	_lpjsValidateStr = "";
}

function lpjsValidateEnd (endstr)
{
	if (_lpjsValidateStr)
	{
		s = _lpjsValidateBeginStr+"\n\n"+_lpjsValidateStr;
		if (endstr && endstr != '') s += "\n\n"+endstr;
		window.alert (s);
		return false;
	}
	return true;
}

function lpjsValidateAppend (text, id)
{
	if (_lpjsValidateStr == "" && id) id.focus ();
	_lpjsValidateStr += "- "+text+"\n";
}

function lpjsValidateField (id, text)
{
	// var val = document.getElementById (id);
	var val = lpjsForm (_lpjsValidateForm, id);
	if (val && lpjsStripTags (val.value) == "") lpjsValidateAppend (text, val);
// if (val.value != "") window.alert (val.value);
	if (!val) window.alert ("Check id "+id);
}


function lpjsValidateEmail (id, text)
{
	// var val = document.getElementById (id);
	var val = lpjsForm (_lpjsValidateForm, id);
	if (val && !_lpjsIsEmail (val.value)) lpjsValidateAppend (text, val);
}



function _lpjsMyFix (s, first)
{
	var res = "";
	var pc = ' ';
	if (!first) first = 1;
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		var code = c.charCodeAt(0);
// if (code > 1000) res += code;
// if (c == '0') window.alert (code); // srdce ¦: 9829, // slunce 0 : 9788
		if (code == 9829) res += "<span id='myHeart'>"+c+"</span>";
		else if (code == 9788) res += "<span id='mySun'>"+c+"</span>";
		else 
		{
			if ((code <= 90 && code >= 65 && pc == '>') || code == 1041 || code == 1052 || code == 1044)
			{
				if (first)
				{
					first++;
					var fixClass = 'myFix';
					if (code > 1000) fixClass = 'myFixSpecial';
					res += "<span class='"+fixClass+"'>"+c+"</span>";
				}
				else
					res += c;
					
				if (c == 'S') first++;
			}
			else 
			{
				res += c;
			}
		}
		pc = c;
	}
	return res;
}

function _lpjsCheckSpace (c)
{
	switch (c)
	{
		case '\t':
		case ' ':
		case '\r':
		case '\n':
			return true;
		default:
			return false;
	}
}

function _lpjsTrim (s)
{
	while (_lpjsCheckSpace (s.charAt(0)))
		s = s.substr(1);
	while (_lpjsCheckSpace (s.charAt(s.length-1)))
		s = s.substr(0,s.length-1);
	return s.toString();
}

function _lpjsOlmFade (elid, colors, fix)
{
	var e = document.getElementById (elid);
	if (e)
	{
		s = _lpjsTrim (e.innerHTML);
		s = gradientstr(s, colors);
		s = _lpjsMyFix (s, fix);
		e.innerHTML = s;
	}
}

 function lpjsSetMonth(i, str)
 {
 	month[i-1] = str;
 }

 function casCE() { 
   nowL = new Date();
   now.setTime(nowL.getTime() + offset);
   var min = now.getMinutes();
   var sec = now.getSeconds();  
   var yer = now.getYear();
   if(yer<2000) yer += 1900;
   mytime = now.getHours() +  ((min < 10) ? ":0" : ":") + min + ((sec < 10) ? ":0" : ":") + sec;
   mydate = now.getDate() + ". " + month[now.getMonth()] + " " + yer;
   ct = document.getElementById ("ClockTime");
   if (ct && ct.innerHTML != mytime) ct.innerHTML = mytime;
   cd = document.getElementById ("ClockDate");
   if (cd && cd.innerHTML != mydate) cd.innerHTML = mydate;
       
    ti = nowL.getTime();
    delay += 1000 - (ti - tiOld);
    tiOld = ti;
    if (ct || cd) Timer = setTimeout("casCE()",delay);
  }


function lpjsInitClock ()
{
   tiOld = nowL.getTime(); setTimeout('casCE()',delay);
}

function lpjsInitOlmIntro ()
{
	_lpjsOlmFade ("olmFader", "E944A7 FFAAAA eeb077 ddbb00");
	_lpjsOlmFade ("olmFader2", "0000ff E944A7 FFAAAA eeb077 ddbb00"); 
	_lpjsOlmFade ("olmFader3", "aaaaaa cccccc");
    lpjsInitClock ();
}

function lpjsInitView ()
{
  lpjsInitToggle();
  
  	_lpjsOlmFade ("olmFader", "FF99FF FFDDDD FFffff FFff77 FFee00");
	_lpjsOlmFade ("olmFader2", "9999FF cc99ff FF99FF ffbbff FFDDff FFffff FFee00");
	_lpjsOlmFade ("olmFader3", "dddddd ffffff"); 
	_lpjsInitFindDate ();	
	if (_lpjsNumTotal) lpjsArSelSetup ('f-m', 'arSel', _lpjsNumTotal);	
    lpjsInitClock ();
}


function lpjsInitToggle ()
{
	if (toggleGetById('toggleOpen'))
	{
				toggleGetById('toggleOpen').onclick = function(){
				toggleDiv(toggleGetById('toggleDiv'));
				}
				/*
				toggleGetById('toggleClose').onclick = function(){
				toggleDiv(toggleGetById('toggleDiv'));
				}*/			
				toggleDiv(toggleGetById('toggleDiv'));
	}
}

function lpjsInitPrint ()
{
	lpjsInitView ();
// document.ondblclick=_lpjsMPrint;
}

function lpjsInitPda ()
{
	lpjsInitToggle();
}

function lpjsLt1OnLoad (run)
{
 	if (document.getElementById('ta'))
	{
		// initEditor ();
	}
	
	lpjsLoaded = true;
	
	OLloaded=1;	
	
	if (typeof start=='function') start();
	
	lpjsItemFocus ('nextImageLink');
}

function lpjsInit (hostDir)
{
	lpjsHostDir = hostDir;	
	// window.alert (lpjsHostDir);
}


function checkKey(e) {
  var code = window.Event ? e.which : event.keyCode;
  var key = String.fromCharCode(code);
  for (var i = 0; i < ar.length; i++) {
    if (key == ar[i].key) location.href = ar[i].url;
  }
}

function htmlescape(str){
    str = str.replace(/&/g, "&amp;" );
    str = str.replace(/</g, "&lt;" );
    str = str.replace(/>/g, "&gt;" );
    return str;
   }


/*
function hotKey(key, url) {
  this.key = key;
  this.url = url;
}

if (window.Event) document.captureEvents(Event.KEYPRESS)
document.onkeypress = checkKey;

var ar = new Array();
ar[ar.length] = new hotKey(10, "http://www.docjs.com/");
ar[ar.length] = new hotKey("m", "http://www.microsoft.com/");
ar[ar.length] = new hotKey("n", "http://www.netscape.com/");
*/


function lpjsFollowLink (a)
{
	if (a.target.length==0) window.location.href=a.href;
}


function lpjsDecodeEmail(mmail)
{
		var str = new String("") + mmail.replace(" zavinac ", "@");
		str = str.replace(/\$/igm, ".");
		return str;
}

function lpjsOpenMailClient(mmail)
{
	var mailto = "mail"+"to"+":";
	if (mmail) document.location = mailto + lpjsDecodeEmail(mmail);
}


function lpjsHighlight(element, color)
{
    element.style.backgroundColor = color;
}

function lpjsSetClassName(element, className)
{
    element.className = className;
}

function lpjsCheckFCKEditorSmileysCount (oEditor, maxCount)
{
	var html=oEditor.FCK.GetHTML();
    var m = html.match(/fckeditor\/editor\/images\/smiley/g); 
    if (m && m.length >= maxCount)
    {
        window.alert("Maximum allowed number of smileys in one post is "+maxCount);
        return false;
    }
    return true;
}

function lpjsStripTags(s)
{
  s=s.replace(/(<br\/?\s*>|<\/p>\s*<p>)/gi,'\n');
  return s.replace(/<\/?[^>]+>/gi,'');
}


function lpjsLinkClick(href)
{
	if (document.images)
	{
		img = new Image (1,1);
		url = lpjsHostDir+'/linkclick?url='+href;
		img.src = url;
// window.alert (url);
	}
	return true;
}


var lpjsArticleFontSize =
(
	{
		Size:		1,
		CookieName: 	"lpjsFontSize=",
		CookieExpire:	120, // days
		ArticleSpot:	"middleBorder",
		LineHeights:	[145, 145, 145],
		Dir: "",
		SetSize:
			
			function(	FontSize)
			{                
				if(!document.getElementById(this.ArticleSpot + "-" + this.Size))
				{
					return;
				}

				if(!FontSize)
				{
					var FontSize = this.GetSize();
					if(FontSize==null)
					{
						FontSize = this.Size;
					}
					else
					{
						this.Size = FontSize;
					}
				}
				else
				{
					document.getElementById(this.ArticleSpot + "-" + this.Size).src = this.Dir+"/icon-size-" + this.Size + ".gif";
					this.Size = FontSize;
				}
				var date = new Date();
				date.setTime(date.getTime()+(this.CookieExpire*24*60*60*1000));
				var expires = "; expires=" + date.toGMTString();
				document.cookie = this.CookieName + FontSize + expires + "; path=/";

				var ArticlePlace = document.getElementById(this.ArticleSpot /*+ "-area"*/);
				if(ArticlePlace)
				{
					ArticlePlace.style.fontSize = ((FontSize-1)*15 + 100) + "%";
					// ArticlePlace.style.lineHeight = this.LineHeights[FontSize-1] + "%";
					document.getElementById(this.ArticleSpot + "-" + FontSize).src = this.Dir+"/icon-size-" + FontSize + "-active.gif";
					
					var ArticlePlaceSec = document.getElementById(this.ArticleSpot+"Sec");
					if(ArticlePlaceSec)	ArticlePlaceSec.style.fontSize = ((FontSize-1)*15 + 100) + "%";			
					
				var ArticlePlaceRest = document.getElementById(this.ArticleSpot+"Rest");
					if(ArticlePlaceRest)	ArticlePlaceRest.style.fontSize = ((FontSize-1)*15 + 100) + "%";								
				}
			},

		GetSize:
			function()
			{
				var ca = document.cookie.split(';');
				for(var i=0;i < ca.length;i++)
				{
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if (c.indexOf(this.CookieName) == 0) return c.substring(this.CookieName.length,c.length);
				}
				return null;
			},

		ClearSize:
			function()
			{
				document.cookie = this.CookieName + "-1" + "; path=/";
			},


		Init:
			function(dir, cookieName, cookieExpire, articleSpot, size)
			{
				this.Dir = lpjsHostDir+dir;
// window.alert(this.Dir);
				if (cookieName) 
				{
// if (cookieName != this.CookieName) ClearSize ();
					this.CookieName = cookieName+'=';
				}
				if (cookieExpire) this.CookieExpire = cookieExpire;
				if (articleSpot) this.ArticleSpot = articleSpot;
				if (size) this.Size = size;
				this.SetSize ();
			}
	}
)
function toggleGetById(id)
{ 
	return document.getElementById(id);
}

function toggleDiv(element)
{ 
	var style = element.style.display;
	var newstyle = (style==='block' || style==='') ? 'none' : 'block'; 
	element.style.display = newstyle;
// element.style.display = 'block'; 
	// toggleGetById('toggleDiv').style.display = 'block'; 

}

/*
<!-- This script has been in the http://www.javascripts.com Javascript Public Library! -->
<!-- Note that though this material may have been in a var depository, certain author copyright restrictions may apply. -->
<SCRIPT language="JavaScript">
<!--
*/

// ------------- g_browser Detector ---------------
// Possible values for g_browser are:
//  "netscape"
//  "opera"     <--(ewww)
//  "msie"      <--(double ewww)
//  "robot"
//  "unknown"
// Possible values for g_version are:
//  any numerical value (3, 2.02, 4.04, etc.)
//  0 if unable to determine

var g_browser = "unknown";
var g_version = 0;

if (navigator.userAgent.indexOf("Opera") >= 0)
 g_browser = "opera";
else if (navigator.userAgent.indexOf("obot") >= 0)
 g_browser = "robot";
else if (navigator.appName.indexOf("etscape") >= 0)
 g_browser = "netscape";
else if (navigator.appName.indexOf("icrosoft") >= 0)
 g_browser = "msie";

g_version = parseFloat(navigator.appVersion);
if (isNaN(g_version)) g_version = 0;
if ((g_browser == "msie")&&(g_version == 2)) g_version = 3;

// ------------------ Gradient Output --------------------
// Syntax for use:

//     gradient(TEXT_STRING_HERE,HEXCODES_STRING_HERE);

//  use in similar way you would use document.write();
//  note, it cannot be used to return a string value.
//  gradient() takes two arguements. the first will
//  be the original pure text string. (no htmlcodes)
//  the second argument is a string of color hexcodes
//  seperated with spaces thru which the text should
//  progress. for example say you wanted to print out
//  the string "color gradient", and you wanted it to
//  progress from blue to red. a color code for blue
//  is 4444FF, and a color code for red is FF4444.
//  taking those two codes, and the original string,
//  somewhere in the body of the document you would
//  write within a <Script> tag the following:
//  gradient("color gradient","4444FF FF4444");
//  if however, you wanted it to progress thru three
//  or more colors, its as simple as adding them to the
//  string of color codes. it is important to remember
//  however that the string must be color HEXCODES, and
//  not merely just color names, (e.x- "red", "yellow")
//  if this seems like too much trouble, then perhaps
//  you should try something simple like ripping off
//  some annoying status bar text scroller. =T
//  one last thing. if you overuse this script, i can
//  pretty much gaurantee people will hate your webpage.
//  the fact is, this javascript is memory intensive. if
//  you overdo it, you're crashing some visitors' browsers.
//  ------------------------------------------------------

// lookup table
var g_tohex = new Array(256);
var ghex = "0123456789ABCDEF";
var g_count = 0;
for (x=0; x<16; x++) {
 for (y=0; y<16; y++) {
 g_tohex[g_count] = ghex.charAt(x) + ghex.charAt(y);
 g_count++;
 }
}

//ColorCode constructor
function ColorCode(hexcode) {
  if (hexcode.length == 7) {
    this.r = parseInt(hexcode.substring(1,3),16);
    this.g = parseInt(hexcode.substring(3,5),16);
    this.b = parseInt(hexcode.substring(5,7),16);
  }
  else if (hexcode.length == 6) {
    this.r = parseInt(hexcode.substring(0,2),16);
    this.g = parseInt(hexcode.substring(2,4),16);
    this.b = parseInt(hexcode.substring(4,6),16);
  }
  else {
    this.r = this.g = this.b = 0;
    alert("Error: ColorCode constructor failed");
  }
  if (isNaN(this.r)||isNaN(this.g)||isNaN(this.b))
    alert("Error: ColorCode constructor failed");
}

// ColorList constructor
function ColorList(hexcodes) {
  var i = 0;
  var c = 0;
  this.codes = new Array(Math.round(hexcodes.length/7));
  while (i < hexcodes.length) {
    if (isNaN(parseInt(hexcodes.substring(i,i+6),16))) ++i;
    else {
      this.codes[c] = new ColorCode(hexcodes.substring(i,i+6));
      i += 7;
      ++c;
    }
  }
  this.len = c;
}

function interpolate (x1, y1, x3, y3, x2) {
  if (x3 == x1) return y1
  else return (x2-x1)*(y3-y1)/(x3-x1) + y1
}

// x=index of letter, y=number of letters, z=number of colors
function lowcolorindex (x, y, z) {
  if (y == 1) return 0
  else return Math.floor( (x*(z-1))/(y-1) )
}

function hicolorindex (x, y, z, low) { 
  if ( low*(y-1) == x*(z-1) ) return low
  else if (y == 1) return 0
  else return Math.floor( (x*(z-1))/(y-1) + 1 )
}

function gradient (thetext,thecolors) {
  if (((g_browser == "netscape")||(g_browser == "msie")||(g_browser == "opera"))&&(g_version>=3.0)) {
    var colors = new ColorList(thecolors);
    var numcolors = colors.len;
    var numchars = thetext.length;
    var rr = 0;
    var gg = 0;
    var bb = 0;
    var lci = 0; //lower color index
    var hci = 0; //high color index
    for (i=0; i<numchars; ++i) {
      lci = lowcolorindex(i, numchars, numcolors);
      hci = hicolorindex(i, numchars, numcolors, lci);
      rr = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].r, hci/(numcolors-1), colors.codes[hci].r, i/(numchars-1)));
      gg = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].g, hci/(numcolors-1), colors.codes[hci].g, i/(numchars-1)));
      bb = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].b, hci/(numcolors-1), colors.codes[hci].b, i/(numchars-1)));
      if (g_browser == "opera") {
        rr = 255 - rr;
        gg = 255 - gg;
        bb = 255 - bb;
      }
        //document.write(thetext.charAt(i).fontcolor(g_tohex[rr]+g_tohex[gg]+g_tohex[bb]));
        document.write ("<span style='color:#"+g_tohex[rr]+g_tohex[gg]+g_tohex[bb]+"'>"+thetext.charAt(i)+"</span>");
    }
  }
  else document.write(thetext); // unrecognized g_browser, better not to attempt anything fancy
}


function gradientstr (thetext,thecolors) {
  if (((g_browser == "netscape")||(g_browser == "msie")||(g_browser == "opera"))&&(g_version>=3.0)) {
    var colors = new ColorList(thecolors);
    var numcolors = colors.len;
    var numchars = thetext.length;
    var rr = 0;
    var gg = 0;
    var bb = 0;
    var lci = 0; //lower color index
    var hci = 0; //high color index
    
    var s="";
    
    for (i=0; i<numchars; ++i) {
      lci = lowcolorindex(i, numchars, numcolors);
      hci = hicolorindex(i, numchars, numcolors, lci);
      rr = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].r, hci/(numcolors-1), colors.codes[hci].r, i/(numchars-1)));
      gg = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].g, hci/(numcolors-1), colors.codes[hci].g, i/(numchars-1)));
      bb = Math.round(interpolate( lci/(numcolors-1), colors.codes[lci].b, hci/(numcolors-1), colors.codes[hci].b, i/(numchars-1)));
//      if (g_browser == "opera") {
    //    rr = 255 - rr;
        //gg = 255 - gg;
        //bb = 255 - bb;
      //}
         //s += thetext.charAt(i).fontcolor(g_tohex[rr]+g_tohex[gg]+g_tohex[bb]);
        s += "<span style='color:#"+g_tohex[rr]+g_tohex[gg]+g_tohex[bb]+"'>"+thetext.charAt(i)+"</span>";
    }
  }
  else s = thetext; // unrecognized g_browser, better not to attempt anything fancy
  
  return s;
}

/*      
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="black" text="white" link="2070FF">


<DIV align=center>
<SCRIPT language="JavaScript">
gradient("always wanted to be a genius?","FF0000 FFFFFF 0000FF");
document.write('<BR>');
gradient("...well...do it, in...","444444 DDDDDD 444444");
document.write('<BR><FONT size=+1><TT><B>');
gradient("snazzy, eyecatching, gradient colors!","FF8888 FFFF88 88FF88 88FFFF 8888FF FF88FF");
document.write('</B></TT></FONT><BR><FONT size=2>');
gradient("but uhm, just be careful not to overdo it","884488 444488 448888 448844 888844 884444");
document.write("</FONT><BR>");
</SCRIPT>
</DIV>
<!-- Simba says Roar. -->

*//************************************************************************************************
* Floatbox v3.23
* November 23, 2008
*
* Copyright (C) 2008 Byron McGregor
* Website: http://randomous.com/tools/floatbox/
* License: Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/)
* This comment block must be retained in all deployments and distributions
*************************************************************************************************/

function Floatbox() {
this.defaultOptions = {

/***** BEGIN OPTIONS CONFIGURATION *****/
// see docs/options.html for detailed descriptions

/*** <General Options> ***/
theme:          'blue'    ,// 'auto'|'black'|'white'|'blue'|'yellow'|'red'|'custom'
padding:         12       ,// pixels
panelPadding:    8        ,// pixels
outerBorder:     1        ,// pixels
innerBorder:     1        ,// pixels
overlayOpacity:  55       ,// 0-100
controlOpacity:  60       ,// 0-100
autoSizeImages:  true     ,// true|false
autoSizeOther:   false    ,// true|false
resizeImages:    true     ,// true|false
resizeOther:     false    ,// true|false
resizeTool:     'both'  ,// 'cursor'|'topleft'|'both'
infoPos:        'bl'      ,// 'tl'|'tc'|'tr'|'bl'|'bc'|'br'
controlPos:     'br'      ,// 'tl'|'tr'|'bl'|'br'
boxLeft:        'auto'    ,// 'auto'|pixels|'[-]xx%'
boxTop:         'auto'    ,// 'auto'|pixels|'[-]xx%'
shadowType:     'drop'    ,// 'drop'|'halo'|'none'
shadowSize:      12       ,// 8|12|16|24
enableDrag:      true     ,// true|false
showCaption:     true     ,// true|false
showItemNumber:  true     ,// true|false
showClose:       true     ,// true|false
hideFlash:       true     ,// true|false
hideJava:        true     ,// true|false
disableScroll:   false    ,// true|false
autoGallery:     true    ,// true|false
preloadAll:      true     ,// true|false
enableCookies:   false    ,// true|false
cookieScope:    'site'    ,// 'site'|'folder'
language:       'auto'    ,// 'auto'|'en'|... (see the languages folder)
graphicsType:   'auto'    ,// 'auto'|'international'|'english'
urlGraphics:    '/include/js/floatbox/graphics/'   ,// change this if you install in another folder
urlLanguages:   '/include/js/floatbox/languages/'  ,// change this if you install in another folder
/*** </General Options> ***/

/*** <Navigation Options> ***/
navType:           'both'    ,// 'overlay'|'button'|'both'|'none'
navOverlayWidth:    35       ,// 0-50
navOverlayPos:      30       ,// 0-100
showNavOverlay:    'always'   ,// 'always'|'once'|'never'
showHints:         'once'    ,// 'always'|'once'|'never'
enableWrap:         true     ,// true|false
enableKeyboardNav:  true     ,// true|false
outsideClickCloses: true     ,// true|false
numIndexLinks:      60        ,// number, -1 = no limit
indexLinksPanel:   'control' ,// 'info'|'control'
showIndexThumbs:    true     ,// true|false
/*** </Navigation Options> ***/

/*** <Animation Options> ***/
doAnimations:         false   ,// true|false
resizeDuration:       1    ,// 0-10
imageFadeDuration:    1    ,// 0-10
overlayFadeDuration:  1      ,// 0-10
splitResize:         'no'    ,// 'no'|'auto'|'wh'|'hw'
startAtClick:         true   ,// true|false
zoomImageStart:       true   ,// true|false
liveImageResize:      false  ,// true|false
/*** </Animation Options> ***/

/*** <Slideshow Options> ***/
slideInterval:  4.5    ,// seconds
endTask:       'exit'  ,// 'stop'|'exit'|'loop'
showPlayPause:  true   ,// true|false
startPaused:    false  ,// true|false
pauseOnResize:  true   ,// true|false
pauseOnPrev:    true   ,// true|false
pauseOnNext:    false   // true|false
/*** </Slideshow Options> ***/
};

/*** <New Child Window Options> ***/
// Will inherit from the primary floatbox options unless overridden here
// Add any you like
this.childOptions = {
overlayOpacity:      45,
resizeDuration:       3,
imageFadeDuration:    3,
overlayFadeDuration:  0
};
/*** </New Child Window Options> ***/

/***** END OPTIONS CONFIGURATION *****/
this.init();
}
Floatbox.prototype = {
init: function() {
	this.bod = document.body || document.getElementsByTagName('body')[0];
	this.html = document.documentElement;
	this.items = [];
	this.nodeNames = [];
	this.hiddenEls = [];
	this.timeouts = {};
	this.pos = {};
	this.setOptions(this.defaultOptions);
	if (typeof fbPageOptions === 'object') this.setOptions(fbPageOptions);
	this.setOptions(this.parseOptionString(location.search.substring(1)));
	this.panelGap = 22;
	this.infoLinkGap = 16;
	this.showHintsTime = 1600;
	this.zoomPopBorder = 1;
	this.controlSpacing = 8;
	this.minInfoWidth = 80;
	this.minIndexWidth = 120;
	this.ctrlJump = 5;
	this.slowLoadDelay = 750;
	this.loaderDelay = 200;
	this.autoSizeSpace = 4;
	this.initialSize = 120;
	this.slowZoomImg = this.urlGraphics + 'loading_white.gif';
	this.slowLoadImg = this.urlGraphics + 'loading_black.gif';
	this.iframeSrc = this.urlGraphics + 'loading_iframe.html';
	this.resizeUpCursor = this.urlGraphics + 'magnify_plus.cur';
	this.resizeDownCursor = this.urlGraphics + 'magnify_minus.cur';
	this.notFoundImg = this.urlGraphics + '404.jpg';
	this.defaultWidth = '85%';
	this.defaultHeight = '82%';
	this.isChild = !!(self.fb && self.fb.fbBox);
	if (!this.isChild) {
		this.fbParent = this.lastChild = this;
		this.anchors = [];
		this.children = [];
		this.preloads = {};
		this.preloads.count = 0;
		this.xhr = this.getXMLHttpRequest();
		this.strings = {
			hintClose: 'Exit (key: Esc)',
			hintPrev: 'Previous (key: <--)',
			hintNext: 'Next (key: -->)',
			hintPlay: 'Play (key: spacebar)',
			hintPause: 'Pause (key: spacebar)',
			hintResize: 'Resize (key: Tab)',
			imgCount: 'Image %1 of %2',
			nonImgCount: 'Page %1 of %2',
			mixedCount: '(%1 of %2)',
			infoText: 'Info...',
			printText: 'Print...'
		};
	} else {
		this.fbParent = fb.lastChild;
		fb.lastChild = this;
		fb.children.push(this);
		if (this.fbParent.isSlideshow) this.fbParent.setPause(true);
		this.anchors = fb.anchors;
		this.children = fb.children;
		this.xhr = fb.xhr;
		this.strings = fb.strings;
	}
	var agent = navigator.userAgent,
		version = navigator.appVersion;
	this.mac = version.indexOf('Macintosh') !== -1;
	if (window.opera) {
		this.opera = true;
		this.operaOld = parseFloat(version) < 9.5;
		this.operaMac = this.mac;
	} else if (document.all) {
		this.ie = true;
		this.ieOld = parseInt(version.substr(version.indexOf('MSIE') + 5), 10) < 7;
		this.ie8b2 = version.indexOf('MSIE 8.0') !== -1 && navigator.appMinorVersion === 'beta 2';
		this.ieXP = parseInt(version.substr(version.indexOf('Windows NT') + 11), 10) < 6;
	} else if (agent.indexOf('Firefox') !== -1) {
		this.ff = true;
		this.ffOld = parseInt(agent.substr(agent.indexOf('Firefox') + 8), 10) < 3;
		this.ffNew = !this.ffOld;
		this.ffMac = this.mac;
	} else if (version.indexOf('WebKit') !== -1) {
		this.webkit = true;
		this.webkitNew = parseInt(version.substr(version.indexOf('WebKit') + 7), 10) >= 500;
		this.webkitOld = !this.webkitNew;
		this.webkitMac = this.mac;
	}
	this.browserLanguage = (navigator.language || navigator.userLanguage || navigator.systemLanguage || navigator.browserLanguage || 'en').substring(0, 2);
	if (!this.isChild) {
		var lang = this.language === 'auto' ? this.browserLanguage : this.language;
		if (this.xhr) {
			var that = this;
			this.xhr.getResponse(this.urlLanguages + lang + '.json', function(xhr) {
				if ((xhr.status === 200 || xhr.status === 203 || xhr.status === 304) && xhr.responseText) {
					var text = xhr.responseText;
					if (that.ieXP) {
						text = text.replace(String.fromCharCode(8592), '<--').replace(String.fromCharCode(8594), '-->');
					}
					try {
						var obj = eval('(' + text + ')');
						if (obj && obj.hintClose) that.strings = obj;
					} catch(e) {}
				}
			});
		}
	}
	if (this.graphicsType.toLowerCase() === 'english' || (this.graphicsType === 'auto' && this.browserLanguage === 'en')) {
		this.offPos = 'top left';
		this.onPos = 'bottom left';
	} else {
		this.offPos = 'top right';
		this.onPos = 'bottom right';
		this.controlSpacing = 0;
	}
	this.zIndex = {
		base: 90000 + 10*this.children.length,
		fbOverlay: 1,
		fbBox: 2,
		fbCanvas: 3,
		fbMainDiv: 4,
		fbLeftNav: 5,
		fbRightNav: 5,
		fbOverlayPrev: 6,
		fbOverlayNext: 6,
		fbResizer: 7,
		fbZoomDiv: 8,
		fbInfoPanel: 8,
		fbControlPanel: 8
	};
	var match = /\bautoStart=(.+?)(?:&|$)/i.exec(location.search);
	this.autoHref = match ? match[1] : false;
},
tagAnchors: function(baseEl) {
	var that = fb.lastChild,
		doOutline = this.ieOld && /^fb/.test(baseEl.id);
	function tag(tagName) {
		var elements = baseEl.getElementsByTagName(tagName);
		for (var i = 0, len = elements.length; i < len; i++) {
			var el = elements[i];
			if (that.autoGallery && that.fileType(el.href) === 'img' && el.getAttribute('rel') !== 'nofloatbox') {
				el.setAttribute('rel', 'floatbox.autoGallery');
				if (that.autoTitle && !el.getAttribute('title')) el.setAttribute('title', that.autoTitle);
			}
			if (doOutline) el.setAttribute('hideFocus', 'true');
			that.tagOneAnchor(el);
		}
	}
	tag('a');
	tag('area');
},
tagOneAnchor: function(anchor) {
	var that = this,
		isAnchor = !!anchor.getAttribute;
	if (isAnchor) {
		var a = {
			href: anchor.href || anchor.getAttribute('href'),
			rel: anchor.getAttribute('rel'),
			rev: anchor.getAttribute('rev'),
			title: anchor.getAttribute('title'),
			anchor: anchor,
			thumb: this.getThumb(anchor)
		};
		var match;
		if (a.thumb && (match = /(?:^|\s)fbPop(up|down)(?:\s|$)/i.exec(anchor.className))) {
			var up = (match[1] === 'up');
			a.popup = true;
			a.thumb.style.borderWidth = this.zoomPopBorder + 'px';
			anchor.onmouseover = function () {
				a.thumb.style.display = 'none';
				var aPos = that.getLeftTop(this, true),
					aLeft = aPos.left,
					aTop = aPos.top;
				aPos = that.getLayout(this);
				a.thumb.style.display = '';
				var relLeft = (aPos.width - a.thumb.offsetWidth)/2,
					relTop = up ? 2 - a.thumb.offsetHeight : aPos.height,
					scroll = that.getScroll(),
					screenRight = scroll.left + that.getDisplayWidth();
				var spill = aPos.left + relLeft + a.thumb.offsetWidth - screenRight;
				if (spill > 0) relLeft -= spill;
				var spill = aPos.left + relLeft - scroll.left;
				if (spill < 0) relLeft -= spill;
				if (up) {
					if (aPos.top + relTop < scroll.top) relTop = aPos.height;
				} else {
					if (aPos.top + relTop + a.thumb.offsetHeight > scroll.top + that.getDisplayHeight()) relTop = 2 - a.thumb.offsetHeight;
				}
				a.thumb.style.left = (aLeft + relLeft) + 'px';
				a.thumb.style.top = (aTop + relTop) + 'px';
			};
			anchor.onmouseout = function () {
				a.thumb.style.left = '-9999px';
				a.thumb.style.top = '0';
			};
			if (!anchor.onclick) anchor.onclick = anchor.onmouseout;
		}
	} else {
		var a = anchor;
	}
	if (/^(floatbox|gallery|iframe|slideshow|lytebox|lyteshow|lyteframe|lightbox)/i.test(a.rel)) {
		if (isAnchor) {
			anchor.onclick = function() {
				fb.start(this);
				if (window.event) event.returnValue = false;
				return false;
			};
		}
		a.revOptions = this.parseOptionString(a.rev);
		a.level = this.children.length + (fb.lastChild.fbBox && !a.revOptions.sameBox ? 1 : 0);
		var a_i, i = this.anchors.length;
		while (i--) {
			a_i = this.anchors[i];
			if (a_i.href === a.href && a_i.rel === a.rel && a_i.rev === a.rev && a_i.title === a.title && a_i.level === a.level) {
				a_i.anchor = anchor;
				break;
			}
		}
		if (i === -1) {
			a.type = a.revOptions.type || this.fileType(a.href);
			if (a.type === 'html') {
				a.type = 'iframe';
				var match = /#(\w+)/.exec(a.href);
				if (match) {
					var doc = document;
					if (a.anchor) {
						doc = a.anchor.ownerDocument || a.anchor.document || doc;
					}
					if (doc === document && this.currentItem && this.currentItem.anchor) {
						doc = this.currentItem.anchor.ownerDocument || this.currentItem.anchor.document || doc;
					}
					var el = doc.getElementById(match[1]);
					if (el) {
						a.type = 'inline';
						a.sourceEl = el;
					}
				}
			}
			this.anchors.push(a);
			if (this.autoHref) {
				if (a.revOptions.showThis !== false && this.autoHref === a.href.substr(a.href.length - this.autoHref.length)) this.autoStart = a;
			} else if (a.revOptions.autoStart === true) {
				this.autoStart = a;
			} else if (a.revOptions.autoStart === 'once') {
				var match = /fbAutoShown=(.+?)(;|$)/.exec(document.cookie),
					val = match ? match[1] : '',
					href = escape(a.href);
				if (val.indexOf(href) === -1) {
					this.autoStart = a;
					document.cookie = 'fbAutoShown=' + val + href + '; path=/';
				}
			}
		}
	}
	return a;
},
fileType: function(href) {
	var s = href.toLowerCase(),
		i = s.indexOf('?');
	if (i !== -1) s = s.substr(0, i);
	s = s.substr(s.lastIndexOf('.') + 1);
	if (/^(jpe?g|png|gif|bmp)$/.test(s)) return 'img';
	if (s === 'swf' || /^(http:)?\/\/(www.)?youtube.com\/v\//i.test(href)) return 'flash';
	if (/^(mov|mpe?g|movie)$/.test(s)) return 'quicktime';
	return 'html';
},
preloadImages: function(href, chain) {
	if (this !== fb) return fb.preloadImages(href, chain);
	if (typeof chain !== 'undefined') arguments.callee.chain = chain;
	if (!href && arguments.callee.chain && (this.preloadAll || !this.preloads.count)) {
		for (var i = 0, len = this.anchors.length; i < len; i++) {
			var a = this.anchors[i];
			if (a.type === 'img' && !this.preloads[a.href]) {
				href = a.href;
				break;
			}
		}
	}
	if (href) {
		if (this.preloads[href]) {
			this.preloadImages();
		} else {
			var img = this.preloads[href] = new Image();
			img.onerror = function() {
				setTimeout(function() { fb.preloadImages(); }, 50);
				fb.preloads[href] = true;
			};
			img.onload = function() {
				fb.preloads.count++;
				this.onerror();
			};
			img.src = href;
		}
	}
},
start: function(anchor) {
	if (this !== fb.lastChild) return fb.lastChild.start(anchor);
	var that = this;
	this.preloadImages('', false);
	if (anchor.getAttribute) {
		var a = {
			href: anchor.href || anchor.getAttribute('href'),
			rel: anchor.getAttribute('rel'),
			rev: anchor.getAttribute('rev'),
			title: anchor.getAttribute('title')
		};
		a.revOptions = this.parseOptionString(a.rev);
		anchor.blur();
	} else {
		var a = anchor;
	}
	this.isRestart = !!this.fbBox;
	if (this.isRestart) {
		if (!a.revOptions.sameBox) return new Floatbox().start(anchor);
		this.setOptions(a.revOptions);
	} else {
		this.clickedAnchor = anchor.getAttribute ? anchor : false;
	}
	a.level = this.children.length + (fb.lastChild.fbBox && !a.revOptions.sameBox ? 1 : 0);
	this.itemsShown = 0;
	fb.previousAnchor = this.currentItem;
	this.buildItemArray(a);
	if (!this.itemCount) return;
	if (this.itemCount === 1 && this.fbNavControls) this.fbNavControls.style.display = 'none';
	self.focus();
	this.revOptions = a.revOptions;
	if (!this.isRestart) {
		this.getOptions();
		this.buildDOM();
		this.addEventHandlers();
		this.initState();
	}
	this.collapse();
	this.updatePanels();
	var fetchAndGo = function() {
		that.fetchContent(function() {
			that.clearTimeout('slowLoad');
			that.calcSize();
		} );
	};
	if (this.fbBox.style.visibility  || this.isRestart) {
		fetchAndGo();
	} else {
		var offset = this.initialSize/2,
			size = { id: 'fbBox', left: that.pos.fbBox.left - offset, top: that.pos.fbBox.top - offset,
			width: that.initialSize, height: that.initialSize, borderWidth: that.outerBorder };
		if (this.splitResize) {
			var oncomplete = function() {
				that.setSize(fetchAndGo, size);
			};
		} else {
			this.timeouts.slowLoad = setTimeout(function() {
				that.setSize(size);
			}, this.slowLoadDelay);
			var oncomplete = fetchAndGo;
		}
		this.fadeOpacity(this.fbOverlay, this.overlayOpacity, this.overlayFadeDuration, oncomplete);
	}
},
buildItemArray: function(a) {
	this.itemCount = this.items.length = this.currentIndex = 0;
	this.justImages = true;
	var isSingle = /^(floatbox|gallery|iframe|lytebox|lyteframe|lightbox)$/i.test(a.rel);
	for (var i = 0, len = this.anchors.length; i < len; i++) {
		var a_i = this.anchors[i];
		if (a_i.rel === a.rel && a_i.level === a.level) {
			if (a_i.revOptions.showThis !== false) {
				var isMatch = a_i.rev === a.rev && a_i.title === a.title && a_i.href === a.href.substr(a.href.length - a_i.href.length);
				if (isMatch || !isSingle) {
					a_i.seen = false;
					this.items.push(a_i);
					if (a_i.type !== 'img') this.justImages = false;
					if (isMatch) this.currentIndex = this.items.length - 1;
				}
			}
		}
	}
	if (a.revOptions.showThis === false && a.href) {
		i = this.items.length;
		while (i--) {
			var href = this.items[i].href;
			if (href === a.href.substr(a.href.length - href.length)) {
				this.currentIndex = i;
			}
		}
	}
  	this.itemCount = this.items.length;
  	this.currentItem = this.items[this.currentIndex];
},
getOptions: function() {
	if (this.isChild) {
		for (var name in this.defaultOptions) {
			if (this.defaultOptions.hasOwnProperty(name)) this[name] = this.fbParent[name];
		}
		this.setOptions(this.childOptions);
	} else {
		this.setOptions(this.defaultOptions);
	}
	this.doSlideshow = this.loadPageOnClose = this.sameBox = false;
	if (!(this.isChild || this.fbBox)) {
		if (typeof setFloatboxOptions === 'function') setFloatboxOptions();
		if (typeof fbPageOptions === 'object') this.setOptions(fbPageOptions);
		if (this.enableCookies) {
			var match = /fbOptions=(.+?)(;|$)/.exec(document.cookie);
			if (match) this.setOptions(this.parseOptionString(match[1]));
			var strOptions = '';
			for (var name in this.defaultOptions) {
				if (this.defaultOptions.hasOwnProperty(name)) {
					strOptions += ' ' + name + ':' + this[name];
				}
			}
			var strPath = '/';
			if (this.cookieScope === 'folder') {
				strPath = location.pathname;
				strPath = strPath.substring(0, strPath.lastIndexOf('/') + 1);
			}
			document.cookie = 'fbOptions=' + strOptions + '; path=' + strPath;
		}
	}
	this.setOptions(this.revOptions);
	this.setOptions(this.parseOptionString(location.search.substring(1)));
	if (this.theme === 'grey') this.theme = 'white';
	if (this.endTask === 'cont') this.endTask = 'loop';
	if (this.navType === 'upper') this.navType = 'overlay';
	if (this.navType === 'lower') this.navType = 'button';
	if (this.upperOpacity) this.controlOpacity = this.upperOpacity;
	if (this.upperNavWidth) this.navOverlayWidth = this.upperNavWidth;
	if (this.upperNavPos) this.navOverlayPos = this.upperNavPos;
	if (this.showUpperNav) this.showNavOverlay = this.showUpperNav;
	if (this.dropShadow) this.shadowType = 'drop';
	if (!/^(auto|black|white|blue|yellow|red|custom)$/.test(this.theme)) this.theme='auto';
	if (!/^(overlay|button|both|none)$/i.test(this.navType)) this.navType = 'button';
	if (!/^(auto|wh|hw)$/.test(this.splitResize)) this.splitResize = false;
	if (this.webkitOld && (this.navType === 'overlay' || this.navType === 'both') ) {
		this.navType = 'button';
	}
	if (this.itemCount > 1) {
		this.isSlideshow = this.doSlideshow || /^(slideshow|lyteshow)/i.test(this.currentItem.rel);
		var overlayRequest = /overlay|both/i.test(this.navType),
			buttonRequest = /button|both/i.test(this.navType);
		this.navOverlay = this.justImages && overlayRequest;
		this.navButton = buttonRequest || (!this.justImages && overlayRequest);
		this.lclShowItemNumber = this.showItemNumber;
		this.lclNumIndexLinks = this.numIndexLinks;
	} else {
		this.isSlideshow = this.navOverlay = this.navButton = this.lclShowItemNumber = this.lclNumIndexLinks = false;
	}
	this.isPaused = this.startPaused;
	if ((this.lclTheme = this.theme) === 'auto') {
		this.lclTheme = this.currentItem.type === 'img' ? 'black' : /flash|quicktime/.test(this.currentItem.type) ? 'blue' : 'white';
	}
	if (!this.doAnimations) {
		this.resizeDuration = this.imageFadeDuration = this.overlayFadeDuration = 0;
	}
	if (!this.resizeDuration) this.zoomImageStart = false;
	this.controlTop = this.controlPos.charAt(0) === 't';
	this.controlLeft = this.controlPos.charAt(1) === 'l';
	this.infoTop = this.infoPos.charAt(0) === 't';
	this.infoCenter = this.infoPos.charAt(1) === 'c';
	this.infoLeft = this.infoPos.charAt(1) === 'l' || (this.infoCenter && this.controlTop === this.infoTop && !this.controlLeft);
	if (this.infoLeft === this.controlLeft && this.infoTop === this.controlTop) {
		this.infoLeft = true;
		this.controlLeft = false;
	}
	if (this.indexLinksPanel === 'info') {
		this.indexCenter = this.infoCenter;
		this.indexLeft = this.infoLeft;
		this.indexTop = this.infoTop;
	} else {
		this.indexLeft = this.controlLeft;
		this.indexTop = this.controlTop;
	}
	if (!/^(drop|halo|none)$/.test(this.shadowType)) this.shadowType='drop';
	if (!/^(8|12|16|24)$/.test(this.shadowSize + '')) this.shadowSize = 8;
	this.shadowSize = +this.shadowSize;
	if (this.opera || (this.mac && !this.webkitNew)) {
		this.resizeTool = 'topleft';
	} else {
		this.resizeTool = this.resizeTool.toLowerCase();
		if (!/topleft|cursor|both/.test(this.resizeTool)) this.resizeTool = 'cursor';
	}
	if (this.ieOld) this.shadowType = 'none';
	this.overlayOpacity /= 100;
	this.controlOpacity /= 100;
},
parseOptionString: function(str) {
	if (!str) return {};
	var quotes = [], match,
		rex = /`([^`]*?)`/g;
	while ((match = rex.exec(str))) quotes.push(match[1]);
	if (quotes.length) str = str.replace(rex, '``');
	str = str.replace(/\s*[:=]\s*/g, ':');
	str = str.replace(/\s*[;&]\s*/g, ' ');
	str = str.replace(/^\s+|\s+$/g, '');
	var pairs = {},
		aVars = str.split(' '),
		i = aVars.length;
	while (i--) {
		var aThisVar = aVars[i].split(':'),
			name = aThisVar[0],
			value = aThisVar[1];
		if (typeof value === 'string') {
			if (!isNaN(value)) value = +value;
			else if (value === 'true') value = true;
			else if (value === 'false') value = false;
		}
		if (value === '``') value = quotes.pop() || '';
		pairs[name] = value;
	}
	return pairs;
},
setOptions: function(pairs) {
	for (var name in pairs) {
		if (pairs.hasOwnProperty(name)) this[name] = pairs[name];
	}
},
buildDOM: function() {
	this.fbOverlay		= this.newNode('div', 'fbOverlay', this.bod);
	this.fbZoomDiv		= this.newNode('div', 'fbZoomDiv', this.bod);
	this.fbZoomImg		= this.newNode('img', 'fbZoomImg', this.fbZoomDiv);
	this.fbBox			= this.newNode('div', 'fbBox');
	this.fbShadowTop	= this.newNode('div', 'fbShadowTop', this.fbBox);
	this.fbShadowRight	= this.newNode('div', 'fbShadowRight', this.fbBox);
	this.fbShadowBottom	= this.newNode('div', 'fbShadowBottom', this.fbBox);
	this.fbShadowLeft	= this.newNode('div', 'fbShadowLeft', this.fbBox);
	this.fbShadowCorner	= this.newNode('div', 'fbShadowCorner', this.fbBox);
	this.fbLoader		= this.newNode('div', 'fbLoader', this.fbBox);
	this.fbCanvas		= this.newNode('div', 'fbCanvas', this.fbBox);
	this.fbMainDiv		= this.newNode('div', 'fbMainDiv', this.fbCanvas);
	this.fbLeftNav		= this.newNode('a', 'fbLeftNav', this.fbMainDiv);
	this.fbRightNav		= this.newNode('a', 'fbRightNav', this.fbMainDiv);
	this.fbOverlayPrev	= this.newNode('a', 'fbOverlayPrev', this.fbMainDiv, this.strings.hintPrev);
	this.fbOverlayNext	= this.newNode('a', 'fbOverlayNext', this.fbMainDiv, this.strings.hintNext);
	this.fbResizer		= this.newNode('a', 'fbResizer', this.fbMainDiv, this.strings.hintResize);
	this.fbInfoPanel	= this.newNode('div', 'fbInfoPanel', this.fbCanvas);
	this.fbCaptionDiv	= this.newNode('div', 'fbCaptionDiv', this.fbInfoPanel);
	this.fbCaption		= this.newNode('span', 'fbCaption', this.fbCaptionDiv);
	this.fbInfoDiv		= this.newNode('div', 'fbInfoDiv', this.fbInfoPanel);
	if (this.infoLeft || this.infoCenter) {
		this.fbInfoLink		= this.newNode('span', 'fbInfoLink', this.fbInfoDiv);
		this.fbPrintLink	= this.newNode('span', 'fbPrintLink', this.fbInfoDiv);
		this.fbItemNumber	= this.newNode('span', 'fbItemNumber', this.fbInfoDiv);
	} else {
		this.fbItemNumber	= this.newNode('span', 'fbItemNumber', this.fbInfoDiv);
		this.fbPrintLink	= this.newNode('span', 'fbPrintLink', this.fbInfoDiv);
		this.fbInfoLink		= this.newNode('span', 'fbInfoLink', this.fbInfoDiv);
	}
	this.fbControlPanel	= this.newNode('div', 'fbControlPanel', this.fbCanvas);
	this.fbControls		= this.newNode('div', 'fbControls', this.fbControlPanel);
	this.fbNavControls	= this.newNode('div', 'fbNavControls', this.fbControls);
	this.fbPrev			= this.newNode('a', 'fbPrev', this.fbNavControls, this.strings.hintPrev);
	this.fbNext			= this.newNode('a', 'fbNext', this.fbNavControls, this.strings.hintNext);
	this.fbSubControls	= this.newNode('div', 'fbSubControls', this.fbControls);
	this.fbPlayPause	= this.newNode('div', 'fbPlayPause', this.fbSubControls);
	this.fbPlay			= this.newNode('a', 'fbPlay', this.fbPlayPause, this.strings.hintPlay);
	this.fbPause		= this.newNode('a', 'fbPause', this.fbPlayPause, this.strings.hintPause);
	this.fbClose		= this.newNode('a', 'fbClose', this.fbSubControls, this.strings.hintClose);
	this.fbIndexLinks	= this.newNode('span', 'fbIndexLinks', this.indexLinksPanel === 'info' ? this.fbInfoPanel : this.fbControlPanel);
	this.bod.appendChild(this.fbBox);
},
newNode: function(nodeType, id, parentNode, title) {
	if (this[id] && this[id].parentNode) {
		this[id].parentNode.removeChild(this[id]);
	}
	var node = document.createElement(nodeType);
	node.id = id;
	node.className = id + '_' + (id.indexOf('fbShadow') === -1 ? this.lclTheme : this.shadowType + this.shadowSize);
	if (nodeType === 'a') {
		if (!this.operaOld) node.setAttribute('href', '');
		if (this.ieOld) node.setAttribute('hideFocus', 'true');
		node.style.outline = 'none';
	} else if (nodeType === 'iframe') {
		node.setAttribute('scrolling', this.itemScroll);
		node.setAttribute('frameBorder', '0');
		node.setAttribute('align', 'middle');
		node.src = this.iframeSrc;
	}
	if (this.isChild && this.fbParent[id]) title = this.fbParent[id].getAttribute('title');
	if (title && this.showHints !== 'never') node.setAttribute('title', title);
	if (this.zIndex[id]) node.style.zIndex = this.zIndex.base + this.zIndex[id];
	node.style.display = 'none';
	if (parentNode) parentNode.appendChild(node);
	this.nodeNames.push(id);
	return node;
},
addEventHandlers: function() {
	var that = this,
	leftNav = this.fbLeftNav.style,
	rightNav = this.fbRightNav.style,
	overlayPrev = this.fbOverlayPrev.style,
	overlayNext = this.fbOverlayNext.style,
	prev = this.fbPrev.style,
	next = this.fbNext.style;
	if (this.showHints === 'once') {
		this.hideHint = function(id) {
			if (that[id].title) {
				that.timeouts[id] = setTimeout(function() {
					that[id].title = that.fbParent[id].title = '';
					var id2 = '';
					if (/fbOverlay(Prev|Next)/.test(id)) {
						id2 = id.replace('Overlay', '');
					} else if (/fb(Prev|Next)/.test(id)) {
						id2 = id.replace('fb', 'fbOverlay');
					}
					if (id2) that[id2].title = that.fbParent[id2].title = '';
				}, that.showHintsTime);
			}
		};
	} else {
		this.hideHint = function() {};
	}
	this.fbPlay.onclick = function() {
		that.setPause(false);
		if (window.event) event.returnValue = false;
		return false;
	};
	this.fbPause.onclick = function() {
		that.setPause(true);
		if (window.event) event.returnValue = false;
		return false;
	};
	this.fbClose.onclick = function() {
		that.end();
		if (window.event) event.returnValue = false;
		return false;
	};
	if (this.outsideClickCloses) {
		this.fbOverlay.onclick = this.fbShadowTop.onclick = this.fbShadowRight.onclick =
		this.fbShadowBottom.onclick = this.fbShadowLeft.onclick = this.fbShadowCorner.onclick = this.fbClose.onclick;
	}
	this.fbPrev.onclick = function(step) {
		if (typeof step !== 'number') step = 1;
		var newIndex = (that.currentIndex - step) % that.itemCount;
		if (newIndex < 0) newIndex += that.itemCount;
		if (that.enableWrap || newIndex < that.currentIndex) {
			that.newContent(newIndex);
			if (that.isSlideshow && that.pauseOnPrev && !that.isPaused) {
				that.setPause(true);
			}
		}
		if (window.event) event.returnValue = false;
		return false;
	};
	this.fbNext.onclick = function(step) {
		if (typeof step !== 'number') step = 1;
		var newIndex = (that.currentIndex + step) % that.itemCount;
		if (that.enableWrap || newIndex > that.currentIndex) {
			that.newContent(newIndex);
			if (that.isSlideshow && that.pauseOnNext && !that.isPaused) {
				that.setPause(true);
			}
		}
		if (window.event) event.returnValue = false;
		return false;
	};
	this.fbLeftNav.onclick = this.fbOverlayPrev.onclick = this.fbPrev.onclick;
	this.fbRightNav.onclick = this.fbOverlayNext.onclick = this.fbNext.onclick;
	this.fbLeftNav.onmouseover = this.fbLeftNav.onmousemove =
	this.fbOverlayPrev.onmousemove = function() {
		if (!that.timeouts.fbCanvas) overlayPrev.visibility = '';
		if (that.navButton) prev.backgroundPosition = that.onPos;
		return true;
	};
	this.fbRightNav.onmouseover = this.fbRightNav.onmousemove =
	this.fbOverlayNext.onmousemove = function() {
		if (!that.timeouts.fbCanvas) overlayNext.visibility = '';
		if (that.navButton) next.backgroundPosition = that.onPos;
		return true;
	};
	this.fbOverlayPrev.onmouseover = this.fbOverlayNext.onmouseover = function() {
		this.onmousemove();
		that.hideHint(this.id);
		return true;
	};
	this.fbLeftNav.onmouseout = function() {
		overlayPrev.visibility = 'hidden';
		if (that.navButton) prev.backgroundPosition = that.offPos;
	};
	this.fbRightNav.onmouseout = function() {
		overlayNext.visibility = 'hidden';
		if (that.navButton) next.backgroundPosition = that.offPos;
	};
	this.fbOverlayPrev.onmouseout = this.fbOverlayNext.onmouseout = function() {
		this.style.visibility = 'hidden';
		that.clearTimeout(this.id);
	};
	this.fbLeftNav.onmousedown = this.fbRightNav.onmousedown = function(e) {
		e = e || window.event;
		if (e.button === 2) {
			leftNav.visibility = rightNav.visibility = 'hidden';
			that.timeouts.hideNavOverlay = setTimeout(function() {
				leftNav.visibility = rightNav.visibility = '';
			}, 600);
		}
	};
	this.fbPlay.onmouseover = this.fbPause.onmouseover = this.fbClose.onmouseover =
	this.fbPrev.onmouseover = this.fbNext.onmouseover = function() {
		this.style.backgroundPosition = that.onPos;
		that.hideHint(this.id);
		return true;
	};
	this.fbResizer.onmouseover = function() {
		that.hideHint(this.id);
		return true;
	};
	this.fbPlay.onmouseout = this.fbPause.onmouseout = this.fbClose.onmouseout =
	this.fbPrev.onmouseout = this.fbNext.onmouseout = function() {
		this.style.backgroundPosition = that.offPos;
		that.clearTimeout(this.id);
	};
	this.fbResizer.onmouseout = function() {
		that.clearTimeout(this.id);
	};
	if (this.enableKeyboardNav) {
		if (!document.keydownSet) {
			this.priorOnkeydown = document.onkeydown;
			document.onkeydown = this.keyboardHandler;
			document.keydownSet = true;
		}
	} else if (document.keydownSet) {
		document.onkeydown = this.priorOnkeydown;
		document.keydownSet = false;
	}
	if (this.opera && !document.keypressSet) {
		this.priorOnkeypress = document.onkeypress;
		document.onkeypress = function() { return false; };
		document.keypressSet = true;
	}
	if (this.enableDrag) this.fbBox.onmousedown = this.dragonDrop();
},
keyboardHandler: function(e) {
	e = e || window.event;
	var that = fb.lastChild,
		keyCode = e.keyCode || e.which;
	switch (keyCode) {
		case 37: case 39:
			if (that.itemCount > 1) {
				that[keyCode === 37 ? 'fbPrev' : 'fbNext'].onclick((e.ctrlKey || e.metaKey) ? that.ctrlJump : 1);
				if (that.showHints === 'once') {
					that.fbPrev.title = that.fbNext.title =
					that.fbOverlayPrev.title = that.fbOverlayNext.title = '';
				}
			}
			return false;
		case 32:
			if (that.isSlideshow) {
				that.setPause(!that.isPaused);
				if (that.showHints === 'once') that.fbPlay.title = that.fbPause.title = '';
			}
			return false;
		case 9:
			if (that.fbResizer.onclick) {
				that.fbResizer.onclick();
				if (that.showHints === 'once') that.fbResizer.title = '';
			}
			return false;
		case 27:
			if (that.showHints === 'once') that.fbClose.title = '';
			that.end();
			return false;
		case 13:
			return false;
	}
},
dragonDrop: function() {
	var that = this,
		fbBox = this.fbBox;
	return function(e) {
		e = e || window.event;
		if (/fb(Box|Canvas|Info|Caption|Item|Control|Index)/.test((e.target || e.srcElement).id)) {
			var startX = e.clientX,
				startY = e.clientY,
				box = that.fbBox.style,
				content = that.fbContent.style,
				pos = that.pos.fbBox,
				boxX = pos.left,
				boxY = pos.top;
			pos.dx = pos.dy = 0;
			var moveHandler = function(e) {
				if (that.currentItem.type === 'iframe' && !(that.ie || that.opera) && !content.visibility) content.visibility = 'hidden';
				if (that.isSlideshow && !that.isPaused) that.setPause(true);
				e = e || window.event;
				pos.dx = e.clientX - startX;
				pos.dy = e.clientY - startY;
				box.left = (boxX + pos.dx) + 'px';
				box.top = (boxY + pos.dy) + 'px';
				(e.stopPropagation && e.stopPropagation()) || (e.cancelBubble = true);
				that.clearTimeout('dragonDrop');
				that.timeouts.dragonDrop = setTimeout(upHandler, 1500);
				return false;
			};
			var upHandler = function(e) {
				that.clearTimeout('dragonDrop');
				e = e || window.event;
				if (document.removeEventListener) {
					document.removeEventListener("mouseup", upHandler, true);
					document.removeEventListener("mousemove", moveHandler, true);
				} else if (fbBox.detachEvent) {
					fbBox.detachEvent("onlosecapture", upHandler);
					fbBox.detachEvent("onmouseup", upHandler);
					fbBox.detachEvent("onmousemove", moveHandler);
					fbBox.releaseCapture();
				}
				if (e) (e.stopPropagation && e.stopPropagation()) || (e.cancelBubble = true);
				pos.left += pos.dx;
				pos.top += pos.dy;
				content.visibility = '';
				return false;
			};
			if (document.addEventListener) {
				document.addEventListener("mousemove", moveHandler, true);
				document.addEventListener("mouseup", upHandler, true);
			} else if (fbBox.attachEvent) {
				fbBox.setCapture();
				fbBox.attachEvent("onmousemove", moveHandler);
				fbBox.attachEvent("onmouseup", upHandler);
				fbBox.attachEvent("onlosecapture", upHandler);
			}
			return false;
		}
	};
},
initState: function() {
	var that = this,
		box = this.fbBox.style,
		mainDiv = this.fbMainDiv.style,
		resizer = this.fbResizer.style,
		canvas = this.fbCanvas.style,
		zoomDiv = this.fbZoomDiv.style,
		zoomImg = this.fbZoomImg.style;
	if (this.currentItem.popup) this.currentItem.anchor.onmouseover();
	var anchorPos = this.getAnchorPos(this.clickedAnchor, this.currentItem.anchor === this.clickedAnchor && this.currentItem.type === 'img');
	if (anchorPos.width) {
		this.pos.fbZoomDiv = anchorPos;
		zoomDiv.borderWidth = this.zoomPopBorder + 'px';
		zoomDiv.left = (anchorPos.left - this.zoomPopBorder) + 'px';
		zoomDiv.top = (anchorPos.top - this.zoomPopBorder) + 'px';
		zoomDiv.width = (this.fbZoomImg.width = anchorPos.width) + 'px';
		zoomDiv.height = (this.fbZoomImg.height = anchorPos.height) + 'px';
		this.fbZoomImg.src = anchorPos.src;
		box.visibility = 'hidden';
		this.timeouts.slowLoad = setTimeout(function() {
			if (that.fbOverlay.style.display) that.fadeOpacity(that.fbOverlay, that.overlayOpacity, that.overlayFadeDuration);
			that.fbZoomImg.src = that.slowZoomImg;
			zoomDiv.display = zoomImg.display = '';
		}, this.slowLoadDelay);
	} else {
		this.pos.fbBox = anchorPos;
		this.pos.fbBox.borderWidth = 0;
		this.pos.fbMainDiv = { width:0, height:0 };
	}
	box.position = 'absolute';
	box.left = box.top = box.width = box.height = box.borderWidth = '0';
	mainDiv.borderWidth = this.innerBorder + 'px';
	mainDiv.left = this.padding + 'px';
	this.fbControlPanel.style[this.controlLeft ? 'left' : 'right'] =
	this.fbInfoPanel.style[this.infoLeft ? 'left' : 'right'] = Math.max(this.padding, this.panelPadding) + 'px';
	canvas.visibility = 'hidden';
	box.display = canvas.display = '';
	if (this.shadowType === 'none') {
		this.shadowSize = 0;
	} else {
		var shadowTop = this.fbShadowTop.style,
			shadowRight = this.fbShadowRight.style,
			shadowBottom = this.fbShadowBottom.style,
			shadowLeft = this.fbShadowLeft.style,
			shadowCorner = this.fbShadowCorner.style;
		shadowRight.top = shadowBottom.left = shadowLeft.top = -this.outerBorder + 'px';
		shadowRight.paddingRight = shadowBottom.paddingBottom =
		shadowCorner.paddingRight = shadowCorner.paddingBottom = (this.outerBorder + this.shadowSize) + 'px';
		if (this.shadowType === 'halo') {
			shadowTop.paddingRight = shadowRight.paddingBottom =
			shadowBottom.paddingRight = shadowLeft.paddingBottom = (this.outerBorder*2 + this.shadowSize) + 'px';
			shadowTop.top = shadowTop.left = shadowRight.top = shadowLeft.left = -(this.outerBorder + this.shadowSize) + 'px';
		} else {
			shadowBottom.backgroundPosition = 'bottom left';
			shadowRight.paddingBottom = shadowBottom.paddingRight = this.outerBorder*2 + 'px';
		}
	}
	if (this.navOverlay) {
		if (fb.showNavOverlay === 'never' || (fb.showNavOverlay === 'once' && fb.navOverlayShown)) {
			fb.showNavOverlay = false;
		} else {
			this.fbOverlayPrev.style.backgroundPosition = this.fbOverlayNext.style.backgroundPosition = this.onPos;
			this.fadeOpacity(this.fbOverlayPrev, this.controlOpacity);
			this.fadeOpacity(this.fbOverlayNext, this.controlOpacity);
		}
	}
	this.initPanels();
	this.lastShown = false;
	if (this.hideFlash) this.hideElements('flash');
	if (this.hideJava) this.hideElements('applet');
	if (this.ieOld) {
		this.hideElements('select');
		this.fbOverlay.style.position = 'absolute';
		this.stretchOverlay()();
		attachEvent('onresize', this.stretchOverlay());
		attachEvent('onscroll', this.stretchOverlay());
	}
},
hideElements: function(type, thisWindow) {
	if (!thisWindow) {
		this.hideElements(type, self);
	} else {
		var tagName, tagNames = type === 'flash' ? ['object', 'embed'] : [type];
		try {
			while ((tagName = tagNames.pop())) {
				var els = thisWindow.document.getElementsByTagName(tagName),
					i = els.length;
				while (i--) {
					var el = els[i];
					if (el.style.visibility !== 'hidden' && (tagName !== 'object' ||
					(el.getAttribute('type') && el.getAttribute('type').toLowerCase() === 'application/x-shockwave-flash') ||
					(el.getAttribute('classid') && el.getAttribute('classid').toLowerCase() === 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000') ||
					/data\s*=\s*"?[^>"]+\.swf\b/i.test(el.innerHTML) ||
					/param\s+name\s*=\s*"?(movie|src)("|\s)[^>]+\.swf\b/i.test(el.innerHTML))) {
						this.hiddenEls.push(el);
						el.style.visibility = 'hidden';
					}
				}
			}
		} catch(e) {}
		var frames = thisWindow.frames, i = frames.length;
		while (i--) {
			try {
				if (typeof frames[i].window === 'object') this.hideElements(type, frames[i].window);
			} catch(e) {}
		}
	}
},
getAnchorPos: function(anchor, useThumb) {
	var display = this.getDisplaySize(),
		scroll = this.getScroll(),
		noAnchorPos = { left: display.width/2 + scroll.left, top: display.height/3 + scroll.top, width: 0, height: 0 };
	var thumb = useThumb ? this.getThumb(anchor) : false;
	if (thumb && this.zoomImageStart) {
		var pos = this.getLeftTop(thumb),
			border = (thumb.offsetWidth - thumb.width)/2;
		pos.left += border;
		pos.top += border;
		pos.width = thumb.width;
		pos.height = thumb.height;
		pos.src = thumb.src;
	} else if (this.startAtClick && anchor && anchor.offsetWidth && anchor.tagName.toLowerCase() === 'a') {
		var pos = this.getLayout(thumb || anchor);
	} else {
		return noAnchorPos;
	}
	var centerPos = { left: pos.left + pos.width/2, top: pos.top + pos.height/2, width: 0, height: 0 };
	if (centerPos.left < scroll.left || centerPos.left > (scroll.left + display.width) ||
	centerPos.top < scroll.top || centerPos.top > (scroll.top + display.height)) {
		return noAnchorPos;
	}
	return (thumb && this.zoomImageStart ? pos : centerPos);
},
getThumb: function(anchor) {
	var nodes = anchor && anchor.childNodes, i = (nodes && nodes.length) || 0;
	while (i--) {
		if ((nodes[i].tagName || '').toLowerCase() === 'img') return nodes[i];
	}
	return false;
},
initPanels: function() {
	var infoPanel = this.fbInfoPanel.style,
		infoLink = this.fbInfoLink.style,
		printLink = this.fbPrintLink.style,
		itemNumber = this.fbItemNumber.style;
	if (this.infoCenter) {
		var infoPos = ' posCenter';
		infoPanel.textAlign = 'center';
		infoLink.paddingLeft = printLink.paddingLeft = itemNumber.paddingLeft =
		infoLink.paddingRight = printLink.paddingRight = itemNumber.paddingRight = (this.infoLinkGap/2) + 'px';
	} else if (this.infoLeft) {
		var infoPos = ' posLeft';
		infoPanel.textAlign = 'left';
		infoLink.paddingRight = printLink.paddingRight = this.infoLinkGap + 'px';
	} else {
		var infoPos = ' posRight';
		infoPanel.textAlign = 'right';
		infoLink.paddingLeft = printLink.paddingLeft = this.infoLinkGap + 'px';
	}
	this.fbInfoPanel.className += infoPos;
	this.fbInfoDiv.className += infoPos;
	infoPanel.width = '400px';
	var controlPanel = this.fbControlPanel.style,
		controls = this.fbControls.style,
		subControls = this.fbSubControls.style;
	if (this.controlLeft) {
		var controlPos = ' posLeft';
		controlPanel.textAlign = 'left';
	} else {
		var controlPos = ' posRight';
		controlPanel.textAlign = 'right';
		controls.right = '0';
	}
	this.fbControlPanel.className += controlPos;
	this.fbSubControls.className += controlPos;
	if (!this.ieOld) this.fbControls.className += controlPos;
	if (this.navButton) {
		var prev = this.fbPrev.style,
			next = this.fbNext.style,
			navControls = this.fbNavControls.style;
		prev.backgroundPosition = next.backgroundPosition = this.offPos;
		navControls['padding' + (this.controlLeft ? 'Left' : 'Right')] = this.controlSpacing + 'px';
		this.fbNavControls.className += controlPos;
		controlPanel.display = navControls.display = prev.display = next.display = '';
	}
	var width = 0;
	if (this.showClose) {
		var close = this.fbClose.style;
		close.backgroundPosition = this.offPos;
		this.fbClose.className += controlPos;
		controlPanel.display = controls.display = subControls.display = close.display = '';
		width = this.fbClose.offsetWidth;
	}
	if (this.showPlayPause && this.isSlideshow) {
		var play = this.fbPlay.style,
			pause = this.fbPause.style,
			playPause = this.fbPlayPause.style;
		play.backgroundPosition = pause.backgroundPosition = this.offPos;
		playPause['padding' + (this.controlLeft ? 'Left' : 'Right')] = this.controlSpacing + 'px';
		this.fbPlayPause.className += controlPos;
		controlPanel.display = controls.display = subControls.display = playPause.display = play.display = pause.display = '';
		play.left = this.isPaused ? '' : '-9999px';
		pause.left = this.isPaused ? '-9999px' : '';
		width += this.fbPlayPause.offsetWidth;
	}
	subControls.width = width + 'px';
	controlPanel.width = controls.width = (width + this.fbNavControls.offsetWidth) + 'px';
	if (this.lclNumIndexLinks) {
		var indexLinks = this.fbIndexLinks.style;
		if (this.indexLinksPanel === 'info') {
			this.fbIndexLinks.className += infoPos;
			infoPanel.display = '';
			if (this.showIndexThumbs) infoPanel.overflow = 'visible';
		} else {
			this.fbIndexLinks.className += controlPos;
			controlPanel.display = '';
			if (this.showIndexThumbs) controlPanel.overflow = 'visible';
			indexLinks['padding' + (this.indexLeft ? 'Left' : 'Right')] = '2px';
		}
		indexLinks.width = '250px';
		indexLinks.display = '';
	}
},
fetchContent: function(callback, phase) {
	var that = this;
	if (!phase) {
		if (this.fbContent) {
			this.fbMainDiv.removeChild(this.fbContent);
			delete this.fbContent;
			return this.timeouts.fetch = setTimeout(function() { that.fetchContent(callback, 1); }, 10);
		}
	}
	var item = this.currentItem;
	item.nativeWidth = item.revOptions.width;
	item.nativeHeight = item.revOptions.height;
	if (item.type !== 'img') {
		item.nativeWidth = item.nativeWidth || (fb.previousAnchor && fb.previousAnchor.nativeWidth) || this.defaultWidth;
		item.nativeHeight = item.nativeHeight || (fb.previousAnchor && fb.previousAnchor.nativeHeight) || this.defaultHeight;
	}
	if (this.ieOld) this.fbMainDiv.style.backgroundColor = item.type === 'img' ? '#000' : '';
	this.itemScroll = item.revOptions.scrolling || item.revOptions.scroll || 'auto';
	if (/img|iframe/.test(item.type)) {
		this.fbContent = this.newNode(item.type, 'fbContent', this.fbMainDiv);
		if (item.type === 'img') {
			var loader = new Image();
			loader.onload = function() {
				item.nativeWidth = item.nativeWidth || loader.width;
				item.nativeHeight = item.nativeHeight || loader.height;
				that.fbContent.src = loader.src;
				if (callback) callback();
			};
			loader.onerror = function() {
				if (this.src !== that.notFoundImg) this.src = that.notFoundImg;
			};
			loader.src = item.href;
		}
	} else {
		this.fbContent = this.newNode('div', 'fbContent', this.fbMainDiv);
		this.fbContent.style.overflow = this.itemScroll === 'yes' ? 'scroll' : (this.itemScroll === 'no' ? 'hidden' : 'auto');
		if (item.type === 'inline') {
			var el = item.sourceEl.cloneNode(true);
			el.style.display = el.style.visibility = '';
			try { this.fbContent.appendChild(el); }
			catch(e) { this.setInnerHTML(this.fbContent, el.innerHTML); }
			this.tagAnchors(this.fbContent);
		} else if (item.type === 'ajax') {
			this.xhr.getResponse(item.href, function(xhr) {
				if ((xhr.status === 200 || xhr.status === 203 || xhr.status === 304) && xhr.responseText) {
					that.setInnerHTML(that.fbContent, xhr.responseText);
					that.tagAnchors(that.fbContent);
				} else {
					that.setInnerHTML(that.fbContent, '<p style="color:#000; background:#fff; margin:1em; padding:1em;">' +
					'Unable to fetch content from ' + item.href + '</p>');
				}
			});
		}
	}
	this.fbContent.style.border = '0';
	this.fbContent.style.display = '';
	if (item.type !== 'img' && callback) callback();
},
updatePanels: function() {
	var infoPanel = this.fbInfoPanel.style,
		captionDiv = this.fbCaptionDiv.style,
		caption = this.fbCaption.style,
		infoDiv = this.fbInfoDiv.style,
		infoLink = this.fbInfoLink.style,
		printLink = this.fbPrintLink.style,
		itemNumber = this.fbItemNumber.style,
		item = this.currentItem,
		str;
	infoPanel.display = captionDiv.display = caption.display = infoDiv.display = infoLink.display = printLink.display = itemNumber.display = 'none';
	if (this.showCaption) {
		str = item.revOptions.caption || item.title || '';
		if (str === 'href') {
			str = this.encodeHTML(this.currentItem.href);
		} else {
			str = this.decodeHTML(str).replace(/&/g, '&amp;');
		}
		if (this.setInnerHTML(this.fbCaption, str) && str) infoPanel.display = captionDiv.display = caption.display = '';
	}
	if (item.revOptions.info) {
		str = this.encodeHTML(this.decodeHTML(item.revOptions.info));
		var options = item.revOptions.infoOptions || '';
		if (options) options = this.encodeHTML(this.decodeHTML(options));
		str = '<a href="' + str + '" rel="floatbox" rev="' + options + '"><b>' +
		(item.revOptions.infoText || this.strings.infoText) + '</b></a>';
		if (this.setInnerHTML(this.fbInfoLink, str)) infoPanel.display = infoDiv.display = infoLink.display = '';
	}
	if (item.revOptions.showPrint) {
		var css = item.revOptions.printCSS || '';
		str = '<a href="' + this.encodeHTML(this.currentItem.href) +
		'" onclick="fb.printContents(null, \'' + css + '\'); if (window.event) event.returnValue = false; return false;"><b>' +
		(item.revOptions.printText || this.strings.printText) + '</b></a>';
		if (this.setInnerHTML(this.fbPrintLink, str)) infoPanel.display = infoDiv.display = printLink.display = '';
	}
	if (this.lclShowItemNumber) {
		str = this.justImages ? this.strings.imgCount : this.strings.nonImgCount;
		str = str.replace('%1', this.currentIndex + 1);
		str = str.replace('%2', this.itemCount);
		if (this.setInnerHTML(this.fbItemNumber, str)) infoPanel.display = infoDiv.display = itemNumber.display = '';
	}
	var w = this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth;
	if (this.ie) {
		if (this.fbInfoLink.offsetWidth) w += this.infoLinkGap;
		if (this.fbPrintLink.offsetWidth) w += this.infoLinkGap;
		if (this.fbItemNumber.offsetWidth) w += this.infoLinkGap;
	}
	infoDiv.width = w + 'px';
	if (this.lclNumIndexLinks) {
		str = '';
		var max = this.itemCount - 1,
			loRange, hiRange;
		if (this.lclNumIndexLinks === -1) {
			loRange = 0;
			hiRange = max;
		} else {
			var range = Math.floor(this.lclNumIndexLinks/2) - 1;
			loRange = this.currentIndex - range;
			hiRange = this.currentIndex + range;
			if (loRange <= 0) hiRange += Math.min(1 - loRange, range);
			if (this.currentIndex === 0) hiRange++;
			if (hiRange - max >= 0) loRange -= Math.min(1 + hiRange - max, range);
			if (this.currentIndex === max) loRange--;
		}
		var pos = this.indexTop ? 'down' : 'up',
			i = 0;
		while (i < this.itemCount) {
			if (i !== 0 && i < loRange) {
				str += '... ';
				i = loRange;
			} else if (i !== max && i > hiRange) {
				str += '... ';
				i = max;
			} else {
				if (i !== this.currentIndex) {
					var item = this.items[i];
					str += '<a class="fbPop' + pos + '" rel="nofloatbox" href="' + item.href +
					'" onclick="fb.newContent(' + i + '); if (window.event) event.returnValue = false; return false;">' + ++i;
					try {
						if (this.showIndexThumbs && item.thumb) {
							str += '<img src="' + item.thumb.src + '" />';
						}
					} catch(e) {}
					str += '</a> ';
				} else {
					str += ++i + ' ';
				}
			}
		}
		if (this.setInnerHTML(this.fbIndexLinks, str)) {
			if (this.indexLinksPanel === 'info') {
				infoPanel.display = '';
			} else {
				this.tagAnchors(this.fbIndexLinks);
			}
		}
	}
	if (!infoPanel.display) this.tagAnchors(this.fbInfoPanel);
},
calcSize: function(fit, pass) {
	var that = this;
	if (!this.fbBox) return;
	var boxX, boxY, boxW, boxH, mainW, mainH ;
	if (typeof fit === 'undefined') {
		fit = this.currentItem.type === 'img' ? this.autoSizeImages : this.autoSizeOther;
	}
	var box = this.fbBox.style,
		infoPanel = this.fbInfoPanel.style,
		controlPanel = this.fbControlPanel.style,
		indexLinks = this.fbIndexLinks.style,
		captionDiv = this.fbCaptionDiv.style,
		itemNumber = this.fbItemNumber.style;
	if (!pass) {
		this.displaySize = this.getDisplaySize();
		if (this.showCaption && this.fbCaption.innerHTML) captionDiv.display = '';
		if (this.lclShowItemNumber) itemNumber.display = '';
	}
	this.upperSpace = Math.max(this.infoTop ? this.fbInfoPanel.offsetHeight : 0, this.controlTop ? this.fbControlPanel.offsetHeight : 0);
	this.lowerSpace = Math.max(this.infoTop ? 0 : this.fbInfoPanel.offsetHeight, this.controlTop ? 0 : this.fbControlPanel.offsetHeight);
	if (this.upperSpace) this.upperSpace += 2*this.panelPadding;
	if (this.lowerSpace) this.lowerSpace += 2*this.panelPadding;
	this.upperSpace = Math.max(this.upperSpace, this.padding);
	this.lowerSpace = Math.max(this.lowerSpace, this.padding);
	var extraSpace;
	if (this.shadowType === 'none') {
		extraSpace = 2*this.autoSizeSpace;
	} else if (this.shadowType === 'halo') {
		extraSpace = 2*this.shadowSize + this.autoSizeSpace;
	} else {
		extraSpace = this.shadowSize + 1.5*this.autoSizeSpace;
	}
	var pad = 2*(this.outerBorder + this.innerBorder) + extraSpace,
		maxW = Math.floor(this.displaySize.width - pad - 2*this.padding),
		maxH = Math.floor(this.displaySize.height - pad - this.upperSpace - this.lowerSpace),
		hardW = false, hardH = false;
	mainW = this.currentItem.nativeWidth + '';
	if (mainW === 'max') {
		mainW = maxW;
	} else if (mainW.substr(mainW.length - 1) === '%') {
		mainW = Math.floor(maxW * parseInt(mainW, 10) / 100);
	} else {
		mainW = parseInt(mainW, 10);
		hardW = true;
	}
	mainH = this.currentItem.nativeHeight + '';
	if (mainH === 'max') {
		mainH = maxH;
	} else if (mainH.substr(mainH.length - 1) === '%') {
		mainH = Math.floor(maxH * parseInt(mainH, 10) / 100);
	} else {
		mainH = parseInt(mainH, 10);
		hardH = true;
	}
	this.scaledBy = this.oversizedBy = 0;
	if (fit) {
		var scaleW = maxW/mainW,
			scaleH = maxH/mainH,
			fullW = mainW, fullH = mainH;
		if (hardW && hardH) scaleW = scaleH = Math.min(scaleW, scaleH);
		if (scaleW < 1) mainW = Math.round(mainW * scaleW);
		if (scaleH < 1) mainH = Math.round(mainH * scaleH);
		this.scaledBy = Math.max(fullW - mainW, fullH - mainH);
		if (this.scaledBy && this.scaledBy < this.outerBorder + extraSpace + this.panelPadding) {
			mainW = fullW;
			mainH = fullH;
			this.scaledBy = 0;
		}
	}
	boxW = mainW + 2*(this.innerBorder + this.padding);
	boxH = mainH + 2*this.innerBorder + this.upperSpace + this.lowerSpace;
	var infoH = this.fbInfoPanel.offsetHeight,
		controlH = this.fbControlPanel.offsetHeight;
	var infoW = boxW - 2*Math.max(this.padding, this.panelPadding);
	if (this.infoTop === this.controlTop && this.fbControls.offsetWidth) {
		infoW -= this.fbControls.offsetWidth + this.panelGap;
	}
	if (infoW < 0) infoW = 0;
	infoPanel.width = infoW + 'px';
	if (!this.lclNumIndexLinks) {
		var indexW = 0;
	} else if (this.indexLinksPanel === 'info' || this.infoTop !== this.controlTop) {
		var indexW = infoW;
	} else if (this.indexLinksPanel !== 'info' && this.infoTop === this.controlTop && this.infoCenter) {
		var indexW = Math.max(this.minIndexWidth, this.fbControls.offsetWidth);
	} else {
		var infoUsed = Math.max(this.fbCaption.offsetWidth, this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth);
		var indexW = Math.max(this.minIndexWidth, this.fbControls.offsetWidth, (boxW - infoUsed - 2*Math.max(this.padding, this.panelPadding)));
		if (infoUsed) indexW -= this.panelGap;
	}
	if (indexW) indexLinks.width = (indexW - (this.indexLinksPanel !== 'info' ? 2 : 0)) + 'px';
	controlPanel.width = Math.max(indexW, this.fbControls.offsetWidth) + 'px';
	var changed = this.fbInfoPanel.offsetHeight !== infoH || this.fbControlPanel.offsetHeight !== controlH;
	if (this.showCaption) {
		if (this.minInfoWidth > infoW && !captionDiv.display) {
			captionDiv.display = 'none';
			changed = true;
		}
	}
	if (this.lclShowItemNumber) {
		if (this.fbInfoLink.offsetWidth + this.fbPrintLink.offsetWidth + this.fbItemNumber.offsetWidth > infoW && !itemNumber.display) {
			itemNumber.display = 'none';
			changed = true;
		}
	}
	if (changed && pass !== 3) return this.calcSize(fit, (pass || 0) + 1);
	if (!fit) this.oversizedBy = Math.max(boxW - this.displaySize.width, boxH - this.displaySize.height) + 2*this.outerBorder + extraSpace;
	if (this.oversizedBy < 0) this.oversizedBy = 0;
	if (this.shadowType === 'halo') {
		extraSpace = this.shadowSize + this.autoSizeSpace/2;
	} else {
		extraSpace = this.autoSizeSpace;
	}
	if (typeof this.boxLeft === 'number') {
		boxX = this.boxLeft;
	} else if (mainW === maxW) {
		boxX = extraSpace;
	} else {
		var freeSpace = this.displaySize.width - boxW - 2*this.outerBorder;
		boxX = Math.floor(freeSpace/2);
		if (boxX < this.autoSizeSpace) {
			boxX = this.autoSizeSpace;
		} else {
			if (typeof this.boxLeft === 'string' && this.boxLeft.substr(this.boxLeft.length - 1) === '%') {
				boxX += parseInt(this.boxLeft, 10)/100 * boxX;
			}
		}
	}
	if (typeof this.boxTop === 'number') {
		boxY = this.boxTop;
	} else if (mainH === maxH) {
		boxY = extraSpace;
	} else {
		var freeSpace = this.displaySize.height - boxH - 2*this.outerBorder,
			ratio = freeSpace / this.displaySize.height, factor;
		if (ratio <= 0.15) {
			factor = 2;
		} else if (ratio >= 0.3) {
			factor = 3;
		} else {
			factor = 1 + ratio/0.15;
		}
		boxY = Math.floor(freeSpace/factor);
		if (boxY < this.autoSizeSpace) {
			boxY = this.autoSizeSpace;
		} else {
			if (typeof this.boxTop === 'string' && this.boxTop.substr(this.boxTop.length - 1) === '%') {
				boxY += parseInt(this.boxTop, 10)/100 * boxY;
			}
		}
	}
	var boxPosition = box.position;
	if (this.ieOld) {
		box.display = 'none';
		this.stretchOverlay()();
	} else {
		this.setPosition(this.fbBox, 'fixed');
	}
	var scroll = this.getScroll();
	this.setPosition(this.fbBox, boxPosition);
	box.display = '';
	boxX += scroll.left;
	boxY += scroll.top;
	if (this.isChild) {
		var rex = /max|%/i,
			pos = this.fbParent.pos.fbBox,
			childX = rex.test(this.currentItem.nativeWidth) ? 99999 : (pos.left + boxX)/2,
			childY = rex.test(this.currentItem.nativeHeight) ? 99999 : (pos.top + boxY)/2;
		if (scroll.left < childX && scroll.top < childY) {
			boxX = Math.min(boxX, childX);
			boxY = Math.min(boxY, childY);
		}
	}
	var split = (pos = this.pos.fbBox) && !this.liveResize && this.splitResize;
	if (split === 'auto') split = boxW - pos.width <= boxH - pos.height ? 'wh' : 'hw';
	var oncomplete2 = function() {
		that.fbBox.style.visibility ? that.zoomIn() : that.showContent();
	};
	var oncomplete = function() {
		that.setSize(split,
			{ id: 'fbBox', left: boxX, top: boxY, width: boxW, height: boxH, borderWidth: that.outerBorder },
			{ id: 'fbMainDiv', width: mainW, height: mainH, top: that.upperSpace },
			function() { that.timeouts.showContent = setTimeout(oncomplete2, 10); }
		);
	};
	this.timeouts.setSize = setTimeout(oncomplete, 10);
},
setPosition: function(el, position) {
	if (el.style.position === position) return;
	var scroll = this.getScroll();
	if (position === 'fixed') {
		scroll.left = -scroll.left;
		scroll.top = -scroll.top;
	}
	if (this.pos[el.id]) {
		this.pos[el.id].left += scroll.left;
		this.pos[el.id].top += scroll.top;
	}
	el.style.left = (el.offsetLeft + scroll.left) + 'px';
	el.style.top = (el.offsetTop + scroll.top) + 'px';
	el.style.position = position;
},
collapse: function(callback, phase) {
	var that = this;
	if (!phase) {
		this.setPosition(this.fbBox, 'absolute');
		this.fbResizer.onclick = null;
		this.fbResizer.style.display = 'none';
		if (this.fbContent) {
			this.fbContent.onclick = null;
			this.fbContent.style.cursor = '';
		}
		if (this.navOverlay) {
			this.fbLeftNav.style.display = this.fbRightNav.style.display =
			this.fbOverlayPrev.style.display = this.fbOverlayNext.style.display = 'none';
		}
		var opacity = 0, duration = 0;
		if (this.currentItem.type === 'img' && !this.fbCanvas.style.visibility) {
			if (this.currentItem === this.lastShown && this.liveImageResize) opacity = 1;
			duration = this.imageFadeDuration;
		}
		this.liveResize = (opacity === 1);
		var oncomplete = function() { that.collapse(callback, 1); };
		return this.fadeOpacity(this.fbCanvas, opacity, duration, oncomplete);
	}
	if (!this.liveResize) {
		this.fbMainDiv.style.display = 'none';
		if (this.fbContent) this.fbContent.style.display = 'none';
		this.clearTimeout('loader');
		this.timeouts.loader = setTimeout(function() { that.fbLoader.style.display = ''; }, this.loaderDelay);
	}
	var infoPanel = this.fbInfoPanel.style,
		controlPanel = this.fbControlPanel.style;
	infoPanel.visibility = controlPanel.visibility = 'hidden';
	infoPanel.left = controlPanel.left = infoPanel.top = controlPanel.top = '-9999px';
	if (callback) callback();
},
restore: function(callback, phase) {
	var that = this;
	if (!phase) {
		if (this.fbShadowRight.style.display && this.shadowType !== 'none') {
			this.fbShadowRight.style.display = this.fbShadowBottom.style.display = '';
			if (this.shadowType === 'halo') {
				this.fbShadowTop.style.display = this.fbShadowLeft.style.display = '';
			} else {
				this.fbShadowCorner.style.display = '';
			}
		}
		var infoPanel = this.fbInfoPanel.style,
			controlPanel = this.fbControlPanel.style,
			pad = this.upperSpace + this.pos.fbMainDiv.height + 2*this.innerBorder;
		infoPanel.top = (((this.infoTop ? this.upperSpace : this.lowerSpace) - this.fbInfoPanel.offsetHeight) / 2 - 1 + (this.infoTop ? 0 : pad)) + 'px';
		controlPanel.top = (((this.controlTop ? this.upperSpace : this.lowerSpace) - this.fbControlPanel.offsetHeight) / 2 + (this.controlTop ? 0 : pad)) + 'px';
		var pad = Math.max(this.padding, this.panelPadding) + 'px';
		infoPanel.left = [this.infoLeft ? pad : ''];
		controlPanel.left = [this.controlLeft ? pad : ''];
		infoPanel.visibility = controlPanel.visibility = '';
		this.clearTimeout('loader');
		this.fbLoader.style.display = 'none';
		this.fbMainDiv.style.display = this.fbContent.style.display = '';
		var duration = (this.currentItem.type === 'img' && !this.fbCanvas.style.visibility) ? this.imageFadeDuration : 0,
			oncomplete = function() { that.restore(callback, 1); };
		return this.fadeOpacity(this.fbCanvas, 1, duration, oncomplete);
	}
	if (this.currentItem.type === 'img' ? this.resizeImages : this.resizeOther) {
		var scale = 0;
		if (this.scaledBy > 35) {
			scale = 1;
		} else if (this.oversizedBy > 28){
			scale = -1;
		}
		if (scale) {
			this.fbResizer.onclick = function() {
				if (that.isSlideshow && that.pauseOnResize && !that.isPaused) {
					that.setPause(true);
				}
				that.collapse(function() { that.calcSize(scale === -1); });
				if (window.event) event.returnValue = false;
				return false;
			};
			if (this.currentItem.type === 'img' && /cursor|both/.test(this.resizeTool)) {
				this.fbContent.style.cursor = 'url(' + (scale === -1 ? this.resizeDownCursor : this.resizeUpCursor) +'), default';
				this.fbContent.onclick = this.fbResizer.onclick;
			}
			if (this.currentItem.type !== 'img' || /topleft|both/.test(this.resizeTool)) {
				this.fbResizer.style.backgroundPosition = (scale === -1 ? 'bottom' : 'top');
				this.fadeOpacity(this.fbResizer, this.controlOpacity);
			}
		}
	}
	if (this.navOverlay) {
		var leftNav = this.fbLeftNav.style,
			rightNav = this.fbRightNav.style,
			overlayPrev = this.fbOverlayPrev.style,
			overlayNext = this.fbOverlayNext.style;
		leftNav.width = rightNav.width = Math.max(this.navOverlayWidth/100 * this.pos.fbMainDiv.width, this.fbOverlayPrev.offsetWidth) + 'px';
		leftNav.display = rightNav.display = '';
		if (fb.showNavOverlay) {
			overlayPrev.visibility = overlayNext.visibility = 'hidden';
			overlayPrev.display = overlayNext.display = '';
			overlayPrev.top = overlayNext.top = ((this.pos.fbMainDiv.height - this.fbOverlayPrev.offsetHeight) * this.navOverlayPos/100) + 'px';
		}
	}
	if (callback) callback();
},
setSize: function(order) {
	var that = this,
		oncomplete = function() {},
		arr = [[], []],
		defer = {},
		node,
		i = arguments.length;
	if (order === 'wh') {
		defer.top = 1;
		defer.height = 1;
	} else if (order === 'hw') {
		defer.left = 1;
		defer.width = 1;
	}
	while (i--) {
		if (typeof arguments[i] === 'object' && (node = this[arguments[i].id])) {
			var obj = arguments[i];
			if (!this.pos[obj.id]) this.pos[obj.id] = {};
			for (var property in obj) {
				if (obj.hasOwnProperty(property) && property !== 'id') {
					var idx = defer[property] || 0;
					var start = this.pos[obj.id][property];
					if (typeof start !== 'number' || node.style.display || node.style.visibility) {
						start = obj[property];
					}
					arr[idx].push({ node: node, property: property, start: start, finish: obj[property] });
					if (obj.id === 'fbMainDiv') {
						arr[idx].push({ node: this.fbContent, property: property, start: start, finish: obj[property] });
					}
					if (obj.id === 'fbZoomDiv' && /\b(width|height)\b/i.test(property)) {
						arr[idx].push({ node: this.fbZoomImg, property: property, start: start, finish: obj[property] });
					}
					this.pos[obj.id][property] = obj[property];
				}
			}
		} else if (typeof arguments[i] === 'function') {
			oncomplete = arguments[i];
		}
	}
	this.resizeGroup(arr[0], function() { that.resizeGroup(arr[1], oncomplete); });
},
showContent: function(phase) {
	var that = this;
	if (!phase) {
		var displaySize = this.getDisplaySize();
		if (!this.resized) {
			var vscrollChanged = displaySize.width !== this.displaySize.width,
				hscrollChanged = displaySize.height !== this.displaySize.height;
			if ((vscrollChanged && Math.abs(this.pos.fbBox.width - displaySize.width) < 50) ||
			(hscrollChanged && Math.abs(this.pos.fbBox.height - displaySize.height) < 50)) {
				this.resized = true;
				return this.calcSize(this.scaledBy);
			}
		}
		this.resized = false;
		self.focus();
		if (this.ieOld) this.stretchOverlay()();
		if ((this.disableScroll || (this.ffOld && /iframe|quicktime/i.test(this.currentItem.type))) && !(this.ieOld || this.webkitOld || this.ie8b2)) {
			if (this.pos.fbBox.width <= displaySize.width && this.pos.fbBox.height <= displaySize.height) {
				this.setPosition(this.fbBox, 'fixed');
			}
		}
		if (this.currentItem.type === 'iframe') {
			this.fbContent.src = this.currentItem.href;
		} else if (/flash|quicktime/.test(this.currentItem.type)) {
			this.setInnerHTML(this.fbContent, this.objectHTML(this.currentItem.href,
			this.currentItem.type, this.pos.fbMainDiv.width, this.pos.fbMainDiv.height));
		}
		this.prevIndex = this.currentIndex ? this.currentIndex - 1 : this.itemCount - 1;
		this.nextIndex = this.currentIndex < this.itemCount - 1 ? this.currentIndex + 1 : 0;
		var prevHref = this.enableWrap || this.currentIndex !== 0 ? this.items[this.prevIndex].href : '',
			nextHref = this.enableWrap || this.currentIndex !== this.itemCount - 1 ?  this.items[this.nextIndex].href : '';
		if (this.navButton) {
			if (prevHref) {
				if (!this.operaOld) this.fbPrev.href = prevHref;
				this.fbPrev.title = this.fbOverlayPrev.title;
			} else {
				this.fbPrev.removeAttribute('href');
				this.fbPrev.title = '';
			}
			if (nextHref) {
				if (!this.operaOld) this.fbNext.href = nextHref;
				this.fbNext.title = this.fbOverlayNext.title;
			} else {
				this.fbNext.removeAttribute('href');
				this.fbNext.title = '';
			}
			var prevOn = this.fbPrev.className.replace('_off', ''),
				nextOn = this.fbNext.className.replace('_off', '');
			this.fbPrev.className = prevOn + (prevHref ? '' : '_off');
			this.fbNext.className = nextOn + (nextHref ? '' : '_off');
		}
		if (this.navOverlay) {
			if (!this.operaOld) {
				this.fbLeftNav.href = this.fbOverlayPrev.href = prevHref;
				this.fbRightNav.href = this.fbOverlayNext.href = nextHref;
			}
			this.fbLeftNav.style.visibility = prevHref ? '' : 'hidden';
			this.fbRightNav.style.visibility = nextHref ? '' : 'hidden';
			fb.navOverlayShown = true;
		}
		this.fbCanvas.style.visibility = '';
		return this.restore(function() {
			that.timeouts.showContent = setTimeout(function() { that.showContent(1); }, 10);
		} );
	}
	this.lastShown = this.currentItem;
	if (!this.currentItem.seen) {
		this.currentItem.seen = true;
		this.itemsShown++;
	}
	if (this.isSlideshow && !this.isPaused) {
		this.timeouts.slideshow = setTimeout(function() {
			if (that.endTask === 'loop' || that.itemsShown < that.itemCount) {
				that.newContent(that.nextIndex);
			} else if (that.endTask === 'exit') {
				that.end();
			} else {
				that.setPause(true);
				var i = that.itemCount;
				while (i--) that.items[i].seen = false;
				that.itemsShown = 0;
			}
		}, this.slideInterval*1000);
	}
	this.timeouts.preload = setTimeout(function() {
			that.preloadImages(nextHref || prevHref || '', true);
	}, 10);
},
objectHTML: function(href, type, width, height) {
	if (type === 'flash') {
		var classid = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"',
			mime = 'type="application/x-shockwave-flash"',
			pluginurl = 'http://get.adobe.com/flashplayer/',
			match = /\bwmode=(\w+?)\b/i.exec(href),
			wmode = match ? match[1] : 'window',
			match = /\bbgcolor=(#\w+?)\b/i.exec(href),
			bgcolor = match ? match[1] : '',
			match = /\bscale=(\w+?)\b/i.exec(href),
			scale = match ? match[1] : 'exactfit',
			params = { wmode:wmode, bgcolor:bgcolor, scale:scale, quality:'high',
			flashvars:'autoplay=1&amp;ap=true&amp;border=0&amp;rel=0' };
		if (this.ffOld) params.wmode = this.ffMac ? 'window' : 'opaque';
		if (this.ffNew && href.indexOf('YV_YEP.swf') !== -1) params.wmode = 'window';
	} else {
		var classid = 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"',
			mime = 'type="video/quicktime"',
			pluginurl = 'http://www.apple.com/quicktime/download/',
			params = { autoplay:'true', controller:'true', showlogo:'false', scale:'tofit' };
	}
	var html = '<object id="fbObject" name="fbObject" width="' + width + '" height="' + height + '" ';
	if (this.ie) {
		html += classid + '>';
		params[type === 'flash' ? 'movie' : 'src'] = this.encodeHTML(href);
	} else {
		html += mime + ' data="' + this.encodeHTML(href) + '">';
	}
	for (var name in params) {
		if (params.hasOwnProperty(name)) {
			html += '<param name="' + name + '" value="' + params[name] + '" />';
		}
	}
	if (type === 'quicktime' && this.webkitMac) {
		html += '<embed src="' + this.encodeHTML(href) +
		'" width="' + width + '" height="' + height + '" autoplay="true" controller="true" showlogo="false" scale="tofit" pluginspage="' +
		pluginurl + '"></embed></object>';
	} else {
		html += '<p style="color:#000; background:#fff; margin:1em; padding:1em;">' +
		(type === 'flash' ? 'Flash' : 'QuickTime') + ' player is required to view this content.' +
		'<br /><a href="' + pluginurl + '">download player</a></p></object>';
	}
	return html;
},
newContent: function(index) {
	var that = this;
	this.clearTimeout('slideshow');
	this.clearTimeout('resize');
	this.currentIndex = index;
	fb.previousAnchor = this.currentItem;
	this.currentItem = this.items[index];
	if (this.showNavOverlay == 'once' && this.navOverlayShown) this.showNavOverlay = false;
	var oncomplete = function() {
		that.updatePanels();
		that.fetchContent(function() { that.calcSize(); });
	};
	this.collapse(function() {
		that.timeouts.fetch = setTimeout(oncomplete, 10);
	} );
},
end: function(all) {
	if (this !== fb.lastChild) return fb.lastChild.end(all);
	var that = this;
	this.endAll = this.endAll || all;
	this.fbOverlay.onclick = null;
	if (this.isChild) {
		if (this.endAll) this.imageFadeDuration = this.overlayFadeDuration = this.resizeDuration = 0;
	} else {
		if (document.keydownSet) {
			document.onkeydown = this.priorOnkeydown;
			document.keydownSet = false;
		}
		if (this.keypressSet) {
			document.onkeypress = this.priorOnkeypress;
			document.keypressSet = false;
		}
		parent.focus();
	}
	if (this.ieOld) {
		detachEvent('onresize', this.stretchOverlay());
		detachEvent('onscroll', this.stretchOverlay());
	}
	for (var key in this.timeouts) {
		if (this.timeouts.hasOwnProperty(key)) this.clearTimeout(key);
	}
	if (this.fbBox.style.visibility) {
		if (!this.lastShown) this.fbZoomDiv.style.display = 'none';
	} else if (this.currentItem.type === 'img' && this.zoomImageStart) {
		if (this.currentItem.popup) this.currentItem.anchor.onmouseover();
		var anchorPos = this.getAnchorPos(this.currentItem.anchor, true);
		if (this.currentItem.popup) this.currentItem.anchor.onmouseout();
		if (anchorPos.width) {
			this.fbZoomDiv.style.borderWidth = this.zoomPopBorder + 'px';
			anchorPos.left -= this.zoomPopBorder;
			anchorPos.top -= this.zoomPopBorder;
			this.pos.thumb = anchorPos;
			return this.zoomOut();
		}
	}
	if (!this.fbBox.style.visibility) {
		var anchorPos = this.getAnchorPos(this.currentItem.anchor, !this.currentItem.popup),
			offset = this.initialSize/2,
			initialPos = { id: 'fbBox', left: anchorPos.left - offset, top: anchorPos.top - offset, width: this.initialSize, height: this.initialSize },
			zeroPos = { id: 'fbBox', left: anchorPos.left, top: anchorPos.top, width: 0, height: 0, borderWidth: 0 },
			split = this.splitResize;
		if (split === 'wh') {
			split = 'hw';
		} else if (split === 'hw') {
			split = 'wh';
		} else if (split === 'auto') {
			split = this.pos.fbBox.width <= this.pos.fbBox.height ? 'hw' : 'wh';
		}
		var oncomplete3 = function() {
			setTimeout(function() {
				that.fbBox.style.visibility = 'hidden';
				that.end();
			}, 10);
		};
		if (split) {
			var oncomplete2 = function() {
				that.setSize(split, initialPos, function() {
					that.setSize(zeroPos, oncomplete3);
				});
			};
		} else {
			var oncomplete2 = function() {
				that.setSize(zeroPos, oncomplete3);
			};
		}
		var oncomplete = function() {
			if (that.fbContent) {
				that.fbMainDiv.removeChild(that.fbContent);
				delete that.fbContent;
			}
			that.fbLoader.style.display = '';
			that.fbCanvas.style.display = that.fbShadowTop.style.display = that.fbShadowRight.style.display =
			that.fbShadowBottom.style.display = that.fbShadowLeft.style.display = that.fbShadowCorner.style.display = 'none';
			oncomplete2();
		};
		return this.collapse(oncomplete);
	}
	this.fbBox.style.display = 'none';
	var level = this.children.length + 1,
		i = this.anchors.length;
	while(i && this.anchors[i-1].level >= level) i--;
	this.anchors.length = i;
	if (this.isChild) this.children.length--;
	fb.lastChild = this.children[this.children.length-1] || fb;
	var oncomplete2 = function() {
		setTimeout(function() {
			while (that.nodeNames.length) {
				var id = that.nodeNames.pop();
				if (that[id] && that[id].parentNode) {
					that[id].parentNode.removeChild(that[id]);
					delete that[id];
				}
			}
			if (that.endAll && that.isChild) {
				return fb.end(true);
			} else if (that.loadPageOnClose) {
				if (that.loadPageOnClose === 'self' || that.loadPageOnClose === 'this') {
					location.reload(true);
				} else if (that.loadPageOnClose === 'back') {
					history.back();
				} else {
					location.replace(that.loadPageOnClose);
				}
			}
		}, 10);
	};
	var oncomplete = function() {
		while(that.hiddenEls.length) {
			var el = that.hiddenEls.pop();
			el.style.visibility = 'visible';
			if (this.ffOld && this.ffMac) {
				el.focus();
				el.blur();
			}
		}
		var overlay = that.fbOverlay.style;
		overlay.display = 'none';
		overlay.width = overlay.height = '0';
		var duration = that.currentItem.popup ? 6.5 : 0;
		that.fbZoomDiv.style.opacity = '1';
		that.fadeOpacity( that.fbZoomDiv, 0, duration, oncomplete2);
		that.currentItem = fb.previousAnchor = null;
	};
	this.fadeOpacity(this.fbOverlay, 0, this.overlayFadeDuration, oncomplete);
},
zoomIn: function(phase) {
	var that = this,
		zoomDiv = this.fbZoomDiv.style;
	if (!phase) {
		this.clearTimeout('slowLoad');
		zoomDiv.display = this.fbZoomImg.style.display = '';
		if (this.currentItem.popup) this.currentItem.anchor.onmouseout();
		var pad = this.outerBorder + this.innerBorder - this.zoomPopBorder;
		var oncomplete = function () {
			that.fbZoomImg.src = that.currentItem.href;
			that.setSize(
				{ id: 'fbZoomDiv', width: that.pos.fbMainDiv.width, height: that.pos.fbMainDiv.height,
				left: that.pos.fbBox.left + pad + that.padding, top: that.pos.fbBox.top + pad + that.upperSpace },
				function() { that.zoomIn(1); } );
		};
		return this.fadeOpacity(this.fbOverlay, this.overlayOpacity, this.overlayFadeDuration, oncomplete);
	}
	if (phase === 1) {
		var boxPos = {
			left: this.pos.fbBox.left, top: this.pos.fbBox.top,
			width: this.pos.fbBox.width, height: this.pos.fbBox.height
		};
		var pad = 2*(this.zoomPopBorder - this.outerBorder);
		this.pos.fbBox = {
			left: this.pos.fbZoomDiv.left, top: this.pos.fbZoomDiv.top,
			width: this.pos.fbZoomDiv.width + pad, height: this.pos.fbZoomDiv.height + pad
		};
		this.fbBox.style.visibility = '';
		var oncomplete = function() {
			that.restore(function() { that.zoomIn(2); });
		};
		return this.setSize(
			{ id: 'fbBox', left: boxPos.left, top: boxPos.top,
			width: boxPos.width, height: boxPos.height},
			oncomplete);
	}
	var show = function() {
		zoomDiv.display = 'none';
		that.fbZoomImg.src = '';
		zoomDiv.left = zoomDiv.top = zoomDiv.width = zoomDiv.height = that.fbZoomImg.width = that.fbZoomImg.height = '0';
		that.showContent();
	};
	this.timeouts.showContent = setTimeout(show, 10);
},
zoomOut: function(phase) {
	var that = this;
	if (!phase) {
		this.fbZoomImg.src = this.currentItem.href;
		var pad = this.outerBorder + this.innerBorder - this.zoomPopBorder;
		this.setSize(
		{ id: 'fbZoomDiv', width: this.pos.fbMainDiv.width, height: this.pos.fbMainDiv.height,
		left: this.pos.fbBox.left + pad + this.padding, top: this.pos.fbBox.top + pad + this.upperSpace },
		function() { that.zoomOut(1); } );
	}
	if (phase === 1) {
		this.fbZoomDiv.style.display = this.fbZoomImg.style.display = '';
		this.fbCanvas.style.visibility = 'hidden';
		return this.collapse(function() { that.zoomOut(2); });
	}
	if (phase === 2) {
		var pad = 2*(this.zoomPopBorder - this.outerBorder);
		return this.setSize(
			{ id: 'fbBox', left: this.pos.fbZoomDiv.left, top: this.pos.fbZoomDiv.top,
			width: this.pos.fbZoomDiv.width + pad, height: this.pos.fbZoomDiv.height + pad },
			function() { that.zoomOut(3); }
		);
	}
	this.fbBox.style.visibility = 'hidden';
	var end = function() {
		that.fbZoomImg.src = that.pos.thumb.src;
		that.end();
	};
	this.setSize(
		{ id: 'fbZoomDiv', left: this.pos.thumb.left, top: this.pos.thumb.top,
		width: this.pos.thumb.width, height: this.pos.thumb.height },
		end);
},
setPause: function(pause) {
	this.isPaused = pause;
	if (pause) {
		this.clearTimeout('slideshow');
	} else {
		this.newContent(this.nextIndex);
	}
	if (this.showPlayPause) {
		this.fbPlay.style.left = pause ? '' : '-9999px';
		this.fbPause.style.left = pause ? '-9999px' : '';
	}
},
fadeOpacity: function(el, opacity, duration, callback) {
	var startOp = +(el.style.opacity || 0);
	duration = duration || 0;
	this.clearTimeout['fade' + el.id];
	var fadeIn = (startOp <= opacity && opacity > 0);
	if (duration > 10) duration = 10;
	if (duration < 0) duration = 0;
	if (duration === 0) {
		startOp = opacity;
		var incr = 1;
	} else {
		var root = Math.pow(100, 0.1),
			power = duration + ((10 - duration)/9) * (Math.log(2)/Math.log(root) - 1),
			incr = 1/Math.pow(root, power);
	}
	if (fadeIn) {
		el.style.display = el.style.visibility = '';
	} else {
		incr = -incr;
	}
	this.stepFade(el, startOp, opacity, incr, fadeIn, callback);
},
stepFade: function(el, thisOp, finishOp, incr, fadeIn, callback) {
	if (!el) return;
	var that = this;
	if ((fadeIn && thisOp >= finishOp) || (!fadeIn && thisOp <= finishOp)) thisOp = finishOp;
	if (this.ie) el.style.filter = 'alpha(opacity=' + thisOp*100 + ')';
	el.style.opacity = thisOp + '';
	if (thisOp === finishOp) {
		if (this.ie && finishOp >= 1) el.style.removeAttribute('filter');
		if (callback) callback();
	} else {
		this.timeouts['fade' + el.id] = setTimeout(function() { that.stepFade(el, thisOp + incr, finishOp, incr, fadeIn, callback); }, 20);
	}
},
resizeGroup: function(arr, callback) {
	var i = arr.length;
	if (!i) return callback ? callback() : null;
	this.clearTimeout('resize');
	var diff = 0;
	while (i--) {
		diff = Math.max(diff, Math.abs(arr[i].finish - arr[i].start));
	}
	var duration = this.resizeDuration * (this.liveResize ? 0.65 : 1);
	var rate = diff && duration ? Math.pow(Math.max(1, 2.2 - duration/10), (Math.log(diff))) / diff : 1;
	i = arr.length;
	while (i--) arr[i].diff = arr[i].finish - arr[i].start;
	this.stepResize(rate, rate, arr, callback);
},
stepResize: function(increment, rate, arr, callback) {
	var that = this;
	if (increment > 1) increment = 1;
	var i = arr.length;
	while (i--) {
		var node = arr[i].node,
			prop = arr[i].property,
			val = Math.round(arr[i].start + arr[i].diff * increment),
			tag = node.tagName.toLowerCase();
		if (tag === 'img' || tag === 'iframe') {
			node[prop] = val;
		} else {
			node.style[prop] = val + 'px';
		}
	}
	if (increment >= 1) {
		delete this.timeouts.resize;
		if (callback) callback();
	} else {
		this.timeouts.resize = setTimeout(function() { that.stepResize(increment + rate, rate, arr, callback); }, 20);
	}
},
getDisplaySize: function() {
	return { width: this.getDisplayWidth(), height: this.getDisplayHeight() };
},
getDisplayWidth: function() {
	return this.html.clientWidth || this.bod.clientWidth;
},
getDisplayHeight: function() {
	if (this.webkitOld) return window.innerHeight;
	if (!this.html.clientHeight || this.operaOld || document.compatMode === 'BackCompat') {
		return this.bod.clientHeight;
	}
	return this.html.clientHeight;
},
getScroll: function(win) {
	win = win || self;
	var doc = win.document,
		bod = doc.body || doc.getElementsByTagName('body')[0];
	return {
		left: win.pageXOffset || bod.scrollLeft || doc.documentElement.scrollLeft || 0,
		top: win.pageYOffset || bod.scrollTop || doc.documentElement.scrollTop || 0
	};
},
getLeftTop: function(el, local) {
	var left = el.offsetLeft || 0,
		top = el.offsetTop || 0,
		doc = el.ownerDocument || el.document,
		bod = doc.body || doc.getElementsByTagName('body')[0],
		win = doc.defaultView || doc.parentWindow || doc.contentWindow,
		scroll = this.getScroll(win),
		position = ((el.currentStyle && el.currentStyle.position) || (win.getComputedStyle && win.getComputedStyle(el, '').getPropertyValue('position')) || '').toLowerCase(),
		rex = /absolute|fixed/,
		elFlow = !rex.test(position),
		inFlow = elFlow,
		node = el;
	if (position === 'fixed') {
		left += scroll.left;
		top += scroll.top;
	}
	while (position !== 'fixed' && (node = node.offsetParent)) {
		var borderLeft = 0, borderTop = 0, nodeFlow = true;
		if (node.currentStyle) {
			position = (node.currentStyle.position || '').toLowerCase();
			nodeFlow = !rex.test(position);
			if (this.opera) {
				if (local && node !== bod) {
					left += node.scrollLeft - node.clientLeft;
					top += node.scrollTop - node.clientTop;
				}
			} else {
				if (node.currentStyle.hasLayout && node !== doc.documentElement) {
					borderLeft = node.clientLeft;
					borderTop = node.clientTop;
				}
			}
		} else if (win.getComputedStyle) {
			position = (win.getComputedStyle(node, '').getPropertyValue('position') || '').toLowerCase();
			nodeFlow = !rex.test(position);
			borderLeft = parseInt(win.getComputedStyle(node, '').getPropertyValue('border-left-width'), 10);
			borderTop = parseInt(win.getComputedStyle(node, '').getPropertyValue('border-top-width'), 10);
			if (this.ff && node === el.offsetParent && !nodeFlow && (this.ffOld || !elFlow)) {
				left += borderLeft;
				top += borderTop;
			}
		}
		if (!nodeFlow) {
			if (local) return { left: left, top: top };
			inFlow = false;
		}
		left += node.offsetLeft + borderLeft;
		top += node.offsetTop + borderTop;
		if (position === 'fixed') {
			left += scroll.left;
			top += scroll.top;
		}
		if (!(this.opera && elFlow) && node !== bod && node !== doc.documentElement) {
			left -= node.scrollLeft;
			top -= node.scrollTop;
		}
	}
	if (this.ff && inFlow) {
		left += parseInt(win.getComputedStyle(bod, '').getPropertyValue('border-left-width'), 10);
		top += parseInt(win.getComputedStyle(bod, '').getPropertyValue('border-top-width'), 10);
	}
	if (this.webkitOld) {
		var scriptElement = doc.createElement('script');
		scriptElement.innerHTML = 'document.parentWindow=self';
		doc.documentElement.appendChild(scriptElement);
		doc.documentElement.removeChild(scriptElement);
		win = doc.parentWindow;
	}
	if (!local && win !== self) {
		var iframes = win.parent.document.getElementsByTagName('iframe'),
			i = iframes.length;
		while (i--) {
			var node = iframes[i],
				idoc = false;
			try {
				idoc = node.contentDocument || node.contentWindow;
				idoc = idoc.document || idoc;
			} catch(e) {}
			if (idoc === doc || (typeof idoc !== 'object' && node.src === win.location.href.substr(win.location.href.length - node.src.length))) {
				if (this.webkitOld) win = doc.defaultView;
				var pos = this.getLeftTop(node);
				left += pos.left - scroll.left;
				top += pos.top - scroll.top;
				if (node.currentStyle) {
					var padLeft = 0, padTop = 0;
					if (!this.ie || elFlow) {
						padLeft = parseInt(node.currentStyle.paddingLeft, 10);
						padTop = parseInt(node.currentStyle.paddingTop, 10);
					}
					left += node.clientLeft + padLeft;
					top += node.clientTop + padTop;
				}
				else if (win.getComputedStyle) {
					left += parseInt(win.getComputedStyle(node, '').getPropertyValue('border-left-width'), 10) +
					parseInt(win.getComputedStyle(node, '').getPropertyValue('padding-left'), 10);
					top += parseInt(win.getComputedStyle(node, '').getPropertyValue('border-top-width'), 10) +
					parseInt(win.getComputedStyle(node, '').getPropertyValue('padding-top'), 10);
				}
				break;
			}
		}
	}
	return { left: left, top: top };
},
getLayout: function(el) {
	var lay = this.getLeftTop(el);
	lay.width = el.offsetWidth;
	lay.height = el.offsetHeight;
	return lay;
},
clearTimeout: function(key) {
	if (this.timeouts[key]) {
		clearTimeout(this.timeouts[key]);
		delete this.timeouts[key];
	}
},
stretchOverlay: function() {
	var that = this;
	return function() {
		if (arguments.length === 1) {
			that.clearTimeout('stretch');
			that.timeouts.stretch = setTimeout(function() { that.stretchOverlay()(); }, 25);
		} else {
			delete that.timeouts.stretch;
			if (!that.fbBox) return;
			var width = that.fbBox.offsetLeft + that.fbBox.offsetWidth,
				height = that.fbBox.offsetTop + that.fbBox.offsetHeight,
				display = that.getDisplaySize(),
				scroll = that.getScroll(),
				overlay = that.fbOverlay.style;
			overlay.width = overlay.height = '0';
			overlay.width = Math.max(width, that.bod.scrollWidth, that.bod.clientWidth, that.html.clientWidth, display.width + scroll.left) + 'px';
			overlay.height = Math.max(height, that.bod.scrollHeight, that.bod.clientHeight, that.html.clientHeight, display.height + scroll.top) + 'px';
		}
	};
},
encodeHTML: function(str) {
	return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
},
decodeHTML: function(str) {
	return str.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&#39;/g, "'");
},
getXMLHttpRequest: function() {
	var xhr, that = this;
	if (window.XMLHttpRequest) {
		if (!(xhr = new XMLHttpRequest())) return false;
	} else {
		try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {
			try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { return false; }
		}
	}
	return {
		getResponse: function(url, callback) {
			try {
				xhr.open('GET', url, true);
				xhr.setRequestHeader('If-Modified-Since', 'Thu, 1 Jan 1970 00:00:00 GMT');
				xhr.setRequestHeader('Cache-Control', 'no-cache');
				xhr.onreadystatechange = function() {
					if (xhr.readyState === 4) {
						xhr.onreadystatechange = function() {};
						callback(xhr);
					}
				};
				xhr.send(null);
			} catch(e) {}
		}
	};
},
setInnerHTML: function(el, strHTML) {
	try {
		var range = document.createRange();
		range.selectNodeContents(el);
		range.deleteContents();
		if (strHTML) {
			var xmlDiv = new DOMParser().parseFromString('<div xmlns="http://www.w3.org/1999/xhtml">' + strHTML + '</div>', 'application/xhtml+xml'),
				childNodes = xmlDiv.documentElement.childNodes;
			for (var i = 0, len = childNodes.length; i < len; i++) {
				el.appendChild(document.importNode(childNodes[i], true));
			}
		}
		return true;
	} catch (e) {}
	try {
		el.innerHTML = strHTML;
		return true;
	} catch(e) {}
	return false;
},
printContents: function(el, style) {
	if (el && el.offsetWidth) {
		var width = el.offsetWidth,
			height = el.offsetHeight;
	} else {
		el = fb.lastChild.fbContent;
		var pos = fb.lastChild.pos.fbMainDiv,
			width = pos.width,
			height = pos.height;
	}
	var win = window.open('', '', 'width=' + width + ', height=' + height),
		doc = win && win.document;
	if (!doc) {
		alert('Popup windows are being blocked by your browser.\nUnable to print.');
		return false;
	}
	if (/\.css$/i.test(style)) {
		style = '<link rel="stylesheet" type="text/css" href="' + style + '" />';
	} else {
		style = '<style type="text/css"> html,body{border:0;margin:0;padding:0;}' + (style || '') + '</style>';
	}
	var div = document.createElement('div');
	div.appendChild(el.cloneNode(true));
	doc.open('text/html');
	doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' +
	' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>' +
	style + '</head><body><div>' + div.innerHTML + '</div></body></html>');
	doc.close();
	setTimeout(function() { win && win.print(); win && win.close(); }, 200);
	return true;
},
loadAnchor: function(href, rev, title) {
	if (href.setAttribute) {
		var anchor = href;
		if (!anchor.getAttribute('rel')) anchor.setAttribute('rel', 'floatbox');
		fb.lastChild.start(this.tagOneAnchor(anchor));
	} else {
		fb.lastChild.start(this.tagOneAnchor({ href: href, rev: rev, title: title, rel: 'floatbox' }));
	}
},
goBack: function() {
	var a = fb.previousAnchor;
	if (a) this.loadAnchor(a.href, a.rev + ' sameBox:true', a.title);
},
resize: function(width, height) {
	var changed = false;
	if (width && fb.lastChild.currentItem && fb.lastChild.currentItem.nativeWidth != width) {
		fb.lastChild.currentItem.nativeWidth = width;
		changed = true;
	}
	if (height && fb.lastChild.currentItem && fb.lastChild.currentItem.nativeHeight != height) {
		fb.lastChild.currentItem.nativeHeight = height;
		changed = true;
	}
	if (changed) fb.lastChild.calcSize(false);
}
};
function initfb() {
	if (arguments.callee.done) return;
	var fbWindow = 'self';
	if (self !== parent) {
		try {
			if (self.location.host === parent.location.host && self.location.protocol === parent.location.protocol) fbWindow = 'parent';
		} catch(e) {}
		if (fbWindow === 'parent' && !parent.fb) return setTimeout(initfb, 50);
	}
	arguments.callee.done = true;
	if (document.compatMode === 'BackCompat') {
		alert('Floatbox does not support quirks mode.\nPage needs to have a valid a doc type.');
		return;
	}
	fb = (fbWindow === 'self' ? new Floatbox() : parent.fb);
	fb.tagAnchors(self.document.body || self.document.getElementsByTagName('body')[0]);
	if (fb.autoStart) {
		fb.start(fb.autoStart);
		if (typeof fb !== 'undefined') delete fb.autoStart;
	} else {
		fb.preloadImages('', true);
	}
}
if (document.addEventListener) {
	document.addEventListener('DOMContentLoaded', initfb, false);
}
(function() {
	/*@cc_on
	if (document.body !== null) {
		try {
			document.createElement('div').doScroll('left');
			return initfb();
		} catch(e) {}
	}
	/*@if (false) @*/
	if (/loaded|complete/.test(document.readyState)) return initfb();
	/*@end @*/
	if (!initfb.done) setTimeout(arguments.callee, 50);
})();
fb_prevOnload = window.onload;
window.onload = function() {
	if (typeof fb_prevOnload === 'function') fb_prevOnload();
	initfb();
};
