var rollover = function() {
    if (!document.getElementById) return;

    var imgOriginSrc;
    var imgTemp = new Array();
    var imgarr = document.getElementsByTagName('img');

    for (var i = 0; i < imgarr.length; i++) {
        if (imgarr[i].getAttribute('longdesc')) {
            imgTemp[i] = new Image();
            imgTemp[i].src = imgarr[i].getAttribute('longdesc');
            imgarr[i].onmouseover = function() {
                imgOriginSrc = this.getAttribute('src');
                this.setAttribute('src',this.getAttribute('longdesc'))
            }
            imgarr[i].onmouseout = function() {
                this.setAttribute('src',imgOriginSrc)
            }
        }
    }
};

var pop = function(url, wd, width, height) {
	// var windowOpen = open(url,"schedule",'center=yes,scrollbars=yes,resizable=yes,status=no,width=430,height=370');

	winwidth = width; // width of the new window
	winheight = height; // height of the new window
	winleft = (screen.width / 2) - (winwidth / 2); // center the window right to left
	wintop = (screen.height / 2) - (winheight / 2); // center the window top to bottom

	// the values get inserted into the features parameter of the window.open command...
	window.open(url, wd, 'top=' + wintop + ',left=' +
		winleft + ',height=' + winheight +  ',width=' + winwidth + ',scrollbars=yes,resizable=yes,status=no');

    return false;
};

var hook_popups = function() {
    $('.popup').click(function() {
        pop($(this).attr('href'), 'popup', 700, 500);
        return false;
    });
};

$(function() {
    rollover();
    hook_popups();
});
