// =========== Kleinigkeiten for SIMONE 2007 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('button_dark_send','button_light_send');
	IMGS = new Array('menu-level1-over-b.gif','menu-level1-over-t.gif','menu-level2-over-b.gif','menu-level2-over-t.gif');
	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/" + BUTTONS[i] + ".gif\"");
			eval("BUTT_" + BUTTONS[i] + "_over=new Image()");
			eval("BUTT_" + BUTTONS[i] + "_over.src=\"obrazky/" + 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\"");
		}
	}


//=============================================================
//=====   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);
	}


//=============================================================
//=====   TOOLBARS - schovavani a zpruhlednovani toolbaru v zahlavi a zapati
//=============================================================


	var TheObject;
	var TheObject1='header';
	var TheObject2='footer';

	//-------------------------------------------------------------
	//--- opacity - pozadovana pruhlednost - 0=0%, 0.5=50%, 1=100%
	//-------------------------------------------------------------
	function set_object_transparency(opacity) {
        Objektik=document.getElementById(TheObject);
		Objektik.style.filter='alpha(opacity=' + opacity*100 + ')';
		Objektik.style.opacity=opacity;
	}

	//-------------------------------------------------------------
	//--- objID - id objektu s kterym chceme pracovat
	//--- startOpacity - pocatecni pruhlednost - 0=0%, 0.5=50%, 1=100%
	//--- endOpacity - koncova pruhlednost - 0=0%, 0.5=50%, 1=100%
	//--- steps - pocet kroku "fejdu"
	//-------------------------------------------------------------
	function fade_object_transparency(objID,startOpacity,endOpacity,steps) {
        OpacityStep=(endOpacity-startOpacity)/steps;
		Opacity=startOpacity;
		TheObject=objID;
		for(i=0;i<=steps;i++){
			Commando="set_object_transparency(" + Opacity + ")";
			setTimeout(Commando,50*i);
			Opacity+=OpacityStep;
		}
	}

	//-------------------------------------------------------------
	function set_toolbars_transparency(opacity) {
        Objektik1=document.getElementById(TheObject1);
        Objektik2=document.getElementById(TheObject2);
		Objektik1.style.filter='alpha(opacity=' + opacity*100 + ')';
		Objektik1.style.opacity=opacity;
		Objektik2.style.filter='alpha(opacity=' + opacity*100 + ')';
		Objektik2.style.opacity=opacity;
	}
	//-------------------------------------------------------------
	function fade_toolbars_transparency(startOpacity,endOpacity,steps) {
        OpacityStep=(endOpacity-startOpacity)/steps;
		Opacity=startOpacity;
		TheObject1='header';
		TheObject2='footer';
		for(i=0;i<=steps;i++){
			Commando="set_toolbars_transparency(" + Opacity + ")";
			setTimeout(Commando,50*i);
			Opacity+=OpacityStep;
		}
	}

	var ToolbarShown=true;
	//-------------------------------------------------------------
	function gogo_toolbar_transparent() {
		fade_toolbars_transparency(1,0.65,10);
		document.getElementById('transparentswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_solid(); return false;\" class=\"ico-right\">solid toolbars</a>';
		setCookie('simonetoolbar','transparent',20)
	}
	//-------------------------------------------------------------
	function gogo_toolbar_solid() {
		fade_toolbars_transparency(0.65,1,10);
		document.getElementById('transparentswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_transparent(); return false;\" class=\"ico-right\">transparent toolbars</a>';
		setCookie('simonetoolbar','solid',20)
	}
	//-------------------------------------------------------------
	function gogo_toolbar_hide() {
		fade_toolbars_transparency(1,0.05,15);
		document.getElementById('showswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_show();\" class=\"ico-right\">show toolbars</a>';
		ToolbarShown=false;
		setCookie('simonetoolbar','hidden',20)
	}
	//-------------------------------------------------------------
	function gogo_toolbar_show() {
		set_toolbars_transparency(1);
		document.getElementById('showswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_hide();\" class=\"ico-right\">hide toolbars</a>';
		document.getElementById('transparentswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_transparent(); return false;\" class=\"ico-right\">transparent toolbars</a>';
		ToolbarShown=true;
		setCookie('simonetoolbar','solid',20)
	}
	//-------------------------------------------------------------
	function init_toolbar() {
		var Cookie=getCookie('simonetoolbar');
//		alert(Cookie);
		var ToolbarOpacity=1;
		if(Cookie!=null){
			if(Cookie=="solid"){
				ToolbarOpacity=1;
				document.getElementById('transparentswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_transparent(); return false;\" class=\"ico-right\">transparent toolbars</a>';
				ToolbarShown=true;
			}
			if(Cookie=="transparent"){
				ToolbarOpacity=0.65;
				document.getElementById('transparentswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_solid(); return false;\" class=\"ico-right\">solid toolbars</a>';
				ToolbarShown=true;
			}
			if(Cookie=="hidden"){
				ToolbarOpacity=0.05;
				document.getElementById('showswitch').innerHTML='<a href=\"#null\" onclick=\"gogo_toolbar_show();\" class=\"ico-right\">show toolbars</a>';
				ToolbarShown=false;
			}
		}
		fade_toolbars_transparency(0.05,ToolbarOpacity,15);
	}


//=============================================================
//=====   PF 2007
//=============================================================

//-------------------------------------------------------------
	function gogo_pf() {
		var Cookie=getCookie('simonepf');
		if(Cookie!="seen"){
			gogo_gallery_picture("./obrazky-special/pf2008.jpg",520,293);
			setCookie('simonepf','seen',1)
		}
		else {
		}
	}



//=============================================================
//=====   GALERIE Jerome v 1.0.5
//=============================================================

	//-------------------------------------------------------------
	GalFakePic = new Image();
	GalFakePic.src = "./obrazky/fake-1x1.gif";
	//-------------------------------------------------------------
	function gogo_gallery_picture(picname,xwidth,yheight){

		GalleryBackground=document.getElementById('gallerybcg');
		GalleryPictureContainer=document.getElementById('gallerypicturecontainer');
		GalleryPicture=document.getElementById('gallerypicture');
//		GalleryHref=document.getElementById('galleryhref');

		GalleryPicture.src=picname;

		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=xwidth + 9 + 76 + 'px';
		GalleryBackground.style.height=yheight + 8 + 76 + 'px';
		
		PictureXPosition=(SirkaProhlizece-xwidth)/2;
		PictureYPosition=(VyskaProhlizece-yheight)/2+PosunY;
		if(VyskaProhlizece<yheight)PictureYPosition=PosunY+30;
		
		GalleryBackground.style.left=PictureXPosition-15-38+'px';
		GalleryBackground.style.top=PictureYPosition-15-38+'px';
		GalleryPictureContainer.style.left=PictureXPosition-15+'px';
		GalleryPictureContainer.style.top=PictureYPosition-15+'px';

		GalleryBackground.style.visibility='visible';
		GalleryPictureContainer.style.visibility='visible';
		GalleryPicture.style.visibility='visible';
	}

	//-------------------------------------------------------------
	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;
	}


//=============================================================
//=====   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");
	}


//=============================================================
//=====   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 SIMONE 2007 Presentation === END
