////////////////////////////////////////////////////////////////////////////
//   Script Name: Sh content viewer                                      //
//   Version: 0.95                                                      //
//   Author: Bracsek  (bracsek(at)dweb(dot)ro)                         //
//   Author URI: http://bracsek.extra.hu                              //
//   Last update 2009/05/16                                          //
//   Copyright(c) 2009 DWEB(R)                                      //
//   External lybrarys: Jquery.js,ui.core.js,ui.draggable.js       //
//   Included lybrarys: f_client*()                               //
//   changlog:                                                   //
//     added slideshow                                          //
//                                                             //
//                                                            //
//                                                           //            
//////////////////////////////////////////////////////////////

// for ie 6 fixed positioned divs
//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//<html xmlns="http://www.w3.org/1999/xhtml">

// for single image
// <a href='imageurl' rel='sh' [title=".htmlspecialchars('mit ')."]  >...</a>

// for gallery [rev='gal*'] 
// <a href='imageurl' rel='sh' rev='gal*' [title=".htmlspecialchars('mit ')."]  >...</a>

// for slideshow
// <a href='imageurl' rel='shs' [rev='gal*'] [title=".htmlspecialchars('mit ')."]  >...</a>

// for iframe
//<a title="" href="javascript:" onclick="shbox.sh({url:'x.html',width:'600',height:'300',type:'iframe'});"> ... </a>


var box1,box2;
var globalSlideshowTimer;
var globalGalery;
var globalGaleryIndex;
var keptarak = new Array();
var keptarakLinkek = new Array();

