var posX = 0, posY = 0, dir = 0;
var szer_okna = 0, gal_trig = 0;
var action = null;

function intro(){
	$("#loading").fadeOut({duration: 500, queue: "global", scope: "#01"});
	$("div.animate").fadeIn({duration: 1000, queue: "global", scope: "#01"});
	$("#play_arch_pl").fadeIn({duration: 1000, queue: "global", scope: "#01"});
	$("#play_arch_en").fadeIn({duration: 1000, queue: "global", scope: "#01"});
	$("#play_ai_pl").fadeIn({duration: 1000, queue: "global", scope: "#01"});
	$("#play_ai_en").fadeIn({duration: 1000, queue: "global", scope: "#01"});
}
function intro_cycle(){
	$('#intro1').cycle({fx: 'fade', speed: 1000, next: '#intro1',timeout: 7000});
	$('#intro2').cycle({fx: 'fade', speed: 900, next: '#intro2',timeout: 6500});
	$('#intro3').cycle({fx: 'fade', speed: 800, next: '#intro3',timeout: 8000});
	$('#intro6').cycle({fx: 'fade', speed: 800, next: '#intro6',timeout: 5000});
	$('#intro5').cycle({fx: 'fade', speed: 800, next: '#intro5',timeout: 7500});
	$('#intro4').cycle({fx: 'fade', speed: 800, next: '#intro4',timeout: 6000});
}
function intro_ai_cycle(){
	$('#intro_ai1').cycle({fx: 'fade', speed: 1000, next: '#intro_ai1',timeout: 7000});
	$('#intro_ai2').cycle({fx: 'fade', speed: 900, next: '#intro_ai2',timeout: 6500});
	$('#intro_ai3').cycle({fx: 'fade', speed: 800, next: '#intro_ai3',timeout: 8000});
	$('#intro_ai5').cycle({fx: 'fade', speed: 800, next: '#intro_ai5',timeout: 7500});
	$('#intro_ai4').cycle({fx: 'fade', speed: 800, next: '#intro_ai4',timeout: 6000});
}
function zanikanie(){
	$("#pion").animate({marginLeft: "50px"}, {duration: 1500, queue: "global", scope : "#01"});
	$("#adgroup").fadeOut({duration: 1000, queue: "global", scope : "#01"});
	$("#logo_arch").fadeOut({preDelay: 200, duration: 1000, queue: "global", scope : "#01"});	
	$("#logo_ai").fadeOut({preDelay: 200, duration: 1000, queue: "global", scope : "#01"});
	$("#play_arch_pl").fadeOut({preDelay: 300, duration: 1000, queue: "global", scope : "#01"});
	$("#arch_pl").fadeOut({preDelay: 300, duration: 1000, queue: "global", scope : "#01"});
	$("#play_ai_pl").fadeOut({preDelay: 300, duration: 1000, queue: "global", scope : "#01"});
	$("#ad_pl").fadeOut({preDelay: 300, duration: 1000, queue: "global", scope : "#01"});
	$("#play_arch_en").fadeOut({preDelay: 600, duration: 1000, queue: "global", scope : "#01"});
	$("#play_ai_en").fadeOut({preDelay: 600, duration: 1000, queue: "global", scope : "#01"});
}

function play_arch_pl() {
	$("#logo_arch_gora").fadeIn({duration: 500, queue: "global", scope : "#02"});
	//menu
	$("#menu_firma").fadeIn({preDelay: 100, duration: 500, queue: "global", scope : "#02"});
	$("#menu_projekty").fadeIn({preDelay: 100, duration: 500, queue: "global", scope : "#02"});
	$("#menu_konkursy").fadeIn({preDelay: 200, duration: 500, queue: "global", scope : "#02"});
	$("#menu_klienci").fadeIn({preDelay: 300, duration: 500, queue: "global", scope : "#02"});
	$("#menu_publikacje").fadeIn({preDelay: 400, duration: 500, queue: "global", scope : "#02"});
	$("#menu_nagrody").fadeIn({preDelay: 500, duration: 500, queue: "global", scope : "#02"});
	$("#menu_kontakt").fadeIn({preDelay: 600, duration: 500, queue: "global", scope : "#02"});
	$("#content,#pasek").fadeIn({preDelay: 300, duration: 1000, queue: "global", scope : "#02"});
	intro_cycle();
}

function play_arch_en() {
	$("#logo_arch_gora").fadeIn({duration: 500, queue: "global", scope : "#02"});
	//menu
	$("#menu_firma").fadeIn({preDelay: 100, duration: 500, queue: "global", scope : "#02"});
	$("#menu_projekty").fadeIn({preDelay: 100, duration: 500, queue: "global", scope : "#02"});
	$("#menu_konkursy").fadeIn({preDelay: 200, duration: 500, queue: "global", scope : "#02"});
	$("#menu_klienci").fadeIn({preDelay: 300, duration: 500, queue: "global", scope : "#02"});
	$("#menu_publikacje").fadeIn({preDelay: 400, duration: 500, queue: "global", scope : "#02"});
	$("#menu_nagrody").fadeIn({preDelay: 500, duration: 500, queue: "global", scope : "#02"});
	$("#menu_kontakt").fadeIn({preDelay: 600, duration: 500, queue: "global", scope : "#02"});
	$("#content,#pasek").fadeIn({preDelay: 300, duration: 1000, queue: "global", scope : "#02"});
	intro_cycle();
}

