/*
    EMERSON COLLEGE
    (c) 2006
	Visit Application
*/

// Constants (Do not touch)
	var EmersonJS_src = '';
	var EmersonJS_includes = '';


// Edit only this line:
//		NO SPACES!!!!!
	var EmersonJS_includes = 'FormChek,vars,bubbletooltips,onload';
	// Disabled: wz_tooltip,anchorposition,popupwindow,

// Build JS pull list
	if (EmersonJS_includes != "") {
		var EmersonJS_src = 'builder,effects,controls,dragdrop,slider' + ',' + EmersonJS_includes;
	} else {
		var EmersonJS_src = 'builder,effects,controls,dragdrop,slider';
	}
	// Disabled: 
	
/* Current Page Reference
	http://javascript.about.com/od/guidesscriptindex/a/url.htm
	copyright Stephen Chapman, 1st Jan 2005
	you may copy this function but please keep the copyright notice with it
*/
function getURL(uri) {
	uri.dir = location.href.substring(0,location.href.lastIndexOf('\/'));
	uri.dom = uri.dir;
		if (uri.dom.substr(0,7) == 'http:\/\/') {
			uri.dom = uri.dom.substr(7);
		} else if (uri.dom.substr(0,8) == 'https:\/\/') {
			uri.dom = uri.dom.substr(8);
		}
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1,location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURL(uri);

var aWindow = null; 
	function openWin(URL, w, h){
	aWindow = open(URL,'aWindow','width='+w+',height='+h+',scrollbars=yes'); 
		if(aWindow.opener == null) aWindow.opener = window; 
	aWindow.opener.name="opener";
	aWindow.focus();
	}

/*
	Find fgcolor for color picker
*/

function ColorPicker_updateFgColor(targetID) {
	
	var targetIDcolor = $(targetID).style.color;
	var hiddenID = 'fgcolor';
	
	var targetIDcolorArray = targetIDcolor.replace(/rgb\(/,"").replace(/\)/,"").split(", ");
	
	$(hiddenID).value = YAHOO.util.Color.rgb2hex(targetIDcolorArray[0],targetIDcolorArray[1],targetIDcolorArray[2]);
	
}

function typesSaveForm(fgid,targetID) {
	
	// Update fgcolor field
		ColorPicker_updateFgColor(fgid);
		
	// Submit form
		$(targetID).submit();
		
}

function tooltipOnload() {
	var calendarsDivs = $A($('emerson_body').getElementsByTagName('table'));
	var fullCalendars = calendarsDivs.findAll (
		function(link) {
			//alert(link.id+" | "+link.className);
			return link.className == 'tour_calendar';
		});
	fullCalendars.each(
		function(member) {
			enableTooltips(member.id);
	});
}

function tooltipColor(newcolor) {
	var tooltipDivs = $A($('emerson_body').getElementsByTagName('table'));
	var fullCalendars = calendarsDivs.findAll (
		function(link) {
			//alert(link.id+" | "+link.className);
			return link.className == 'tooltip';
		});
	fullCalendars.each(
		function(member) {
			$(member.id).style.color = '#'+newcolor;
	});
}



