
//window.focus();
if(window.opener == null && window.dialogArguments != null) window.opener = window.dialogArguments;

var CWS_sOnLoad = '';
var CWS_sOnUnload = '';
var CWS_sOnResize = '';
var CWS_bUnload = true;

var CWS_nMaxX = 0;
var CWS_nMaxY = 0;

var nWinPosX = -1;
var nWinPosY = -1;
var bCentered = true;

var sLinkToTarget = '';

var oCWS_Popup = null;

CWS_sOnResize += 'CWS_AutoResize();';

function CWS_onLoad() {	eval(CWS_sOnLoad); CWS_onResize(); }
function CWS_onResize() { eval(CWS_sOnResize); }

//window.onmoveend = CWS_MoveEnd;
window.onbeforeunload = CWS_onUnLoad;

// Track cursor position
var CWS_curPosX, CWS_curPosY;
if(window.Event) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = CWS_MouseMove;
function CWS_MouseMove(evt)
{
	if(window.Event)
	{
		if(evt && evt.pageX)
		{
			CWS_curPosX = evt.pageX;
			CWS_curPosY = evt.pageY;
		}
	}
	else if(document.body)
	{
		CWS_curPosX = event.clientX + document.body.scrollLeft;
		CWS_curPosY = event.clientY + document.body.scrollTop;
	}
	
	//window.status = CWS_curPosX + ',' + CWS_curPosY;
}
// End - Track cursor position

//function CWS_MoveEnd()
//{
//	nWinPosX = window.screenLeft;
//	nWinPosY = window.screenTop;
//}

//function CWS_Link(sUrl, bUnload)
//{
//	CWS_bUnload = bUnload;
//	document.location = sUrl;
//	
//	return bUnload;
//}

function CWS_onUnLoad()
{
	if(CWS_bUnload)
	{
		if(document.getElementById('CWS_All')) document.getElementById('CWS_All').style.display = 'none';
		if(document.getElementById('CWS_Wait')) document.getElementById('CWS_Wait').style.display = 'inline';
		
		eval(CWS_sOnUnload);
	}
	
	//CWS_bUnload = true;
}

function CWS_Reload()
{
//	if(document.ReloadForm)
//	{
//		document.ReloadForm.submit();
//	}
//	else
	if(document.ReloadForm2)
	{
		document.ReloadForm2.submit();
	}
	else
	{
		try
		{
			window.location = (''+window.location).replace('action=','xxx=');
		}
		catch(e){}
	}
}

function CWS_OnMouseLeave(obj, evt)
{
	oParent = window.event?evt.toElement:evt.relatedTarget;
	while(oParent != null)
	{
		if(oParent == obj) return false;
		oParent = oParent.parentNode;
	}
	
	return true;
}

function CWS_AutoResize()
{
	bCenter = false;
	if(nWinPosX == -1) bCenter = true;
	
	nWinPosX = window.screenLeft;
	nWinPosY = window.screenTop;
					
	try
	{
		if(document.images && document.images["CWS_dummyWidth"])
		{
			x = document.images["CWS_dummyWidth"].width + 30;
			y = document.images["CWS_dummyHeight"].height + 32 + 24;
			if(!window.opener) y += 96;
			if(x < 100) x = 100;
			if(y < 200) y = 200;
			if(x > screen.width - 10) x = screen.width - 10;
			if(y > screen.height - 10) y = screen.height - 10;
									
			if(window.frameElement)
			{
				try{window.frameElement.width=x;}catch(e){}
			}
			else
			{
				if(window.dialogArguments != null)
				{
				//	window.dialogWidth = (x-20) + 'px'; 
				//	window.dialogHeight = (y-24) + 'px';
					window.dialogWidth = (x-20) + 'px'; 
					window.dialogHeight = (y-0) + 'px';
				}
				else window.resizeTo(x, y);
				
				
			}
			
			if(document.getElementById('CWS_FirstWait')) document.getElementById('CWS_FirstWait').style.display = 'none';
			
			if(window.dialogArguments != null)
			{
				if(bCenter)
				{
					if(!window.frameElement)
					{
						window.dialogTop = ((screen.height - y) / 2 - 16) + 'px';
						window.dialogLeft = ((screen.width - x) / 2) + 'px';
					}
				}
				else
				{
				//	window.dialogLeft = (nWinPosX-4) + 'px';
				//	window.dialogTop = (nWinPosY-23) + 'px';
				//	if(window.screenTop + y > screen.height - 16) window.dialogTop = (screen.height - 16 - y) + 'px';
				}
			}
		}
	}
	catch(e)
	{
		//alert('cannot resize !');
	}
}

