//*************************************************************************************************
//* Author: tobias.larsson@firstinsys.se
//* Desc:   Open a popup window in center of the calling window.
//*************************************************************************************************
function gJS_OpenPopupWinCenterOfWin(sURL,sWinName,iWidth,iHeight){
	if (document.all) {
		var w = (top.document.body.clientWidth / 2) + top.window.screenLeft;
		var h = (top.document.body.clientHeight / 2) + top.window.screenTop;
	}else if (document.layers) {
		var w = window.innerWidth;
		var h = window.innerHeight;
	}
	var xpos = w - (iWidth / 2);
	var ypos = h - (iHeight / 2);
	win = window.open(sURL,sWinName,'toolbar=no,location=no,directories=no,status=no,width='+iWidth+',height='+iHeight+',resize=no,scrollbars=no,top='+ ypos +',left='+ xpos);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

//*************************************************************************************************
//* Author: tobias.larsson@firstinsys.se
//* Desc:   Set background color on HTML elements.
//*************************************************************************************************
function gJS_SetBGColor(oElement, sHexValue){
	oElement.style.backgroundColor = sHexValue;
}

//*************************************************************************************************
//* Author: tobias.larsson@firstinsys.se
//* Desc:   Sets hidden formvalues used to submit klient actions to server script.
//*************************************************************************************************
function gJS_DoAction(sAction,sValue,sMsg){
	if (sMsg != ""){
		if (confirm(sMsg)){							
			document.forms(0).Action.value = sAction;
			document.forms(0).Value.value = sValue;
			document.forms(0).submit();
		}
	}else{
		document.forms(0).Action.value = sAction; 
		document.forms(0).Value.value = sValue;
		document.forms(0).submit();
	}
}

//*************************************************************************************************
//* Author: tobias.larsson@firstinsys.se
//* Desc:   Display alert message box in klient.
//*************************************************************************************************
function gJS_DoAlert(sMsg){
	if (sMsg != ""){
		alert(sMsg);
	}
}

//*************************************************************************************************
//* Author: tobias.larsson@firstinsys.se
//* Desc:   Set value to klient form elements.
//*************************************************************************************************
function gJS_SetFieldValue(sElement,sValue){
	document.forms(0)[sElement].value = sValue;
	document.forms(0).submit();
}

