/*	TrölfHistory - Flash-HTML-Framework
		v1.0b - Copyright 2007 Trölfdesign
		http://www.troelfdesign.com

		This work is licensed under the Creative Commons Attribution 2.0 Germany License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.0/de/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
*/
th_lid=new Date();
th_lid=th_lid.getTime();
th_hash='';
var th_checki;
var th_movievars;
var th_swfo;
if(th_movievars==undefined) th_movievars='';
function th_browsercheck(){
	if(navigator.userAgent.indexOf('Firefox')!=-1) th_b='f';
	else if(navigator.userAgent.indexOf('Opera')!=-1) th_b='o';
	else if(navigator.userAgent.indexOf('Safari')!=-1) th_b='s';
	else if(navigator.userAgent.indexOf('IE')!=-1) th_b='i';
	else th_b='x';
}
function th_cleanhash(a){
	if(a.substr(0,1)=="#") return a.substr(1);
	else return a;
}
th_browsercheck();

th_swfv=new Object();
if(navigator.plugins['Shockwave Flash']){
	th_swfv.v=navigator.plugins['Shockwave Flash'].description.substring(15).split(".");
	th_swfv.m1=Number(th_swfv.v[0]);
	th_swfv.v=th_swfv.v[1].split(" r");
	th_swfv.m2=Number(th_swfv.v[0]);
	th_swfv.m3=Number(th_swfv.v[1]);
}else{
	try{th_swfo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');}catch(e){}
	if(!th_swfo) try{th_swfo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');}catch(e){}
	if(th_swfo){
		th_swfv.v=th_swfo.GetVariable('$version').split(" ")[1].split(",");
		th_swfv.m1=Number(th_swfv.v[0]);
		th_swfv.m2=Number(th_swfv.v[1]);
		th_swfv.m3=Number(th_swfv.v[2]);
	}
}
th_neededversion=th_neededversion.split(",");
th_neededversion[0]=Number(th_neededversion[0]);
th_neededversion[1]=Number(th_neededversion[1]);
th_neededversion[2]=Number(th_neededversion[2]);
var noversion=0;
if(!th_swfv.m1) noversion=1;

/*if(th_b=='s'){
	h=th_cleanhash(window.location.hash);
	if(window.history.length==1){
		if(h.substr(0,2)!="f_"){
			window.location.hash="f_"+h;
			window.history.reload();
		}
	}
}*/
function th_checkf(){
	if(th_b=='s'&&th_cleanhash(window.location.hash).substr(0,2)=="f_"){
		window.location.hash=th_cleanhash(window.location.hash).substr(2);
	}
	if(th_cleanhash(window.location.hash)!=th_hash){
		th_hash=th_cleanhash(window.location.hash);
		th_action('history',th_hash);

	}
}

function th_navigate(i){
	if(i!=th_hash){
		th_hash=i;
		window.location.href="#"+i;
		if(th_b=='i') window.frames['th_frm'].window.location.href="th_history/th_iframe.php?"+i+"=1";
	}
}

function th_iframef(i){
	if(i!=''){
		if(th_hash!=i){
			window.location.hash=i;
			th_action('history',i);
		}
	}
}
function th_version(x){
	document.getElementById('th_comdiv').innerHTML='';
	try{
		x=x.split(" ")[1].split(",");
		th_swfv.m1=x[0];
		th_swfv.m2=x[1];
		th_swfv.m3=x[2];
		if(th_swfv.m1<th_neededversion[0]) th_noswf();
		else if(th_swfv.m1>th_neededversion[0]) return true;
		else if(th_swfv.m2<th_neededversion[1]) th_noswf();
		else if(th_swfv.m2>th_neededversion[1]) return true;
		else if(th_swfv.m3<th_neededversion[2]) th_noswf();
	}catch(e){
		th_noswf();
	}
}
function th_start(){
	if(!document.getElementById('th_comdiv')){
		document.write('<div id="th_comdiv"></div>');
		if(th_b=='i'){
			document.writeln('<script language="VBScript">');
			document.writeln('Sub '+th_moviename+'_FSCommand(ByVal cmd,ByVal para)');
			document.writeln('call '+th_moviename+'_DoFSCommand(cmd,para)');
			document.writeln('end sub');
			document.writeln('</script>');
		}
	}
	if(noversion==0){
		if(th_swfv.m1<th_neededversion[0]) th_noswf();
		if(th_swfv.m1>th_neededversion[0]) th_swf();
		else if(th_swfv.m2<th_neededversion[1]) th_noswf();
		else if(th_swfv.m2>th_neededversion[1]) th_swf();
		else if(th_swfv.m3<th_neededversion[2]) th_noswf();
		else th_swf();
	}else{
		th_noswf();
//		th_swf();
//		th_controlswf('th_version');
	}
	if(th_b=='i') document.write('<iframe src="th_history/th_iframe.php?'+th_hash+'=1" name="th_frm" style="width:10px;height:10px;visibility:hidden;position:absolute;top:0px;left:0px;" />');
}

function th_swf(){
	window.clearInterval(th_checki);
	th_checki=window.setInterval("th_checkf()",200);
	th_v=th_movievars+"&amp;th_lid="+th_lid;
	document.getElementById(th_moviediv).innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+th_neededversion+'" width="'+th_moviewidth+'" height="'+th_movieheight+'" id="'+th_moviename+'" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+th_moviefile+'" /><param name="quality" value="high" /><param name="bgcolor" value="'+th_moviebackground+'" /><param name="swliveconnect" value="true" /><param name="flashVars" value="'+th_v+'" /><embed swliveconnect="true" src="'+th_moviefile+'" quality="high" bgcolor="'+th_moviebackground+'" width="'+th_moviewidth+'" height="'+th_movieheight+'" name="'+th_moviename+'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" flashVars="'+th_v+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	th_action('start',th_hash);
}

function th_controlswf(cmd,p1){
	th_v="th_lid="+th_lid+"&amp;cmd="+escape(cmd)+"&amp;p1="+p1;
	if(document.getElementById('th_comdiv'))
	document.getElementById('th_comdiv').innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width="10" height="10" id="th_comswf" align="middle" style="position:absolute;top:-50px;left:-50px;"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="th_history/th_com.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="swliveconnect" value="true" /><param name="flashVars" value="'+th_v+'" /><embed swliveconnect="true" src="th_history/th_com.swf" quality="high" bgcolor="#ffffff" width="10" height="10" name="th_comswf" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" flashVars="'+th_v+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="position:absolute;top:-50px;left:-50px;" /></object>';
}

eval("function "+th_moviename+"_DoFSCommand(cmd,para){th_fscommand(cmd,para);}");
function th_fscommand(cmd,para){
	switch(cmd){
		case 'th_checkinterval':
			window.clearInterval(th_checki);
			th_checki=window.setInterval("th_checkf()",200);
		break;
		case 'th_navigate':
			th_navigate(para);
		break;
		case 'th_back':
			history.back();
		break;
		case 'th_scroll':
			window.scrollBy(0,para);
		break;
		case 'th_title':
			document.title=para;
		default: th_usercommand(cmd,para); break;
	}
	if(cmd!='th_checkinterval') document.getElementById('th_comdiv').innerHTML='';
}

th_hash=th_cleanhash(window.location.hash);