var shBox = function(){

this.box;     //elsotetedo box 
this.settings;
this.boxC;    //fixed pozicioju div
this.boxLeft;
this.boxLeftTop;
this.boxCellContent; //ebben jelenik meg a tartalom
this.boxCTable;
this.progressSig;
this.slideShowTimer = 4500;
this.lang = "ro";

this.langTxt = {
	hu : {
		bezar:'Bezár',
		elozo:'Előző',
		kovetkezo:'Következő',
		elso:'Első',
		utolso:'Utolsó',
		segitseg:'Kezelés: \n\n'+
		'     P,E      -  Billentyűk lenyomása előző kép megtekintése \n '+
		'    N,K      -  Billentyűk lenyomása következő kép megtekintése \n '+
		'    S          - Diavetítés elinditása \n '+
		'    Esc, X  - Kilépés az Sh content viewer-ből \n '+
		'    F1,H     - Súgó megtekintése \n\n '+
		'                   Sh content viewer \n '+
		'                Copyright(C) 2009 DWEB(R)   \n '
	},
	ro : {
		bezar:'Close',
		elozo:'Anterior',
		kovetkezo:'Urmatorul',	
		elso:'Primul',
		utolso:'Ultimul',
		segitseg:''
	},
	en :{
		bezar:'Close',
		elozo:'Previous',
		kovetkezo:'Next',	
		elso:'First',
		utolso:'Last',
		segitseg:''
	},
	de :{
		bezar:'Close',
		elozo:'Previous',
		kovetkezo:'Next',	
		elso:'First',
		utolso:'Last',
		segitseg:''
	}
	
	
	
}

var opacityLevel = "0.4";
var fadingTime = 700;
var animateLength = 300;

this.sh_imageloader;
this.boxCell;
this.boxLabel;
this.init = function(){
	this.loadVars();
	this.hatterDoboz();
	this.changeAnchors();
	//this.handleKeyControl();
	this.setFlashWmode();
}

this.fadeIn = function(){	
	// kepvetites leallitasa
//	if(slideKepTimer) window.clearTimeout(slideKepTimer);
//	if(slideKepTimer1) window.clearTimeout(slideKepTimer1);
	// /
	
	this.setFlashWmode();

	var selects = document.getElementsByTagName('select');
	for (var i=0; i<selects.length;i++){
		selects[i].style.visibility='hidden';
	}
	$(box).css({opacity:"0.0"});
	box.style.display = "block";
	$(box).stop().animate({opacity:opacityLevel},fadingTime, function(){boxC.style.display = "block";} );
	boxC.onclick = function(){shbox.fadeOut();}
}

this.fadeOut = function(){
	window.setTimeout(function(){shbox.fadeOut1();},00);
	window.setTimeout(function(){
		$(".fixme").css("display","none");
		window.setTimeout( "shbox = 0;shbox = new shBox();",100);
	},1000);
}
this.fadeOut1 = function(){
	// kepvetites inditasa
//	slideKep()
//	slideKep1()
	// /
	
	window.clearInterval(globalSlideshowTimer);
	boxLeftTop.className="shboxTopLeft";
	globalSlideshowTimer = false;
	shbox.stopSlide();
	boxC.style.display = "none";
	$(box).stop().animate({opacity:"0.0"},fadingTime/2, function(){box.style.display = "none";});
	var selects = document.getElementsByTagName('select');
	for (var i=0; i<selects.length;i++){
			selects[i].style.visibility='visible';
	}
	
	window.setTimeout( "shbox = 0;shbox = new shBox();",1000);
	
}

this.loadContentIframe = function(url, width, height, subtext){
	
	boxLabel.innerHTML = "";
	$(boxCellContent).css('background','url(js/shimages/tolto.gif) center center no-repeat');
	if (box.style.display != "block" ) shbox.fadeIn();
	$(boxCellContent).stop().animate({width:width,height:height},animateLength, function(){
		var iframe = "<iframe src='"+url+"' border=0 frameborder=0 ALLOWTRANSPARENCY=true width='"+width+"' height='"+height+"' ></iframe>";
		$(boxCellContent).css('background','transparent');
		//alert(iframe)
		boxCellContent.innerHTML = iframe;
	});
	
	var boxLabelText = document.createElement("span");
			
	if (typeof(subtext)!="undefined"&&subtext!="null"){
			boxLabelText.innerHTML += "&nbsp;&nbsp;"+ subtext;
		}
	$(boxLabel).empty();
	boxLabel.appendChild(boxLabelText);
			
	$(boxLabelText).css('opacity',0.5);
	$(boxLabelText).animate({'opacity':1.0},300);
	
}

this.loadContentHtml = function(width, height, html , subtext){
	
	boxLabel.innerHTML = "";
	$(boxCellContent).css('background','url(js/shimages/tolto.gif) center center no-repeat');
	if (box.style.display != "block" ) shbox.fadeIn();
	$(boxCellContent).stop().animate({width:width,height:height},animateLength, function(){
		$(boxCellContent).css('background','transparent');
		boxCellContent.innerHTML = html;
		boxCellContent.innerHTML += "<div style='font-size:12px !important;text-align:center;width:"+(width)+"px;height:23px;overflow:hidden;' class='shsubtexte' >"+""+
			"<a href='javascript:;' onclick='shbox.fadeOut();' >"+
			shbox.langTxt[shbox.lang].bezar+
			"</a>"+
			"</div>";
	});
	
	var boxLabelText = document.createElement("span");
			
	if (typeof(subtext)!="undefined"&&subtext!="null"){
			boxLabelText.innerHTML += "&nbsp;&nbsp;"+ subtext;
		}
	$(boxLabel).empty();
	boxLabel.appendChild(boxLabelText);
			
	$(boxLabelText).css('opacity',0.5);
	$(boxLabelText).animate({'opacity':1.0},300);
	
}


this.loadContentImage = function(img, gal, index, subtext){
	globalGalery = gal;
	globalGaleryIndex = index;
	progressSig.style.height="0px";
	progressSig.style.width="0px";
	
	if (gal){
		if(boxLeftTop.className=="shboxTopLeft") boxLeftTop.className="shboxTopLeftPlay";
		boxLeftTop.style.cursor = "pointer";
		boxLeftTop.onclick = function(){shbox.slideShowStart();}
	} else {
		boxLeftTop.className="shboxTopLeft";
		boxLeftTop.style.cursor = "default";
		boxLeftTop.onclick = function(){}
	}
	
	if (img.length>3){
	
		image = null;
		image= new Image();
		image.src=img;
	}
	
	$(boxCellContent).find("img").animate({opacity:0.8},200,function(){shbox.loaderContent();$(boxCellContent).find("div").remove();})
	
	boxLabel.innerHTML = "";
	//$(boxCellContent).html("<img src='js/shimages/tolto.gif' />");

	//$(boxCellContent).html("<embed alt='Loading...' mode='transparent' src='http://dev.dweb.ro/stagecompany/tolto.swf' height='30' width='70'  >");
	//$(boxCellContent).css({marginTop:$(boxCellContent).height()/2-50});
	
	//$(boxCellContent).css({height:$(boxCellContent).height()/2+50});
	if (box.style.display != "block" ) shbox.fadeIn();
	shbox.sh_imageloader = window.setInterval ( "if (image.width) { if (image.height > f_clientHeight()-40 || image.width > f_clientWidth()-40) { if(image.height /image.width > f_clientHeight() /  f_clientWidth()) { image.width = ((image.width* (f_clientHeight()-80))/image.height);   image.height = f_clientHeight()-60; }  else { image.height = ((image.height* (f_clientWidth()-80))/image.width); image.width = f_clientWidth()-60;}   }   shbox.animateImage(image.src,image.width,image.height,'"+gal+"','"+index+"','"+subtext+"');  window.clearTimeout(shbox.sh_imageloader); } ", 100 );
	

}

this.animateImage = function(url,width,height,gal,index, subtext){
	window.clearTimeout(shbox.sh_imageloader);
	
	
	$(box).css('opacity',opacityLevel-0.01);
	$(box).animate({opacity:opacityLevel},animateLength);
	//$(boxC).animate({opacity:0.95},200);
	$(boxCellContent).stop().animate({width:width,height:height},animateLength, "linear" , function(){
		var img = document.createElement("img");
		img.src = url;
		img.width  = width;
		img.height = height;
		$(boxCellContent).empty();	
	
	if (gal){
		if (globalSlideshowTimer) shbox.slideBar();
	
		var div = document.createElement("div");
		var div1 = document.createElement("div");
		div1.style.position="relative";
		div1.style.width=width+"px";
		div1.style.textAlign = "left";
		div.style.height=height+"px";div.style.width=width+"px";
		div.style.position = "absolute";
		div.style.top = ((-1)*height)+"px";
		var divb = document.createElement("div");
		divb.style.height="100%";divb.style.width= width/2 -2 +"px";
		divb.style.border = "0px solid #ff0000";
		divb.style.background = "transparent url(js/shimages/empty.gif) ";
		divb.style.cursor = "pointer";
		divb.style.cssFloat = "left";
		divb.style.styleFloat = "left";
		var divj = document.createElement("div");
		divj.style.height="100%";divj.style.width= width/2 -2 +"px";
		divj.style.cursor = "pointer";
		divj.style.border = "0px";
		divj.style.background = "transparent url(js/shimages/empty.gif) ";
		divj.style.cssFloat = "right";
		divj.style.styleFloat = "right";

		
		
		
		divb.onmouseover = new Function("this.style.background='url(js/shimages/nyilj.png) 0px 50px no-repeat'");
		divj.onmouseover = new Function("this.style.background='url(js/shimages/nyilb.png)  right 50px no-repeat'");
		if($.browser.msie&&$.browser.version < 7){
			divb.onmouseover = new Function("this.style.background='url(js/shimages/nyilj.gif) 0px 50px no-repeat'");
			divj.onmouseover = new Function("this.style.background='url(js/shimages/nyilb.gif)  right 50px no-repeat'");
		}
		divb.onmouseout = new Function("this.style.background='transparent url(js/shimages/empty.gif)'");
		divj.onmouseout = new Function("this.style.background='transparent url(js/shimages/empty.gif)'");
		
		var linkb = document.createElement("a");
		var linkj = document.createElement("a");
			
		if(index>0){
				divb.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][(index*1-1)].href,gal,index*1-1,keptarakLinkek[gal][(index*1-1)].subtext)};
				linkb.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][(index*1-1)].href,gal,index*1-1,keptarakLinkek[gal][(index*1-1)].subtext)};
					var img1 = new Image();
					img1.src = keptarakLinkek[gal][(index*1-1)].href;
			} else {
				divb.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][keptarakLinkek[gal].length-1].href,gal,keptarakLinkek[gal].length-1,keptarakLinkek[gal][keptarakLinkek[gal].length-1].subtext)};
				linkb.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][keptarakLinkek[gal].length-1].href,gal,keptarakLinkek[gal].length-1,keptarakLinkek[gal][keptarakLinkek[gal].length-1].subtext)};
					var img2 = new Image();
					img2.src = keptarakLinkek[gal][keptarakLinkek[gal].length-1].href;
			}
			
		if(index<(keptarakLinkek[gal].length-1)){
				divj.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][(index*1+1)].href,gal,index*1+1,keptarakLinkek[gal][(index*1+1)].subtext)};
				linkj.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][(index*1+1)].href,gal,index*1+1,keptarakLinkek[gal][(index*1+1)].subtext)};
				var img3 = new Image();
				img3.src = keptarakLinkek[gal][(index*1+1)].href;
			} else {
				divj.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][0].href,gal,0,keptarakLinkek[gal][0].subtext)};
				linkj.onclick = function(){ shbox.stopSlide(); shbox.loadContentImage(keptarakLinkek[gal][0].href,gal,0,keptarakLinkek[gal][0].subtext)};
				var img4 = new Image();
				img4.src = keptarakLinkek[gal][0].href;
			}
			
		div.appendChild(divb);
		div.appendChild(divj);
		div1.appendChild(div);
	}
		
		$(img).css({opacity:0.20});
		$(img).css({background:"#000000"});
		
		$(boxCellContent).empty();
		boxCellContent.appendChild(img);
		shbox.rLoaderContent();
			
		$(img).animate({opacity:1.0},100,function(){
			if (gal){
				$(img).animate({opacity:1.0},100,function(){
				
				    boxCellContent.appendChild(div1);
				});
			}
				


			var boxLabelText = document.createElement("div");
			boxLabelText.style.width = (width-10)+"px";
			boxLabelText.style.overflow = "hidden";
			//boxLabelText.style.position = "absolute";
			
			boxLabelText.innerHTML = "";
			
			if (typeof(linkb)!="undefined") linkb.href='javascript:';
			if (typeof(linkj)!="undefined") linkj.href='javascript:';
			
			if (typeof(linkb)!="undefined")  linkb.innerHTML = shbox.langTxt[shbox.lang].elozo;
			if (typeof(linkj)!="undefined") linkj.innerHTML = shbox.langTxt[shbox.lang].kovetkezo;
			
			if (gal) {
				boxLabelText.innerHTML += "<div style='float:left;width:35px;text-align:left' class='shperpage' >"+(index*1+1) +"/" + keptarakLinkek[gal].length+"</div>";
			}
			
							
			if (typeof(subtext)!="undefined"&&subtext!="null"){
				boxLabelText.innerHTML += "<div style='float:right;margin-right:20px;margin-top:-4px;width:"+(width-95)+"px;height:15px;overflow:hidden;' class='shsubtexte' >"+"&nbsp;&nbsp;"+ subtext+
				//"&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' onclick='shbox.fadeOut();' >"+
				//shbox.langTxt[shbox.lang].bezar+
				//"</a>"+
				"</div>";
			}
			
			//boxLabelText.appendChild(linkb);
			//boxLabelText.appendChild(linkj);
			
		
			$(boxLabel).empty();
			boxLabel.appendChild(boxLabelText);
			
			$(boxLabelText).css('opacity',0.5);
			$(box).css('opacity',opacityLevel-0.01);
			$(box).animate({opacity:opacityLevel},animateLength);
			$(boxLabelText).animate({'opacity':1.0},300);
			
		});
		

		//$(boxC).animate({opacity:1.0},200);
		
	});

}

