function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function confirm_delete(form)
{
	var verify = confirm("Do you really want to delete this?");
	if (verify== true)
	{
		form.submit();
	}
}

function mask(str,textbox,loc,delim) {
	var locs = loc.split(',');
	for (var i=0; i<=locs.length; i++) {
		for (var k=0; k <=str.length; k++) {
			if (k == locs[i]) {
				if (str.substring(k, k+1) != delim) {
					str = str.substring(0,k) + delim + str.substring(k, str.length);
				}
			}
		}
	}
	textbox.value = str;
}

function isEmpty(str) {
	// check whether string is empty
	for (var intLoop =0; intLoop < str.length; intLoop++)
		if (" " != str.charAt(intLoop))
			return false;
	return true;
}

function checkRequired(f) {
	var strError = "";
	for (var intLoop = 0; intLoop < f.elements.length; intLoop++)
		if (null!=f.elements[intLoop].getAttribute("required"))
			if(isEmpty(f.elements[intLoop].value))
				strError += "  " + f.elements[intLoop].name + "\n";
	if ("" != strError) {
		alert("Please fill in all required fields.");
		return false;
	} else
	return true;
}
