// =========== Kleinigkeiten for AVICA Presentation
// =========== created by JaryK
// =========== STUDIO SYNAPSE


//=============================================================
//=====   TEST IE6 a IE5 PROHLIZECE
//=============================================================

	//-------------------------------------------------------------
	//--- pokud se pouziva IE5 nebo IE6 nastavi se promenna
	//--- fuckingIE na true
	//-------------------------------------------------------------
	var Bprohlizec = navigator.appName.toLowerCase();
    var Bagent = navigator.userAgent.toLowerCase();
    var Bverze = navigator.appVersion.toLowerCase();
	var fuckingIE = false;
	if((Bverze.indexOf("msie 6")!=-1) || (Bverze.indexOf("msie 5")!=-1)) fuckingIE = true;


//=============================================================
//=====   PRELOAD OBRAZKU
//=============================================================

	//-------------------------------------------------------------
	BUTTONS = new Array('search','detail','buy','next','prev','close');
	IMGS = new Array();
	preload_buttons();
//	preload_imgs();


//=============================================================
//=====   FUNKCE PRO PRELOAD OBRAZKU
//=============================================================

	//-------------------------------------------------------------
	function preload_buttons(){
		for(i=0;i<BUTTONS.length;i++){
			eval("BUTT_" + BUTTONS[i] + "_out=new Image()");
			eval("BUTT_" + BUTTONS[i] + "_out.src=\"obrazky/button-" + BUTTONS[i] + ".gif\"");
			eval("BUTT_" + BUTTONS[i] + "_over=new Image()");
			eval("BUTT_" + BUTTONS[i] + "_over.src=\"obrazky/button-" + BUTTONS[i] + "-over.gif\"");
		}
	}
	//-------------------------------------------------------------
	function preload_imgs(){
		for(i=0;i<IMGS.length;i++){
			eval("IMG_" + i + "=new Image()");
			eval("IMG_" + i + ".src=\"obrazky/" + IMGS[i] + ".gif\"");
		}
	}


//=============================================================
//=====   INTERAKCE V NAVIGACI
//=============================================================

	//-------------------------------------------------------------
	function butt_over(jmeno,obj){
		obj.src=eval("BUTT_" + jmeno + "_over.src");
	}
	function butt_out(jmeno,obj){
		obj.src=eval("BUTT_" + jmeno + "_out.src");
	}


