var akt = 0;
var wmode = false;
var wmode;


function init_gallery()
{
	try
	{
		if (typeof(Shadowbox) != "undefined")
		{
			Shadowbox.init();
		}
	} catch(e) {}
	var onloadimages = new Array('menu_bg.jpg', 'foglalasbg.jpg', 'left_on.png', 'right_on.png');
	var nimage = new Array();
	for(var i = 0; i < onloadimages.length; i++) {
		nimage[i] = new Image();
		nimage[i].src = "http://www.szivosteam.hu/gallery_bla/images/"+onloadimages[i];
	}

	if ($("szb_kepbox"))
	{
		$("gal_nybal").onclick = function() { Gallery.Previous(); return false; };
		$("gal_nyjobb").onclick = function() { Gallery.Next(); return false; };
		Gallery.max = galleryPictures.length - 1;
		Gallery.elem = $("mainpicture");
		Gallery.Init();
		fillup();
	}
}

var transitions = [
	"progid:DXImageTransform.Microsoft.Barn()",
	"progid:DXImageTransform.Microsoft.Blinds()",
	"progid:DXImageTransform.Microsoft.CheckerBoard()",
	"progid:DXImageTransform.Microsoft.Fade()",
	"progid:DXImageTransform.Microsoft.GradientWipe()",
	"progid:DXImageTransform.Microsoft.Inset()",
	"progid:DXImageTransform.Microsoft.Iris()",
	"progid:DXImageTransform.Microsoft.Pixelate(maxSquare=15)",
	"progid:DXImageTransform.Microsoft.RadialWipe()",
	"progid:DXImageTransform.Microsoft.RandomBars()",
	"progid:DXImageTransform.Microsoft.RandomDissolve()",
	"progid:DXImageTransform.Microsoft.Slide()",
	"progid:DXImageTransform.Microsoft.Spiral()",
	"progid:DXImageTransform.Microsoft.Stretch()",
	"progid:DXImageTransform.Microsoft.Strips()",
	"progid:DXImageTransform.Microsoft.Wheel()",
	"progid:DXImageTransform.Microsoft.Zigzag()"
]

var Gallery = {};
Gallery.akt = 0;
Gallery.preloadImages = new Array();
Gallery.player = new SWFObject('http://www.szivosteam.hu/gallery_bla/flvplayer.swf', 'mediaplayer', '950', '412', '8');
Gallery.player.addParam("wmode", "transparent");
Gallery.video = 0;
Gallery.Init = function()
{
	for (var i = 0; i <= this.max; i++)
	{
		if (galleryPictures[i][2] != 21) {
			this.preloadImages[i] = new Image();
			this.preloadImages[i].src = "http://www.szivosteam.hu/images/" + galleryPictures[i][0];
		}
	}
	Gallery.filtersupport = isIE;
	Gallery.oldHTML = $("mainpicturebox").innerHTML;
};

Gallery.setopacity = function(el, degree) { 
	if (typeof el.style.opacity != "undefined") {
		el.style.opacity = degree;
	}
	else {
		el.style.MozOpacity = degree;
	}
	el.currentopacity = degree;
};

Gallery.hideTransition = function() {
	if (this.filtersupport) {
		$("mainpicturebox").filters[0].apply();
	}
	else {
		this.setopacity($("mainpicturebox"), 0);
	}
};

Gallery.playEffect = function() {
	if (Gallery.filtersupport) {
		$("mainpicturebox").filters[0].play(1);
	}
	else {
		$("mainpicturebox").fadetimer = setInterval(function() {
			if ($("mainpicturebox").currentopacity < 1)
				Gallery.setopacity($("mainpicturebox"), $("mainpicturebox").currentopacity + 0.1);
			else
				clearInterval($("mainpicturebox").fadetimer);
		}, 50) //end setInterval
	}

};


Gallery.Next = function()
{
	 clearTimeout(timeint);
	if (this.akt < this.max)
	{
		this.SetBorder(0);
		this.akt++;

			if (this.filtersupport) {
				var effectindex = 4; //Math.floor(Math.random()*transitions.length);
				$("mainpicturebox").style.filter = transitions[effectindex];
			}
			this.hideTransition();
			this.elem.src = "http://www.szivosteam.hu/images/" + galleryPictures[this.akt][0];
			this.elem.alt = galleryPictures[this.akt][1];
			this.elem.title = galleryPictures[this.akt][1];
			this.SetBorder(1);
			this.playEffect();
			return(true);
	}
	return(false);
};

Gallery.Previous = function()
{
	 clearTimeout(timeint);
	if (this.akt > 0)
	{
		this.SetBorder(0);
		this.akt--;
		
			if (this.filtersupport) {
				var effectindex = 4; //Math.floor(Math.random()*transitions.length);
				$("mainpicturebox").style.filter = transitions[effectindex];
			}
			this.hideTransition();
			this.elem.src = "http://www.szivosteam.hu/images/" + galleryPictures[this.akt][0];
			this.elem.alt = galleryPictures[this.akt][1];
			this.elem.title = galleryPictures[this.akt][1];
			this.SetBorder(1);
			this.playEffect();
			return(true);
	}
	return(false);
};

Gallery.Set = function(kepid)
{
	clearTimeout(timeint);
	this.SetBorder(0);
	this.akt = kepid;
	
		this.elem = $("mainpicture");
		if (this.filtersupport) {
			var effectindex = 4; //Math.floor(Math.random()*transitions.length);
			$("mainpicturebox").style.filter = transitions[effectindex];
		}
		this.hideTransition();
		this.elem.src = "http://www.szivosteam.hu/images/" + galleryPictures[this.akt][0];
		this.SetBorder(1);
		this.playEffect();

};
Gallery.SetBorder = function(melyik)
{
	$("gkep"+this.akt).className = melyik ? "gkep" : "";
};