function xCWS_AutoResize()
{
	nWinPosX = window.screenLeft;
	nWinPosY = window.screenTop;
	
	if( (window.dialogArguments != null) && (window.dialogWidth == '20px') ) bCentered = false;
	
	try
	{
		if(document.images && document.images["CWS_dummyWidth"])
		{
			x = document.images["CWS_dummyWidth"].width + 30;
			y = document.images["CWS_dummyHeight"].height + 32 + 24;
			if(!window.opener) y += 96;
			if(x < 100) x = 100;
			if(y < 100) y = 100;
			if(x > screen.width - 100) x = screen.width - 100;
			if(y > screen.height - 100) y = screen.height - 100;
			if(x > CWS_nMaxX || y > CWS_nMaxY)
			{
				if(x > CWS_nMaxX) CWS_nMaxX = x;
				if(y > CWS_nMaxY) CWS_nMaxY = y;
					
				x = CWS_nMaxX;
				y = CWS_nMaxY;
			}
			if(!bCentered)
			{
				if(window.opener != null && window.dialogArguments == null) window.moveTo( (screen.width - CWS_nMaxX) / 2, (screen.height - CWS_nMaxY) / 2 - 16 );
				if(window.dialogArguments != null) window.dialogTop = ((screen.height - CWS_nMaxY) / 2 - 16) + 'px';
				if(window.dialogArguments != null) window.dialogLeft = ((screen.width - CWS_nMaxX) / 2) + 'px';
				
				nWinPosX = -1;
				nWinPosY = -1;
				
				if( (window.dialogArguments != null) && (window.dialogWidth != '20px') ) bCentered = true;
				if(window.frameElement)
				{
					try{window.frameElement.width=CWS_nMaxX;}catch(e){}
					window.frameElement.CWS_AutoResize();
					window.frameElement.parent.CWS_AutoResize();
				}
			}
			
			if(window.dialogArguments != null)
			{
				window.dialogWidth = (x-20) + 'px'; 
				window.dialogHeight = (y-24) + 'px';
							
				if(nWinPosX != -1) window.dialogLeft = (nWinPosX-4) + 'px';
				if(nWinPosY != -1) window.dialogTop = (nWinPosY-23) + 'px';
				if(window.screenTop + y > screen.height - 16) window.dialogTop = ((screen.height - CWS_nMaxY) / 2 - 16) + 'px';
			}
			else window.resizeTo(x, y);
		}
	}
	catch(e)
	{
		//alert('cannot resize !');
	}
}

function CWS_OpenDialog(ur)
{
	if(navigator.userAgent.indexOf('MSIE') != -1) return window.showModalDialog(ur,window,'center:yes;resizable:yes;status:no;help:no;dialogWidth:174px;dialogHeight:240px;');
	else return window.open(ur,'','width=100,height=200,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes,systembar=no');
}
function CWS_OpenWindow(ur)
{
	return CWS_OpenWindow(ur, 20, 20);
}
function CWS_OpenWindow(ur, nX, nY)
{
	return window.open(ur,'','width=' + nX + ',height=' + nY + ',scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=yes,systembar=no');
}
function CWS_OpenViewWindow(ur)
{
	return CWS_OpenWindow(ur, 800, 600);
}
function CWS_OpenFixedWindow(ur)
{
	return CWS_OpenFixedWindow(ur, 100, 100);
}
function CWS_OpenFixedWindow(ur, nX, nY)
{
	return window.open(ur,'','width=' + nX + ',height=' + nY + ',scrollbars=no,toolbar=no,menubar=no,location=no,resizable=no,systembar=no');
}
function CWS_DateNow(fname)
{
	dt = new Date();

	dd = eval('document.all.' + fname + '_DD');
	mm = eval('document.all.' + fname + '_MM');
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	hh = eval('document.all.' + fname + '_HH');
	nn = eval('document.all.' + fname + '_NN');
	ss = eval('document.all.' + fname + '_SS');
	
	if(yyyy) yyyy.value = dt.getYear();
	if(mm) mm.value = dt.getMonth() + 1;
	if(dd) dd.value = dt.getDate();
	
	if(hh) hh.value = dt.getHours();
	if(nn) nn.value = dt.getMinutes();
	if(ss) ss.value = dt.getSeconds();
}
function CWS_DateClear(fname)
{
	dd = eval('document.all.' + fname + '_DD');
	mm = eval('document.all.' + fname + '_MM');
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	hh = eval('document.all.' + fname + '_HH');
	nn = eval('document.all.' + fname + '_NN');
	ss = eval('document.all.' + fname + '_SS');
	
	if(yyyy) yyyy.value = '';
	if(mm) mm.value = '';
	if(dd) dd.value = '';
	
	if(hh) hh.value = '';
	if(nn) nn.value = '';
	if(ss) ss.value = '';
}
function CWS_CheckDay(fname)
{
	dd = eval('document.all.' + fname + '_DD');
	mm = eval('document.all.' + fname + '_MM');
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	if(parseInt(dd.value) < 1) dd.value = 1;
	if(parseInt(dd.value) > 31) dd.value = 31;
	if(parseInt(dd.value) > 30 && (parseInt(mm.value) == 4 || parseInt(mm.value) == 6 || parseInt(mm.value) == 9 || parseInt(mm.value) == 11)) dd.value = 30;
	if(parseInt(dd.value) > 28 && parseInt(mm.value) == 2)
	{
		if(parseInt(yyyy.value) % 4 != 0 || parseInt(yyyy.value) == 2000) dd.value = 28;
		else dd.value = 29;
	} 
}

function CWS_CheckMonth(fname)
{
	mm = eval('document.all.' + fname + '_MM');
	
	if(parseInt(mm.value) < 1) mm.value = 1;
	if(parseInt(mm.value) > 12) mm.value = 12;
	
	CWS_CheckDay(fname);
}

function CWS_CheckYear(fname)
{
	yyyy = eval('document.all.' + fname + '_YYYY');
	
	if(parseInt(yyyy.value) < 1900) yyyy.value = 1900 + parseInt(yyyy.value);
	if(parseInt(yyyy.value) < 1950) yyyy.value = 100 + parseInt(yyyy.value);
	if(parseInt(yyyy.value) > 2100) yyyy.value = 2100;
	
	CWS_CheckDay(fname);
}

function CWS_CheckHour(fname)
{
	hh = eval('document.all.' + fname + '_HH');
	
	if(parseInt(hh.value) < 0) hh.value = 0;
	if(parseInt(hh.value) > 23) hh.value = 23;
}