this.sh = function(settings){
	shbox.settings = settings;
	if (typeof(settings)  =="undefined"){ return;var settings = new Object();}
	if (typeof(settings.type)  =="undefined"){ settings.type   = "img"; }
	if (typeof(settings.url)   =="undefined"){ settings.url    = "http://google.com"; }
	if (typeof(settings.sizeX) =="undefined"){ settings.sizeX  = ""; }
	if (typeof(settings.sizeY) =="undefined"){ settings.sizeY  = ""; }
	if (typeof(settings.gal) =="undefined"){ settings.gal  = ""; }
	if (typeof(settings.index) =="undefined"){ settings.index  = ""; }
	if (typeof(settings.subtext) =="undefined"){ settings.subtext  = ""; }
	if (settings.type=="img") { shbox.loadContentImage(settings.url,settings.gal,settings.index,settings.subtext); } 
	if (settings.startSlide=="igen") {
		window.setTimeout("shbox.slideShowStart();",800);
	}
	if (settings.type=="iframe") { shbox.loadContentIframe(settings.url,settings.width,settings.height,settings.subtext); } 
	if (settings.type=="html") { shbox.loadContentHtml(settings.width,settings.height,settings.html,settings.subtext); } 
	
}

this.hatterDoboz = function(){

	if ($.browser.msie&&$.browser.version<7){
		styleSheetObj=document.styleSheets[0];
		styleSheetObj.addRule(".fixme","left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );");
		styleSheetObj.addRule(".fixme","top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );");
	}

    box = document.createElement("div");
	box.className ="fixme";
	box1 = box;
	box.style.zIndex = 100;
	box.style.left = "0px";
	box.style.background = "#000000";
	box.style.position = "absolute";
	box.style.display = "none";
	box.style.width = $(window).width()+"px";
	box.style.height = $(window).height()+"px";
	box.innerHTML =" "


    boxC = document.createElement("div");
	boxC.className ="fixme";
	box2 = boxC;
	boxC.style.display = "none";
	boxC.style.width = "100%";
	boxC.style.zIndex = 101;
	boxC.style.left = "0px";
	boxC.style.background = "transparent";

	if ($.browser.msie&&$.browser.version>=5.5&&$.browser.version<7){
		boxC.style.position = "absolute";
		boxC.style.height = $(window).height()-2+"px";
		box.style.width = $(window).width()+"px";
		box.style.height = $(window).height()+"px";
	} else {
		boxC.style.position = "fixed";
		box.style.position = "fixed";
	}
	
	
	var boxTable = document.createElement("table");
	boxTable.width="100%";
	var boxTbody = document.createElement("tbody");
	var boxRow = document.createElement("tr");
	boxCelll = document.createElement("td");
	boxTable.appendChild(boxTbody);
	boxCelll.width= "100%";
	boxCelll.height= $(window).height();
	boxCelll.align= "center";
	boxTbody.appendChild(boxRow);
	boxRow.appendChild(boxCelll);
	
	
	boxCTable = document.createElement("table");
	boxCTable.id ="shboxTable";
    boxCTable.cellPadding="0"
    boxCTable.cellSpacing="0"
	
	
	//select tiltasa
	if (typeof boxCTable.onselectstart!="undefined") boxCTable.onselectstart=function(){return false}
	else if (typeof boxCTable.style.MozUserSelect!="undefined") 	boxCTable.style.MozUserSelect="none"
	else boxCTable.onmousedown=function(){return false}
	boxCTable.style.cursor = "default"
	
	
	boxCTable.className = "box";
	var boxCTbody = document.createElement("tbody");
	var boxCRow1 = document.createElement("tr");
	var boxCRow2 = document.createElement("tr");
	var boxCRow3 = document.createElement("tr");
	var boxCCell11 = document.createElement("td");
	boxCCell11.className = "shboxTopLeft";
	boxCCell11.style.textAlign = "left";
	boxLeftTop = boxCCell11;
	var boxCCell12 = document.createElement("td");
	boxCCell12.className = "shboxTopCenter";
	var muver = document.createElement("div");
	muver.className="shboxMover";
	boxCCell12.appendChild(muver);
	boxCCell12.style.cursor = "move";
	boxCCell12.align = "center";
	var boxCCell13 = document.createElement("td");
	boxCCell13.className = "shboxTopRight";
	boxCCell13.onmouseover = new Function("this.className = 'shboxTopRighthover'; ");
	boxCCell13.onmouseout  = new Function("this.className = 'shboxTopRight'; ");
	var boxCCell21 = document.createElement("td");
	boxCCell21.className = "shboxCenterLeft";
	boxCCell21.style.textAlign = "left";
	boxLeft = boxCCell21;
	boxCell = document.createElement("td");
	boxCellContent = document.createElement("div")
	boxCell.valign="center";
	boxCell.className = "shboxCenterCenter";
	boxCell.style.height = "100px";
	boxCell.style.width = "80px";
	boxCell.appendChild(boxCellContent);
	
	var boxCCell23 = document.createElement("td");
	boxCCell23.className = "shboxCenterRight";
	var boxCCell31 = document.createElement("td");
	boxCCell31.className = "shboxBottomLeft";
	var boxCCell32 = document.createElement("td");
	boxCCell32.className = "shboxBottomCenter";
	boxCCell32.align = "center";
	boxLabel = boxCCell32;
	var boxCCell33 = document.createElement("td");
	boxCCell33.className = "shboxBottomRight";

	boxCRow1.appendChild(boxCCell11);
	boxCRow1.appendChild(boxCCell12);
	boxCRow1.appendChild(boxCCell13);
	boxCRow2.appendChild(boxCCell21);
	boxCRow2.appendChild(boxCell);
	boxCRow2.appendChild(boxCCell23);
	boxCRow3.appendChild(boxCCell31);
	boxCRow3.appendChild(boxCCell32);
	boxCRow3.appendChild(boxCCell33);
	boxCTbody.appendChild(boxCRow1);
	boxCTbody.appendChild(boxCRow2);
	boxCTbody.appendChild(boxCRow3);
	boxCTable.appendChild(boxCTbody);
	
	boxCCell13.style.cursor = "pointer";
	boxCCell13.onclick = function(e){ shbox.fadeOut();shbox.stopEvent(e); }
	boxCTable.onclick = function(e){ shbox.stopEvent(e); }
	
	boxCTable.style.border = "0px";
	
	boxCell.padding = "0px";
	boxCell.margin = "0px";
	boxCell.valign = "middle";
	boxCell.align = "center";
	
	boxCelll.appendChild(boxCTable);
	
	boxC.appendChild(boxTable); 
	document.body.insertBefore(box,document.body.firstChild);
	document.body.insertBefore(boxC,document.body.firstChild);
	
	progressSig = document.createElement("div");
	var progressSig1 = document.createElement("div");
	progressSig1.style.position = "relative";
	progressSig1.appendChild(progressSig);
	
	boxLeft.appendChild(progressSig1);
	boxLeft.vAlign = "top";

	$(window).bind('resize', function() {   shbox.handleWindowResize(); });
	
	if(!($.browser.msie&&$.browser.version<7)) $(boxCTable).draggable({ opacity: 0.35,  revert: 'invalid' });

	boxCTable.onmouseover = function(e){
		if(((e && e.target)||(window.event && window.event.srcElement)).className=="shboxTopCenter"||((e && e.target)||(window.event && window.event.srcElement)).className=="shboxMover"){
			if(!($.browser.msie&&$.browser.version<7))  {
			   $(boxCTable).draggable('enable');
			} else {
				boxCCell12.style.cursor = "default";
			}
		} else {
			$(boxCTable).draggable('disable');
		}
	}
}

