// 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,0);
	}
	else if(locat=="" && temp=="")
	{
		window.location="default.aspx";
	}
	locat=temp;
	setTimeout("checkWhetherChanged()", 200);
}

function load(id,flag)
{
	var	url;
		id = id.replace(/-/g, "/");
		id = id.replace('$','');
		url='content/text/' + id + '.html';
		window.location.href="#"+ (locat=id);	
		var div = document.getElementById('subMenu');
		div.innerHTML="<div class=\"centerLoad1\" >Please wait...</div>";

		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 div1 =document.getElementById('viewWindow');
		url1='content/text/div' + id + '.html';
		div1.innerHTML="<div class=\"w500 h290 mr5 mb5 fl bg centerLoad\">Please wait...</div>";
		httpReq1 = getXmlhttpObject();
		if(httpReq1)	{
			httpReq1.abort();
			}
		
			httpReq1.open ("GET", url1, true);
        httpReq1.onreadystatechange = function (id) 
		{
			
			if (httpReq1.readyState== 4)
			{
				div1.innerHTML = httpReq1.responseText;
			}
			else if (httpReq1.readyState == 3)		
				div1.innerHTML="<div class=\"w500 h290 mr5 mb5 fl bg centerLoad\" >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;
}

function changeSubLink(x)
{
  switch(x)
  {
    case 1:text="ALUMNI";
           break;
    case 2:text="ABOUT THANJAVUR";
           break;
    case 3:text="CAMPUS MAP";
           break;
    case 4:text="PHOTO ALBUM";
           break;
    case 5:text="HOW TO REACH SASTRA";
           break;
    case 6:text="PHOTO GALLERY";
           break;
    case 7:text="SHANMAIL";
           break;
    case 8:text="DOWNLOAD LOGO";
	   break;
    default:text="";
  }
  var div1 = document.getElementById('changeSub');
  div1.innerHTML=text;
}