// =========== 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;
	var fuckingIE7 = false;
	if((Bverze.indexOf("msie 6")!=-1) || (Bverze.indexOf("msie 5")!=-1)) fuckingIE = true;
	if(Bverze.indexOf("msie 7")!=-1) fuckingIE7 = true;


//=============================================================
//=====   SUBMIT
//=============================================================

	//-------------------------------------------------------------
	function submitClick(){
		
		if (typeof document.formMain.onsubmit == 'function'){
			document.formMain.onsubmit();
		}
		document.formMain.submit();
	}


//=============================================================
//=====   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 = 1;
	var GalleryDirectory = "galerie/velke/";
	//-------------------------------------------------------------
	var xwidth = 662;
	var yheight = 662;
	//-------------------------------------------------------------
	function get_doc_height() {
		var D = document;
		return Math.max(
			Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
			Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
			Math.max(D.body.clientHeight, D.documentElement.clientHeight)
		);
	}

	//-------------------------------------------------------------
	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 = GalleryDirectory + GalleryPictures[picnumber];

		VyskaDokumentu = get_doc_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-5+'px';
		if (PictureYPosition > 50) GalleryPictureContainer.style.top = PictureYPosition-20+'px';
		else GalleryPictureContainer.style.top = 20+'px';

		GalleryBackground.style.visibility = 'visible';
		GalleryPictureContainer.style.visibility = 'visible';
		GalleryPicture.style.visibility = 'visible';
		
/*		oldId = "minibutton" + GallerySelectedPicture;
		newId = "minibutton" + picnumber;
		GalleryButtonOld = document.getElementById(oldId);
		GalleryButtonNew = document.getElementById(newId);
		GalleryButtonOld.className = "minibutton number-" + GallerySelectedPicture;
		GalleryButtonNew.className = "minibutton number-" + picnumber + " active"; */

		GallerySelectedPicture = picnumber;
	}

	//-------------------------------------------------------------
	function gogo_gallery_next(){

		GalleryPicture = document.getElementById('gallerypicture');

		nextpic = GallerySelectedPicture + 1;
		if (nextpic >= GalleryPictures.length) nextpic = 1;
		
		GalleryPicture.src = GalleryDirectory + GalleryPictures[nextpic];
		GallerySelectedPicture = nextpic;
	}

	//-------------------------------------------------------------
	function gogo_gallery_prev(){

		GalleryPicture = document.getElementById('gallerypicture');

		nextpic = GallerySelectedPicture - 1;
		if (nextpic < 1) nextpic = GalleryPictures.length - 1;
		
		GalleryPicture.src = GalleryDirectory + GalleryPictures[nextpic];
		GallerySelectedPicture = nextpic;
	}

	//-------------------------------------------------------------
	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
