isLoading=false;
isNewsOpen=false;

function getBrowser() {
	var sBrowser = navigator.userAgent;
	if (sBrowser.toLowerCase().indexOf('msie 5.0') > 0) return 'ie5';
	if (sBrowser.toLowerCase().indexOf('msie 6.0') > 0) return 'ie6';
	if (sBrowser.toLowerCase().indexOf('firefox/2') > 0) return 'ff2';
	else return;
}


function team(par){
	//alert(par);
	if(par==1) document.getElementById('homeSWF').team1();
	else if(par==2) document.getElementById('homeSWF').team2();
	else if(par==3) document.getElementById('homeSWF').team3();
	else if(par==4) document.getElementById('homeSWF').team4();
	else if(par==5) document.getElementById('homeSWF').team5();
	else if(par==6) document.getElementById('homeSWF').team6();
	else if(par==7) document.getElementById('homeSWF').team7();
	else if(par==8) document.getElementById('homeSWF').team8();
	else document.getElementById('homeSWF').team0();
	
	//tu bedzie
}



function hideLoading(){
	Element.hide('loading2');
	Element.show('config');
	//new Effect.Fade('config',{ from: 0.0, to: 1.0, duration:0.5 });

}
/*
function showLoading(){
	Element.show('loading2');
	Element.hide('config');
}
*/

function start(){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', '/conf_paths/index', {asynchronous:true,
			onSuccess:function(request){
				Element.hide('loading2');
				Element.show('config');
				
				/*
				var so = new SWFObject("/Mp3Panel.swf", "Mp3Panel", "600", "100", "8", "#FFFFFF");
	  			 so.addParam("wmode", "transparent");
				 so.write("flashcontent");
				 */
				
			}
		}
	);
}

function jakas (parametr,krok){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').playSound(krok);
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}

function jakas_back (parametr,krok){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').prevSound(krok);
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}

function start_back(krok){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', '/conf_paths/index', {asynchronous:true,
			onSuccess:function(request){
				Element.hide('loading2');
				Element.show('config');
				document.getElementById('Mp3Panel').prevSound(krok);
				/*
				var so = new SWFObject("/Mp3Panel.swf", "Mp3Panel", "600", "100", "8", "#FFFFFF");
	  			 so.addParam("wmode", "transparent");
				 so.write("flashcontent");
				 */
				
			}
		}
	);
}


function jakasprev (parametr){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').prevSound();
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}


function jakasprev2 (parametr){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').prevSound2();
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}



function jakas2 (parametr, krok){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').playSound2(krok);
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}

function jakas3 (parametr, krok){
	Element.show('loading2');
	Element.hide('config');
	new Ajax.Updater('config', parametr, { method:'post',
											asynchronous:true,
	 										//onSuccess:function (request){alert(request.responseText)},
											onSuccess:function(request){
																		Element.hide('loading2');
																		Element.show('config');
																		document.getElementById('Mp3Panel').playSound3(krok);
																		},
											evalScripts:true,
											requestHeaders:['X-Update', 'config']

											});
}

function x_update(id_site,name)
	{
	if (!isLoading){
		var so = new SWFObject("/loaderBR.swf", "LoaderSwf_"+name, "450", "150", "8", "#FFFFFF");
			so.addParam("scale", "noscale");
			so.addParam("wmode", "transparent");
			so.write('content');
		window.location =  "#siteId/"+id_site;
											isLoading=true;
											
											new Ajax.Updater(
															'content',
															'/articles/showarticle/'+id_site+'/null/ajax',
															{
																	onSuccess:function(request){
																		//Element.hide('loading');
																		//new Effect.Fade('content',{ from: 0.0, to: 1.0, duration:0.5 });
																		//new Effect.BlindDown('content',{duration:0.6});
																		isLoading=false;
																	},
																	asynchronous:true,
																	evalScripts:true,
																	requestHeaders:['X-Update', 'content']
															}
														)

											/*new Effect.Fade('content',{ from: 1.0, to: 0.0, duration:0.5 });
											new Effect.BlindUp(
												'content',
												{	duration:0.7,
													afterFinish: function(effect)
													{
														Element.show('loading');
														new Ajax.Updater(
															'content',
															'/articles/showarticle/'+id_site+'/null/ajax',
															{
																	onSuccess:function(request){
																		Element.hide('loading');
																		new Effect.Fade('content',{ from: 0.0, to: 1.0, duration:0.5 });
																		new Effect.BlindDown('content',{duration:0.6});
																		isLoading=false;
																	},
																	asynchronous:true,
																	evalScripts:true,
																	requestHeaders:['X-Update', 'content']
															}
														)

													}
												}
											)*/
										}
	return;
};