function CWS_CheckMinute(fname)
{
	nn = eval('document.all.' + fname + '_NN');
	
	if(parseInt(nn.value) < 0) nn.value = 0;
	if(parseInt(nn.value) > 59) nn.value = 59;
}

function CWS_CheckSeconde(fname)
{
	ss = eval('document.all.' + fname + '_SS');
	
	if(parseInt(ss.value) < 0) ss.value = 0;
	if(parseInt(ss.value) > 59) ss.value = 59;
}

function CWS_GetParent(oNode, sNodeName, nLevel)
{
	while(oNode)
	{
		if(oNode.nodeName == sNodeName)
		{
			nLevel --;
			
			if(nLevel <= 0) return oNode;			
		}

		oNode = oNode.parentNode;
	}
}

function CWS_GetChild(oNode, sNodeName, nLevel)
{
	var		i;
	
	if(oNode)
	{
		for(i=0;i<oNode.childNodes.length;i++)
		{
			if(oNode.childNodes[i].nodeName == sNodeName)
			{
				nLevel --;
				if(nLevel <= 0) return oNode.childNodes[i];
				else return CWS_GetChild(oNode.childNodes[i], sNodeName, nLevel-1)
			}
		}
	}
	
	return null;
}

function CWS_GetNextNode(oNode)
{
	var sNodeName = oNode.nodeName;
	
	while(oNode)
	{
		oNode = oNode.nextSibling;
		if(oNode != null && oNode.nodeName == sNodeName) return oNode;
	}
	
	return null;
}

function CWS_GetFirstChild(oNode)
{
	for(i=0;i<oNode.childNodes.length;i++)
	{
		if(oNode.childNodes[i].nodeName != '#text') return oNode.childNodes[i];
	}
}

function CWS_GetLastChild(oNode)
{
	for(i=oNode.childNodes.length - 1;i>=0;i--)
	{
		if(oNode.childNodes[i].nodeName != '#text') return oNode.childNodes[i];
	}
}

function removeFormattingFct(sTxt, bKeepCRLF)
{
	sText = "" + sTxt;
	
	if(!bKeepCRLF)
	{
		while(sText.indexOf('\r') != -1) sText = sText.replace('\r', '');
		while(sText.indexOf('\n') != -1) sText = sText.replace('\n', '');
		while(sText.indexOf('<BR') != -1) sText = sText.replace('<BR', '\r\n< BR');
		while(sText.indexOf('</P') != -1) sText = sText.replace('</P', '\r\n\r\n< /P');
	}
				
	s = sText.indexOf('<');
	while(s != -1)
	{
		e = sText.indexOf('>');
		if(e<s) e = s;
		sTemp = sText.substr(s, e-s + 1);
		sTag = '';
		sText = sText.replace(sTemp, sTag);
					
		s = sText.indexOf('<');
	}
	
	if(!bKeepCRLF)
	{			
		while(sText.indexOf('\r\n\r\n') != -1) sText = sText.replace('\r\n\r\n', '</P><P>');
		while(sText.indexOf('\r\n') != -1) sText = sText.replace('\r\n', '<BR>');
		sText = '<P>' + sText + '</P>'
		while(sText.indexOf('<P></P>') != -1) sText = sText.replace('<P></P>', '');
	}
	
	return sText;
}

function removeTagsFct(sTxt)
{
	sText = "" + sTxt;
	
	s = sText.indexOf('<');
	while(s != -1)
	{
		e = sText.indexOf('>');
		if(e < s) e = s;
		sTemp = sText.substr(s, e-s + 1);
		sText = sText.replace(sTemp, '');
					
		s = sText.indexOf('<');
	}
	
	while(sText.indexOf('\r') != -1) sText = sText.replace('\r', ' ');
	while(sText.indexOf('\n') != -1) sText = sText.replace('\n', ' ');
	while(sText.indexOf('  ') != -1) sText = sText.replace('  ', ' ');
	
	return sText;
}

function LinkTo(sUrl, sTarget)
{
	var sValue;
	var sFieldName = sLinkToTarget;
	
	if(sUrl.length > 0)
	{
		if(sTarget == 'popup') sValue = 'href="javascript:" onclick="CWS_OpenWindow(\'' + sUrl + '\');return false;"';
		if(sTarget == 'fpopup') sValue = 'href="javascript:" onclick="CWS_OpenFixedWindow(\'' + sUrl + '\');return false;"';
		if(sTarget == 'anchor') sValue = 'href="javascript:" onclick="CWS_GotoAnchor(\'' + sUrl + '\');return false;"';
		else sValue = 'href="' + sUrl + '" target="' + sTarget + '"';
	}
	else sValue = '';

	if(sFieldName.indexOf('sLINK2_') != 0) sValue = '<a ' + sValue + '>';
	document.getElementsByName(sFieldName)[0].value = sValue;
	
	sLinkToTarget = '';
}
function CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2)
{
	CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2, false);
}
function CWS_Toggle(sDivName, sImgName, sSrc1, sSrc2, bSetCookie)
{
	b = 0;
	
	if(document.getElementById(sDivName).style.display == 'none')
	{
		document.getElementById(sDivName).style.display = 'inline';
		if(sImgName != null) document.getElementById(sImgName).src = sSrc1;
		b = 1;
	}
	else
	{
		document.getElementById(sDivName).style.display = 'none';
		if(sImgName != null) document.getElementById(sImgName).src = sSrc2;
	}
	
	if(bSetCookie) document.cookie = sDivName + "=" + b + ";expires=Fri, 31 Dec 2010 23:59:59 GMT";
	
	CWS_AutoResize();
}

