function tabSwitcher() {
	if(document.getElementById("tabs")) {
		var tabitem = document.getElementById("tabs").getElementsByTagName("A");
		for (var k=0; k < tabitem.length; k++) {
			tabitem[k].onclick = function() {
				var par = this.parentNode;
				var ent = par.parentNode.id;
				highLighter(ent);
				tabBuilder(this.id.replace("tab",""));
				Set_Cookie('tabcook',this.id.replace("tab",""),'20');
			}
		}
	}
}

function Set_Cookie( name, value, expires ) {
// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
	if ( expires ){
		expires = expires * 1000 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
}

function readCookie(someVar) {
	var cookname = someVar;
	var mon = cookname + "tab";
	if(document.getElementById(mon)) {
		var ster = document.getElementById(mon);
		var snicker = ster.parentNode;
		var doodle = snicker.parentNode.id;
		tabBuilder(cookname);
		highLighter(doodle);
	}
}

function highLighter(tabid) {
	var allli = document.getElementById("tabs").getElementsByTagName("LI");
	for (var j=0; j < allli.length; j++) {
		if(allli[j].id == tabid) {
			allli[j].className = "tabon";
		} else {
			allli[j].className = "";
		}
	}
}

function tabBuilder(tab) {
	var tabbed = document.getElementById("resume").getElementsByTagName("DIV");
	for (var i=0; i < tabbed.length; i++) {
		if(tabbed[i].id == tab) {
			tabbed[i].className = "";
		} else if (tabbed[i].parentNode.id == "resume") {
			tabbed[i].className = "invisible";
		}
	}
}

function newAdd(plus, field) {
	var add = document.getElementById(plus);
	var newadd = document.getElementById(field);
	if(add.className == "add") {
		add.className = "";
		newadd.className = "invisible";
	} else {
		add.className = "add";
		newadd.className = "new";
	}
}

function reName() {
	var title = document.getElementById('resumetitle');
	var renamer = document.getElementById('renameform');
	if(title.className == "invisible") {
		title.className = "";
		renamer.className = "invisible";
	} else {
		title.className = "invisible";
		renamer.className = "";
	}
}

document.onmousemove = mouseMove;
document.onmouseup = mouseUp;
document.onmousedown = mouseDown;
var dragObject = null;
var mouseOffset = null;
var iMouseDown  = false;
var lMouseState = false;
var curTarget   = null;
var lastTarget  = null;
Number.prototype.NaN0=function(){return isNaN(this)?0:this;}

function activateTracker() {
	if(document.getElementById('allSkills')) {
		var skillz = document.getElementById('allSkills').getElementsByTagName('DIV');
		/*for (var h=0; h < skillz.length; h++) {}*/
			makeDraggable(document.getElementById('allSkills'));
		
	}
}

function getMouseOffset(target,ev) {
	ev = ev || window.event;
	var docPos = getPosition(target);
	var mousePos = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}

function showPosition(e){
	var left = 0;
	var top  = 0;	
	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	window.alert(top);
}

function makeDraggable(item) {
	if(!item) { 
		return;
	}
	item.onmousedown = function(ev) {
		dragObject = this;
		mouseOffset = getMouseOffset(this, ev);
		return false;
	}
}

function mouseMove(ev){
	ev = ev || window.event;
	var mousePos = mouseCoords(ev);
	var target   = ev.target || ev.srcElement;
	if(dragObject) {
			dragObject.style.position = 'absolute';
			dragObject.style.top = mousePos.y - mouseOffset.y;
			dragObject.style.left = mousePos.x - mouseOffset.x;
			return false;
	}
}

function mouseUp() {
	dragObject = null;
}

function mouseDown(){
	iMouseDown = true;
	if(lastTarget){
		return false;
	}
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}

function CreateDragContainer(){
	/*
	Create a new "Container Instance" so that items from one "Set" can not
	be dragged into items from another "Set"
	*/
	var cDrag        = DragDrops.length;
	DragDrops[cDrag] = [];

	/*
	Each item passed to this function should be a "container".  Store each
	of these items in our current container
	*/
	for(var i=0; i<arguments.length; i++){
		var cObj = arguments[i];
		DragDrops[cDrag].push(cObj);
		cObj.setAttribute('DropObj', cDrag);

	}
}

/* function used to activate the explanation box on the externship survey if
   the student selects other for the notification
*/   

function activeOther() {
	listofopts = document.surveyform.q7;
	actTxt = document.getElementById("q7Explanation").getElementsByTagName("SPAN");
	actInput = document.getElementById("q7Explanation").getElementsByTagName("INPUT");
	if(listofopts.options[listofopts.selectedIndex].value=="6") {
		actTxt[0].style.color="black";
		actInput[0].disabled=false;
		actInput[0].style.borderColor="";
	} else {
		actTxt[0].style.color="#cccccc";
		actInput[0].disabled=true;
		actInput[0].style.borderColor="#cccccc";
	}
}

/* function used to activate the explanation box on the externship survey if
   the student did not attend info session
*/   

function activeNo() {
	chosen = "";
	arrLen = document.surveyform.q8.length;
	for (i=0; i<arrLen; i++){
		if (document.surveyform.q8[i].checked)
			chosen = document.surveyform.q8[i].value;
	}
	actTxt = document.getElementById("q8Explanation").getElementsByTagName("SPAN");
	actInput = document.getElementById("q8Explanation").getElementsByTagName("INPUT");
/*	alert('here it is ' + chosen); */
	if(chosen=="0") {
		actTxt[0].style.color="black";
		actInput[0].disabled=false;
		actInput[0].style.borderColor="";
	} else {
		actTxt[0].style.color="#cccccc";
		actInput[0].disabled=true;
		actInput[0].style.borderColor="#cccccc";
	}
}
				
				