function flashMovie_DoFSCommand(command,args) {
	// alert("dupa");
	 document.getElementById("flashMovie").style.height=args + "px";
}

function redirectTo() {
	if(swfobject.hasFlashPlayerVersion("9.0.0")) {
		var address = window.location.href;
		path = address.replace(/http:\/\/[^\/]*\//,'/');
		host = address.replace(path,'');
	
		if(path!='/' && path.indexOf('#')==-1) {
			//alert('here');
			window.location = host + '#' + path
		}
	}
}

function flashLoad() {
//alert('again');
	if(swfobject.hasFlashPlayerVersion("9.0.0")) {
		//document.getElementById("flash_content").innerHTML="";
		var flashvars={};
		var params={};
		var attr={};
		params.allowNetworking="all";
		params.allowScriptAccess="always";
		//params.menu=false;
		params.scale='noscale';
		//params.salign='T';
		params.wmode='window';
		params.play="false";
		params.quality="best";
		params.movie='djtuning-v001';
		params.background="#000000";
		attr.id="flashMovie";
		attr.name="flashMovie";
		//address = window.location.href.split('#');
		//alert("a " + window.location.href + " a");	
		if(window.location.hash =="") {
			swfobject.createCSS("body","background: #000;");
			swfobject.createCSS("#flash_movie2","height: 800px;");
	
			add=readCookie("address");
			if(add!=null) {
				flashvars.address=add;
				//alert(add);
				eraseCookie("address");
			}
			//window.location.hash="";
	
			swfobject.embedSWF("/flash/djtuning-v001.swf", "flash_content", "100%", "800", "9.0.0", false, flashvars, params, attr);
	
			//flashvars.address=address[1];
		} else {
			//lert(address[1]);
			if(!document.getElementById("flashMovie")) {
				createCookie("address",window.location.hash,0.001);
				//window.location.hash="";
				window.location=window.location.href.replace(/#.*/,"");
			}
		}
	} //else {
		//dv = document.createElement("div");
		//noscri = document.getElementsByTagName("noscript")[0];
		//x = noscri.innerHTML;
		
		//atto = noscri.parentNode;
		//atto.removeChild(noscri);
		//document.getElementsByTagName("body")[0].appendChild(dv);
		//dv.innerHTML = x.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
	//}
}
function createCookie(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 readCookie(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);
			}
			function getFlash() {return document.getElementById("flashMovie");}
			/*function checkChange() {
				ad = window.location.href;
				ad = ad.replace(/[^#]*#/,'');
				cook = readCookie('address');
				if(cook == null || cook!=ad) {
					createCookie('address',ad,1);
					//alert('adres się zmienił! ' + ad);
					movie = getFlash();
					movie.setAddress(ad);
				}
			}*/
redirectTo();
addEvent(window,"load",flashLoad);
//addEvent(window,"load",function() {
	//createCookie('test','test',1);
	//if(readCookie('test')=='test') setInterval(checkChange,100);
//});

$(function() {
	pageTracker._setDomainName(".dj-tuning.pl");
	$.historyInit(function() {});
});

function History(hash) {
	$.historyLoad(hash);
	if(pageTracker) 
		pageTracker._trackPageview(hash); 
}

