// =========== Kleinigkeiten for BORCHARDT & Partner - Architekten
// =========== 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;


//=============================================================
//=====   GALERIE Jerome v 1.0.5
//=============================================================

	//-------------------------------------------------------------
	GalFakePic = new Image();
	GalFakePic.src = "../obrazky/fake-1x1.gif";
	//-------------------------------------------------------------
	var GallerySelectedPicture = 1;
	//-------------------------------------------------------------
	var xwidth = 686;
	var yheight = 557;
	//-------------------------------------------------------------
	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 = "obrazky-hracky/" + 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_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;
	}

	//-------------------------------------------------------------
	function gogo_gallery_preview(previewnumber){

		oldId = "preview" + SelectedPreviewPicture;
		newId = "preview" + previewnumber;
		GalleryPreviewOld = document.getElementById(oldId);
		GalleryPreviewNew = document.getElementById(newId);
		GalleryPreviewOld.className = "minibutton number-" + SelectedPreviewPicture;
		GalleryPreviewNew.className = "minibutton number-" + previewnumber + " active";

		GalleryPreviewPicture = document.getElementById('previewpicture');
		GalleryPreviewPicture.src = "obrazky-hracky-nahledy/" + GalleryPreviews[previewnumber];
		SelectedPreviewPicture = previewnumber;
	}


//=============================================================
//=====   Hrefs Colouring
//=============================================================

	//-------------------------------------------------------------
	function getElementsByClass(searchClass,tag) {
		var classElements = new Array();
        var els = document.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("\\b"+searchClass+"\\b");
        for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
        }
        return classElements;
	}

	//-------------------------------------------------------------
	function gogo_href_colors() {
        var el = getElementsByClass('randomcolor','a');
		var randm = Math.round((Math.random()*4))+1; 
        for (i = 0; i != el.length; i++) {
			el[i].className = 'color' + randm;
			randm++;
			if(randm>5)randm = 1;
        }
	}

	//-------------------------------------------------------------
	function gogo_href_sizes() {
        var el = getElementsByClass('randomsize','span');
		var randm = Math.floor(Math.random()*5+1);
        for (i = 0; i != el.length; i++) {
			el[i].className = 'size' + randm;
			randm = Math.floor(Math.random()*5+1);
        }
        var el = getElementsByClass('randomsize','a');
		var randm = Math.floor(Math.random()*5+1);
        for (i = 0; i != el.length; i++) {
			el[i].className = 'size' + randm;
			randm = Math.floor(Math.random()*5+1);
        }
	}

	//-------------------------------------------------------------
	function change_href_color(elID) {
		var randm = Math.round((Math.random()*4))+1; 
		elID.className = 'c' + randm;
	}


//=============================================================
//=====   Flying Stuff (posouvani pindinu)
//=============================================================

	//-------------------------------------------------------------
	var FlyingPositionY = 300;
	var FlyingCurrentPositionY = 300;
	var FlyingDesiredPositionY = 300;
	var FlyingPosunY = 0;
	var FlyingSlowDown = 7;
	var FlyingTimer;
	var FlyingDelay = 100; // milliseconds
	var FlyingBottomDistance = 800; // height of footer in px 

	//-------------------------------------------------------------
	function scrollY(){
		return window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	}

	//-------------------------------------------------------------
	function gogo_check_position(){
		setInterval("check_pindini()", FlyingDelay);
	}

	//-------------------------------------------------------------
	function check_pindini(){
		FlyingDesiredPositionY = FlyingPositionY + scrollY();
		if(FlyingDesiredPositionY > (get_doc_height() - FlyingBottomDistance)) FlyingDesiredPositionY = get_doc_height() - FlyingBottomDistance;
		if(FlyingDesiredPositionY != FlyingCurrentPositionY){
			clearTimeout(FlyingTimer);
			FlyingTimer = setTimeout("move_pindin();",20);
		}
	}

	//-------------------------------------------------------------
	function move_pindin(){
		FlyingPosunY = (FlyingDesiredPositionY - FlyingCurrentPositionY) / FlyingSlowDown;
		if(FlyingPosunY<0 && FlyingPosunY>-1) FlyingPosunY = -1;
		if(FlyingPosunY>0 && FlyingPosunY<1) FlyingPosunY = 1;
		FlyingCurrentPositionY = Math.round(FlyingCurrentPositionY + FlyingPosunY);
		document.getElementById('flying').style.top = FlyingCurrentPositionY + "px";
		if(FlyingCurrentPositionY != FlyingDesiredPositionY){
			FlyingTimer = setTimeout("move_pindin();",20);
		}
	}


//=============================================================
//=====   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 Prague Patchwork Meeting === END