function israelexporter_validateAddBiz ()
{
	var formValidator = new Validator("addBizForm");
	var oForm		  = document.getElementById("addBizForm");

	setFilesNames('addBizForm');

	formValidator.clearAllValidations ();
	formValidator.addValidation('company',			'required',	'Please enter the company name');
	formValidator.addValidation('address',			'required',	'Please enter your address');
	formValidator.addValidation('phone',			'required',	'Please enter a phone number');
	formValidator.addValidation('desc',				'required',	'Please write a short profile');
	formValidator.addValidation('username',			'required',	'Please enter your user name');
	formValidator.addValidation('password',			'required',	'Please enter your password');
	formValidator.addValidation('password2',		'required',	'Please retype the password');
	formValidator.addValidation('email',			'required',	'Please enter your e-Mail address');
	formValidator.addValidation('email',			'email',	'Please enter a valid e-Mail address');

	if (formValidator.validate ())
	{
		if (document.getElementById('password').value != document.getElementById('password2').value)
		{
				alert('The two passwords are not identical');
				document.getElementById("password2").focus ();
				return false;
		}	

		if (multiUploadCountPics != 0)
		{
				alert('Please wait for file upload to end');
				return false;
		}

		// count number of selected categories
		var oItemType = document.getElementById("itemType");
		var countItems = 0;
	    for (var i=0; i<oItemType.options.length; i++)
	    {
	        if (oItemType.options[i].selected)
	            countItems++;
	    }

	    if (countItems == 0)
	    {
	        alert("Please choose at least one category");
	        oItemType.focus ();
			return false;
	    }
	    else if (countItems > 3)
	    {
	        alert("As a Bronze exporter you may choose no more that 3 categories");
	        oItemType.focus ();
			return false;
	    }
	
		// test that username/email are unique	
		var xml = "<data>" +
					"<command>private.checkMember</command>"   	+
					"<username>"	+ oForm.username.value 		+ "</username>" 	+
					"<email>"		+ oForm.email.value 		+ "</email>" 		+
				  "</data>";
		xmlRequest.init (xml);
		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "israelexporter_checkMember_response");

		return false;
	}
	else
	{
		return false;
	}
}

function israelexporter_validateAddOp ()
{
	var formValidator = new Validator("addBizForm");
	var oForm		  = document.getElementById("addBizForm");

	setFilesNames('addBizForm');

	formValidator.clearAllValidations ();
	formValidator.addValidation('company',			'required',	'Please enter the company name');
	formValidator.addValidation('address',			'required',	'Please enter the address');
	formValidator.addValidation('email',			'required',	'Please enter your e-Mail address');
	formValidator.addValidation('email',			'email',	'Please enter a valid e-Mail address');

	if (formValidator.validate ())
	{
		if (multiUploadCountPics != 0)
		{
				alert('Please wait for file upload to end');
				return false;
		}
		return true;
	}

	return false;

}

function israelexporter_checkMember_response (i)
{
	xmlRequest.init(commonDecode(asyncHttpObj.responseText));
						
	try
	{
		success = xmlRequest.getValue("success");
	}
	catch (e)
	{
		alert ("AJAX Error");
		return false;
	}
	
	if (success == "1")
	{
		return true;
	}
	else if (success == "0")
	{
		alert ("This Username or E-mail are already taken");
		document.getElementById("username").focus ();
		return false;
	}
}

/* ------------------------------------------------------------------------------------------------ */
/* setFilesNames																					*/
/* ------------------------------------------------------------------------------------------------ */
function setFilesNames (formName)
{
	filesNamesStr = "";

	oTbl = document.getElementById("picsTbl").getElementsByTagName("tbody")[0];

	numPics = oTbl.rows.length;

	for (r=1; r<numPics; r++)
	{
		row = oTbl.rows[r];

		picName = row.cells[0].childNodes[1].id;

		if (filesNamesStr != "") filesNamesStr += " ";

		filesNamesStr += picName.replace(/\s/g, "_");
	}

	document.getElementById(formName).filesNames.value = filesNamesStr;
}

/* ------------------------------------------------------------------------------------------------ */
/* israelexporter_openSubMenu																		*/
/* ------------------------------------------------------------------------------------------------ */
function israelexporter_openSubMenu (fatherId)
{
	return;
	document.getElementById('subs' + fatherId).style.display = '';
}

/* ------------------------------------------------------------------------------------------------ */
/* israelexporter_closeSubMenu																		*/
/* ------------------------------------------------------------------------------------------------ */
function israelexporter_closeSubMenu (fatherId)
{
	return;
	document.getElementById('subs' + fatherId).style.display = 'none';
}
