var DeepLink=new Object();
DeepLink.aHash='';
DeepLink.listeners=new Array();
DeepLink.isIE=(navigator.userAgent.toLowerCase().indexOf("msie")>-1)?true:false;
DeepLink.init=function(){ if(DeepLink.isIE) DeepLink.ieinit(); }
DeepLink.start=function(){ DeepLink.interval=setInterval(DeepLink.check,200); }
DeepLink.stop=function(){ clearInterval(DeepLink.interval); }
DeepLink.ieinit=function(){
	var frame=document.createElement('iframe');
	frame.setAttribute('id','iFrameDeepLinker');
	frame.style.display='none';
	document.body.appendChild(frame);
}
DeepLink.check=function(){
	var bHash=window.location.hash;
	if(DeepLink.aHash!=bHash){
		DeepLink.aHash=bHash;
		DeepLink.value=bHash.replace('#/','');
		DeepLink.onchange(DeepLink.value);
		if(DeepLink.isIE) DeepLink.ietrap(bHash);
	}
}
DeepLink.ietrap=function(value){
	var doc=document.getElementById('iFrameDeepLinker').contentWindow.document;
	doc.open('');
	doc.write('<html><head><script>parent.window.location.hash="'+value+'"</script></head><body></body></html>')
	doc.close();
}
DeepLink.setTitle=function(title){ document.title=title; }
DeepLink.getTitle=function(){ return document.title; }
DeepLink.setValue=function(value){ window.location.hash='#/'+value; }
DeepLink.addEvent=function(func){ DeepLink.listeners.push(func); }
DeepLink.removeEvent=function(func){ 
 var list=new Array();
 for(var i=0;i<DeepLink.listeners.length;i++){ if(DeepLink.listeners[i]!=func) list.push(DeepLink.listeners[i]); }
 DeepLink.listeners=list;
}
DeepLink.onchange=function(value){for(var i=0;i<DeepLink.listeners.length;i++){ DeepLink.listeners[i](value);	}}
DeepLink.getValue=function(){ return window.location.hash.substr(2); }
DeepLink.avaliable=function(){ return "DeepLinkAvaliable"; }
try{ DeepLink.init(); }
catch(e){
	try{ window.addEventListener('load',DeepLink.init,false); }
	catch(ee){	
		try{ window.attachEvent('onload',DeepLink.init); }
		catch(eee){ 
			try{ window.onload=DeepLink.init; }
			catch(eeee){ alert("Browser does not suport DeepLink"); }
		}
	}
}