var homeIssues_current = 1;
var currentTab = "videoTab";


function homeIssues_jumpTo(index){
	/* change image */	
	$('#homeIssues_image_' + homeIssues_current).hide();
	$('#homeIssues_image_' + index).show();
	/* change slider */
	$('#homeIssues_slider_' + homeIssues_current).removeClass("active");
	$('#homeIssues_slider_' + index).addClass("active");
	/* change text */
	$('#homeIssues_content_' + homeIssues_current).hide();
	$('#homeIssues_content_' + index).show();

	homeIssues_current = index;
}

function switchTab(newTab){
	/* check against current tab */
	if(newTab != currentTab){
		/* change the tab appearance */
		$("#" + currentTab).removeClass("active");
		$("#" + newTab).addClass("active");
	
		/* change the tab list */
		$("#" + currentTab + "_list").hide();
		$("#" + newTab + "_list").show();
		
		/* change the tab content */
		$("#" + currentTab + "_content").hide();
		$("#" + newTab + "_content").show();
	}
	
	currentTab = newTab;
}

function switchContent(type, id){
	switch(type){
		case 'image':
			$("#photoTab_content a").hide();
			$("#img" + id).show();
			break;
		case 'video':
			$("#videoTab_content div").hide();
			$("#obj" + id).show();
			break;
		case 'audio':
			$("#audioTab_content .audioTab_contentItem").hide();
			$("#aud" + id).show();
			break;
		default:
			/* console.log("unknown content type ["+ type +"] passed to switchContent"); */
	}
	return false;
}


jQuery('document').ready(function(){
/* MULTIMEDIA TABS */
	$('.multimediaTabs li a').bind("click",function(){ switchTab($(this).parent().get(0).id); return false; });

	/* TAB ITEMS */
	$('#photoTab_list .tabItem').bind("click",function(){ switchContent('image',this.id); return false; });
	$('#videoTab_list .tabItem').bind("click",function(){ switchContent('video',this.id); return false; });
	$('#audioTab_list .tabItem').bind("click",function(){ switchContent('audio',this.id); return false; });

/* HOME PAGE ISSUES */
	var homeIssues_max = $('.homeIssues_image').length;
	/* prev */
	$('#homeIssues_prevArrow').bind("click",function(){
		if(homeIssues_current-1 < 1){
			homeIssues_jumpTo(homeIssues_max);
		} else {
			homeIssues_jumpTo(homeIssues_current-1);
		}
		return false;
	});
	/* next */
	$('#homeIssues_nextArrow').bind("click",function(){
		if(homeIssues_current+1 > homeIssues_max){
			homeIssues_jumpTo(1);
		} else {
			homeIssues_jumpTo(homeIssues_current+1);
		}
		return false;
	});
	/* slider buttons */
	$('.homeIssues_sliderButton').bind("click",function(){
		homeIssues_jumpTo(this.id.substring(this.id.length-1));
		return false;
	});

/* NEWSLETTER SIGNUP TEXT */
	$('#signupEmail').bind('focus',function(){
		if(this.value == 'Enter Email Address') this.value='';
	}).bind('blur', function(){
		if(this.value == '') this.value = 'Enter Email Address';
	});

	$('#signupBtn').bind('mouseenter',function(){
		this.style.cursor = 'pointer';
	}).bind('mouseleave',function(){
		this.style.cursor = 'default';
	});
});

