function MpDebug(cMessage)
{
	if (typeof console == 'undefined')
	{
		return;
	}

/*	if (!console.log)
	{
		return;
	}*/

	console.log(cMessage);
}

function StringToXmlDocument(/* string */ cXmlString)
{
	//console.log(cXmlString);
	if (window.ActiveXObject)
	{
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(cXmlString);
	}
	else
	{
		var parser=new DOMParser();
		var doc=parser.parseFromString(cXmlString,"text/xml");
	}

	return doc.documentElement;
}

function MpCreateDiv(divid, parent)
{
	// MDR 31/08/2007 - Returns ID of div for easy use with ext UI element creation
	var d = document.createElement('DIV');
	d.id = divid;
	if (parent) parent.appendChild(d);
	else document.body.appendChild(d);
	
	return divid;
}

function SetChildStyles(elItem, style, value)
{
	// MDR 07/09/2007 - Recursively set 'style' for all child nodes
	//if (!elItem) return
	if (elItem.style)
		eval("elItem.style." + style + " = '" + value + "';");
		//eval(elItem.setStyle(style, value);

	for (var x = 0; x < elItem.childNodes.length; x++)
	{
		var elCurrChild = elItem.childNodes[x];
		SetChildStyles(elItem.childNodes[x], style, value);
		elCurrChild = elItem.childNodes[x];
	}
}	
function getParameter ( queryString, parameterName )
{
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
	// Find the beginning of the string
	begin = queryString.indexOf ( parameterName );
	// If the parameter name is not found, skip it, otherwise return the value
	if ( begin != -1 ) {
	// Add the length (integer) to the beginning
	begin += parameterName.length;
	// Multiple parameters are separated by the "&" sign
	end = queryString.indexOf ( "&" , begin );
	if ( end == -1 ) {
	end = queryString.length
	}
	// Return the string
	return unescape ( queryString.substring ( begin, end ) );
	}
	// Return "null" if no parameter has been found
	return null;
	}
}
function MpUrlDecode(strTargetHref)
{
	var iLocationGetParams = strTargetHref.indexOf("?");
	var iLocationHashParams = strTargetHref.indexOf("#");

	var strBaseHref = null;
	var aGetParams = null;
	var aHashParams = null;
	
	// MDR 30/07/2008 - Fixed this method a bit to deal with missing params better
	if(iLocationGetParams != -1 && iLocationHashParams != -1)
	{
		strBaseHref = strTargetHref.substring(0, iLocationGetParams - 1);
		aGetParams = Ext.urlDecode(strTargetHref.substring(iLocationGetParams + 1, iLocationHashParams - 1));
		aHashParams = Ext.urlDecode(strTargetHref.substring(iLocationHashParams + 1));
	} else if (iLocationGetParams == -1 && iLocationHashParams != -1)
	{
		strBaseHref = strTargetHref.substring(0, iLocationHashParams - 1);
		aGetParams = {}
		aHashParams = Ext.urlDecode(strTargetHref.substring(iLocationHashParams + 1));
	} else if (iLocationGetParams != -1 && iLocationHashParams == -1)
	{
		strBaseHref = strTargetHref.substring(0, iLocationGetParams);
		aGetParams = Ext.urlDecode(strTargetHref.substring(iLocationGetParams + 1));
		aHashParams = {};
	} else if (iLocationGetParams == -1 && iLocationHashParams == -1)
	{
		strBaseHref = strTargetHref;
		aGetParams = {};
		aHashParams = {};
	}

	var oReturn = {};
	oReturn.strBaseHref = strBaseHref;
	oReturn.Params = aGetParams
	oReturn.HashParams = aHashParams;
	return oReturn;

/*	if(iLocationHashParams != -1)
	{
		var hashParams = Ext.urlDecode(strTargetHref.substring(iLocationHashParams + 1));
		var strBaseHrefFinal = strBaseHref || strTargetHref.substring(0, iLocationHashParams + 1);
		var paramsFinal = Ext.urlDecode(strTargetHref.substring(iLocationGetParams+1, iLocationHashParams-1));
	}
	if(iLocationGetParams == -1 && iLocationHashParams == -1)
	{
		var strBaseHref = strTargetHref;
	}

	var oReturn = {};
	oReturn.strBaseHref = strBaseHrefFinal || strBaseHref;
	oReturn.Params = paramsFinal || params;
	oReturn.HashParams = hashParams;
	return oReturn;*/
}