var curTopTab; 
var curLeftTab;
var tab;
var currentIssue = "Vol22I1";

var innerDoc = new Array
	(
	 	"/lihj/TabContents/V21_1/articles.html",
		"/lihj/TabContents/V21_1/reviews.html",
		"/lihj/TabContents/V21_1/interviews.html",
		"/lihj/TabContents/V21_1/emuseum.html",
		"/lihj/TabContents/V21_1/tocblank.html",
		"/lihj/TabContents/V21_2/articles.html",	
		"/lihj/TabContents/V21_2/reviews.html",
		"/lihj/TabContents/V22_1/articles.html",	
		"/lihj/TabContents/V22_1/reviews.html"		
	 );

function setout() {
		document.getElementById('try').style.border= '1px solid #FFFFFF';
}
	
function unsetout(){
		document.getElementById('try').style.border= '1px dashed #FFFFFF';
}

function setOutline() {
		document.getElementById('linkImg').style.outline= '1px solid #FFFFFF';
}
	
function unsetOutline(){
		document.getElementById('linkImg').style.outline= '1px dashed #FFFFFF';
}





/**
*	Sets the focus of the navigation bar to the mentioned menuId
*/
function setFocus(menuId){
//	$('#' +menuId).css("background-color", "#FFFFFF");
	$('#' +menuId).css("color", "#000000");			
	$('#' +menuId).css('text-decoration','underline');	
	$('#' +menuId +'_menu').css('display','block');	
}

/*	Displays the animation mentioned for the museum 
*/
function displayMuseum(){
	$('ul.thumb > li').hover(function() {
	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-110px',
			top: '90%',
			left: '0',
			width: '140px', /* Set new width */
			height: '150px', /* Set new height */
			padding: '20px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: '100px', /* Set width back to default */
			height: '100px', /* Set height back to default */
			padding: '5px'
		}, 200);
});
}
/*	Changes the contents depending on the combination of the tabs selected.
*/
function changeTabContent(){
	
	$('#leftTabButtons').find('li').each(function (){
		$(this).removeClass();
		if(this.id == curLeftTab && (curTopTab == 'Articles' || curTopTab == 'Reviews')){
			$('#' + curLeftTab).addClass('leftTabOn');
		}else{
			$(this).addClass('leftTabOff');
		}
	});
	
	$('#topTabButtons').find('li').each(function (){
		$(this).removeClass();
		if(this.id == curTopTab){
			$('#' + curTopTab).addClass('topTabOn');
		}else{
			$(this).addClass('topTabOff');
		}
	});
	
	/* For Vol21 Issue 1*/
	if (curTopTab == "Articles" && curLeftTab == "Vol21I1"){
		tab = innerDoc[0];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I1"){
		tab = innerDoc[1];
	}else if (curTopTab == "Articles" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}
	
	/*For Vol21 Issue 2 */
	if (curTopTab == "Articles" && curLeftTab == "Vol21I2"){
		tab = innerDoc[5];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I2"){
		tab = innerDoc[6];
	}else if (curTopTab == "Articles" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}	
	
	/*For Vol22 Issue 1 */
	if (curTopTab == "Articles" && curLeftTab == "Vol22I1"){
		tab = innerDoc[7];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol22I1"){
		tab = innerDoc[8];
	}
	
	if (curTopTab == "Articles" && curLeftTab == undefined) {
		curLeftTab = currentIssue;
		tab = innertab[7];
	} else if (curTopTab == "Reviews" && curLeftTab == undefined) {
		curLeftTab = currentIssue;
		tab = innerDoc[8];
	}

	if (curLeftTab == "Volume_default") {
		tab = innerDoc[7];
	}
	
	if (curTopTab == "Interviews"){
		tab = innerDoc[2];
	}else if (curTopTab == "Museum"){
		tab = innerDoc[3];
	}
	$('#divTabFrame').load(tab);
}

/*	Associates the necessary functions with the left and top tabs
*/
function handleTabs(){
	//alert("current tab is " + curLeftTab);
	$('#leftTabButtons li').click(function(){
		curLeftTab = this.id;
		if (curTopTab == "Interviews" || curTopTab == "Museum") {
			curTopTab = 'Articles';
		}
		changeTabContent();
	});
	
	$('#topTabButtons li').click(function(){
		curTopTab = this.id;
		changeTabContent();
	});
	

}