this.loaderContent = function(){
	$(boxCellContent).css('background','url(js/shimages/tolto.gif) center center no-repeat');
}
this.rLoaderContent = function(){
	$(boxCellContent).css('background','transparent');
}

this.changeAnchors = function(){
	var ak = document.getElementsByTagName("a");
	for (var i=0;i<ak.length;i++){
		if(ak[i].getAttribute("href").indexOf('javascript')<0&&ak[i].getAttribute("rel")=="sh"||ak[i].getAttribute("rel")=="shs"){	
		if(ak[i].getAttribute("rev")){
			if (!keptarak[ak[i].getAttribute("rev")]) keptarak[ak[i].getAttribute("rev")]=0;
			if (typeof(keptarakLinkek[ak[i].getAttribute("rev")])=="undefined") keptarakLinkek[ak[i].getAttribute("rev")]= new Array();
			keptarakLinkek[ak[i].getAttribute("rev")][keptarak[ak[i].getAttribute("rev")]] = new Object();
			keptarakLinkek[ak[i].getAttribute("rev")][keptarak[ak[i].getAttribute("rev")]].href=ak[i].href;
			keptarakLinkek[ak[i].getAttribute("rev")][keptarak[ak[i].getAttribute("rev")]].subtext=ak[i].getAttribute("title");
			//if (ak[i].getAttribute("rel")=="sh")  ak[i].href = "javascript:shbox.sh({img:'img',url:'"+ak[i].href+"', gal:'"+ak[i].getAttribute("rev")+"' ,index :'"+keptarak[ak[i].getAttribute("rev")]+"' , subtext : '"+ak[i].getAttribute("title")+"' });"  ; 
			//if (ak[i].getAttribute("rel")=="shs") ak[i].href = "javascript:shbox.sh({img:'img',url:'"+ak[i].href+"', gal:'"+ak[i].getAttribute("rev")+"' ,index :'"+keptarak[ak[i].getAttribute("rev")]+"' , subtext : '"+ak[i].getAttribute("title")+"' , startSlide : 'igen' });"  ; 
			if (ak[i].getAttribute("rel")=="sh")  ak[i].onclick = new Function("shbox.sh({img:'img',url:'"+ak[i].href+"', gal:'"+ak[i].getAttribute("rev")+"' ,index :'"+keptarak[ak[i].getAttribute("rev")]+"' , subtext : '"+ak[i].getAttribute("title")+"' });");
			if (ak[i].getAttribute("rel")=="shs") ak[i].onclick = new Function("shbox.sh({img:'img',url:'"+ak[i].href+"', gal:'"+ak[i].getAttribute("rev")+"' ,index :'"+keptarak[ak[i].getAttribute("rev")]+"' , subtext : '"+ak[i].getAttribute("title")+"' , startSlide : 'igen' });" );
			
			ak[i].target = "_self";
			ak[i].href = "javascript:;";
			keptarak[ak[i].getAttribute("rev")]++;
		} else {
			ak[i].onclick = new Function("shbox.sh({img:'img',url:'"+ak[i].href+"' , subtext : '"+ak[i].getAttribute("title")+"' }); return false;" ) ; 
			ak[i].href = "javascript:;";
			ak[i].target = "_self";
		}
		}
	}
}