function CWS_ShowPopmenu(sDivName)
{
	oDiv = document.getElementById(sDivName);

	if(oDiv)
	{	
		nPosLeft = oEvent.clientX - 12;
		nPosTop = oEvent.clientY - 12 + document.body.scrollTop;
		
		oParent = oDiv.offsetParent;
		while(oParent)
		{
			nPosLeft -= oParent.offsetLeft;
			nPosTop -= oParent.offsetTop;
			oParent = oParent.offsetParent;
		}

		oDiv.style.display = 'inline';
		oDiv.style.left = nPosLeft;
		oDiv.style.top = nPosTop;
		oDiv.scrollIntoView;
		
		oDiv.style.zIndex = 1000;
	}
}

function CWS_ShowObj(sObjId)
{
	oObj = document.getElementById(sObjId);
	if(oObj != null)
	{
		oObj.style.display = 'inline';
		
		oDivs = oObj.getElementsByTagName('DIV');
		for(i=0;i<oDivs.length;i++)
		{
			if(oDivs.item(i).getAttribute('id') != null)
			{
				if(oDivs.item(i).getAttribute('id').substr(0, 8) == 'cmsAjax_') eval(oDivs.item(i).getAttribute('id') + '_Load()');
			}
		}
	}
}

function CWS_HideObj(sObjId)
{
	oObj = document.getElementById(sObjId);
	if(oObj != null)
	{
		oObj.style.display = 'none';
	}
}

function CWS_HTMLEncode(str)
{
	var div = document.createElement('div');
	var text = document.createTextNode(str);
	div.appendChild(text);
	return div.innerHTML;
}

function CWS_HTMLDecode(str)
{
	var div = document.createElement('div');
	div.innerHTML = str;
	if(div.firstChild) return div.firstChild.nodeValue;
	else return '';
}

function CWS_Alert(sAlert)
{
	while(sAlert.indexOf('&eacute;') != -1) sAlert = sAlert.replace('&eacute;', 'é');
	while(sAlert.indexOf('&egrave;') != -1) sAlert = sAlert.replace('&egrave;', 'è');
	while(sAlert.indexOf('&agrave;') != -1) sAlert = sAlert.replace('&agrave;', 'à');
	while(sAlert.indexOf('&ccedil;') != -1) sAlert = sAlert.replace('&ccedil;', 'ç');
	while(sAlert.indexOf('&acirc;') != -1)  sAlert = sAlert.replace('&acirc;',  'â');
	while(sAlert.indexOf('&ecirc;') != -1)  sAlert = sAlert.replace('&ecirc;',  'ê');
	while(sAlert.indexOf('&ucirc;') != -1)  sAlert = sAlert.replace('&ucirc;',  'û');
	while(sAlert.indexOf('&icirc;') != -1)  sAlert = sAlert.replace('&icirc;',  'î');
	while(sAlert.indexOf('&ocirc;') != -1)  sAlert = sAlert.replace('&ocirc;',  'ô');
	while(sAlert.indexOf('&ugrave;') != -1) sAlert = sAlert.replace('&ugrave;', 'ù');
	while(sAlert.indexOf('&auml;') != -1)   sAlert = sAlert.replace('&auml;',   'ä');
	while(sAlert.indexOf('&euml;') != -1)   sAlert = sAlert.replace('&euml;',   'ë');
	while(sAlert.indexOf('&iuml;') != -1)   sAlert = sAlert.replace('&iuml;',   'ï');
	while(sAlert.indexOf('&ouml;') != -1)   sAlert = sAlert.replace('&iuml;',   'ö');
	while(sAlert.indexOf('&uuml;') != -1)   sAlert = sAlert.replace('&iuml;',   'ü');
	
	alert(sAlert);
}

function CWS_GotoAnchor(sID)
{
	sURL = window.location.href;
	if(sURL.indexOf('#') != -1) sURL = sURL.substring(0,sURL.indexOf('#'));
		
	window.location = sURL + '#' + sID;
}

function CWS_SetCookie(sName, sValue)
{
	document.cookie = sName.toLowerCase() + "=" + sValue + ";path=/;expires=Fri, 31 Dec 2010 23:59:59 GMT";
//	alert(document.cookie);
}

function CWS_SetCookieVolatile(sName, sValue)
{
	document.cookie = sName.toLowerCase() + "=" + sValue + ";path=/";
//	alert(document.cookie);
}

function CWS_GetCookie(sName)
{
//	alert(document.cookie);
	sCookies = '' + document.cookie + ';';
	s = 0;
	while( -1 != (e = sCookies.indexOf(';', s)) )
	{
		sCookie = sCookies.substr(s, e-s);
		if(sCookie.indexOf('=') != -1)
		{
			sCookieName = sCookie.substr(0, sCookie.indexOf('=')).toLowerCase().replace(' ', '');
		//	alert(sCookieName + ' ' + sName.toLowerCase());
			if(sCookieName == sName.toLowerCase()) return sCookie.substr(sCookie.indexOf('=') + 1);
		}
		
		s = e + 1;
	}
	
	return '';
}

function CWS_Print(sParams)
{
	CWS_Print(sParams, 520, 600);
}

function CWS_Print(sParams, nWidth, nHeight)
{
	try
	{
		sLocation = '' + window.location;
		if(sLocation.indexOf('?') == -1) sLocation += '?bPrint=1';
		else sLocation += '&bPrint=1';
		if(sParams && sParams.length > 0) sLocation += '&' + sParams;
		
		CWS_OpenWindow(sLocation, nWidth, nHeight);//.replace('action=','xxx=');
	}
	catch(e){}

/*	
	//Creating new page
	var pp = window.open('print');
	
	pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')
	pp.document.writeln('<base target="_self"></HEAD>')
	if(document.getElementById('st_MainStyles') && document.getElementById('st_MainStyles').outerHTML) pp.document.write(document.getElementById('st_MainStyles').outerHTML);
	pp.document.writeln('<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" onload="//window.print();window.close();"><div style="width:640px;">');
	pp.document.writeln(print_area.innerHTML);
	pp.document.writeln('</div></body></HTML>');

	pp.location.reload(true);
	pp.print();
//	pp.close();
*/
}

