
// -------------------------------------------
// When DOM is loaded
// -------------------------------------------
$(document).ready(function(){

	/* Add padding to top and bottom of top-nav menus */
	$(".sf-menu ul").each(function() { 
		$(this).children(":first").css("padding-top","3px");
		$(this).children(":last").css("padding-bottom","4px");
	});
	
});

// -------------------------------------------
// Image rollovers for Left Nav
// -------------------------------------------

function showMenu(event) {
    var img=(event.srcElement)?event.srcElement:event.target;
	var filepath = $(img).attr('src').split('/');
	var filename = filepath[5].split('.');
	var newpath = "http://www.pozen.com/" + filepath[3] + "/" + filepath[4] + "/" + filename[0] + "_on.gif";
	$(img).attr('src',newpath);
}

function hideMenu(event) {
    var img=(event.srcElement)?event.srcElement:event.target;
	var filepath = $(img).attr('src').split('/');
	var filename = filepath[5].split('.');
	filename = filename[0].split('_');
	filename = filename[0] + "_" + filename[1];
	var newpath = "http://www.pozen.com/" + filepath[3] + "/" + filepath[4] + "/" + filename + ".gif";
	$(img).attr('src',newpath);
}

// -------------------------------------------
// Functions called by the calendar and search pages
// -------------------------------------------

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
		// MSIE 4 DOM
		return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } else {
		return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
		styleObject.visibility = newVisibility;
		return true;
    } else {
		// we couldn't find the object, so we can't change its visibility
		return false;
    }
} // changeObjectVisibility

function changeObjectDisplay(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
		styleObject.display = newVisibility;
		return true;
    } else {
		// we couldn't find the object, so we can't change its visibility
		return false;
    }
} // changeObjectDisplay

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
		if (document.layers) {
			styleObject.left = newXCoordinate;
			styleObject.top = newYCoordinate;
		} else if (document.getElementById || document.all) {
			styleObject.left = newXCoordinate + "px";
			styleObject.top = newYCoordinate + "px";
		}

	return true;
    } else {
		// we couldn't find the object, so we can't very well move it
		return false;
    }
} // moveObject

function togglepanel(elm) {
	var obj = document.getElementById(elm);
	if (!obj) return;
	obj.style.display = (obj.style.display=="none")?"":"none";
	return false;
}


// -------------------------------------------
// Utilities
// -------------------------------------------

var popupwin=null;
function popup(href,options) {
	if (!options) options="width=500,height=500,resizeable=no,scrollbars=yes,status=no,toolbar=no";
	var popupwin=window.open(href,"popupwin",options);
	popupwin.focus();
	return false;
}

function fix_ie_objects() {
	var objects=document.getElementsByTagName("object");
	for (var i=0;i<objects.length;i++) objects[i].outerHTML = objects[i].outerHTML;
}

	

