var gv_soundInit=false;
var gv_timer=new Array();
var browserName=navigator.appName; 

/* START: Inicializacia zvukov */
soundManager.defaultOptions = {
	autoLoad:true
}
//soundManager.waitForWindowLoad = true;
soundManager.debugMode = false;
soundManager.url = 'swf/';
soundManager.onload = function() {
	soundManager.createSound({id:'snd_swish',url:'sound/swish_11-20-m.mp3'});
	soundManager.createSound({id:'snd_scrape',url:'sound/scrape_11-20-m.mp3'});
	soundManager.createSound({id:'snd_servo',url:'sound/servo_11-20-m.mp3'});
	soundManager.createSound({id:'snd_neon',url:'sound/blink_11-20-m.mp3'});
	soundManager.createSound({id:'snd_ambient',url:'sound/ambient_11-20-m.mp3'});
	soundManager.createSound({id:'snd_outro',url:'sound/data_22-64-m.mp3'});	
	gv_soundInit=true;
}
soundManager.onerror = function() {
	gv_soundInit=false;
}

// JavaScript Document
$(document).ready(function(){
						   
// aplikovanie tooltipov
$('img, a').tooltip({
	track: true,
	delay: 200,
	showURL: false,
	showBody: " _ ",
    fade: 250
});

$("#bd_link").hover(function () {
		$(this).attr("src","graphics/bd_logo_.png");
		return false;
	}, function() {
		$(this).attr("src","graphics/bd_logo.png");
		return false;
	});
			   

});

function headAnim() {
	playSnd("snd_ambient",100);
	if (isIE()) {
		$("#hsFace").show();$("#hsFace").animate({width: "100%", height: "100%", top:"0px", left: "0px"});
		$("#hsEye").show();$("#hsEye").animate({width: "100%", height: "100%", top:"0px", left: "0px"},1000);
		setTimeout('$("#hsTemple").show();$("#hsTemple").animate({width: "100%", height: "100%", top:"0%", left: "0%"},1300);',600);
		setTimeout('$("#hsEar").show();$("#hsEar").animate({width: "100%", height: "100%", top:"0px", left: "0px"},600);',0);
		setTimeout('$("#hsCheek").show();$("#hsCheek").animate({width: "100%", height: "100%", top:"0px", left: "0px"},1100);',0);
		setTimeout('$("#headComplete").fadeIn(1000);',1200);
	}
	else {
		$("#hsFace").animate({width: "100%", height: "100%", top:"0px", left: "0px", opacity:1},1000);
		$("#hsEye").animate({width: "100%", height: "100%", top:"0px", left: "0px", opacity:1},1000);
		setTimeout('$("#hsTemple").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},1300);',600);
		setTimeout('$("#hsEar").animate({width: "100%", height: "100%", top:"0px", left: "0px", opacity:1},600);',0);
		setTimeout('$("#hsCheek").animate({width: "100%", height: "100%", top:"0px", left: "0px", opacity:1},1100);',0);
		setTimeout('$("#headComplete").fadeIn(1000);',1200);
	}
}

function logoAnim() {
	playSnd("snd_swish",200);
	setTimeout('playSnd("snd_scrape",200)',100);	
	setTimeout('playSnd("snd_servo",250)',600);
	if (isIE()) {
		setTimeout('$("#lsE1").show;$("#lsE1").animate({width: "100%", height: "100%", top:"8.8%", left: "-7.5%"},{easing: "easeOutExpo"},1300);',200);
		setTimeout('$("#lsE2").show;$("#lsE2").animate({width: "100%", height: "100%", top:"-6%", left: "0%"},{easing: "easeOutExpo"},1300);',200);	
		setTimeout('$("#lsE1").animate({width: "100%", height: "100%", top:"0%", left: "0%"},{easing: "easeOutQuad"},1300);',600);
		setTimeout('$("#lsE2").animate({width: "100%", height: "100%", top:"0%", left: "0%"},{easing: "easeOutQuad"},1300);',600);
	
		setTimeout('$("#lsM1").show();$("#lsM1").animate({width: "100%", height: "100%", top:"0%", left: "12.7%"},{easing: "easeOutExpo"},1300);',0);
		setTimeout('$("#lsA1").show();$("#lsA1").animate({width: "100%", height: "100%", top:"0%", left: "-30%"},{easing: "easeOutExpo"},1300);',0);
		setTimeout('$("#lsM1").animate({width: "100%", height: "100%", top:"0%", left: "0%"},{easing: "easeOutQuad"},1300);',1000);
		setTimeout('$("#lsA1").animate({width: "100%", height: "100%", top:"0%", left: "0%"},{easing: "easeOutQuad"},1300);',1000);	

		setTimeout('$("#lsM2").show();$("#lsM2").animate({width: "100%", height: "100%", top:"0%", left: "0%"},1300);',1000);
		setTimeout('$("#lsS").show;$("#lsS").animate({width: "100%", height: "100%", top:"0%", left: "0%"},1300);',1000);
		setTimeout('$("#lsA2d").show(500);',900);
	}
	else {
		setTimeout('$("#lsE1").animate({width: "100%", height: "100%", top:"8.8%", left: "-7.5%", opacity:1},{easing: "easeOutExpo"},1300);',200);
		setTimeout('$("#lsE2").animate({width: "100%", height: "100%", top:"-6%", left: "0%", opacity:1},{easing: "easeOutExpo"},1300);',200);	
		setTimeout('$("#lsE1").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},{easing: "easeOutQuad"},1300);',600);
		setTimeout('$("#lsE2").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},{easing: "easeOutQuad"},1300);',600);
		
		setTimeout('$("#lsM1").animate({width: "100%", height: "100%", top:"0%", left: "12.7%", opacity:1},{easing: "easeOutExpo"},1300);',0);
		setTimeout('$("#lsA1").animate({width: "100%", height: "100%", top:"0%", left: "-30%", opacity:1},{easing: "easeOutExpo"},1300);',0);
		setTimeout('$("#lsM1").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},{easing: "easeOutQuad"},1300);',1000);
		setTimeout('$("#lsA1").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},{easing: "easeOutQuad"},1300);',1000);	

		setTimeout('$("#lsM2").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},1300);',1000);
		setTimeout('$("#lsS").animate({width: "100%", height: "100%", top:"0%", left: "0%", opacity:1},1300);',1000);
		setTimeout('$("#lsA2d").show(500);',900);
	}

}

