/**************************************************************************
This script will return the first "stn" parameter value from the URL.
usage : getURLstn(window.location.href)
stn MUST be letters, numbers or underscore or dash WITHOUT space.
June 5, 2007 - by Philippe Boivin
December 4, 2007 - modify by René Gravel (id to stn)
***************************************************************************/
function getURLstn(url) {
  
	var defaultSTN = "none"; // The default "stn" if none exist		  	
	var reString =  /stn=[\w-]+/;  	// The regular expression : stn=ABC_abc-123
	var re = new RegExp(reString); 	// Creating the RegExp object
	var result = re.exec(url); 	// store the search result in "result"

	// Checking if the "stn" is present or valid
	if (result == null) {
    return (defaultSTN); // return the defaultSTN value
  } else {
  	var stnString = String(result);
    var theSTN = stnString.substring(4,stnString.length); // remove "stn="
  	return (theSTN);
  }
}
