//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function showdocMrp(urlstr)
{
	var sUrl  = urlstr;
	openlowresMrp(sUrl,'previewdoc',560,700,40);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function PortalSummary(urlstr)
{
	var sUrl  = urlstr;
	openlowresMrp(sUrl,'portal',420,580,0);
	//openlowresMrp(sUrl,'portal',546,580,0);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function openlowresMrp(filename,winname,sHeight,sWidth, sIdent) {

	parameter = 'top=' + [(screen.height-sHeight)/2 - sIdent] + ',left=' + [(screen.width-sWidth)/2 - sIdent] + ',height=' + sHeight + ',width=' + sWidth + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes';
	NewWin = window.open(filename,winname,parameter);
	
	if (NewWin != null)
	{
		NewWin.focus();
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function openNewWin(sUrl) 
{
	openlowresMrp(sUrl,'dochighlight',600,760,40);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function init_message() 
{
	if (document.frmSum.closewin != null)
	{
		if (document.frmSum.closewin.value == 'ON')
		{
			window.setTimeout("window.close()",10000);
		}
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function SearchBack()
{
	//window.history.go(-1);
	window.history.back();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function ClearFields(fId, nbrFields)
{
	if (nbrFields == 0){
		ClearField(fId);
	}else{
		for (var i=0;i<nbrFields;i++) {
			var vfId = fId.toString() + "_" + i;
			ClearField(vfId);
		}
	}	
}	
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function ClearField(fId)
{
	if (document.all){
		// IE 5+
		document.all[fId.toString()].checked = false;
	}else{
		// NS 6+ and compatible
		if (document.getElementById)
		{
			document.getElementById(fId.toString()).checked = false;
		}
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function ClearDateFields(fId)
{
	var vfId = fId.toString() + "__Day";
	ClearDateField(vfId);

	vfId = fId.toString() + "__Month";
	ClearDateField(vfId);
		
	vfId = fId.toString() + "__Year";
	ClearDateField(vfId);	
	
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function ClearDateField(fId)
{
	var fobj = null;
	if (document.all){
		fobj = document.all[fId.toString()];
	}else{
		fobj = document.getElementById(fId.toString());
	}
	
	if (fobj != null){
		fobj.options[0].selected = true;
		//inutile car une seule selection a la fois
		//for (var i=1;i<fobj.options.length;i++) {
		//		fobj.options[i].selected = false;
		//}		
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function FillField(fId)
{
	if (document.all){
		document.all[fId.toString()].checked = true
	}else{
		if (document.getElementById)
		{
			document.getElementById(fId.toString()).checked = true;
		}
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function DisplayAssistant(sUrl) 
{
	var sHeight = 600;
	var sWidth = 810;	
	
	parameter = 'top=20,left=' + (screen.width - sWidth - 40) + ',height=' + sHeight + ',width=' + sWidth + ',status=no,toolbar=yes,menubar=yes,location=no,resizable=yes,scrollbars=yes';
	NewWin = window.open(sUrl,'Assistant',parameter);
	
	if (NewWin != null)
	{
		NewWin.focus();
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function SelectCat(pFId,fId,nbrFields)
{
	if (nbrFields > 0){
		var atLeatOneChecked = false;
		for (var i=0;i<nbrFields;i++) {
			var vfId = fId.toString() + "_" + i;
			var blnChecked = FieldSatus(vfId);
			if (blnChecked){
				atLeatOneChecked = true;
				break;
			}
		}
		if (!(atLeatOneChecked)){
			FillField(pFId);
		}		
	}	
	return;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function FieldSatus(fId)
{
	var blnRetVal = false;
	if (document.all){
		blnRetVal = document.all[fId.toString()].checked;
	}else{
		if (document.getElementById)
		{
			blnRetVal = document.getElementById(fId.toString()).checked;
		}
	}
	return blnRetVal;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function GoVariant(variantquery, iskeyword, btnId, idQuery, idKeyword)
{
	if ((variantquery != '') && (document.forms.length > 0))
	{
		var vTxtQryI = eval("document.forms[0]." + idQuery);
		if (typeof vTxtQryI != "undefined")
		{
			var vQryObj = getElById(idQuery);
			if (vQryObj != null){
				vQryObj.value = variantquery;
			}
			
			var vTxtKeyI = eval("document.forms[0]." + idKeyword);
			if ((iskeyword != '') && (typeof vTxtKeyI != "undefined"))
			{
				var vKeyObj = getElById(idKeyword);
				if (vKeyObj != null){
					vKeyObj.value = iskeyword;
				}
			}
			
			// non encore implemente
			//document.frm.ComputeVariants.value = "No";

			//non fonvtionnel avec un type=image
			//var vTxtBtnI = eval("document.forms[0]." + btnId);
			//if (typeof vTxtBtnI != "undefined")
			//{
				var vBtnObj = getElById(btnId);
				if (vBtnObj != null){
					vBtnObj.click();
				}
			//}			
		}
	}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function getElById(idVal)
{
	if (document.getElementById != null){
		return document.getElementById(idVal.toString());
	}else{
		if (document.all != null){
			return document.all[idVal.toString()];
		}else{
			return null;
		}
	}
	return null;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// NOT USED
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//function DoClickOnEnterKeyPressed(fieldId)
//{	
//	if(event.keyCode==13)
//	{
//		event.cancelBubble = true;
//		event.returnValue = false;
//
//		if (document.all){
//				document.all[fieldId.toString()].click();
//		}else{
//			if (document.getElementById)
//			{
//				document.getElementById(fId.toString()).click();
//			}
//		}
//	}	
//}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

