if (section==undefined) {
 var section = "default";	
}

var t;

// this function hides all elements on the page with id's lx (left div num) and rx (right div num). x being the total
function hideAll(total, str) {
	//alert("str: "+str);
	for (num=0; num<total; num++) {
		var hideId = "l"+str;
		var hideId2 = "r"+str;
		//alert("hiding id: "+hideId);
		document.getElementById(hideId).style.display = "none";
		document.getElementById(hideId2).style.display = "none";
		str = str+1;
	}
}

/////////////////////////

function changeSection(id, total) {
	var str = 1;
	hideAll(total, str);
	var showId = "l"+id;
	var showId2 = "r"+id;
	document.getElementById(showId).style.display = "inline";
	document.getElementById(showId2).style.display = "inline";
	//alert("showing id: "+showId);
	if (id=="2" && total=="2") {
		document.getElementById("contactpanel").style.display = "block";
	}
	else {
		document.getElementById("contactpanel2").style.display = "block";
		document.getElementById("contactpanel").style.display = "block";
	}
}

/////////////////////////

gfirstRun2 = 0;

function changeGallery(id, total) {
	clearTimeout(t);
	gfirstRun2 = gfirstRun2+1;
	//alert("run: "+gfirstRun2)
	gtotal = total;
	gid = id
	animateGallery();
}


function animateGallery() {
	//gtotal = gtotal - 1;
	var str2 = 1;
	hideAll(gtotal, str2);
	var showgid = "l"+gid;
	var showgid2 = "r"+gid;
	document.getElementById(showgid).style.display = "inline";
	document.getElementById(showgid2).style.display = "inline";
	//alert("showing gid: "+showgid);
	//alert("gid: "+gid);
	//alert("gtotal: " + gtotal);
	if (gid<gtotal) { //&& gfirstRun2<=2
		if (gid==7 && gtotal ==7){
			
		}
		else {
		gid = (gid + 1);
		t = setTimeout(animateGallery,3000);
		}
	}
	else {
		clearTimeout(t);
	}
	
}


/////////////////////////

gfirstRun1 = 0;

function changeExcess(id, total) {
	clearTimeout(t);
	gfirstRun1 = gfirstRun1+1;
	//alert("run: "+gfirstRun)
	gtotal = total;
	gid = id
	animateExcess();
}


function animateExcess() {
	//gtotal = gtotal - 1;
	var str2 = 1;
	hideAll(gtotal, str2);
	var showgid = "l"+gid;
	var showgid2 = "r"+gid;
	document.getElementById(showgid).style.display = "inline";
	document.getElementById(showgid2).style.display = "inline";
	//alert("showing gid: "+showgid);
	//alert("gid: "+gid);
	//alert("gtotal: " + gtotal);
	if (gid<gtotal && gid>1) { //&& gfirstRun1<=2 
		if (gid==7 && gtotal ==7){
			
		}
		else {
			gid = (gid + 1);
			t = setTimeout(animateExcess,3000);
		}
	}
	else {
		clearTimeout(t);
	}
}


/////////////////////////

gfirstRun = 0;

function changeCaseStudy(id, total) {
	clearTimeout(t);
	gfirstRun = gfirstRun+1;
	//alert("run: "+gfirstRun)
	gtotal = total;
	gid = id
	animateProof();
}


function animateProof() {
	//gtotal = gtotal - 1;
	var str = 0;
	hideAll(gtotal+1, str);
	var showgid = "l"+gid;
	var showgid2 = "r"+gid;
	document.getElementById(showgid).style.display = "inline";
	document.getElementById(showgid2).style.display = "inline";
	//alert("showing gid: "+showgid);
	//alert("gid: "+gid);
	//alert("gtotal: " + gtotal);
	if (gid<gtotal && gid>1) {  //&& gfirstRun<=2
		if (section=="hitachi-gst" && gid==6) {
			
		}
		else {
			gid = (gid + 1);
			t = setTimeout(animateProof,3000);
		}
	}
	else {
		clearTimeout(t);
	}
}

/////////////////////////

var count = 4;

function animateHome() {
	document.getElementById("intro-panel").style.display = "none";
	document.getElementById("m1").style.display = "block";
	count = count-1;
	t = setTimeout("animateHome();",1000);
	if (count == 2 ){
		document.getElementById("home").style.display = "none";
		document.getElementById("home2").style.display = "block";
		document.getElementById("nav").style.display = "block";
	}
	if (count == 0 ){
		document.getElementById("home2").style.display = "none";
		document.getElementById("flash").style.display = "block";
		clearTimeout(t);
	}
}


/////////////////////////


function hideAll2(total) {
	var str = 0;
	for (num=0; num<=total; num++) {
		var hideId = "l"+str;
		var hideId2 = "r"+str;
		var hideId3 = "head"+str;
		//alert("hiding id: "+hideId3);
		document.getElementById(hideId).style.display = "none";
		document.getElementById(hideId3).style.fontWeight = "normal";
		str = str+1;
	}
}

function changeNewsSection(id, total) {
	hideAll2(total);
	//alert("showing id: "+id);
	var showId = "l"+id;
	var showId2 = "r"+id;
	var showId3 = "head"+id;
	document.getElementById(showId).style.display = "inline";
	document.getElementById(showId3).style.fontWeight = "bold";
}

/////////////////////////

function load() {
	var strHref = window.location.href;
	var aQueryString = strHref.split("?");
	var location = aQueryString[aQueryString.length-1];
	//alert("loc: "+location);
	if (location.length==1 || location.length==2) {
		changeNewsSection(location,numItems);
	}
	else {
		changeNewsSection(numItems,numItems);
	}
}