//--------------------------------------------------------------------------------------------------


function showLoading(name){

	var so = new SWFObject("loader.swf", "LoaderSwf_"+name, "200", "80", "8", "#FFFFFF");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("align", "left");
	so.addParam("salign", "b");
	so.write(name);
	
}

function updateNews(id_site,name){
	showLoading(name);
	window.location =  '#'+name+'/Page/'+id_site;
	new Ajax.Updater(
						name,
						'/general_newses/showgeneralajaxnewses/1/'+id_site+'/null/ajax',
						{
								onSuccess:function(request){
									new Effect.Fade('content',{ from: 0.0, to: 1.0, duration:0.5 });
								},
								asynchronous:true,
								evalScripts:true,
								requestHeaders:['X-Update', 'news']
						}
					)

}



//--------------------------------------------------------------------------------------------------
/*
function news_update(id_site,name)
	{
	if (!isLoading){
		window.location =  '#'+name+'/Page/'+id_site;
		isLoading=true;
		new Effect.Fade(
			'news',
			{	duration:0.7,
				afterFinish: function(effect)
				{
					alert( 'xxxx');
					$('news').innerHTML='Loading...';

					new Ajax.Updater(
						'news',
						'/general_newses/showgeneralajaxnewses/1/'+id_site+'/null/ajax',
						{
								onSuccess:function(request){
									Element.hide('loading3');
									alert("done");
									new Effect.Fade('news',{duration:0.6});
									isLoading=false;
									alert(reguest.responseText);
								},
								asynchronous:true,
								evalScripts:true,
								requestHeaders:['X-Update', 'news']
						}
					)

				}
			}
		)
	}
};*/

/*
function news_open(id_site,name){
	//if (isLoading) return;
	window.location = "#"+name+"/"+id_site;
	isLoading=true;
	new Effect.Fade('content',{ from: 1.0, to: 0.0, duration:0.5 });
	new Effect.BlindUp(
		'content',
		{	duration:0.7,
			afterFinish: function(effect)
			{
				var so = new SWFObject("loader.swf", "LoaderSwf_"+name, "40", "40", "8", "#FFFFFF");
				so.addParam("scale", "noscale");
				so.addParam("wmode", "transparent");
				so.addParam("align", "left");
				so.addParam("salign", "b");
				so.write('content');
			}
		}
	);
}
*/

/*var so = new SWFObject("loader.swf", "LoaderSwf_"+name, "200", "80", "8", "#FFFFFF");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("align", "left");
	so.addParam("salign", "b");
	so.write(name);
*/


function news_open(id_site,name){

	if (isLoading) return;
	window.location =  "#"+name+"/"+id_site;
	isLoading=true;
	var so = new SWFObject("loaderBR.swf", "LoaderSwf_"+name, "450", "150", "8", "#FFFFFF");
			so.addParam("scale", "noscale");
			so.addParam("wmode", "transparent");
			so.write('content');

	if (isNewsOpen) {
			new Ajax.Updater(
						'content',
						'/general_newses/showgeneralnews/'+id_site+'/null/ajax',
						{
								onSuccess:function(request){
									new Effect.Fade('content',{ from: 0.0, to: 1.0, duration:0.5 });
									isLoading=false;
									isNewsOpen=true;
								},
								asynchronous:true,
								evalScripts:true,
								requestHeaders:['X-Update', 'content']
						}
					)
	}
	else{
		new Effect.Fade('content',{ from: 0.0, to: 1.0, duration:0.5 });
		new Effect.BlindDown(
			'content',
			{	duration:0.7,
				afterFinish: function(effect)
				{
					new Ajax.Updater(
						'content',
						'/general_newses/showgeneralnews/'+id_site+'/null/ajax',
						{
								onSuccess:function(request){
									isLoading=false;
									isNewsOpen=true;
								},
								asynchronous:true,
								evalScripts:true,
								requestHeaders:['X-Update', 'content']
						}
					)

				}
			}
		)
	}
};

