// JavaScript Document
function viewBusiness()
{
	with (window.document.frmListBusiness) {
		if (cboCategory.selectedIndex == 0) {
			window.location.href = 'index.php';
		} else {
			window.location.href = 'index.php?businessId=';
		}
	}
}

function checkAddBusinessForm()
{
	with (window.document.frmAddBusiness) {
		if (isEmpty(businessName, 'Enter Business name')) {
			return;
		} else if (businessSubcategorie.selectedIndex == 0) {
			alert("Choose Category");
		} else if (isEmpty(businessPhone, 'Enter Business phone')) {
			return;
		} else if (isEmpty(businessEmail, 'Enter Business email')) {
			return;
		} else {
			submit();
		}
	}
}

function checkForm()
{
	with (window.document.frmPhotoForm) {
		if (!document.getElementById("fleImage").value) {
			alert("You must attach a photo");
		} else if (isEmpty(photoTitle, 'Please enter a photo title')) {
			return;
		} else if (isEmpty(photoCredit, 'Please enter a photo credit')) {
			return;
		} else if (isEmpty(email, 'Please enter your email')) {
			return;
		} else if (email.value.search(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/) == -1) {
			alert("Please enter a valid e-mail address");
		} else {
			submit();
			if (submit) {
				return ray.ajax();
			}
		}
	}
}


function checkPage()
{
	with (window.document.frmAddBusiness) {
			submit();
	}
}

function addBusiness(businessId)
{
	window.location.href = 'index.php?view=add&businessId=' + businessId;
}

function modifyBusiness(businessId)
{
	window.location.href = 'index.php?view=modify&businessId=' + businessId;
}

function deleteBusiness(businessId)
{
	if (confirm('Delete this business information?')) {
		window.location.href = 'processBusiness.php?action=deleteBusiness&businessId=' + businessId;
	}
}

function deleteImage(image)
{
	if (confirm('Delete this image')) {
		window.location.href = 'processBusiness.php?action=deleteImage' + image;
	}
}
