window.BRP = window.BRP || {};

var SelectedSiteMapNodes = "";

BRP = {
	// Main function call (page init)
	Init : function() {
		document.body.className += " hasJS";
		
		if(typeof MCMSConsoleInit == "function") {
			AdvancedHTMLToolsLoad = false;
			MCMSConsoleInit();
			}
		if(typeof initAdvancedHTMLTools == "function") 
		{
			if (AdvancedHTMLToolsLoad)	initAdvancedHTMLTools();		
		}
		}
		
};

YAHOO.util.Event.addListener(window, "load", BRP.Init, BRP, true);

// ------[ Expand ]------------------------------------------------- //	
BRP.Expand = function(el) {
	if (el) {
		this.Root = el;
		YAHOO.util.Event.addListener(window, "load", this.Init, this, true);
	}
};

BRP.Expand.prototype = {
	
	Root : null,

	Init : function() {
		div = document.getElementById(this.Root);
		if(div) {
			dl = div.getElementsByTagName("dl");	

			for (var j=0; j<dl.length; j++) {
				var dt = dl[j].getElementsByTagName('dt');
				dt[0].dl = dl[j];
				dl[j].className += ' closed';
				dt[0].onclick = function() { 
					state = (this.dl.className.indexOf("opened") != -1 ) ? false : true;
					if(state) {
						this.dl.className = this.dl.className.replace('closed','opened');
					} else {
						this.dl.className = this.dl.className.replace('opened','closed');
					}
				};
			}
		}	
	}
};


BRP.Cookie = {

	Load: function (id) {
		var search = id + "=";  
		var cookie = null;
		if (document.cookie.length > 0) { 					// if there are any cookies      
			offset = document.cookie.indexOf(search);       
			if (offset != -1) { 							// if cookie exists          
				offset += search.length; 					// set index of beginning of value         
				end = document.cookie.indexOf(";", offset);	// set index of end of cookie value         
				if (end == -1) end = document.cookie.length;
				cookie = unescape(document.cookie.substring(offset, end));   
				}    
			}	
		return cookie;	
	},

	Save: function (id, data, session) {
		if(session) {
			var now = new Date();
			var expires = now.getTime() + 365 * 24 * 60 * 60 * 1000;
			var expires = new Date(expires);
			session = "; expires=" + expires.toGMTString();
		} else session = "";

		document.cookie = id + "=" + escape(data) + session + "; path=/";
	}			


};


// ------[ QueryUrl ]---------------------------------- //
BRP.QueryUrl = {
	
	Search : function(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
				this.keyValuePairs[i] = this.q.split("&")[i];
				}
			}
		
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1];
				}
			return;
			}
		
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
				}
			return a;
			}
		
		this.getLength = function() { return this.keyValuePairs.length; }		
		},
	
	Get : function(key) {
		var page = new this.Search(window.location.search);
		return unescape(page.getValue(key));		
		}
};



// ------[ Send to Friend pop up ]------------------------------------------------- //

/**
 * Base namespace setup
 */
var SKIDOO = {
    globals: {
		labels: {}
	},
    pages: {
        all: {}
    },
    widgets: {}
}

// ------[ Generic Popup Window ]------------------------------------------------- //
function popWin(url,w,h,scroll,tools,name,center) {
	var str = "height=" + h + ",innerHeight=" + h;
	str += ",width=" + w + ",innerWidth=" + w;
	if(!center) center = true;
	if(!scroll) scroll = 0;
	if(!tools) tools = 0;
	if(!name) name = "pop";

	if((window.screen) && (center)) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - w) / 2;
		var yc = (ah - h) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
	window.name = "main";
	pop = window.open(url,name,'toolbar=' + tools + ',location=0,directories=0,status=0,menubar=0,scrollbars=' + scroll + ',resizable=0,' + str).focus();
	}

// ------[ Pull-down menu Faq Template ]------------------------------------------------- //

function setFaqCategory (newAddress) {

	if(newAddress!="") {

		window.top.location.href=newAddress;

		}

	}

