// =========== 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;


//=============================================================
//=====   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);
	}


//=============================================================
//=====   FORM CHECKING
//=============================================================

	//-------------------------------------------------------------
	function gogo_check_form(){
		if(document.getElementById('formEmail').value == ""){
			alert('Vyplňte, prosím, položku e-mail');
			document.getElementById('formEmail').focus();
			return false;
		}
		else if(!document.getElementById('formCheckbox').checked){
			alert('K odeslání je nutné zaškrtnout souhlas');
			document.getElementById('formCheckbox').focus();
			return false;
		}
		return true;
	}

	//-------------------------------------------------------------
	function gogo_check_form2(){
		if(document.getElementById('formJmeno').value == ""){
			alert('Vyplňte, prosím, položku Jméno');
			document.getElementById('formJmeno').focus();
			return false;
		}
		if(document.getElementById('formPrijmeni').value == ""){
			alert('Vyplňte, prosím, položku Příjmení');
			document.getElementById('formPrijmeni').focus();
			return false;
		}
		if(document.getElementById('formDatumNarozeni').value == ""){
			alert('Vyplňte, prosím, položku Datum narození');
			document.getElementById('formDatumNarozeni').focus();
			return false;
		}
		if(document.getElementById('formEmailAdresa').value == ""){
			alert('Vyplňte, prosím, položku Kontaktní e-mail');
			document.getElementById('formEmailAdresa').focus();
			return false;
		}
		else if(!document.getElementById('formCheckboxOne').checked){
			alert('K odeslání je nutné zaškrtnout souhlas');
			document.getElementById('formCheckboxOne').focus();
			return false;
		}
		return true;
	}


//=============================================================
//=====   NEWS BOX
//=============================================================

	//-------------------------------------------------------------
	var xwidth = 730;
	var yheight = 380;
	//-------------------------------------------------------------
	function getDocHeight() {
		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 gogoNewsBox(){

		var Cookie = getCookie('mojekredencnewsshown');

		if (Cookie == null || Cookie == '0') {

			NewsBoxContainer = document.getElementById('newsBoxContainer');
			VyskaDokumentu = getDocHeight();
	
			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;
			}
	
			PictureXPosition = (SirkaProhlizece-xwidth)/2;
			PictureYPosition = (VyskaProhlizece-yheight)/2+PosunY;
			if(VyskaProhlizece<yheight)PictureYPosition = PosunY+30;
			
			NewsBoxContainer.style.left = PictureXPosition-5+'px';
			if(PictureYPosition > 50) NewsBoxContainer.style.top = PictureYPosition-20+'px';
			else NewsBoxContainer.style.top=20+'px';
			
			NewsBoxContainer.className = 'news-overlay-block';

			setCookie('mojekredencnewsshown','1',2)
		}
	}

	//-------------------------------------------------------------
	function gogoNewsBoxClose(){

		NewsBoxContainer = document.getElementById('newsBoxContainer');
		NewsBoxContainer.style.visibility = 'hidden';
	}


//=============================================================
//=====   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