function CWS_HidePopup(sName)
{
	if(sName == null) oPopup = oCWS_Popup;
	else oPopup = document.getElementById(sName);
	
	if(oPopup) oPopup.style.display = 'none';
}

function CWS_ShowPopup(sName, bCloseOnleave, bKeepOldPos)
{
	if(sName == null) sName = 'div_CWSPopup';

	oPopup = document.getElementById(sName);
	
	if(oPopup == null)
	{
		if(bCloseOnleave)
		{
		//	oPopup = document.createElement('DIV id="' + sName + '" onmouseleave="CWS_HidePopup(\'' + sName + '\');"');
			oPopup = document.createElement('DIV');
			oPopup.onmouseout = function(){CWS_HidePopup(sName);};
		}
		else oPopup = document.createElement('DIV');

		oPopup.setAttribute('id', sName);
	
		document.body.insertBefore(oPopup, null);
		oPopup.style.display = 'none';
		oPopup.style.position = 'absolute';
		oPopup.style.border = 'solid 1px #000000';
		oPopup.style.padding = '2px';
		oPopup.style.backgroundColor = '#E8E8E8';
		oPopup.style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color=\'#808080\', Direction=135, Strength=5)';
	
		oPopup.style.left = CWS_curPosX - 10;
		oPopup.style.top = CWS_curPosY- 10;
	}
	
	if(oPopup)
	{
		oPopup.style.display = 'inline';
		if(!bKeepOldPos)
		{
			px = CWS_curPosX - 10;
			py = CWS_curPosY - 10;
			oParent = oPopup.offsetParent;
			while(oParent)
			{
				px -= oParent.offsetLeft;
				py -= oParent.offsetTop;
				oParent = oParent.offsetParent;
			}
		
			oPopup.style.left = px;//CWS_curPosX - 10;
			oPopup.style.top = py;//CWS_curPosY- 10;
		}
		oPopup.style.zIndex = 20;
	//	oPopup.scrollIntoView();
		
		Drag.init(oPopup);
	}
	
	return oPopup;
}

function CWS_GetSelectedIDs(oForm)
{
	sIDs = '';
	
	for(i=0;i<oForm.length;i++)
	{
		if(oForm.elements[i].getAttribute('name') == 'IDs' && oForm.elements[i].checked)
		{
			if(sIDs.length > 0) sIDs += ',';
			sIDs += oForm.elements[i].value;
		}
	}
	
	return sIDs;
}

function GED_GetFolderID()
{
	if(oCWS_Tree2_CurrentObject != null)
	{
		sNodeName = oCWS_Tree2_CurrentObject.getAttribute('name');
		nID = parseInt(sNodeName.substr(4));
		sTable = '';
		if(sNodeName.substr(0,4) == 'Fld_') return nID;
	}
	
	return 0;
}
/*
function GED_ShowRecreateVersionsForm(nFolderID, sGedIDs, nUID)
{
	if(nFolderID == 0 && sGedIDs.length() == 0) return;
	
	oPopup = CWS_ShowPopup('div_GEDRecreateVersions', false, true);
	oPopup.innerHTML = '<table cellpadding="0"><tr><td align="right" bgcolor="#C0C0C0"><a href="javascript:" onclick="CWS_HidePopup(\'div_GEDRecreateVersions\');return false;"><img src="/CWS/Img/Close.gif" border="0"></a></td></tr><tr><td><a href="javascript:" onclick=""> + CWS_HttpRequest('/GED_Doc.asmx?action=GetRecreateVersionsOptions&nFolderID=' + nFolderID + '&sGedIDs=' + sGedIDs + '&UID=' + nUID) + '</td><tr></table>';
}

function GED_CallRecreateVersions(nFolderID, sGedIDs, sVersionIDs, bProcessSubFolders, bOnlyMissing, bPredifined)
{
	CWS_HttpRequest('/GED_Doc.asmx?action=recreateversions&nFolderID=' + nFolderID + '&sGedIDs=' + sGedIDs + '&sVersionIDs=' + sVersionIDs + '&bProcessSubFolders=' + (bProcessSubFolders?'1':'0') + '&bOnlyMissing=' + (bOnlyMissing?'1':'0') + '&bPredifined=' + (bPredifined?'1':'0'));
}
*/
function GED_ShowVersions(nID, nUID, sOnClick, nListMode, nZLevel)
{
	oPopup = CWS_ShowPopup('div_GEDVersions' + nZLevel, false, true);
	oPopup.innerHTML = '<table cellpadding="0"><tr><td align="right" bgcolor="#C0C0C0"><a href="javascript:" onclick="CWS_HidePopup(\'div_GEDVersions' + nZLevel + '\');return false;"><img src="/CWS/Img/Close.gif" border="0"></a></td></tr><tr><td>' + CWS_HttpRequest('/GED_Doc.asmx?action=GetVersions&ID=' + nID + '&UID=' + nUID + '&OnClick=' + sOnClick + '&nListMode=' + nListMode + '&ZLevel=' + nZLevel) + '</td><tr></table>';
	
	oPopup.style.zIndex += nZLevel;
}

