// JavaScript Document
function toggle_display(id) {
	var disp = document.getElementById(id).style.display;
	if (disp == 'none') {
		disp = 'block';	
	} else {
		disp = 'none';
	}
}
function validate_required(field)
{
	with (field)
	{
		if (value==null||value=="")
		{
			field.focus();
			return false;
		} else {
			return true;
		}
	}
}
function validate_expression(field, expr)
{
	var ex = '';
	switch (expr) {
		case 'alpha':
			ex = /^[a-zA-Z ]+$/;
			break;
		case 'number':
			ex  = /^[0-9]+$/;
			break;
		case 'alphanum':		
			ex = /^[0-9a-zA-Z ]+$/;
			break;
		case 'email':
			ex = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;	
			break;
		default: // alpha
			ex = /^[a-zA-Z ]+$/;
			break;
	}

	var val = field.value.replace(/ /,'');
	if (val.match(ex)) {
		return true;	
	} else {
		field.focus();
		return false;
	}
}

function compare_values(field_a, field_b) {
	if (field_a.value == field_b.value) {
		return true;
	} else {
		field_a.focus();
		return false;
	}
}

function change_bgcolor(id, color) {
	document.getElementById(id).style.backroundColor = '#' + color;
}

function confirm_delete(obj_name, id, page) {
	if (confirm("Are you sure you want to delete " + obj_name + "?")) {
		window.location.href = page + "?id=" + id + "&action=remove";
	}
}
function show_full_image(img, caption) 
{
	var data = '<div style="font-size:11px; font-weight:bold;">' + caption + '</div><br /><img src="' + img + '" style="border:solid 1px #565545;" /><br />';
	document.getElementById('FullImg').innerHTML = data;
}
function hide_full_image() {
	document.getElementById('FullImg').innerHTML = '';
}
function detect_ie() {
	var ver = 0;
	var msg = '';
	var ua = navigator.userAgent;
	var av = navigator.appVersion;
	if (ua != null)
	{
		if (ua.indexOf("MSIE") != -1)
		{
			if (av.indexOf("MSIE")!=-1){
				var temp=av.split("MSIE");
				ver=parseFloat(temp[1]);
			}
		}
	}
	return ver;
}

