// JavaScript Document
function fnSetRequestObject()
{
	var http_request;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}

	return http_request;
}

function showcurrent(id)
{
	xmlHttp1 = fnSetRequestObject();
	xmlHttp1.onreadystatechange=function(){ fnDispSubcat(xmlHttp1); };
	var url='index.php?action=getajax&cat_id='+id;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);
	for(i=0;i<12;i++)
	{
		document.getElementById('img'+i).className = 'single_story_img';
	}
	document.getElementById('img'+id).className = 'single_story_img_border';
	document.getElementById('curr_page').value = id;
}

function fnDispSubcat(xmlHttp1)
{
	 if (xmlHttp1.readyState == 4) {
	   if (xmlHttp1.status == 200) {
		document.getElementById('mainnews').innerHTML=xmlHttp1.responseText;
		}	
	}
}

function loadpage(page)
{
	if(page==1)
	{
		document.getElementById('v2_5PaneHorizontal1substory1').style.display='inline';
		document.getElementById('v2_5PaneHorizontal1substory2').style.display='none';
		document.getElementById('v2_5PaneHorizontal1substory3').style.display='none';
		document.getElementById('v2_5PaneHorizontal1TabH1').className = 'ir story_roller_tab1 tabActive';
		document.getElementById('v2_5PaneHorizontal1TabH2').className = 'ir story_roller_tab1 ';
		document.getElementById('v2_5PaneHorizontal1TabH3').className = 'ir story_roller_tab1 ';
		document.getElementById('generic_controls').innerHTML='<a href="javascript:void(0)" title="back" id="v2_5PaneHorizontal1_ArrowBack"class="ir controlBack active"  onclick="loadpage(1)">&lt;</a><a href="javascript:void(0)" title="forward" id="v2_5PaneHorizontal1_ArrowForward" onclick="loadpage(2)" class="ir controlForward">&gt; </a>';
		showcurrent(0);
	}
	if(page==2)
	{
		document.getElementById('v2_5PaneHorizontal1substory2').style.display='inline';
		document.getElementById('v2_5PaneHorizontal1substory1').style.display='none';
		document.getElementById('v2_5PaneHorizontal1substory3').style.display='none';
		document.getElementById('v2_5PaneHorizontal1TabH1').className = 'ir story_roller_tab1 ';
		document.getElementById('v2_5PaneHorizontal1TabH2').className = 'ir story_roller_tab1 tabActive';
		document.getElementById('v2_5PaneHorizontal1TabH3').className = 'ir story_roller_tab1 ';
		document.getElementById('generic_controls').innerHTML='<a href="javascript:void(0)" title="back" id="v2_5PaneHorizontal1_ArrowBack"class="ir controlBack"  onclick="loadpage(1)">&lt;</a><a href="javascript:void(0)" title="forward" id="v2_5PaneHorizontal1_ArrowForward" class="ir controlForward" onclick="loadpage(3)">&gt; </a>';
		showcurrent(4);

	}
	if(page==3)
	{
		document.getElementById('v2_5PaneHorizontal1substory3').style.display='inline';
		document.getElementById('v2_5PaneHorizontal1substory1').style.display='none';
		document.getElementById('v2_5PaneHorizontal1substory2').style.display='none';
		document.getElementById('v2_5PaneHorizontal1TabH1').className = 'ir story_roller_tab1 ';
		document.getElementById('v2_5PaneHorizontal1TabH2').className = 'ir story_roller_tab1 ';
		document.getElementById('v2_5PaneHorizontal1TabH3').className = 'ir story_roller_tab1 tabActive';
		document.getElementById('generic_controls').innerHTML='<a href="javascript:void(0)" title="back" id="v2_5PaneHorizontal1_ArrowBack"class="ir controlBack"  onclick="loadpage(2)">&lt;</a><a href="javascript:void(0)" title="forward" id="v2_5PaneHorizontal1_ArrowForward" class="ir controlForward active">&gt; </a>';
		showcurrent(8);

	}
}
function showtimer()
{
	t=setTimeout("showtimer()",12000);
	var thid = parseInt(document.getElementById('curr_page').value)+1
	if(thid == 4) loadpage(1)
	if(thid == 8) loadpage(3)
	if(thid == 12) loadpage(1)
	if(thid == 4) thid = 0;
	if(thid <= 4) showcurrent(thid);
}
function stoptimeout()
{
	clearTimeout(t);
	t=setTimeout("showtimer()",22000);
}