function GED_ShowInfos(nID, nZLevel)
{
	oPopup = CWS_ShowPopup('div_GEDInfos', false, true);
	oPopup.innerHTML = '<table cellpadding="0"><tr><td align="right" bgcolor="#C0C0C0"><a href="javascript:" onclick="CWS_HidePopup(\'div_GEDInfos\');return false;"><img src="/CWS/Img/Close.gif" border="0"></a></td></tr><tr><td>' + CWS_HttpRequest('/GED_Doc.asmx?action=GetInfos&ID=' + nID) + '</td><tr></table>';
	
	oPopup.style.zIndex += nZLevel;
}

function GED_AddToCaddy(nID, nUID)
{
	oPopup = CWS_ShowPopup(null, true, false);
	oPopup.innerHTML = CWS_HttpRequest('/GED_Doc.asmx?action=AddToCaddy&ID=' + nID + '&UID=' + nUID);
	oPopup.style.zIndex = 101;
}

function GED_RemoveFromCaddy(nID, nUID)
{
	oPopup = CWS_ShowPopup(null, true);
	oPopup.innerHTML = CWS_HttpRequest('/GED_Doc.asmx?action=RemoveFromCaddy&ID=' + nID + '&UID=' + nUID);
	oPopup.style.zIndex = 101;
	oPopup.scrollIntoView();
}

function CWS_Publish(sTable, nID)
{
	oPopup = CWS_ShowPopup(null, true, false);
	oPopup.innerHTML = CWS_HttpRequest('/CWS/pop_Publish.aspx?TABLE=' + sTable + '&ID=' + nID);
	oPopup.style.zIndex = 101;
}

function CWS_PublishOK(sTable, nID)
{
	oPopup = CWS_ShowPopup(null, true, false);
	oPopup.innerHTML = CWS_HttpRequest('/CWS/pop_Publish.aspx?OP=OK&TABLE=' + sTable + '&ID=' + nID);
	oPopup.style.zIndex = 101;
}

function CWS_PublishNOK(sTable, nID)
{
	oPopup = CWS_ShowPopup(null, true, false);
	oPopup.innerHTML = CWS_HttpRequest('/CWS/pop_Publish.aspx?OP=NOK&TABLE=' + sTable + '&ID=' + nID);
	oPopup.style.zIndex = 101;
}

function CWS_GetPostDataFromForm(oForm)
{
	var		sPostData = 'bAjax=1', sFieldValue = '';
	
	if(oForm)
	{
		for(i=0;i<oForm.length;i++)
		{
			oField = oForm.elements[i];
		
			if(oField.getAttribute('type') == 'checkbox')
			{
				if(oField.checked) sFieldValue = '1';
				else sFieldValue = '0';
				
				sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
			}
			else if(oField.getAttribute('type') == 'radio')
			{
				if(oField.length > 1)
				{
					for(j=0;j<oField.length;j++)
					{
						if(oField[j].checked)
						{
							sFieldValue = oField[j].value;
							sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
						}
					}
				}
				else
				{
					if(oField.checked)
					{
						sFieldValue = oField.value;
						sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
					}
				} 
			}
			else if(oField.nodeName == 'SELECT')
			{
				if(oField.selectedIndex >= 0)
				{
					sFieldValue = oField.options[oField.selectedIndex].value;
					sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
				}
			}
			else
			{
				sFieldValue = oField.value;
				sPostData += '&' + oField.name + '=' + CWS_URLEncode(sFieldValue);
			}
		}
	}
	
	return sPostData;
}