function close_news_open(){
	new Effect.BlindUp('content',{duration:0.7});
	//new Effect.Fade('content',{ from: 1.0, to: 0.0, duration:0.5 });
	isNewsOpen=false;
}


function play_movie(movie){
	//alert('vcvcv'+movie);
	new Ajax.Updater(
						'play_movie',
						'/articles/ajaxvideo/'+movie,
						{
								asynchronous:true,
								evalScripts:true,
								requestHeaders:['X-Update', 'play_movie']
						}
					)
}


/*
function accordion(el) {
	alert(el.innerHTML);
    if ($("visible") == el) {
        return;
    }
    if ($("visible")) {
        var eldown = el.parentNode.id+"-body";
        var elup = $("visible").parentNode.id+"-body";
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.1
        });
        $("visible").id = "";
    }
    el.id = "visible";
}*/

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}


function accordion(el) {
	//alert(el.innerHTML);
	
	if ($("VIDEO") && el.id=="VIDEO") return;
	
    if ($("visible") == el) {
        return;
    }
    if ($("visible") && el.innerHTML!='VIDEO') {
	
        var eldown = el.parentNode.id+"-body";
        var elup = $("visible").parentNode.id+"-body";
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.1
        });
        $("visible").id = "";
		el.id = "visible";
    }else{
		if ($("visible") && el.innerHTML=='VIDEO'){
			thisMovie("soundSWF").stopSounds();
			
			var eldown = el.parentNode.id+"-body";
	        var elup = $("visible").parentNode.id+"-body";
	        new Effect.Parallel(
	        [
	            new Effect.SlideUp(elup),
	            new Effect.SlideDown(eldown)
	        ], {
	            duration: 0.1
	        });
			$("visible").id = "";
	        el.id  = "VIDEO";
			return;
		}
	}
      
   
   if ($("VIDEO")) {
	
        var eldown = el.parentNode.id+"-body";
        var elup = $("VIDEO").parentNode.id+"-body";
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.1
        });
        $("VIDEO").id = "VIDEO_CLOSE";
		el.id = "visible";
    }
}

function accordion2(el) {
	//alert(el.innerHTML);
	alert("AC2");
	if ($("VIDEO") && el.id=="VIDEO") return;
	
    if ($("visible") == el) {
        return;
    }
    if ($("visible") && el.innerHTML!='MARK SHINN') {
        var eldown = el.parentNode.id+"-body";
        var elup = $("visible").parentNode.id+"-body";
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.1
        });
        $("visible").id = "";
		el.id = "visible";
    }else{
		if ($("visible") && el.innerHTML=='MARK SHINN'){
			var eldown = el.parentNode.id+"-body";
	        var elup = $("visible").parentNode.id+"-body";
	        new Effect.Parallel(
	        [
	            new Effect.SlideUp(elup),
	            new Effect.SlideDown(eldown)
	        ], {
	            duration: 0.1
	        });
			$("visible").id = "";
	        el.id  = "VIDEO";
			return;
		}
	}
      
   
   if ($("VIDEO")) {
        var eldown = el.parentNode.id+"-body";
        var elup = $("VIDEO").parentNode.id+"-body";
        new Effect.Parallel(
        [
            new Effect.SlideUp(elup),
            new Effect.SlideDown(eldown)
        ], {
            duration: 0.1
        });
        $("VIDEO").id = "VIDEO_CLOSE";
		el.id = "visible";
    }
}