//=============================================================
//=====   COOKIES
//=============================================================

	//-------------------------------------------------------------
	function setCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	//-------------------------------------------------------------
	function getCookie(name) {
		var nameEQ = name + "=";
		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(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	//-------------------------------------------------------------
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}


//=============================================================
//=====   GALERIE Jerome v 1.0.5
//=============================================================

	//-------------------------------------------------------------
	GalFakePic = new Image();
	GalFakePic.src = "./obrazky/fake-1x1.gif";
	//-------------------------------------------------------------
	var GallerySelectedPicture = 0;
	//-------------------------------------------------------------
	var xwidth = 706;
	var yheight = 461;
	//-------------------------------------------------------------
	function gogo_gallery_picture(picnumber){

		GalleryBackground=document.getElementById('gallerybcg');
		GalleryPictureContainer=document.getElementById('gallerypicturecontainer');
		GalleryPicture=document.getElementById('gallerypicture');
		GalleryLeft=document.getElementById('galleryleft');
		GalleryRight=document.getElementById('galleryright');

//		GalleryPicture.src=picname;
		GalleryPicture.src=GalleryPictures[picnumber];

		VyskaDokumentu=document.all ? document.body.offsetHeight : document.height;

		if( typeof( window.innerWidth ) == 'number' ) {
			SirkaProhlizece = window.innerWidth;
			VyskaProhlizece = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			SirkaProhlizece = document.documentElement.clientWidth;
			VyskaProhlizece = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			SirkaProhlizece = document.body.clientWidth;
			VyskaProhlizece = document.body.clientHeight;
		}

		PosunY=document.body.scrollTop;
		if(PosunY == 0){
		    if (window.pageYOffset) PosunY = window.pageYOffset;
		    else PosunY = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
		}

		GalleryBackground.style.width='100%';
		if(fuckingIE)GalleryBackground.style.width=SirkaProhlizece + 'px';
		GalleryBackground.style.height=VyskaDokumentu + 'px';
		
		PictureXPosition=(SirkaProhlizece-xwidth)/2;
		PictureYPosition=(VyskaProhlizece-yheight)/2+PosunY;
		if(VyskaProhlizece<yheight)PictureYPosition=PosunY+30;
		
		GalleryPictureContainer.style.left=PictureXPosition-15+'px';
		if(PictureYPosition > 50) GalleryPictureContainer.style.top=PictureYPosition-30+'px';
		else GalleryPictureContainer.style.top=20+'px';

		GalleryBackground.style.visibility='visible';
		GalleryPictureContainer.style.visibility='visible';
		GalleryPicture.style.visibility='visible';
		
		if(picnumber > 1)GalleryLeft.innerHTML = "<a href=\"#null\" onclick=\"gogo_gallery_move(-1);\"><img src=\"obrazky/gallery-zoom-left.gif\" /></a>";
		else GalleryLeft.innerHTML = "";
		if(picnumber < (GalleryPictures.length - 1))GalleryRight.innerHTML = "<a href=\"#null\" onclick=\"gogo_gallery_move(1);\"><img src=\"obrazky/gallery-zoom-right.gif\" /></a>";
		else GalleryRight.innerHTML = "";
		
		GallerySelectedPicture = picnumber;
	}

	//-------------------------------------------------------------
	function gogo_gallery_move(movement){

		GalleryPicture=document.getElementById('gallerypicture');
		GalleryLeft=document.getElementById('galleryleft');
		GalleryRight=document.getElementById('galleryright');
		
		picnumber = GallerySelectedPicture + movement;
		
		if((picnumber > 0) && (picnumber < GalleryPictures.length)){
			GalleryPicture.src = GalleryPictures[picnumber];
			if(picnumber > 1)GalleryLeft.innerHTML = "<a href=\"#null\" onclick=\"gogo_gallery_move(-1);\"><img src=\"obrazky/gallery-zoom-left.gif\" /></a>";
			else GalleryLeft.innerHTML = "";
			if(picnumber < (GalleryPictures.length - 1))GalleryRight.innerHTML = "<a href=\"#null\" onclick=\"gogo_gallery_move(1);\"><img src=\"obrazky/gallery-zoom-right.gif\" /></a>";
			else GalleryRight.innerHTML = "";
			GallerySelectedPicture = picnumber;
		}
	}

	//-------------------------------------------------------------
	function gogo_gallery_close(){

		GalleryBackground=document.getElementById('gallerybcg');
		GalleryPictureContainer=document.getElementById('gallerypicturecontainer');
		GalleryPicture=document.getElementById('gallerypicture');

		GalleryBackground.style.visibility='hidden';
		GalleryPictureContainer.style.visibility='hidden';
		GalleryPicture.style.visibility='hidden';

		GalleryBackground.style.width='100%';
		GalleryBackground.style.height='0px';

		GalleryPicture.src=GalFakePic.src;
	}


//=============================================================
//=====   OTEVIRANI EXTERNICH OKEN
//=============================================================

	//-------------------------------------------------------------
	function ext_window(adresa){
		w1=window.open(adresa,"noveokno");
		w1.focus();
	}


//=============================================================
//=====   Oprava dementniho IE6
//=============================================================

	//-------------------------------------------------------------
	function gogo_ie6_fix(){
		document.body.style.height=document.documentElement.scrollHeight + 'px';
	}


// =========== Kleinigkeiten for AVICA Presentation === END