function handleNavBar(){
	// handle the "home" menu subtabs separately
	
	$('#dolphin_inner div div a').click(function(){
//			var tmpcss = $(this).attr('css','color');
//			var col = tmpcss.attr('color');
	//		alert(tmpcss);
	//		alert(col);
		//	if(tmpcss == '#9DCC48'){
				var y = this.id;
				if(y == 'home_menu_articles')
					curTopTab = 'Articles';
				else if (y == 'home_menu_reviews')
					curTopTab = 'Reviews';
				else if (y == 'home_menu_interviews')
					curTopTab = 'Interviews';		
				else if (y == 'home_menu_museum')
					curTopTab = 'Museum';							
			//}
//		document.location.href='/lihj/index.html';
	
	$('#leftTabButtons').find('li').each(function (){
		$(this).removeClass();
		if(this.id == curLeftTab && (curTopTab == 'Articles' || curTopTab == 'Reviews')){
			$('#' + curLeftTab).addClass('leftTabOn');
		}else{
			$(this).addClass('leftTabOff');
		}
	});
	
	$('#topTabButtons').find('li').each(function (){
		$(this).removeClass();
		if(this.id == curTopTab){
			$('#' + curTopTab).addClass('topTabOn');
		}else{
			$(this).addClass('topTabOff');
		}
	});
	
	if (curTopTab == "Articles" && curLeftTab == "Vol21I1"){
		tab = innerDoc[0];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I1"){
		tab = innerDoc[1];
	}else if (curTopTab == "Articles" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}
	
		/*For Vol21 Issue 2 */
	if (curTopTab == "Articles" && curLeftTab == "Vol21I2"){
		tab = innerDoc[5];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I2"){
		tab = innerDoc[6];
	}else if (curTopTab == "Articles" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I0"){
		tab = innerDoc[4];
	}
	
	// vol 22 issue 1
	if (curTopTab == "Articles" && curLeftTab == "Vol22I1"){
		tab = innerDoc[7];
	}else if (curTopTab == "Reviews" && curLeftTab == "Vol21I2"){
		tab = innerDoc[8];
	}
	
	if (curTopTab == "Interviews"){
		tab = innerDoc[2];
	}else if (curTopTab == "Museum"){
		tab = innerDoc[3];
	}

	$('#divTabFrame').load(tab);
		 
	});
}

function handlefirstLoad(){
	$('#divTabFrame').load(innerDoc[0]);
}

$(document).ready(function() {
	// do something here
//	handlefirstLoad();
	$('#leftTabButtons').find('li').each(function(){
			var classtype = $(this).attr('class');
			if(classtype == 'leftTabOn'){
				curLeftTab = $(this).attr('id');
			}
	});
	
	$('#leftTabButtons').find('li').each(function(){
			var classtype = $(this).attr('class');
			if(classtype == 'leftTabOff tempTabOn'){
				curLeftTab = $(this).attr('id');
				$(this).removeClass('tempTabOn');

			}
	});
	
	$('#topTabButtons').find('li').each(function(){
			var classtype = $(this).attr('class');
			if(classtype == 'topTabOn'){
				curTopTab = $(this).attr('id');
			}
	});



	handleTabs();
	handleNavBar();
	

	$('#dolphinnav ul li a').hover(function(){
		$(this).css('text-decoration','underline');			
		//$(this).addClass('tempClass');
		$(this).css('color', '#000000');
	},function(){
		$(this).css('color', '#0000FF');
//		$(this).removeClass('tempClass');
		$(this).css('text-decoration','none');			
	});
	
	$('#dolphin_inner div div a').hover(function(){
			$(this).css('text-decoration','underline');			
	//		$(this).addClass('tempClass');
//			$(this).css('color', '#9DCC48');
			$(this).css('color', '#000000');
	},function(){
		$(this).css('color', '#0000FF');
	//		$(this).removeClass('tempClass');
			$(this).css('text-decoration','none');			
	});
	
	$('#dolphinnav ul li').click(function(){
	//		$('#dolphinnav ul li').css("background-color", "#FFFFFF");
			$('#dolphinnav ul li').css('text-decoration','none');				
			$('#dolphin_inner >div').css('display','none');
			$('#dolphin_inner >div').css('text-decoration','none');							

//	$(this).css("background-color", "#FFFFFF");
			$(this).css('text-decoration','underline');	
		//	$(this).addClass('tempClass');
			$(this).css("color", "#000000");			
			var x = $(this).find('a:first').attr('rel');
			$('#' +x).css('display','block');
		});

});
