var gv_intro=false;
var gv_soundInit=true;
var gv_timer=new Array();
var browserName=navigator.appName; 

/* START: Inicializacia zvukov 
soundManager.defaultOptions = {
	autoLoad:true
}
//soundManager.flashLoadTimeout =2000;
soundManager.waitForWindowLoad = true;
soundManager.debugMode = false;
soundManager.useConsole = false;
soundManager.url = 'swf/';
soundManager.flashVersion = 9;
soundManager.useMovieStar = true;
soundManager.allowFullScreen = true;
soundManager.onload = function() {
  soundManager.createVideo({
    id:'paliHero',
    url:'http://www.palihokapurkova.sk/video/pali_hero_h264.mp4'
  });


//	gv_soundInit=true;
}
soundManager.onerror = function() {
	gv_soundInit=false;
	alert(gv_soundInit);
}
*/
// JavaScript Document
$(document).ready(function(){
						   
// aplikovanie tooltipov
$('img, p, a').tooltip({
	track: true,
	delay: 500,
	showURL: false,
	showBody: " _ ",
    fade: 250
});
			   

	$("#closeButton, #skipIntro").click(function () {
  		$("#introC").hide(500);
		setTimeout("$('#sm2-container').hide(500);",250);
		setTimeout("$('#vidArchive').show(500);",500);
	});
	$("#nav_emsa").hover(function () {
		$("#logo_emsa").attr("src","http://www.palihokapurkova.sk/wordpress/wp-content/themes/palihokapurkova/images/emsa_logo_.png");
		return false;
	}, function() {
		$("#logo_emsa").attr("src","http://www.palihokapurkova.sk/wordpress/wp-content/themes/palihokapurkova/images/emsa_logo.png");
		return false;
	});	
	$(".art-Header-jpeg").click(function () {
		 location.href='http://www.palihokapurkova.sk/';
	});
	

/*
setTimeout('$("#ib03").animate({width: "221px", height: "57px", left:"-27px", top:"0px"},500);',500);
setTimeout("bannerBounce();",900);
setTimeout('clearTimeout(gv_timer["trBanner1"]);$("#ib03").animate({width: "1px", height: "1px", left:"83px", top:"14px"},500)',4500);
setTimeout('$("#ib03").hide();',4900);
setTimeout('$("#ib01").animate({top: "0px"},{easing: "easeOutBounce"});',7000);
setTimeout('bannerRotate();',7000);
setTimeout('clearTimeout(gv_timer["trBanner2"]);$("#ib01,#ib02").animate({left: "300px"},{easing: "easeInBack"});',21000);
*/
// SlideBanners();


Intro();
// if (isIE()) bannerRotateIE(); else bannerRotate();

});

function Intro() {
//	if (!getCookie('pkintro')) {
	if (gv_intro==false) $('#vidArchive').show();
	setTimeout("$('#introC').show(250);",0);
	setTimeout("$('#sm2-container').show(250);",100);
//	}
}

function SlideBanners() {
	setTimeout('$("#ib03").animate({width: "221px", height: "57px", left:"-27px", top:"0px"},500);',500);
	setTimeout("bannerBounce();",900);
	setTimeout('clearTimeout(gv_timer["trBanner1"]);$("#ib03").animate({width: "5px", height: "2px", left:"83px", top:"14px"},500)',5500);
	setTimeout('$("#ib03").fadeOut(0)',6100);
	setTimeout('$("#ib01,#ib02").animate({top: "0px"},{easing: "easeOutBounce"});',9000);
	setTimeout('if (isIE()) bannerRotateIE(); else bannerRotate();',9000);
	setTimeout('clearTimeout(gv_timer["trBanner2"]);$("#ib01,#ib02").animate({left: "300px"},{easing: "easeInBack"});',23000);
	setTimeout('$("#ib01,#ib02").animate({left: "0px", top: "-200px"},0);',23500);
	gv_timer['trBanner0']=setTimeout("SlideBanners()",24000);
}

function bannerBounce() {
	
	setTimeout('$("#ib03").animate({width: "-=20px", height: "-=8px", left:"+=10px", top:"+=4px"},500)',0);
	setTimeout('$("#ib03").animate({width: "+=20px", height: "+=8px", left:"-=10px", top:"-=4px"},500)',500);
	gv_timer['trBanner1']=setTimeout("bannerBounce()",1000);
}

function bannerRotate() {
	setTimeout("$('#ib01').fadeOut(500);$('#ib02').fadeIn(500);",4000);	
	setTimeout("$('#ib02').fadeOut(2000);$('#ib01').fadeIn(2000);",7000);
	gv_timer['trBanner2']=setTimeout("bannerRotate()",7000);
//	setTimeout("$('#ib01').fadeOut(500);$('#ib02').fadeIn(500);",4000);
//	setTimeout("$('#ib02').fadeOut(2000);$('#ib01').fadeIn(2000);",7000);
//	gv_timer['trBanner2']=setTimeout("bannerRotate()",7000);
}

function bannerRotateIE() {
	setTimeout("$('#ib01').hide();$('#ib02').show();",4000);
	setTimeout("$('#ib02').hide();$('#ib01').show();",7000);
	gv_timer['trBanner2']=setTimeout("bannerRotateIE()",7000);
//	setTimeout("$('#ib01').hide();$('#ib02').show();",4000);
//	setTimeout("$('#ib02').hide();$('#ib01').show();",7000);
//	gv_timer['trBanner2']=setTimeout("bannerRotateIE()",7000);
}

function isIE() {
	if (browserName=="Microsoft Internet Explorer") {
		return true;
	}
	else {
		return false;
	}
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}