this.setFlashWmode = function(){
	// ??
}

this.handleWindowResize = function(){

	if (boxC.style.display != "none"){
		shbox.sh(shbox.settings);
	}


	box.style.width = $(window).width()+"px";
	box.style.width = $(document).width()+"px";
	box.style.height = $(document).height()+"px";
	if ($.browser.msie&&$.browser.version>=5.5&&$.browser.version<7){
		boxC.style.position = "absolute";
		boxC.style.height = $(window).height()-2+"px";
		box.style.width = $(window).width()+"px";
		box.style.height = $(window).height()+"px";
	} else {
		boxC.style.position = "fixed";
	}
	
	

	if ($.browser.msie&&$.browser.version==8){
		box.style.width = ($(window).width()-10)+"px";
	}
	
	boxC.style.height= $(window).height()-10+"px";
	boxCelll.height= $(window).height();
	boxCelll.style.height= $(window).height()+"px";
	
	if($(window).width()<$(boxCellContent).width()+60||$(window).height()<$(boxCellContent).height()+60){
		if ($(window).width()/$(window).height()>$(boxCellContent).width()/$(boxCellContent).height()) {
			//magassagot csokkent
			var ujmag = $(window).height() - 60;
			var ujszell = ujmag*$(boxCellContent).width()/$(boxCellContent).height();
		} else {
			//szellesseget csokkent
			var ujszell = $(window).width() - 60;
			var ujmag = ujszell*$(boxCellContent).height()/$(boxCellContent).width();
			
		}
			$(boxCellContent).find("img").width(ujszell);
			$(boxCellContent).css('overflow','hidden');
			$(boxCellContent).find("img").height(ujmag);
			$(boxCellContent).find("div").width(ujszell);
			$(boxCellContent).find("div div div").width(ujszell/2-10);
			$(boxCellContent).find("div").height(ujmag);
			$(boxCellContent).find("div div").height(ujmag);
			$(boxCellContent).find("div div").css('top', ((-1)*ujmag)+"px");
			$(boxCellContent).find("div div div").css('top',"0px");
			$(boxCellContent).find("div div div").height(ujmag);
			$(boxCellContent).animate({width:ujszell,height:ujmag},200);
	}
	
}

