function s(id) {
	if(document.getElementById) {
		document.getElementById(id).style.visibility = 'visible';
	}
}

function h(id) {
	if(document.getElementById) {
		document.getElementById(id).style.visibility = 'hidden';
	}
}

function sb(id) {
	if(document.getElementById) {
		document.getElementById(id).style.display = 'block';
	}
}

function hb(id) {
	if(document.getElementById) {
		document.getElementById(id).style.display = 'none';
	}
}

function showPreview(img, id) {
	if(document.getElementById) {
		if(document.getElementById('vipi'+id).src.indexOf('trans')>=0) {
			document.getElementById('vipi'+id).src = '/images/villas/big_'+img;
		}
		document.getElementById('vip'+id).style.display = 'block';
	}
}

function intOnly(i) {
	if(i.value.length>0) {
		i.value = i.value.replace(/[^\d]+/g, ''); 
	}
}

function refreshRegions(sel) {
	if(document.getElementById) {
		if(sel.value!=-1) {
			var country = sel.value;
			var html = '<strong>Region:</strong><select name="region[]"><option value="-1">All Regions</option>';
			for(i=0;i<countries[country].length;i++) {
				html = html + '<option value="'+countries[country][i][0]+'">'+countries[country][i][1]+'</option>';
			}
			html = html + '</select>';
			document.getElementById('regionselect').innerHTML = html;
		}
		else {
			document.getElementById('regionselect').innerHTML = '<strong>Region:</strong><select name="region"><option>Please Select A Country</option></select>';
		}
	}
}

function showErrors(errors, id) {
	var html = "<div class=\"errorClose\"><img src=\"/images/close-icon.gif\" alt=\"Close\" onclick=\"closeError('"+id+"');\" />My Perfect Villa</div><div class=\"errorContent\"><span>Before submitting the form, please could you:</span><ul>";
	for(var i=0;i<errors.length;i++) {
		html = html + "<li>" + errors[i] + "</li>";
	}
	html = html + "</ul><span>Thank You!</span></div>";
	document.getElementById(id).innerHTML = html;
	document.getElementById(id).style.visibility = 'visible';
}

function closeError(id) {
	document.getElementById(id).style.visibility = 'hidden';
}

function validEmail(email) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);
}


function checkGo(f) {
	return (f.villa.value>0);
}

function checkNewsletter(f) {
	if(!validEmail(f.email.value)) {
		var errors = Array();
		errors.push('Check the email address you have entered. The current email address is invalid, a valid email address takes the form:<br><br> username@domain.com');
		showErrors(errors, 'errNewsletter');
		return false;
	}
	return true;
}