//************* default submit button ******************************
var button;
function KeyDownHandler() {if (event.keyCode == 13){if (button) {event.returnValue=false;event.cancel = true;button.click();}}}
function setButton(id) {button = document.getElementById(id)}

//************* Image Rollover Functions ******************************
function switchImage(imgName, imgSrc) {if (document.images) {if (imgSrc != "none"){document.images[imgName].src = imgSrc;}}}
function preloadImages(){if(document.images) {if(!document.imageArray) document.imageArray = new Array(); var i,j = document.imageArray.length, args = preloadImages.arguments; for(i=0; i<args.length; i++){if (args[i].indexOf("#")!=0){document.imageArray[j] = new Image;document.imageArray[j++].src = args[i];}}}}

//************* Miscellaneous Functions *******************************
function printWindow() {if (document.all||document.getElementById) {window.print();}} //display print dialog
function messagebox(id) {var string;if (id==0) {string="Funcionalidade não disponível."};alert(string)} //to be erased
//gets refernece to an object with an id
function getObject(id) {
	if (document.all) {	if (document.all(id)) {return(document.all(id));}if (document.all('op_menu_' + id)) {return(document.all('op_menu_' + id));}}
	if (document.getElementById) {if (document.getElementById(id)) {return(document.getElementById(id));}if (document.getElementById('op_menu_' + id)) {return(document.getElementById('op_menu_' + id));}}
}
//performs de combo box selection navigation
function swapClass(id,clsname){var obj; obj = getObject(id); if (obj) obj.className = clsname;}
//simulates submitt - can delete after for final implementation
function doSubmit(url){if(url){document.forms[0].action=url; document.forms[0].submit();}}
//link out of a popup - URL = navigation to -- type = depth of popup (for consola depth is 2)
function fromPopWin(url,type,close){
	if (type==2) {window.opener.parent.location.href=url;}
	else {window.opener.location.href=url;}
	if (close){window.close();}
}
//Shows a popup window
function showPopup(windowName, windowUrl) 
{
   	var mywidth = 670;
    var myheight = 590;
    var x = (window.screen.availWidth/2) - (mywidth/2);
    var y = (window.screen.availHeight/2) - (myheight/2);
    popup = window.open(windowUrl, windowName, "height=" + myheight + ",width=" + mywidth + ",top=" + y + ",left=" + x + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
//Shows a sized popup
function showSizedPopup(windowName, mywidth, myheight, windowUrl) 
{
    var x = (window.screen.availWidth/2) - (mywidth/2);
    var y = (window.screen.availHeight/2) - (myheight/2);
    popup = window.open(windowUrl, windowName, "height=" + myheight + ",width=" + mywidth + ",top=" + y + ",left=" + x + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function showNewsStory(windowUrl){
	showSizedPopup('newsStory', 536, 400, windowUrl);
}