function CWS_HttpRequest(sURL, sPostData)
{
	var xml_objet = false;

	while(sURL.indexOf('&amp;') != -1) sURL = sURL.replace('&amp;', '&');

	try { xml_objet = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e)
	{
		try { xml_objet = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(E) { xml_objet = false; }
	}
	
	if(!xml_objet && typeof XMLHttpRequest != 'undefined')
	{
		try { xml_objet = new XMLHttpRequest(); }
		catch(e) { xml_objet = false; }
	}
	
	if(!xml_objet && window.createRequest)
	{
		try { xml_objet = window.createRequest(); }
		catch(e) { xml_objet = false; }
	}

	if(xml_objet)
	{
		if(sPostData != null && sPostData.length > 0)
		{
			xml_objet.open('POST', sURL, false);
			xml_objet.setRequestHeader('Cache-Control','no-cache');
			xml_objet.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
			xml_objet.send(sPostData);
		}
		else
		{
			xml_objet.open('GET', sURL, false);
			xml_objet.setRequestHeader('Cache-Control','no-cache');
			xml_objet.send(null);
		}
		
		if(xml_objet.readyState == 4)
		{
			return xml_objet.responseText;
		//	return xml_objet.responseXML;
		}
	}

	return '';
}

function CWS_IsOK(sXml)
{
	if(sXml.indexOf('<STATUS>0</STATUS>') != -1) return true;
	else return false;
}

function CWS_Trim(sValue)
{
	sValue = '' + sValue;

	while(sValue.length > 0 && sValue.substr(0,1) == ' ') sValue = sValue.substr(1);
	while(sValue.length > 0 && sValue.substr(sValue.length-1,1) == ' ') sValue = sValue.substr(0,sValue.length-1);
	
	return sValue;
}

function CWS_GetTagValue(sXml, sTagName, sDefault)
{
	s = sXml.indexOf('<' + sTagName + '>');
	e = sXml.indexOf('</' + sTagName + '>');

	if(s != -1 && e > s)
	{
		s += 2 + sTagName.length;
		return sXml.substr(s, e-s);
	}
	else return sDefault;
}

function CWS_CancelBubble(evt)
{
	var e = (window.event)?window.event:evt;
	e.cancelBubble=true;
	return false;
}

function CWS_InsiteEditMenu(oSpan)
{
	if(oSpan == null) return;
		
	HierarchyObject = oSpan;
	
	sHierarchy = '';
	sTemp = '';
	while(HierarchyObject != null)
	{
		if(HierarchyObject.nodeName == 'SPAN')
		{
			sDebugDivName = HierarchyObject.getAttribute('id');
			if(sDebugDivName.substr(0, 2) == 't_')
			{
				sDebugDivName = sDebugDivName.substr(2);
				sLabel = HierarchyObject.getAttribute('label');
				
				sTemp = '<tr><td><a class="CWS_ft-link" href="javascript:" onclick="CWS_ShowPopup(\'' + sDebugDivName + '\', false);return false;"><img src="/CWS/Img/Edit.gif" alt="Properties" border="0">&nbsp;' + sLabel + '</a></td></tr>';
				if(sHierarchy.length > 0) sTemp += '<tr><td colspan="1" bgcolor="#C0C0C0" height="1"></td></tr><tr><td colspan="3" bgcolor="#F0F0F0" height="1"></td></tr>';
				sHierarchy = sTemp + sHierarchy;
			}
		}
		
		HierarchyObject = HierarchyObject.parentNode;
	}
	
	sTitle = 'Select object';
	sHierarchy = '<table cellpadding=2 cellspacing=0 border=0><tr><td><table cellpadding=1 cellspacing=0 border=0><tr><td><table cellspacing=0 cellpadding=0 bgcolor="#A0A0A0" width="200"><tr><td style="font-size:12px;font-family:Arial;color:#D0D0D0;"><b>&nbsp;' + sTitle + '</b></td><td align="right" height="22" valign="bottom"><a href="JavaScript:" onclick="HierarchySelector.style.display=\'none\';return false;"><img src="/CWS/Img/Close.gif" border="0"></a>&nbsp;</td></tr></table></td></tr></table><table align="center" class="CWS_ft-link" width="200" cellpadding=2 cellspacing=0 border=0>' + sHierarchy + '</table>';

	oPop = CWS_ShowPopup('HierarchySelector', false, false);
	oPop.innerHTML = sHierarchy;
	oPopup.style.display = 'inline';
	oPopup.style.zIndex = 10;
	
	return;
}

function CWS_ShowWithTimer(oDiv)
{
	if(oDiv == null) return;
	
	nTimerID = oDiv.getAttribute('TimerID');
	if(nTimerID != null)
	{
		window.clearTimeout(nTimerID);
		oDiv.removeAttribute('TimerID');
	}
	
	oDiv.style.display = 'inline';
}

function CWS_HideWithTimer(oDiv, nMilisec)
{
	if(oDiv == null) return;
	
	nTimerID = oDiv.getAttribute('TimerID');
	if(nTimerID != null)
	{
		window.clearTimeout(nTimerID);
		oDiv.removeAttribute('TimerID');
	}
	
	sID = oDiv.getAttribute('id');
	nTimerID = window.setTimeout('CWS_Hide(\'' + sID + '\')', nMilisec);
	oDiv.setAttribute('TimerID', nTimerID);
}

function CWS_Hide(sID)
{
	oDiv = document.getElementById(sID);
	if(oDiv == null) return;
	
	oDiv.style.display = 'none';
}

function CWS_URLEncode(sText)
{
	return encodeURIComponent(sText);
	
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = sText;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function CWS_URLDecode(sText)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = sText;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
  
   return plaintext;
};

function CWS_isValidEMail(string)
{
	var first;
	var second;
	var last;
	
	if((last=string.length-1) < 4) return false;
	
	if(string.indexOf(' ') != -1) return false;
	if(string.indexOf('..') != -1) return false;
	if(string.indexOf('\'') != -1) return false;
	if(string.indexOf('"') != -1) return false;
	if(string.indexOf('&') != -1) return false;
	if(string.indexOf('|') != -1) return false;
	if(string.indexOf(';') != -1) return false;
	if(string.indexOf(',') != -1) return false;
	if(string.indexOf('£') != -1) return false;
	if(string.indexOf('+') != -1) return false;
	if(string.indexOf('%') != -1) return false;
	if(string.indexOf('?') != -1) return false;
	if(string.indexOf('/') != -1) return false;
	if(string.indexOf('=') != -1) return false;
	if(string.indexOf('µ') != -1) return false;
	if(string.indexOf('$') != -1) return false;
	if(string.indexOf('\\') != -1) return false;
	if(string.indexOf(':') != -1) return false;
	if(string.indexOf('<') != -1) return false;
	if(string.indexOf('>') != -1) return false;
	if(string.indexOf('[') != -1) return false;
	if(string.indexOf(']') != -1) return false;
	if(string.indexOf('(') != -1) return false;
	if(string.indexOf(')') != -1) return false;
	if(string.indexOf('§') != -1) return false;
	if(string.indexOf('!') != -1) return false;
	if(string.indexOf('{') != -1) return false;
	if(string.indexOf('}') != -1) return false;
	
	if( (first=string.indexOf("@",1)) !=-1 )
	{
		if(string.indexOf("@", first+1) != -1) return false;
		
		if( ((last-first) >= 3) && (second=string.indexOf(".",first+2)) !=-1 ) return true;
	}

	return false;
}

function CWS_ValidateNumeric(evt, nLength, bInt, bPos)
{
	var e = (window.event)?window.event:evt;
	oField = (window.event)?e.srcElement:e.target;
	nKeyCode = (window.event)?e.keyCode:e.charCode;
	
	if(nLength == null || nLength == 0) nLength = 16;
	
	sValue = '' + oField.value;
	
	if((e.keyCode == 45 && !bPos && sValue.length == 0) || (e.keyCode == 46 && !bInt && sValue.length < (nLength-1)) || e.keyCode == 8 || e.keyCode == 13 || e.keyCode == 9) return true; 
		
	if(sValue.length >= nLength)
	{
		return false;
	}
	
	if(nKeyCode < 48 || nKeyCode > 58) return false;

	return true;
}

function CWS_SetID(sFieldID, nValue, bOn)
{
	nValue = '' + nValue;

	oField = document.getElementById(sFieldID);
	if(oField && nValue.length > 0)
	{
		sIDs = oField.value;
		if(sIDs.length > 0) sIDs = ',' + sIDs + ',';
		sIDs = sIDs.replace(',' + nValue + ',', ',');
		if(bOn) sIDs += nValue + ',';
		
		if(sIDs.substr(0, 1) == ',') sIDs = sIDs.substr(1);
		if(sIDs.length > 0 && sIDs.substr(sIDs.length-1, 1) == ',') sIDs = sIDs.substr(0, sIDs.length - 1);
			
		oField.value = sIDs;
	} 
}

/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 * Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

function validateDrag(e, oRoot)
{
	oElem = (e.srcElement)?e.srcElement:e.target;

	while(oElem)
	{
		if(oElem == oRoot) return true;
		if(oElem.getAttribute('nodrag') == '1') return false;
		
		if(oElem.nodeName == 'A' || oElem.nodeName == 'INPUT' || oElem.nodeName == 'TEXTAREA') return false;
		oElem = oElem.parentElement;
	}
	
	return true;
}
	
var Drag = {

	obj : null,

	oldmousemovehandler : null,
	oldmouseuphandler : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;
		
		o.onmousedown	= Drag.start;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);

		if(!validateDrag(e, this)) return;

		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		oldmousemovehandler = document.onmousemove;
		oldmouseuphandler = document.onmouseup;

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;
		
		if(!o) return false;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = oldmousemovehandler;
		document.onmouseup   = oldmouseuphandler;
		
		if(Drag.obj) Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};
