var xmlHttp;
var flag = 0;
var str = new String;
var content;
var init_Load = 0;

function readHtml1(url){
	//clearTimeout(timerID);
	
		//alert (url);	
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp==null)
		 {
			 alert ("Your browser does not support AJAX! You may not view News and Cricket Scores properly.");
			 return;
		 }
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);		
		return(1)

}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
 	 }
	catch (e)
 	 {
  		// Internet Explorer
  		try
   		{
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e)
   		{
   			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
 	 }
	return xmlHttp;
}

function stateChanged() 
{ 
	
	var idx=0;	
	var str1 = new String;
	var j = 0;
	if (xmlHttp.readyState==4)
	{
		
		str = xmlHttp.responseText;
		//alert("Response:\n" + str);
		for(i=0; i< str.length; i++){
			if(str.charAt(i) != "\n"){
				str1 += str.charAt(i);										
			}
			else{
				if(str1.match(/^NEWS-\d+/ig)){
					//alert('matched');
					idx++;
					j= -1;	 // the j is initialised to -1 because it is again incremented by 1 at the last of this program.
				}else if((idx == 1) && (str1.match(/\w+/g))){
					//alert(str1);
					fcontent1 += str1+"<br><br>&#8226;";
					//alert('fcontent1[j] :'+fcontent1[j]+'j is :'+j);
				}else if((idx == 2) && (str1.match(/\w+/g))){
					fcontent2 += str1+"<br><br>&#8226;";
				}else if((idx == 3) && (str1.match(/\w+/g))){
					fcontent3 += str1+"<br><br>&#8226;";
				}else if((idx == 4) && (str1.match(/\w+/g))){
					fcontent4 += str1+"<br><br>&#8226;";
				}else if((idx == 5) && (str1.match(/\w+/g))){
					fcontent5 += str1+"<br><br>&#8226;";
				}else if((idx == 6) && (str1.match(/\w+/g))){
					fcontent6 += str1+"<br><br>&#8226;";
				}else if((idx == 7) && (str1.match(/\w+/g))){
					fcontent7 += str1+"<br><br>&#8226;";
				}else if((idx == 8) && (str1.match(/\w+/g))){
					fcontent8 += str1+"<br><br>&#8226;";
				}else if((idx == 9) && (str1.match(/\w+/g))){
					fcontent9 += str1+"<br><br>&#8226;";
				}else if((idx == 10) && (str1.match(/\w+/g))){
					fcontent10 += str1+"<br><br>&#8226;";
				}else if((idx == 11) && (str1.match(/\w+/g))){
					fcontent11 += str1+"<br><br>&#8226;";
				}
				str1 = "";
				j++;
				document.getElementById("highlights").innerHTML = fcontent1;
				boxHeight = document.getElementById('highlights').style.height.replace('px','');
				repeatHeight = document.getElementById('highlights').scrollHeight //get the current height so we know when to wrap
				document.getElementById('highlights').innerHTML = document.getElementById('highlights').innerHTML + document.getElementById('highlights').innerHTML  //add a second copy so we can scroll down to the wrap point
				stopScroll = 0
				//alert (fcontent1[j]);
				//str1 += "<br>";
			}		
		}
				
	}
	
}

function changecontent(val){

	curr_Link = document.getElementById('newsSplit');
	getAnchor = curr_Link.getElementsByTagName('A');
	//alert("this class name = "+ this.className)
	for(z=0; z < getAnchor.length; z++){
		//getAnchor[z].className.style.color = getAnchor[z].className.replace('present', 'past');
		getAnchor[z].className = getAnchor[z].className.replace('present', 'past');
		
	}
	
	switch(val){
		case 1:
			document.getElementById("highlights").innerHTML = fcontent1;
			document.getElementById("tab1").className = 'present';
			break;
		case 2:
			document.getElementById("highlights").innerHTML = fcontent2;
			document.getElementById("tab2").className = 'present';
			break;
		case 3:
			document.getElementById("highlights").innerHTML = fcontent3;
			document.getElementById("tab3").className = 'present';
			break;
		case 4:
			document.getElementById("highlights").innerHTML = fcontent4;
			document.getElementById("tab4").className = 'present';
			break;
		case 5:
			document.getElementById("highlights").innerHTML = fcontent5;
			document.getElementById("tab1").className = 'present';
			break;
		case 6:
			document.getElementById("highlights").innerHTML = fcontent6;
			document.getElementById("tab2").className = 'present';
			break;
		case 7:
			document.getElementById("highlights").innerHTML = fcontent7;
			document.getElementById("tab3").className = 'present';
			break;
		case 8:
			document.getElementById("highlights").innerHTML = fcontent8;
			document.getElementById("tab4").className = 'present';
			break;
		case 9:
			document.getElementById("highlights").innerHTML = fcontent9;
			document.getElementById("tab1").className = 'present';
			break;
		case 10:
			document.getElementById("highlights").innerHTML = fcontent10;
			document.getElementById("tab2").className = 'present';
			break;
		case 11:
			document.getElementById("highlights").innerHTML = fcontent11;
			document.getElementById("tab3").className = 'present';
			break;			
	}
	boxHeight = document.getElementById('highlights').style.height.replace('px','');
	repeatHeight = document.getElementById('highlights').scrollHeight //get the current height so we know when to wrap
	document.getElementById('highlights').innerHTML = document.getElementById('highlights').innerHTML + document.getElementById('highlights').innerHTML  //add a second copy so we can scroll down to the wrap point
	stopScroll = 0
	
	
	
	
}

