﻿function XF_Loadpage_Ancho(x)      
{
	//window.alert(x);
	var V_StrBlockIDLoad=document.getElementById('XAN_BlockIDLoad').innerHTML;
	var V_StrBlockIDElement=document.getElementById('XAN_BlockIDElement').innerHTML;
	XF_AnchorProcess(V_StrBlockIDLoad,V_StrBlockIDElement,x);
	
	if (x.indexOf("LP")!=-1)
	{
		document.getElementById('XAN_CENTER').innerHTML="<img align='center' src='Public/Loadings/loading.gif'><br />Site is loading...!";
		XF_LoadEAjax('AnchorPage.asp?' + x,'XAN_CENTER');
	}
	scroll(0,0);
}
function XF_AnchorProcess(n,m,o)
{
	var StrBlockID;
	var StrBlockIDEl;
	var StrBlockAID = n ;
	var StrBlockAIDEl = m ;
	var StrParas = o ;
	if (StrBlockAID != "0")
	{
		StrBlockID = StrBlockAID.substring(0,StrBlockAID.indexOf(","));
		StrBlockAID = StrBlockAID.substring(StrBlockAID.indexOf(",")+1);
		
		StrBlockIDEl = StrBlockAIDEl.substring(0,StrBlockAIDEl.indexOf(","));
		StrBlockAIDEl = StrBlockAIDEl.substring(StrBlockAIDEl.indexOf(",")+1);
		
		//window.alert(StrBlockID+"/"+StrBlockAID);
		//window.alert(StrBlockIDEl+"/"+StrBlockAIDEl);
		
		if (StrParas.indexOf("?")!=-1){
			XF_LoadEAjax('AnchorPage.asp?X_BlockIDElement='+StrBlockIDEl+'&X_BlockIDLoad='+StrBlockID+'&LP=XB_AnchorLoad.asp' + StrParas.substring(StrParas.indexOf("?")),StrBlockIDEl);
		}
		window.setTimeout("XF_AnchorProcess('"+StrBlockAID+"','"+StrBlockAIDEl+"','"+StrParas+"')",500);
	}
	else
	{
		XF_AjaxPageStatus(StrParas);	
	}
}
//On load page, init the timer which check if the there are anchor changes each 300 ms
setInterval("XF_CheckAnchor()", 300);
var currentAnchor = null;
function XF_CheckAnchor(){
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		if(currentAnchor)
		{
			var query = currentAnchor.substring(1);
			XF_Loadpage_Ancho(query);
		}
	}
}