<!--//

function cdiv() {
	document.getElementById('oback').className = 'oback';
	document.getElementById('oinfo').className = 'oinfo';
}

function divver(div,url) {
	var obj = false;
	var our = this;
	if(window.XMLHttpRequest) {
		our.obj = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		our.obj = new ActiveXObject('Microsoft.XMLHTTP');
	}
	our.obj.open('POST', url, true);
	our.obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	our.obj.onreadystatechange = function() {
		if (our.obj.readyState == 4 && our.obj.status == 200) {
			updatepage(our.obj.responseText, div);
		}
	}
	our.obj.send(null);
}

function inputform() {
	if(document.ivend.name.value == '') {
		window.alert('Please enter a name.');
		document.ivend.name.focus();
	} else if(document.ivend.business.value == '') {
		window.alert('Please enter a business.');
		document.ivend.business.focus();
	} else if(document.ivend.address.value == '') {
		window.alert('Please enter an address.');
		document.ivend.address.focus();
	} else if(document.ivend.phone.value == '') {
		window.alert('Please enter a phone number.');
		document.ivend.phone.focus();
	} else if(!isEMailAddress(document.ivend.email.value)) {
		window.alert('Please enter a valid email address.');
		document.ivend.email.focus();
	} else if(document.ivend.product.value == '') {
		window.alert('Please enter a product for sale.');
		document.ivend.product.focus();
	} else if(document.ivend.produced.checked == false) {
		window.alert('Please verify product is locally grown or produced.');
		document.ivend.produced.focus();
	} else if(document.ivend.policies.checked == false) {
		window.alert('Please accept the policies of the market.');
		document.ivend.policies.focus();
	} else {
		document.forms.ivend.action = 'iform.vendor.php';
		document.forms.ivend.submit();
	}
}

function ipopup(url) {
	overlay(); divver('oinfo', url);
}

function isEMailAddress(email) {
	return isValidText(email,"^([\\w\\._-]+)@([\\w_-]+\\.)+([\\w_]+)$");
}

function isValidText(input,expr) {
	if (window.RegExp){
		if(typeof(expr) == 'string')
			expr = new RegExp(expr);
		return expr.test(input);
	} else {
		return true;
	}
}

function overlay() {

	document.getElementById('oback').className = 'oback_on';
	document.getElementById('oinfo').className = 'oinfo_on';

	var dimh = document.body.getDimensions().height;
	if( dimh < screen.height) { dimh = screen.height; }
	dimh = parseInt(dimh);

	document.getElementById('oback').style.height = dimh + 'px';

	var dimw = document.body.getDimensions().width;
	dimw = parseInt(dimw);

	var ourwidth = 730;
	if(dimw > ourwidth) { var extra = (dimw - ourwidth) / 2; } else { var extra = 0; }
	var overlayw = 540;

	var left = (ourwidth - overlayw) / 2;
	left += extra;
	left = parseInt(left);

	var top = window.pageYOffset || document.documentElement.scrollTop || 0;
	top += 30;
//	if(top < 100) { top = 100; }
	top = parseInt(top);

	document.getElementById('oinfo').style.top	= top + 'px';
	document.getElementById('oinfo').style.left	= left + 'px';

}

function updatepage(ihtml,ident){
	document.getElementById(ident).innerHTML = ihtml;
}

//-->