/*
// setInnerHTML Sécurisé
function setInnerHTML(divContent, HTML)
{var eee = 0;
	divContent.innerHTML = HTML;
	
	try
	{
		var All = divContent.getElementsByTagName("*");
		for (var i=0;i<All.length;i++)
		{
			All[i].id = All[i].getAttribute("id");
			All[i].name = All[i].getAttribute("name");
		//	All[i].className = All[i].getAttribute("class");
		}
	}
	catch(ex) {}
	
	try
	{
		var AllScripts = HTML.extractTags("script");
		AllScripts.forEach(function (v) { eval(v); } );
	}
	catch(ex) {}
	
	try
	{
		var AllStyles = HTML.extractTags("style");
		AllStyles.forEach(function (v)
			{
				var s = document.createStyleSheet();
				s.cssText = v;
				s.enabled = true;
			}, true);
	}
	catch(ex) {}
}

String.prototype.extractTags = function(tag)
{
	var matchAll = new RegExp('(?:<'+tag+'.*?>)((\n|\r|.)*?)(?:<\/'+tag+'>)', 'img');
	var matchOne = new RegExp('(?:<'+tag+'.*?>)((\n|\r|.)*?)(?:<\/'+tag+'>)', 'im');

	return (this.match(matchAll)).map( function(scriptTag) { return (scriptTag.match(matchOne))[1]; } );
}

//Detect IE5.5+
version = 0;
if(navigator.appVersion.indexOf("MSIE")!=-1)
{
	temp = navigator.appVersion.split("MSIE");
	version = parseFloat(temp[1]);
}
// NON IE browser will return 0
if(version >= 5.5)
{
	Object.prototype.forEach = function(delegate, ownpropertiesonly)
	{
		if(typeof(delegate) == "function")
		{
			if(this instanceof Array && typeof(ownpropertiesonly) == "undefined")
			{
				ownpropertiesonly = true;
			}
			for (key in this)
			{
				var ok = (!ownpropertiesonly);
				if (!ok)
				{
					try
					{
						ok = this.hasOwnProperty(key);
					}
					catch(ex) {}
				}
				
				if(ok)
				{
					try
					{
						delegate(this[key], key, this);
					}
					catch(e) {}
				}
			}
		}
		
		return false;
	};
	
	Object.prototype.map = function(iterator)
	{
		var results = [];
		this.forEach(function(value, index)
			{
				results.push(iterator(value, index));
			}
		);
		
		return results;
	};
}
*/
/*
* @param pDivObject - Object qui possède la méthode .innerHTML
* @param pHTML - le code HTML a rajouter dans l'object pDivObject
*/
function setInnerHTML(pDivObject, pHTML)
{
	pDivObject.innerHTML = pHTML;
	
	var All = pDivObject.getElementsByTagName("*");
	for(var i=0; i<All.length; i++)
	{
		All[i].id = All[i].getAttribute("id");
		All[i].name = All[i].getAttribute("name");
	//	All[i].className = All[i].getAttribute("class");
	}
	var AllScripts = pDivObject.getElementsByTagName("script");

	for (var i=AllScripts.length-1; i>=0; i--)
	{
		var s = AllScripts[i];
		var oScript = document.createElement("script");
		
		oScript.type = 'text/javascript';
		
		if(s.src && s.src != "")
		{
			oScript.src = s.src;
		}
		else
		{
		//	oScript.innerHTML = s.innerHTML;
			eval(s.innerHTML);
		}
		
	//	document.body.appendChild(oScript);
		
	//	pDivObject.removeChild(s);
	}
}
