var loading_interval;
$.ajax({cache: true});
$().ajaxSend(function(r,s)
	{
		clearInterval(loading_interval);
		loading_interval = setInterval('batdau()',1);
		$("#loading").fadeIn("fast");
	});   
$().ajaxStop(function(r,s)
	{ 	
	try {
	var pageTracker = _gat._getTracker("UA-6645168-1");
	pageTracker._initData();
	url_no_hash = window.location.href;
	url_no_hash = url_no_hash.split('#');
	url_no_hash = url_no_hash[1];
	pageTracker._trackPageview(url_no_hash);
	}
	catch(Err) {
	}					  
	$("#loading").fadeOut("fast");
	clearInterval(loading_interval);	
	});

function doc()
{
	re=window.location.hash.substr(1).split("/");
	var rq="";
	for(i=0;i<re.length;i++)
	{
		rq+="&re"+(i+1)+"="+re[i];
	}
	rq=rq.substr(1);
	
	//#home/1/1/2/
	//?re1=home&re2=1&re3=1....
	$("#ajax_content").load("ajax.php?"+rq);
}  


function batdau()
{
	centerView("loading");
}


function browser()
{
	var br_s = navigator.userAgent.toLowerCase();
	if (br_s.indexOf('opera')!= -1)
		br='op';
	else if (br_s.indexOf('netscape')!= -1)
		br='ns';
	else if (br_s.indexOf('firefox')!= -1)
		br='ff';
	else
		br='ie';
	return br;
}

function khoidong()
{
	if(window.location.hash=="")
	{
		document.location="#home";
	}
	
	var interval = setInterval('url()',100);
}

var last_url="";

function url()
{
	if(window.location.hash!=last_url)
	{
		doc();
		url_no_hash = window.location.href;
		url_no_hash = url_no_hash.split('#');
		url_no_hash = url_no_hash[1];
	}
	last_url=window.location.hash;
	
}


function centerView(layer/*no display:none*/, doNotAddOffsets){
if(typeof layer=="string"){layer=document.getElementById(layer);};
if(layer){
var parent=layer.parentNode;/*unless body tag, must have position to relative or absolute*/
parent.style.overflow="auto";
layer.style.position="absolute";/*much better if top and left are specified in style, with 'px'*/
layer.style.top=layer.style.top||layer.offsetTop+'px';
layer.style.left=layer.style.left||layer.offsetLeft+'px';
var clientH=0, clientW=0, offsetT=0, offsetL=0, top=0, left=0;
	if(parent && parent.nodeType==1/*a tag*/){
		if(parent.nodeName=="BODY"){
			if(typeof window.innerHeight!="undefined"){clientH=window.innerHeight; clientW=window.innerWidth;}
			else if(document.documentElement && document.documentElement.clientHeight){clientH=document.documentElement.clientHeight; clientW=document.documentElement.clientWidth;}
			else if(document.body.clientHeight){clientH=document.body.clientHeight; clientW=document.body.clientWidth;}
			else{clientH=parent.clientHeight; clientW=parent.clientWidth;};
			//
			if(typeof pageYOffset!="undefined"){offsetT=pageYOffset; offsetL=pageXOffset;}
			else if(document.documentElement && document.documentElement.scrollTop){offsetT=document.documentElement.scrollTop; offsetL=document.documentElement.scrollLeft;}
			else if(document.body && typeof document.body.scrollTop!="undefined"){offsetT=document.body.scrollTop; offsetL=document.body.scrollLeft;}
			else{offsetT=0; offsetL=0;};
		top=Math.abs(parent.offsetTop + ((clientH/2) - (layer.offsetHeight/2)));
		left=Math.abs(parent.offsetLeft + ((clientW/2) - (layer.offsetWidth/2)));
		}
		else{
		clientH=parent.offsetHeight; clientW=parent.offsetWidth;
		offsetT=parent.scrollTop; offsetL=parent.scrollLeft;
		top=Math.abs(((clientH/2) - (layer.offsetHeight/2))); left=Math.abs(((clientW/2) - (layer.offsetWidth/2)));
		};
	if(!doNotAddOffsets){top+=offsetT; left+=offsetL;};
	layer.style.top=top+'px';//comment out to avoid positioning and allow returning only
	layer.style.left=left+'px';//comment out to avoid positioning and allow returning only
	return [top, left, top+'px', left+'px'];
	};
};
}
////////////////////////////////////
function set_focus(e)
{
	try
	{
		document.getElementById(e).focus();
	}
	catch(e)
	{}
}
/////////////////get back data post form/////////////
function alert_data(data)
{
	getE(alert(data));
}
//////////////////////////////////
function getE(e)
{
	return document.getElementById(e); 
}
