<!--Begin

// MAILING FUNCTION // 
function mailme(bottom,top) {document.location="mailto:"+top+"@"+bottom+"";}
// *** // 





// MEMBER SIGNUP CHECK // 
function signupVerify(form) {
	if ( form.nickname.value.length < 6 || form.nickname.value.length > 15  ) { alert('Please choose a valid username!'); return false; }
	else if ( form.pass.value == "" ) { alert('Please enter a password!'); return false; }
	else if ( form.pass.value != form.passVerif.value ) { alert('Make sure your passwords match!'); return false; }
	else if ( form.email.value == "" ) { alert('Please enter your email address!'); return false; }
	
	return true;
}
// *** // 





// MEMBER LOGIN CHECK // 
function loginVerify(form) {
	if ( form.nickname.value.length < 6 || form.nickname.value.length > 15  ) { alert('Please enter your username!'); return false; }
	else if ( form.pass.value == "" ) { alert('Please enter your password!'); return false; }
	return true;
}
// *** // 





// PW CHANGE CHECK // 
function changePWVerify(form) {
	if ( form.password.value == ""  ) { alert('Please enter your old password!'); return false; }
	else if ( form.passwordNew.value != form.passwordNewVerf.value ) { alert('Your new passwords must match!'); return false; }
	else if ( form.passwordNew.value == "" ) { alert('Please enter your new password!'); return false; }
	return true;
}
// *** // 