this.slideBar = function(){
	progressSig.style.width="5px";
	progressSig.style.height="5px";
	progressSig.style.top=(-10+$(boxCellContent).height())+"px";
	//$(progressSig).stop().animate({height:$(boxCellContent).height()-12,top: 0},shbox.slideShowTimer-animateLength-600,"linear");
	//$(boxCellContent).width()-10
	$(progressSig).stop().animate({width:$(boxCellContent).width()-12},shbox.slideShowTimer-(2*animateLength),"linear");
}

this.slideShow = function(){
	index = globalGaleryIndex;
	gal = globalGalery;

	if(index+2<(keptarakLinkek[gal].length-1)){
				var img = new Image();
				img.src = keptarakLinkek[gal][(index*1+3)].href;
	} else {    
				var img = new Image();
				img.src = keptarakLinkek[gal][0].href;
	}
	
	if(index<(keptarakLinkek[gal].length-1)){
				shbox.loadContentImage(keptarakLinkek[gal][(index*1+1)].href,gal,index*1+1,keptarakLinkek[gal][(index*1+1)].subtext);
	} else {
				shbox.loadContentImage(keptarakLinkek[gal][0].href,gal,0,keptarakLinkek[gal][0].subtext);
	}
	
}

this.slideShowStart = function(){
	index = globalGaleryIndex;
	gal = globalGalery;
	if (boxLeftTop.className=="shboxTopLeftPlay") {
		boxLeftTop.className="shboxTopLeftPause"; 
	} else {
		boxLeftTop.className="shboxTopLeftPlay"; 
	}
	
	 if(globalSlideshowTimer){
		window.clearInterval(globalSlideshowTimer);
		globalSlideshowTimer = false;
		shbox.stopSlide();
	 } else {
		if(index+1<(keptarakLinkek[gal].length-1)){
					var img = new Image();
					img.src = keptarakLinkek[gal][(index*1+2)].href;
		} else {    
					var img = new Image();
					img.src = keptarakLinkek[gal][0].href;
		}
		if(index+2<(keptarakLinkek[gal].length-1)){
				var img = new Image();
				img.src = keptarakLinkek[gal][(index*1+3)].href;
		} else {    
				var img = new Image();
				img.src = keptarakLinkek[gal][0].href;
		}
		
		window.clearInterval(globalSlideshowTimer);
		globalSlideshowTimer = window.setInterval("shbox.slideShow()",shbox.slideShowTimer);
		
		progressSig.style.width="5px";
		progressSig.style.height="5px";
		progressSig.style.border="0px solid #ff0000";
		progressSig.style.marginLeft="8px";
		progressSig.style.background="#e4e4e4";
		progressSig.style.position= "absolute";
		progressSig.style.left = "20px";
		progressSig.style.top = "5px";
		$(progressSig).css('opacity',"0.5");
		shbox.slideBar();

	 }
}

