var iDiv;
var images_arr = 
[
	{ _id:"vaskut", _images:"DSCF0003;DSCF0004;DSCF0005;DSCF0008;DSCF0009;DSCF0010;DSCF0036;DSCF0037;DSCF0039;DSCF0042;DSCF00033;DSCF00038;DSCF00039;DSCF00042" },
	{ _id:"inkubator_projekt_alapko", _images:"IMG_01;IMG_02;IMG_03;IMG_04;IMG_05;IMG_06;IMG_07;IMG_08;IMG_09;IMG_10;IMG_11;IMG_12;IMG_13;IMG_14;IMG_15;IMG_16;IMG_17;IMG_18;IMG_19;IMG_20;IMG_21" },
	{ _id:"inkubator_projekt_alapozas", _images:"DSFC01;DSFC02;DSFC03;DSFC04;DSFC05;DSFC06;DSFC07;DSFC08;DSFC09;DSFC10;DSFC11;DSFC12" },
	{ _id:"inkubator_projekt_latvanytervek", _images:"IMG_01;IMG_02;IMG_03;IMG_04;IMG_05;IMG_06;IMG_07;IMG_08;IMG_09;IMG_10;IMG_11;IMG_12" },
	{ _id:"inkubator_projekt_stage01", _images:"IMG01;IMG02;IMG03;IMG04;IMG05;IMG06;IMG07;IMG08"},
	{ _id:"inkubator_projekt_stage02", _images:"img_01;img_02;img_03;img_04;img_05;img_06;img_07;img_08;img_09;img_10;img_11;img_12;img_13"},
	{ _id:"inkubator_projekt_stage03", _images:"img01;img02;img03;img04;img05"},
	{ _id:"inkubator_projekt_stage04", _images:"img01;img02;img03;img04;img05;img06;img07"},
	{ _id:"inkubator_projekt_stage05", _images:"img01;img02;img03;img04;img05;img06;img07;img08;img09;img10;img11"},
	{ _id:"inkubator_projekt_stage06", _images:"img01;img02;img03;img04;img05;img06;img07"},
	{ _id:"inkubator_projekt_stage07", _images:"img01;img02;img03;img04;img05;img06;img07;img08;img09;img10;img11;img12"},
	{ _id:"inkubator_projekt_stage08", _images:"Image00001;Image00002;Image00003;Image00004;Image00005;Image00006;Image00007;Image00008;Image00009;Image00010;Image0001"},
	{ _id:"inkubator_projekt_stage09", _images:"Image00001;Image00002;Image00003;Image00004;Image00005;Image00006;Image00007;Image00008;Image00009;Image00010"},
	{ _id:"inkubator_projekt_stage10", _images:"Image00001;Image00002;Image00003;Image00004;Image00005;Image00006;Image00007"},
	{ _id:"eurobinia", _images:"img_02;img_03;img_04;img_05;img_06;img_07;img_08;img_09;img_10;img_11;img_12;img_13;img_14;img_15;img_16;img_17;img_18;img_19;img_20;img_21;img_22;img_23;img_24;img_25;img_26;img_27;" }
];

function getImagesByID(id) 
{
	for (var i=0; i<images_arr.length; i++ )
	{
		if( id == images_arr[i]._id ) 
		{
			return images_arr[i]._images;
			break;
		}
	}
	return null;
}

function getThumbnailsById(id, num) 
{
	var thumbnail_result = [];
	
	for (var i=0; i<images_arr.length; i++ )
	{
		if( id == images_arr[i]._id ) 
		{
			var gallery_images = images_arr[i]._images.split(";");
			while (thumbnail_result.length < num)
			{
				var rnd = Math.round(Math.random()*gallery_images.length-1);
				thumbnail_result.push(String("img/references/"+images_arr[i]._id+"/"+gallery_images.splice(rnd,1)+"_thb.jpg"));
			}
			return thumbnail_result;
			
			break;
		}
	}
	return  null;
}

function checkKeyUp(e)
{
	var evt = e || window.event;
	if ( evt.keyCode == 27 )
	{ 
		closeImage();
	}
}


function closeImage() 
{
	if ( iDiv )
	{
		iDiv.style.display = "none";
	}
	//	document.body.style.overflow="visible";
}

function setBackgroundImage(file) 
{
	window.scrollTo(0,0);
	var popupDiv = document.getElementById("fullScrPop");
	popupDiv.style.backgroundImage = "url(img/references/"+file.toString()+".jpg)";
	//alert(popupDiv.style.backgroundImage);
}

