/****************************************************************************
 * Compiere (c) Jorg Janke - All rights reseverd
 * $Id: wstore.js,v 1.1 2005/11/07 11:00:20 eldir Exp $
 *
 * Web Store Scripts
 ***************************************************************************/

var mandatory = "Enter mandatory:";

/**
 *	Is field empty ?
 *  Returns true if field is empty
 */
function isEmpty (value)
{
	if (value == null)
		return true;
	if (value == "")
		return true;
	for (var i = 0; i < value.length; i++)
	{
		var c = value.charAt(i);
		if ((c != ' ' && c != '\n' && c != '\t'))
			return false;
	}
	return true;
}



function checkCreditCard(field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}

function checkExpDate(field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}

function checkABA (field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}

function checkBAcct (field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}
function checkChknum (field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}

function checkDL (field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}

function checkForm (field)
{
	window.alert(field.name + "=" + field.value);
	return true;
}


/**
 * 	Test mandatory fields for lookup
 */
function checkLookup (field)
{
	window.alert (field);
	var f = field.form;
	window.alert (f);
	if (!isEmpty(f.EMAIL.value) && !isEmpty(f.password.value))
		return true;
	var msg = mandatory;
	if (isEmpty(f.EMAIL.value))
		mandatory += "\n - " + f.EMAIL.title;
	if (isEmpty(f.password.value))
		mandatory += "\n - " + f.password.title;
	window.alert(mandatory);
	return false;
}

/**
 * Pop up Window
 */
function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}


/* functions that get called when user presses a help button */
function openHelp(basedir, tipName)
{
	width=300, height=350;
	x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

	
	var h_window = null;
	h_window = window.open(basedir + "/helpTip.jsp?tipName=" + tipName,"Help",'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	h_window.focus();
	return;
}

function openIFMHelp(basedir, tipName)
{
	width=300, height=350;
	x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

	
	var h_window = null;
	h_window = window.open(basedir + "/helpTipIFM.jsp?tipName=" + tipName,"Help",'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	h_window.focus();
	return;
}

function checkMandatory(formObj, requiredFields) {
	var alertMsg = "";
	//	check required fields
	for (i=0; i<requiredFields.length; i++)
	{
		formElemLength = eval ("formObj." + requiredFields[i] + ".value.length");
		if (formElemLength == 0)
			alertMsg += "- " + requiredFields[i] + "\n";
	}
	//	show Error Message
	if (alertMsg.length)
	{
		alertMsg = mandatory + "\n" + alertMsg;
		alert (alertMsg);
		return false;
	} else {
	return true;
	}
}

/****************************************************************************
 *  Hide Elements with ID
 */
function hide (idname)
{
    document.getElementById(idname).style.display='none';
}   //  hide

/**
 *  Show Elements with ID
 */
function show (idname)
{
    document.getElementById(idname).style.display='';
}   //  show

/**
 *  Toggle Hide/Show Elements with ID
 */
function toggle (idname)
{
   if (document.getElementById(idname).style.display=='none')
    document.getElementById(idname).style.display='';
   else
    document.getElementById(idname).style.display='none';
}   //  toggle

/* */