function logoBlink() {

	if (isIE()) {
		setTimeout('neonBlinkIE()',0);
		setTimeout("clearTimeout(gv_timer['ignition']);",60);
		setTimeout('neonBlinkIE()',200);
		setTimeout("clearTimeout(gv_timer['ignition']);",780);
		setTimeout('$("#lsA2").show();',840);	
	}
	else {
		setTimeout('neonBlink()',0);
		setTimeout("clearTimeout(gv_timer['ignition']);",60);
		setTimeout('neonBlink()',200);
		setTimeout("clearTimeout(gv_timer['ignition']);",780);
		setTimeout('$("#lsA2").animate({opacity:1},300);',840);	
	}
}

function neonBlink() {
	setTimeout("$('#lsA2').animate({opacity: 0.2}, 0)",60);	
	setTimeout("$('#lsA2').animate({opacity: 0.8}, 0)",0);			
	gv_timer['ignition']=setTimeout("neonBlink()",60);
}

function neonBlinkIE() {
	setTimeout("$('#lsA2').hide();",60);	
	setTimeout("$('#lsA2').show();",0);			
	gv_timer['ignition']=setTimeout("neonBlinkIE()",60);
}

function txtAnim() {
	$("#logoTxtC").animate({width: "682px"},1300);
}

function animate() {
	if (browserCheck()) {
		$("#pageC").fadeIn(2500);
		setTimeout('logoAnim();',2500);
		setTimeout('headAnim();',4500);
		setTimeout('playSnd("snd_outro",50);',8000);
		setTimeout('txtAnim();',8500);
		setTimeout('playSnd("snd_neon",300);logoBlink();',14500);
	//	setTimeout('$("#bd_link").fadeIn(2500)',12000);
		setTimeout('$("#pageC").fadeOut(2500)',19500);
		setTimeout("window.location='http://www.brossmann.sk'",22000);
	}
}

function isIE() {
	if (browserName=="Microsoft Internet Explorer") {
		return true;
	}
	else {
		return false;
	}
}

function browserCheck() {
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	if (browser=="Microsoft Internet Explorer") {
		if (b_version.indexOf("MSIE 5")>=0 || b_version.indexOf("MSIE 6")>=0) {
			var obj=document.getElementById('ie6');
			obj.style.display='block';
/*
			var answer = confirm("Bol detekovany nekompatibilny alebo zastaraly internetovy prehliadac. Stranka pre svoje spravne fungovanie vyzaduje novsiu verziu vami pouzivaneho prehliadaca. Zelate si aktualizovat a nainstalovat najnovsiu verziu prehliadaca Internet Explorer?")
			if (answer){
				window.location = "http://www.microsoft.com/slovakia/windows/internet-explorer/";
			}
			else{
				alert('Aktualizujte svoj prehliadac!');
			}
*/	
			return false;
	
		}
		else return true;
	}
	else return true;
}

function playSnd(mp3sound,vol,loop,destr) {
  if (gv_soundInit) {
  	if (destr=='destruct') {
  		soundManager.play(mp3sound,{
  			volume:vol, 
  			onfinish:function() {
  				this.destruct();
  			}
  		});
  	}
  	else if(loop=='loop') {
  		soundManager.play(mp3sound,{volume:vol,onfinish:loopSound});
  	}
  	else {
  		soundManager.play(mp3sound,{volume:vol});
  	}
  }
}

function stopSnd(mp3sound) {
  if (gv_soundInit) soundManager.stop(mp3sound);
}
