$(document).ready(function() {
	var currentPage = $("body").attr("id");
	if(currentPage == "home") {
		//rotateLogos();
	}
	
	//Code to show selected tab - main menu
	$(".main-menu li").each(function() {
		var tab = $(this).children("a").text().toLowerCase().replace(" ", "");
		if (tab == currentPage) {
			$(this).addClass("selected");
		} else {
			$(this).removeClass("selected");
		}
	});
	
	//CODE TO SHOW SELECTED TAB - LEFT MENU
	var pageid = $("body").attr("sid");
	$("#left-nav ul li").each(function() {
		var lefttab = $(this).children("a").text().toLowerCase().replace(" ", "");
		if (lefttab.indexOf(pageid) > -1) {
			$(this).addClass("selected");
		} else {
			$(this).removeClass("selected");
		}
	});
	
	//Code to show & hide news archive
	$("#archive").hide();
	$("#archive-link").click(function() {
		if($(this).text().indexOf("Show") > -1) {
			$("#archive").show();
			$(this).html("&#171; Hide News Archive");
		} else {
			$("#archive").hide();
			$(this).html("Show News Archive &#187;");
		}
	});
	
	//Function to add contact info to contactus page
	addContact();
});


function addContact() {
	var userid = "pawan";
	var domainname = "alphacube.com";
	var todoAction = "mailto";

	$("#info").html("<strong>If you are having trouble using this form, please send an email directly to</strong> <a href=\"" + todoAction + ":" + userid + "@" + domainname + "\">" + userid + "@" + domainname + "</a><br />");		
}

var logos = new Array("logo_sun.gif", "logo_acresso.gif", "logo_polycom.gif", "logo_ebaotech.gif", "logo_hs2.gif", "logo_au.gif", "logo_rally.gif", "logo_prca.gif", "logo_datavail.gif", "logo_cohfinder.gif", "logo_fairisaac.jpg", "logo_travers.gif", "logo_usav.gif");
var i = 0;
function rotateLogos() {
	setTimeout('changeLogo();', 2000);
}

function changeLogo() {
	i = (i < logos.length-1) ? i+1 : 0;
	document.getElementById("client-logos").src = "images/" + logos[i];
	rotateLogos();
}
