//FUNCTION TO OPEN A NEW BROWSER WINDOW
function openWin(url,winname,w,h,scrollbars) {
        topWin = (screen.availHeight - h) / 2;
        leftWin = (screen.availWidth - w) / 2;
		if(scrollbars){
			var scroll = scrollbars;
		}else{
			var scroll = 'yes';
		}
		
                if (navigator.platform.indexOf('mac') != -1){
                	props = "menubar=yes,width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizabe=yes,scrollbars="+scroll+""; 
				}
                else {
                	props = "width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes,scrollbars="+scroll+""; 
				}
        var myWin = window.open(url,winname,props);
        myWin.focus();
}

//FUNCTION TO OPEN A URL IN NEW BROWSER WINDOW
function openURL(url,winname,w,h) { 
	topWin = (screen.availHeight - h) / 2;
	leftWin = (screen.availWidth - w) / 2;
		if (navigator.platform.indexOf('mac') != -1){
	 	props = "menubar=yes,width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes,scrollbars=no"; }
		else {
		props = "width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes,scrollbars=no"; }
	var myWin = window.open(url,winname,props);
	myWin.focus();
}

//FUNCTION TO RESIZE IMAGE POPUPS
function enlargeImg(url,winname,w,h) { 
	self.resizeTo(w,h);
	self.location = url;
}



//FUNCTION TO OPEN MULTIMEDIA TOOL
function multiTool(url) {
	w=1;
	h=1;
	topWin = (screen.availHeight - h) / 2;
	leftWin = (screen.availWidth - w) / 2;
		if (navigator.platform.indexOf('mac') != -1){
	 	props = "menubar=yes,width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes"; }
		else {
		props = "width="+w+",height="+h+",top="+topWin+",screenY="+topWin+",left="+leftWin+",screenX="+leftWin+",resizable=yes"; }
	var myWin = window.open(url,"toolMediate",props);
	myWin.focus();
}

//FUNCTION TO PRINT PAGE	
function printit() {
	if (window.print) window.print();
	else {
		if (navigator.platform.indexOf('Mac') != -1)alert('This function does not work in your browser! \n Please select the Print option from the File menu.');
		else if (navigator.platform.indexOf('Win') != -1)alert('This function does not work in your browser! \n Please right click on your mouse and select the Print option.');
		else alert('This function does not work in your browser!');
	}
}
// END FUNCTION TO PRINT PAGE

// FUNCTION TO CHECK VALID E-MAIL ADDRESS

function checkMail(form)

{
        var email = document.forms['theform'].email.value;
        var fname = document.forms['theform'].fname.value;
        var lname = document.forms['theform'].lname.value;

        // email cannot be null and must follow a certain format
        var distill  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (distill.test(email)) {
        }
        else {
          alert ('Please enter a valid email address');
          form.email.focus();
          return false ;
        }

        // first name cannot be null
    	if(fname == '') {
    		alert('Please enter your first name.')
            form.fname.focus();
    		return false;
    		}

        // last name cannot be null
    	if(lname == '') {
    		alert('Please enter your last name.')
            form.lname.focus();
    		return false;
    		}

        return true;
}
// END FUNCTION TO CHECK VALID E-MAIL ADDRESS

//BEGIN STYLEWRITER
if(navigator.userAgent.indexOf("MSIE 4.5") != -1){
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/mac_ns.css">');
}
else if(navigator.userAgent.indexOf("IE") != -1){
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/ie.css">');
}
else if(navigator.userAgent.indexOf("Mozilla/5") != -1){
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/ie.css">');
}
else if(navigator.userAgent.indexOf("Mac") != -1 && navigator.appName.indexOf("Netscape") != -1){
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/mac_ns.css">');
}
else if(navigator.userAgent.indexOf("Mac") != -1){
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/ie.css">');
}
else{
        document.write('<link rel="stylesheet" href="' + relativeRoot + 'css/ns.css">')
}
//END STYLEWRITER