this.stopSlide = function(){
	$(progressSig).stop().animate({height:0},10);
	
	if (globalSlideshowTimer){
			window.clearInterval(globalSlideshowTimer);
			globalSlideshowTimer = window.setInterval("shbox.slideShow()",shbox.slideShowTimer);
	}

}

this.handleKeyControl = function(){

  $(document).keydown(function (e) {
  
	index = globalGaleryIndex;
	gal = globalGalery;
  
	//alert(e.which);
	
	 if (e.which == 112){
		alert (shbox.langTxt[shbox.lang].segitseg);
		return false;
	 }
	 
    if (e.which == 27 || e.which == 88 )  {
		window.clearInterval(globalSlideshowTimer);
		shbox.fadeOut();
    }
	
	if (gal){
	
		if (e.which == 69 || e.which == 80 || e.which == 38 || e.which == 33 || e.which == 36 || e.which == 37 || e.which == 100 || e.which == 104 )  {
		 if(index>0){
					shbox.loadContentImage(keptarakLinkek[gal][(index*1-1)].href,gal,index*1-1,keptarakLinkek[gal][(index*1-1)].subtext);
				} else {
					shbox.loadContentImage(keptarakLinkek[gal][keptarakLinkek[gal].length-1].href,gal,keptarakLinkek[gal].length-1,keptarakLinkek[gal][keptarakLinkek[gal].length-1].subtext);
				}
			shbox.stopSlide();
		}
		
		if (e.which == 75 || e.which == 78 || e.which == 40 || e.which == 34 || e.which == 35 || e.which == 39 || e.which == 102 || e.which == 98 )  {
		  if(index<(keptarakLinkek[gal].length-1)){
					shbox.loadContentImage(keptarakLinkek[gal][(index*1+1)].href,gal,index*1+1,keptarakLinkek[gal][(index*1+1)].subtext);
				} else {
					shbox.loadContentImage(keptarakLinkek[gal][0].href,gal,0,keptarakLinkek[gal][0].subtext);
				}
			shbox.stopSlide();
		}
		
		 if (e.which == 83){
			shbox.slideShowStart();
		 }
	}
  });
}

this.stopEvent = function(e){	
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

this.loadVars = function(){
	var scripts = document.getElementsByTagName("script");
	for (var i in scripts){
		if(typeof(scripts[i].src)!="undefined"&&scripts[i].src.indexOf('sh.js')>0){
		
			  var keres = scripts[i].src.replace(/^[^\?]+\??/,'');
			  var valtozok = keres.split(/[;&]/);
			  for ( var i = 0; i < valtozok.length; i++ ) {
				var valtozo = valtozok[i].split('=');
				if ( ! valtozo || valtozo.length != 2 ) continue;
					var kulcs = unescape( valtozo[0] );
					var ertek = unescape( valtozo[1] );
					ertek = ertek.replace(/\+/g, ' ');
					if (kulcs == "lang") {
						lang = ertek;
						this.lang = ertek;
					}
			  }

		};
	}
}

this.init();
return this;
}

var shbox;
$(document).ready(function() {
shbox = new shBox();
});







function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

var myimages=new Array()

function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}
preloadimages("js/shimages/sprite.gif","js/shimages/sprite2.gif","js/shimages/mover.jpg","js/shimages/nyilj.png","js/shimages/nyilb.png","js/shimages/nyilj.gif","js/shimages/nyilb.gif");