// POPUPS // 
function start( page ) {
	var OpenWin;
	if (screen.width > 700 && screen.height > 500) {OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=700,height=500");}
	else {OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=600,height=440");}
}
// *** // 





// SHOW/HIDE DIV BLOCKS // 
function ouvreFerme(title){ // open-close leftbar menu items 
	if (document.getElementById) {
		if (document.getElementById(""+title+"Open").style.display != "none") {
			document.getElementById(""+title+"Open").style.display = "none";
		} else {
			document.getElementById(""+title+"Open").style.display = "block";
		}
	}
	else if (document.all) {
		if (document.all(""+title+"Open").style.display != "none") {
			document.all(""+title+"Open").style.display = "none";
		} else {
			document.all(""+title+"Open").style.display = "block";
		}
	}
}
// *** //





// AJAX // 
/*
*	the core of all AJAX calls
*	loadXMLDoc(url, frame, method?, postContents?) : no return 
*	
*	url : the URL of our ML/data file 
*	frame : the element ID to load the ML/data into
*	method : for the request, GET or POST? (default: GET)
*	postContents : if POST, the contents to POST to the server 
*/
function loadXMLDoc(url, frame, method, postContents) {
	if ( !document.getElementById || !document.getElementById(frame) ) {
		alert("loadXMLDoc:: Invalid frame target! (" + frame+ ")");
		return;
	}
	
	if (url == "" || typeof url == 'undefined') {
		alert("loadXMLDoc:: Invalid URL supplied!");
		return;
	}
	
	if ( !window.XMLHttpRequest && !window.ActiveXObject ) {
		alert("loadXMLDoc:: No AJAX functionality found!");
		return;
	}
	
	if (!method) {method = "GET";}
	if (!postContents) {
		if (window.XMLHttpRequest) {postContents = null;}
		else if (window.ActiveXObject) {postContents = '';}
	}
	
	if (window.XMLHttpRequest) {
		var xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if (xmlhttp) {
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				if (xmlhttp.status==200){document.getElementById(frame).innerHTML=xmlhttp.responseText;}
				else {alert("Problem retrieving data: " + xmlhttp.statusText);}
			}
		}
		xmlhttp.open(method,url,true);
		xmlhttp.send(postContents);
	}
}
// *** // 





// AJAX POPUPS //
/*
*	a simple show/hide with AJAX functionality
*	ajaxStart( frame, url?, forceState?, method?, postContents? ) : no return 
*	
*	frame : the element ID to show and load ML/data into, or to hide
*	url : the URL of our ML/data file (if not given, assumes you want to hide the element) 
*	forceState : force into the hidden state (defaults to show)
*	method : for AJAX, GET or POST? (default: GET)
*	postContents : if POST, the contents to POST to the server 
*/
function ajaxStart( frame, url, forceState, method, postContents ) {
	if ( !document.getElementById || !document.getElementById(frame) ) {
		alert("ajaxStart:: Invalid frame target! (" + frame+ ")");
		return;
	}
	
	if ( forceState == "true" || !url ) {
		document.getElementById(frame).style.display = "none";
		document.getElementById(frame).innerHTML = "";
	} else {
		document.getElementById(frame).style.display = "block";
		loadXMLDoc( url, frame, method, postContents );
	}
}
// *** // 





// AJAX POPUP CREATOR / DESTRUCTOR //
/* 
*	dynamically inserts children into the DOM
*	childCreate( parentFrame, childEleType?, childTypeID? ) : childID
*	
*	parentFrame : the ID of the parent element, who will have a child attached
*	childEleType : the type of child to be attached (eg div, img) (default: div)
*	childTypeID : a (hopefully) meaningful ID for the child (default: Child)
*	
*	childID : the fully-qualified ID of your new child, which must be saved 
*		in order to destroy the child
*/
function childCreate( parentFrame, childEleType, childTypeID ) {
	if ( !document.getElementById || !document.getElementById(parentFrame) ) {
		alert("childCreate:: Invalid parent frame target! (" + parentFrame+ ")");
		return "";
	}
	
	if (childEleType == "" || typeof childEleType == 'undefined') {childEleType = "div";}
	if (childTypeID == "" || typeof childTypeID == 'undefined') {childTypeID = "Child";}	
	
	var childID = "" + parentFrame + childTypeID;
	if (document.getElementById( childID )) {
		alert("Double child creation");
		return "";
	}
	var newEle = document.createElement(childEleType);
	newEle.setAttribute("id", childID);
	document.getElementById(parentFrame).appendChild( newEle );
	return childID;
}

/* 
*	destroys a child
*	childKill( childFrame ) : no return
*	
*	childFrame : the ID of the child element to be destroyed 
*/
function childKill( childFrame ) {
	if ( !document.getElementById || !document.getElementById(childFrame) ) {
		alert("childKill:: Invalid child frame target! (" + childFrame+ ")");
		return;
	}
	
	var childNode = document.getElementById(childFrame);
	var parNode = childNode.parentNode;
	parNode.removeChild(childNode);
}
// *** //





// EXPAND/SHRINK DIV //
/*
*	linearly expands/shrinks an element up to the specified width/height
*	growDiv( eleID, upToWidth, upToHeight, speed?, callback? ) : no return
*	shrinkDiv( eleID, upToWidth, upToHeight, speed?, callback? ) : no return
*	
*	eleID : the ID of the element to expand or shrink
*	upToWidth, upToHeight : the (final) fully-expanded width and height of said element
*	speed : expands an element 20% of the final dimensions per speed ms
*		or shrinks an element 25% of the final dimensions per speed ms (default: 100) 
*	callback : if defined, invoked after growth/shrinking is finished 
*/ 
function growDiv( eleID, upToWidth, upToHeight, speed, callback ) {
	if ( !document.getElementById || !document.getElementById(eleID) ) {
		alert("growDiv:: Invalid frame target! (" + eleID+ ")");
		return;
	}
	
	if (upToWidth == "" || typeof upToWidth == 'undefined' || upToHeight == "" || typeof upToHeight == 'undefined') {
		alert("growDiv:: Invalid dimensions specification!");
		return;
	}
	
	if (speed == "" || typeof speed == 'undefined') {speed = 100;}
	var element = document.getElementById( eleID );
	
	if (element.style.width == "") {element.style.width = '1px';}
	if (element.style.height == "") {element.style.height = '1px';}
	
	var curWidth = parseInt(element.style.width);
	var curHeight = parseInt(element.style.height);
	
	if ( curWidth < upToWidth && curHeight < upToHeight) {
		var propWidth = curWidth + 0.2*upToWidth;
		var propHeight = curHeight + 0.2*upToHeight;
		
		element.style.width = ( propWidth > upToWidth ? upToWidth : propWidth ) + 'px';
		element.style.height = ( propHeight > upToHeight ? upToHeight : propHeight ) + 'px';
		
		setTimeout("growDiv( '" + eleID + "'," + upToWidth + "," + upToHeight + "," + speed + ", \"" + callback + "\")", speed);
	} else if (callback != "" && typeof callback != 'undefined') {
		setTimeout(callback, 100);
	}
}

function shrinkDiv( eleID, upToWidth, upToHeight, speed, callback ) {
	if ( !document.getElementById || !document.getElementById(eleID) ) {
		alert("shrinkDiv:: Invalid frame target!");
		return;
	}
	
	if (speed == "" || typeof speed == 'undefined') {speed = 50;}
	var element = document.getElementById( eleID );
	
	if (element.style.width == "" || element.style.height == "") {
		element.style.width = '0px';
		element.style.height = '0px';
		return;
	}
	
	var curWidth = parseInt(element.style.width);
	var curHeight = parseInt(element.style.height);
	
	if ( curWidth > 0 && curHeight > 0) {
		var propWidth = curWidth - 0.25*upToWidth;
		var propHeight = curHeight - 0.25*upToHeight;
		
		element.style.width = ( propWidth > 0 ? propWidth : 0 ) + 'px';
		element.style.height = ( propHeight > 0 ? propHeight : 0 ) + 'px';
		
		setTimeout("shrinkDiv( '" + eleID + "'," + upToWidth + "," + upToHeight + "," + speed + ", \"" + callback + "\")", speed);
	} else if (callback != "" && typeof callback != 'undefined') {
		setTimeout(callback, 100);
	}
}
//





// GOOGLE MAP GENERATOR //
/*
*	calling interface for the map 
*	doMap( parentFrame, latitude, longitude, width?, height?, zoomLevel? ) : no return 
*	
*	parentFrame : which element to attach the map to (DOM insertion)
*	latitude, longitude : where to center/mark the map
*	width, height : the desired width/height of the map (default: 500x300)
*	zoomLevel : map zoom level (default: 16, we typically want b/t 13-16)
*/
function doMap( parentFrame, latitude, longitude, width, height, zoomLevel ) {
	if (width == "" || typeof width == 'undefined') {width = 500;}
	if (height == "" || typeof height == 'undefined') {height = 300;}
	
	if ( !document.getElementById || !document.getElementById(parentFrame) ) {
		alert("doMap:: Invalid frame target!");
		return;
	}
	
	if (!document.getElementById( "" + parentFrame + "Map" )) { // no double creation 
		var wrapperID = childCreate( parentFrame, "div", "Map" );
		document.getElementById(wrapperID).style.backgroundColor = '#EEEECC';
		setTimeout("growDiv( '" + wrapperID + "' , "+width+", "+(height+15)+", 100, \"buildMap( '" + wrapperID + "', '" + latitude + "', "+longitude+", "+width+", "+height+", "+zoomLevel+" )\")", 100);
	}
}

/*
*	back-end for the map 
*	buildMap( wrapperID, latitude, longitude?, width?, height?, zoomLevel? ) : no return 
*	
*	wrapperID : the element to draw upon (which should've been inserted) 
*	latitude, longitude : where to center/mark the map
*		if longitude not given, latitude is assumed to be an address 
*	width, height : the desired width/height of the map (default: 500x300)
*	zoomLevel : map zoom level (default: 16, we typically want b/t 13-16)
*/
function buildMap( wrapperID, latitude, longitude, width, height, zoomLevel ) {
	if ( !document.getElementById || !document.getElementById(wrapperID) ) {
		alert("buildMap:: Invalid frame target!");
		return;
	}
	
	if (typeof window.GBrowserIsCompatible != 'function' || !GBrowserIsCompatible()) {
		alert("Map module not loaded!");
		return;
	}

	if (latitude == "" || typeof latitude == 'undefined') {
		alert("buildMap:: At least an address must be given!");
		return;
	}
	
	if (width == "" || typeof width == 'undefined') {width = 500;}
	if (height == "" || typeof height == 'undefined') {height = 300;}
	if (zoomLevel == "" || typeof zoomLevel == 'undefined') {zoomLevel = 16;}
	
	// generate the actual map itself 
	var point, map;
	var childNode = document.createElement('div');
	document.getElementById(wrapperID).appendChild(childNode);
	childNode.style.width = width + 'px';
	childNode.style.height = height + 'px';
	map = new GMap2(childNode);
	map.addControl(new GSmallZoomControl());
	
	geoDecodeCallback = function( coords ) {
		if (!coords) {
			alert("Location could not be found!");
			return;
		}
		map.setCenter(coords, zoomLevel);
		map.addOverlay(new GMarker(coords));
	}
	
	if ( longitude ) {
		point = new GLatLng(latitude, longitude);
		map.setCenter(point, zoomLevel);
		map.addOverlay(new GMarker(point));
	}
	else {
		var coordFab = new GClientGeocoder();
		coordFab.getLatLng(latitude, geoDecodeCallback);
	}
	
	// make the close link for it 
	var closeLink = document.createElement('a');
	var closeTxt = document.createTextNode('Hide map');
	closeLink.appendChild(closeTxt);
	closeLink.setAttribute('href','javascript: void(1);');
	closeLink.onclick=function(){killMap(wrapperID);return false;};
	document.getElementById(wrapperID).appendChild( closeLink );
}

/*
*	calling interface for destroying the map and containers 
*	killMap( childFrame ) : no return 
*	
*	childFrame : the outer container's ID that will be destroyed 
*/
function killMap( childFrame ) {
	if ( !document.getElementById || !document.getElementById(childFrame) ) {
		alert("Invalid frame target!");
		return;
	}
	
	document.getElementById(childFrame).innerHTML = "";
	
	setTimeout("shrinkDiv( '" + childFrame + "' , 500, 300, 50, \"childKill( '" + childFrame + "' )\")", 50);
}
// *** //



// END --> 