function play_ai_pl() {
	$("#logo_ai_gora").fadeIn({duration: 500, queue: "global", scope : "#02"});
	//menu
	$("#menu_firma_ai").fadeIn({preDelay: 100, duration: 500, queue: "global", scope : "#02"});
	$("#menu_inwestycje_ai").fadeIn({preDelay: 200, duration: 500, queue: "global", scope : "#02"});
	$("#menu_oferta_specjalna").fadeIn({preDelay: 300, duration: 500, queue: "global", scope : "#02"});
	$("#menu_wynajem").fadeIn({preDelay: 400, duration: 500, queue: "global", scope : "#02"});
	$("#menu_nagrody_ai").fadeIn({preDelay: 500, duration: 500, queue: "global", scope : "#02"});
	$("#menu_kontakt_ai").fadeIn({preDelay: 600, duration: 500, queue: "global", scope : "#02"});
	$("#content,#pasek").fadeIn({preDelay: 300, duration: 1000, queue: "global", scope : "#02"});
	intro_ai_cycle();
}

function mouseOverOut(Id, Name){
	if(document.getElementById(Id)){document.getElementById(Id).src = Name;}
}
	
function change_id(Id,New){
	document.getElementById(Id).id = New;
}
	
function fadein(id){
	$("#"+id).css({display: "block"});
}

function fadeout(id){
	$("#"+id).css({display: "none"});
}

//-------------------------------------------------- MENU----------
var menu_active = 1, active_id = '';

function menu_onclick(id,sub,lng) {
if(menu_active == 1 && active_id != id){
/* lng=''; */ menu_active = 0; active_id = id;clear_menu(lng);

if(id!='intro' && id!='intro_ai'){
document.getElementById('menu_'+id).id = 'menu_'+id+'_on';
document.getElementById('menu_'+id+'_on').src = 'grafika'+lng+'/menu_'+id+'_on.png';}

	$("#content,#pasek").fadeOut({duration: 300});
	$("#loading").fadeIn({preDelay: 250, duration: 250, complete:
		function(){
			$.ajax({
				dataType : "html",
				url: id+'.php?lng='+lng,
				success:
					function(msg){
						document.getElementById('content').innerHTML = msg;
						intro_cycle();
						if(sub==1){//WYSUWANIE SUBMENU
							$("#menu_firma,#menu_projekty_on").animate({marginTop: "-108px"},{duration: 500, queue: "sub"});//menu archdeco
							$("#menu_firma_ai,#menu_inwestycje_ai_on").animate({marginTop: "-33px"},{duration: 500, queue: "sub"});//menu ad inwestycja
							$(".sub_menu").fadeIn({preDelay: 400, duration: 500, queue: "sub"});
						}else{//CHOWANIE SUBMENU
							$(".sub_menu").fadeOut({duration: 500, queue: "sub"});
							$("#menu_firma,#menu_firma_on,#menu_projekty").animate({marginTop: "0px"},{preDelay: 0, duration: 1000, queue: "sub"});//menu archdeco
							$("#menu_firma_ai,#menu_firma_ai_on,#menu_inwestycje_ai").animate({marginTop: "0px"},{preDelay: 0, duration: 500, queue: "sub"});//menu ad inwestycja
						}
						$("#loading").fadeOut({preDelay: 500, duration: 500, queue: "load"});
						$("#content,#pasek").animate({opacity: 0.01},{duration: 10, complete:
							function(){
								$("#content,#pasek").css("display","block");
								$("#"+id).jScrollPane({
									showArrows:true,
									scrollbarWidth: 20,
									arrowSize: 20
								});
								menu_active = 1;
							}});
						$("#content,#pasek").animate({opacity: 1.0},{duration: 200, queue: "load"});
						
					}
			});
		}
	});
		
}}

//--------------------------------------------------- koniec MENU ------------

element_menu = new Array('firma','projekty','mieszkaniowe','biurowe','uzytecznosci','przemyslowe','szpitale','wnetrza','konkursy','klienci','publikacje','nagrody','kontakt','firma_ai','inwestycje_ai','oferta_specjalna','nagrody_ai','kontakt_ai', 'aktualnie','sprzedane','wynajem');

function clear_menu(lng) {

for(var i=0; i < element_menu.length; i++)
	{
	if(document.getElementById('menu_'+element_menu[i]+'_on'))
		{
		document.getElementById('menu_'+element_menu[i]+'_on').src = 'grafika'+lng+'/menu_'+element_menu[i]+'.png';
		document.getElementById('menu_'+element_menu[i]+'_on').id = 'menu_'+element_menu[i];
		}
	}
}

//******************************************** animacja w galerii **********************************************/

function content_load (folder, nazwa, ilosc, skad, lng) {
	$("#content,#pasek").fadeOut({duration: 500, queue: "content_load"});
	
	setTimeout(function(){
		$("#content").load('galerie.php?f='+folder+'&n='+nazwa+'&i='+ilosc+'&s='+skad+'&l='+lng,
		function(){
		$("#content").fadeIn({duration: 500, queue: "content_load"});})
		},500);

	gal_trig = 0;
	active = '';
}

//******************************************** ładowanie inwestycji **********************************************/
function inwest_load (nazwa, skad, co) {
	$("#content").fadeOut({duration: 500, queue: "inwest_load"});
	
	setTimeout(function(){
		$("#content").load('inwestycja.php?nazwa='+nazwa+"&skad="+skad+"&co="+co,
		function(){
		$("#content").fadeIn({duration: 500, queue: "inwest_load"});})
		},500);
}