function showImage(id, title) 
{
	if ( title.toString() == "undefined" ) title = "myTitle";
	title = title.replace("<br>", "<br/>");
	title = title.replace("<br/>", " - "); 
	var img_arr = getImagesByID(id).split(";")
	var str = "";
	for (var k=0; k<img_arr.length ; k++ )
	{
		if (k < img_arr.length - 1 ) str += "<a href=javascript:setBackgroundImage('"+id+"/"+img_arr[k]+"');>"+(k+1)+"</a>  |  ";
		else str += "<a href=javascript:setBackgroundImage('"+id+"/"+img_arr[k]+"');>"+(k+1)+"</a>";
	}

	iDiv = document.getElementById("fullScr");
	iDiv.style.height = document.body.offsetHeight.toString()+"px";
	iDiv.style.width = document.body.offsetWidth.toString()+"px";
	iDiv.style.display = "block";
	iDiv.innerHTML = "<div id=\"fullScrBackground\"></div><div id=\"fullScrPop\"><span>"+title+"</span><a id=\"ESC\" href='javascript:closeImage();'>[ Esc | x ]</a><p>"+str+"</p></div>";

	var bgDiv = document.getElementById("fullScrBackground");

	var popupDiv = document.getElementById("fullScrPop");
	
	var myHeight = 0;
	var myWidth  = 0;
	 
	 if( typeof( window.innerWidth ) == 'number' ) 
	 {
		//	Non-IE
		
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;

     } 
	 else if ( document.documentElement && ( document.documentElement.clientWidth|| document.documentElement.clientHeight ) ) 
	{
		
		//IE 6+ in 'standards compliant mode'
		
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;

    }  else {}

	popupDiv.style.top = Math.round( ( myHeight - 600 ) / 2 ).toString()+"px";
	popupDiv.style.left = Math.round( ( myWidth - 800 ) / 2 ).toString() + "px";
	
	//popupDiv.style.backgroundImage = "url(img/"+id.toString()+".jpg)";
	setBackgroundImage(id+"/"+img_arr[0]);
	popupDiv.style.backgroundRepeat = "no-repeat";
	popupDiv.style.backgroundPosition = "15px 15px";
	//	document.body.style.overflow = "hidden";
	document.onkeyup = checkKeyUp;

}


function showVideo(flv, snap, title) 
{
	if ( title.toString() == "undefined" ) title = "myTitle";
	title = title.replace("<br>", "<br/>");
	title = title.replace("<br/>", " - "); 

	iDiv = document.getElementById("fullScr");
	iDiv.style.height = document.body.offsetHeight.toString()+"px";
	iDiv.style.width = document.body.offsetWidth.toString()+"px";
	iDiv.style.display = "block";
	iDiv.innerHTML = "<div id=\"fullScrBackground\"></div><div id=\"fullScrPop\"><span>"+title+"</span><a id=\"ESC\" href='javascript:closeImage();'>[ Esc | x ]</a><div id=\"video_player\"></div></div>";

	var bgDiv = document.getElementById("fullScrBackground");

	
	var myHeight = 0;
	var myWidth  = 0;
	 
	 if( typeof( window.innerWidth ) == 'number' ) 
	 {
		//	Non-IE
		
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;

     } 
	 else if ( document.documentElement && ( document.documentElement.clientWidth|| document.documentElement.clientHeight ) ) 
	{
		
		//IE 6+ in 'standards compliant mode'
		
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;

    }  else {}

	var flashvars = {
			skin:"swf/skins/default_green.swf",
			thumbnail:snap,
			video:"../"+flv,
			autoplay:"0"
	};
	var params = {
		menu: "false",
		scale: "noScale",
		allowFullscreen: "true",
		allowScriptAccess: "always",
		bgcolor: "#FFFFFF"
	};
	var attributes = {
		id:"player"
	};
	swfobject.embedSWF("swf/player.swf", "video_player", "800", "600", "9.0.0", "expressInstall.swf", flashvars, params, attributes);

	var popupDiv = document.getElementById("fullScrPop");

	popupDiv.style.top = Math.round( ( myHeight - 600 ) / 2 ).toString()+"px";
	popupDiv.style.left = Math.round( ( myWidth - 800 ) / 2 ).toString() + "px";
	
	//popupDiv.style.backgroundImage = "url(img/"+id.toString()+".jpg)";
	popupDiv.style.backgroundRepeat = "no-repeat";
	popupDiv.style.backgroundPosition = "15px 15px";
	//	document.body.style.overflow = "hidden";
	document.onkeyup = checkKeyUp;




}
