// this file is included in every page by CFormBase class
// constant declarations

var FORM_ACTION_FIELD_NAME = "__FORM_ACTION";
var FORM_SUBMIT_COUNTER_FIELD = "__FORM_SUBMIT_COUNTER";
// action constants
var ACTION_DELETE = "DELETE";
var ACTION_UPDATE = "UPDATE";
var ACTION_SAVE = "SAVE";
var ACTION_ADDNEW = "ADDNEW";
var ACTION_REFRESH = "REFRESH";
var ACTION_SORT = "SORT";

var MSGBOX_RES_OK = 1;
var MSGBOX_RES_CANCEL = 0;

var USER_GROUP_ADMIN = 3;
var USER_GROUP_COMPANY = 1;

var LEAD_STATUS_SENT = 3;

//-------------------------------------------------------------------------------------------
function JG_SetFormAction(sAction) {
	var oField = null;
	
	oField = document.all.item(FORM_ACTION_FIELD_NAME);
	if (oField) {
		oField.value = sAction;
		return true;
	}
	
	return false;
}
//-------------------------------------------------------------------------------------------
function JG_SubmitForm(sAction) {
	var oForm = null;
	
	if (window.document.forms.length > 0) {
		if ((sAction) && (sAction.length > 0)) {
			JG_SetFormAction(sAction);
		}
		oForm = window.document.forms.item(0);
		oForm.submit();
	}
}
//-------------------------------------------------------------------------------------------
function JG_MessageBox(sMessage, sTitle, MessageType) {
	var sURL = "";
	var width, height;
	
	width = 350;
	height = 150;
	
	if (!MessageType)
		MessageType = 0

	if (MessageType == 100){
		width = 175;
		height = 100;
	}
	
	if (!sTitle)
		sTitle = "הודעת מערכת"

	sURL = VIRTUAL_DIRECTORY_NAME + "/Base/frmMessageBox.aspx?Title=" + sTitle + 
				"&Message=" + sMessage + 
				"&MessageType=" + MessageType;
	return JG_OpenModalWindow(sURL, height, width);
}
//-------------------------------------------------------------------------------------------
function JG_OpenModalWindow(sURL, iHeight, iWidth, aParams) {
	if (!iHeight)
		iHeight = 300;
	if (!iWidth)
		iWidth = 400;
		
	if (!document.parentWindow) // Firefox probably, "center" is not supported
	{
		var iLeft = 0;
		var iTop = 0;
		
		iLeft = (screen.width - iWidth) / 2;
		iTop = (screen.height - iHeight) / 2;
		
		if (iLeft < 0)
			iLeft = 0;
		if (iTop < 0)
			iTop = 0;
		
		return window.showModalDialog(encodeURI(sURL), aParams, 
					"dialogLeft:" + iLeft + ";dialogTop:" + iTop + ";" +
					"dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;");
	}
	else
	{
		return window.showModalDialog(encodeURI(sURL), aParams, 
					"scroll:no;resizable=no;" +
					"dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;center:yes");
	}
}
//-------------------------------------------------------------------------------------------
function JG_SetScrollPos(iValue)
{
	try 
	{
		window.scroll(0, iValue);
	}
	catch(e) {};
}
//-------------------------------------------------------------------------------------------
function JG_SaveScrollPos()
{
	try 
	{
		document.getElementById('__MASTER_SCROLLTOP').value = document.body.scrollTop;
	}
	catch(e) {};
}
//-------------------------------------------------------------------------------------------
