
function openWindow(url,width,height){
	newWin = window.open(url, 'viewWin', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,left='+(screen.width-width)/2+',top='+(screen.height-height)/2+',width=' + width + ',height=' + height + '');
}		

function changeImg(imgName,imgPre) {
	if(document.images){
		document.images[imgName].src = eval(imgPre + '.src');
	}
}

function changeStyle(obj, new_style) {
    obj.className = new_style;
}
//Usage example: <td class="featurebox" onmouseover="changeStyle(this,'featureboxover')" onmouseout="changeStyle(this,'featurebox')">
/*
var sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/

function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function decode_email(emailaddress) {
    for (i = 0; i <= emailaddress.length; i++) {
        chr_adjust = -1;
        chr = emailaddress.substring(i,i+1);
        ascii = chr.charCodeAt(0);
        document.write(String.fromCharCode(ascii - chr_adjust));
    }
} 


function dropDownMenu(form) {
	var myindex = form.To.selectedIndex;
	if (myindex == 0) {
		alert("\nPlease select a Department to contact from the drop-down menu.");
		form.To.focus();
		return false;
	} else {
		return true;
   	}
}

function notEmpty(elem) {
	var str = elem.value;
	if(str.length == 0) {
		alert("\nPlease fill in all form fields.");
		//elem.focus(); doesn't do anything
		return false;
	} else {
		return true;
	}

}

function formValidation(form){
	if(dropDownMenu(form)) {
		if(notEmpty(form.Name)){
			if(notEmpty(form.Email)){
				if(notEmpty(form.Company)){
					if(notEmpty(form.Message)){
						return true;
					}
				}
			}
		}
	}
	return false;
}
