// JavaScript Document
		

//Switches Images on a timer
function mystart(div_id, img_id, path, which) {
	blendimage(div_id, img_id, path, image_array, rotate_time, which);
	
	if(which+1 < image_array.length){
		which+=1;
	} else {
		which=0;
	}
	//alert(which);
	
	timerID = setTimeout("mystart('"+div_id+"', '"+img_id+"', '"+path+"', " + which + ")", rotate_time);
}

//Performs image switch and fade to a timer
function blendimage(divid, imageid, path, image_array, rotate_time, count) {
	var speed = Math.round(rotate_time / 300);
	var timer = 0;
	var timer_id = null;
	
	//fade in image
	for(i = 100; i >= 0; i--) {
		timer_id = setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
		if(i == 0) {
			clearTimeout(timer_id);
			//switch background to the top image
			imagefile = path+image_array[count];
			document.getElementById(imageid).src = imagefile;
			//set opac to 100 for image
			changeOpac(100, imageid);
			//set new background
			count++;
			if(count >= image_array.length){
				count = 0;
			}
			bg_image = path+image_array[count];
			document.getElementById(divid).style.background = " url('"+bg_image + "') no-repeat";
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}


/**********************************
		Showing and Hiding Tabs
**********************************/
var tab_array = new Array('location_tab', 'counselor_tab'); //List div ids for the tab content
var label_array = new Array('location', 'counselor'); //List div ids for the tab itself

function getDivStyle(divname) {
	style = document.getElementById(divname).style; 
	return style;
}
function hideElement(divname) {
	getDivStyle(divname).visibility = 'hidden';
	getDivStyle(divname).display = 'none';	
}
function showElement(divname) {
	getDivStyle(divname).visibility = 'visible';
	getDivStyle(divname).display = 'block';
}

//Shuts off every tab, and turns on the correct one.
function switch_tabs(current_tab){
	var style;
	for(i=0; i<tab_array.length; i++){
		style = getDivStyle(label_array[i]);
		if(tab_array[i] == current_tab){
			//show
			showElement(tab_array[i]);
			style.background = '#fff';
			style.color = '#000';
			style.fontWeight = 'bold';
			style.textDecoration = 'none';
		}
		else{
			//hide
			hideElement(tab_array[i]);
			style.background = 'transparent';
			style.color = '#00f';
			style.fontWeight = 'normal';
			style.textDecoration = 'underline';
		}
	}
}