function emailWM(choice) {
  switch (choice) {
	case "editor":
		navigate('mai' + 'lto:' + 'editor' + '@' + 'macauart' + '.net');
		break;
	case "info":
		navigate('mai' + 'lto:' + 'info' + '@' + 'macauart' + '.net');
		break;
	default :
		navigate('mai' + 'lto:' + 'Webmaster.Man' + '@' + 'icm.' + 'gov' + '.mo');
		break;
  }
}

function openWin(url, wName, wWidth, wHeight) {
	var newWindow, screenWidth, screenHeight, winLeft, winTop;

	winLeft = (screen.availWidth - wWidth - 10) * 0.5;
	winTop = (screen.availHeight - wHeight - 30) * 0.5;

	newWindow = window.open(url, wName, "height = " + wHeight + ", width = " + wWidth + ", left = " + winLeft + ", top = " + winTop + ", fullscreen = no, channelmode = no, toolbar = no, location = no, directories = no, status = no, menubar = no, scrollbars = yes, resizable = yes");
	newWindow.focus();
}

function printWindow() {
	if (window.print != null) {
		window.print();
	} else {
		alert('Your browser does not support this feature. Please select Print from the File menu.');
	}
}

function formSubmit(formName, url, urlTarget) {
	var objStr = formName, obj;

	obj = eval(objStr);
	obj.action = url;
	obj.target = urlTarget;
	obj.submit();
}

function openSubmit(url, wName, wWidth, wHeight, formName) {
	openWin('/blank.htm', wName, wWidth, wHeight);
	formSubmit(formName, url, wName);
}

function TrimLeft(str) {
	var resultStr = "";
	var i = len = 0;

	if (str+"" == "undefined" || str == null)
		return null;

	str += "";

	if (str.length == 0) {
		resultStr = "";
	} else {
		len = str.length;

  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
		resultStr = str.substring(i, len);
  	}
  	return resultStr;
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	if (str+"" == "undefined" || str == null)
		return null;

	str += "";

	if (str.length == 0)
		resultStr = "";
	else {
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
  		resultStr = str.substring(0, i + 1);
  	}

  	return resultStr;
}

function Trim( str ) {
	var resultStr = "";

	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);

	return resultStr;
}

function mailValidate(emailad){
	var userPat=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var emailPat=/@[\w\-]+\./;
	var domainPat=/\.[a-zA-Z]{2,3}$/;

	if(((emailad.search(userPat) != -1)||(emailad.search(emailPat)) == -1)||(emailad.search(domainPat) == -1)){
		return true;
	} else {
		return false;
	}
}

function getObjectTop(o) {
	var temp = o.offsetTop;

	if (o.offsetParent.tagName != "BODY") {
		temp = temp + getObjectTop(o.offsetParent);
	}

	return temp;
}

function getObjectLeft(o) {
	var temp = o.offsetLeft;

	if (o.offsetParent.tagName != "BODY") {
		temp = temp + getObjectLeft(o.offsetParent);
	}

	return temp;
}

function setZoom(image, bgImage) {
	image.style.position = 'absolute';
	image.style.left = getObjectLeft(bgImage) + bgImage.width - 34;
	image.style.top = getObjectTop(bgImage) + bgImage.height - 22;
}
