// JavaScript Document
DJ_XMLHTTP_PROGIDS = ["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
var locat='';
function checkWhetherChanged ()
{
   	var temp= "";
	temp=window.location.href;
	var i=temp.indexOf('#')+1;
	if (i==0) temp="";	
	else temp = temp.substr(i);
	if(temp!=locat) 
	{
			load(temp);
	}
	else if(locat=="" && temp=="")
	{
		window.location="default.aspx";
	}
	locat=temp;
	setTimeout("checkWhetherChanged()", 200);
}

function load(id,flag)
{
	var	url;
		id1=id;
		id2=id;
		id2 = id2.replace(/-/g, "/");
		id3 = id2.split('/');
		id2 = id3[0];
		lokhat=locat;
		lokhat1=lokhat.split('-');
		lokhat=lokhat1[0];
		if(lokhat!=id2)
		{
		url='content/text/' + id2 + '.html';
		window.location.href="#"+ (locat=id);	
		var div = document.getElementById('subMenu');
		div.innerHTML="<div class=\"centerLoad1\" >Please wait...</div>";
        document.getElementById('headerImage').src='images/inner'+ id2 + ".jpg";
        document.getElementById('headerImage').alt=id2;
		httpReq = getXmlhttpObject();
		
        if(httpReq)	{
			httpReq.abort();
			}
		
			httpReq.open ("GET", url, true);
        httpReq.onreadystatechange = function (id) 
		{
			
			if (httpReq.readyState== 4)
			{
				div.innerHTML = httpReq.responseText;
			}
			else if (httpReq.readyState == 3)		
				div.innerHTML="<div class=\"centerLoad1\" >Receiving ...</div>";
		}
		httpReq.send(null);	
		}
		var	url;
		id1 = id1.replace(/-/g, "/");
		url='content/' + id1 + '.html';
		var div1 = document.getElementById('pageContent');
		div1.innerHTML="<div class=\"centerLoad2\" >Please wait...</div>";

		httpReq1 = getXmlhttpObject();
		
        if(httpReq1)	{
			httpReq1.abort();
			}
		
			httpReq1.open ("GET", url, true);
        httpReq1.onreadystatechange = function (id) 
		{
			
			if (httpReq1.readyState== 4)
			{
				id1=id1.replace(/%20/g," ");
				var idArray =id1.split("/");
				var prevSplit="";
				var chkSplit="<font style='font-size:11px;'>You are here: ";
				for(var isplit=0;isplit<idArray.length-1;isplit++)
				{
					chkSplit+="<a href=\"javascript:load(\'"+prevSplit+idArray[isplit]+"\',1)\" style='text-transform: uppercase;'>"+idArray[isplit]+"</a> &raquo; ";
					prevSplit+=idArray[isplit]+'-';
				}
				chkSplit+="<font color=#000066 style='text-transform:uppercase;'><strong>"+idArray[idArray.length-1]+"</strong></font></font>";
				div1.innerHTML = chkSplit;
				div1.innerHTML += httpReq1.responseText;
				if(id1="photo gallery")Lightbox.init();
			}
			else if (httpReq1.readyState == 3)		
				div1.innerHTML="<div class=\"centerLoad2\" >Receiving ...</div>";
		}
		httpReq1.send(null);	
}

function getXmlhttpObject()
{
	var http = null;
        if(http) return http;
	var last_e = null;
	try{ http = new XMLHttpRequest(); }catch(e){}
        if(!http){
		for(var i=0; i<3; ++i){
			var progid = DJ_XMLHTTP_PROGIDS[i];
			try{
				http = new ActiveXObject(progid);
			}catch(e){
				last_e = e;
			}

			if(http){
				DJ_XMLHTTP_PROGIDS = [progid];  
				break;
			}
		}
	}

	if(!http){
		alert("XMLHTTP not available");
		return;
	}
        
	return http;
}
