/********************************************************************

SDC_SCRIPT.JS

Copyright 2008, Province of British Columbia, all rights reserved.
This material is owned by the Ministry of Forests and Range and
the Government of British Columbia and is protected by copyright
law. It may not be reproduced or redistributed without the prior
written permission of the Province of British Columbia.


Description:

Return a unique profile ID based on directory and environment

This runs a simple regular expression to check for the existence of
the specified directory DIRECTLY after the domain name. After finding
the specified directory in the URL, it returns the associated gDcsId
( based on the current environment )


Notes:

 - gDcsId picked up by "sdc_scripts.js" in Shared scripts.

 - sPath is the full url, e.g.  http://www.for.gov.bc.ca/his/test/

 - As many environments can be set up as required.  Note the env-key
  must be equal to the profile key for the script to return properly

 - Nested profiles may incur incorrect results. If required, ensure
that the deeply nested profile come first in the profile delcarations
If "/" is required, would need to go last, lest it always be returned.

e.g.
http://www.for.gov.bc.ca/his/profile1/subprofile // goes first
http://www.for.gov.bc.ca/his/profile1/

********************************************************************/

var gDcsId = (function(sPath){

var enviros = {
	 dev: null
	,test:"testwww.for.gov.bc.ca"
	,prod:"www.for.gov.bc.ca"
}
var profile = {
	 "/hfd/flc/" : {test:"dcs00sa6i10000w0q9wpn636v_4s3x", prod:"dcskrmgv110000k7z3fnwc36v_9p8h" }
	,"/code/"    : {test:"dcs4fulp900000wkxg20vb9ut_9z5u", prod:"dcscpz6k700000cdmzkoje9ut_9r2c" }
}

var myEnv = sPath.split('/')[2];                       // e.g. www.for.gov.bc.ca
var myDir = sPath.substring( sPath.indexOf("/", 8) ); // e.g. /his/test/

for( var key in profile ) { if(myDir.search("^"+ key)>-1) {
for( var env in enviros ) { if(myEnv.search("^"+ enviros[env])>-1) {

	// found the magical id based on directory and environment
	return profile[key][env]

}}
}}
})(unescape(location.href));