function popup(url, w, h, s, n) {
	if (!n) n = '_blank';
	attr = 'width=' + w + ',height=' + h + ',location=0,menubar=0,resizable=0,scrollbars=' + s + ',status=0,titlebar=0,toolbar=0,hotkeys=0'
	if (parseInt(navigator.appVersion) >= 4) {
		x = (screen.width - w) / 2
		y = (screen.height - h) / 2
		if(x < 0) x = 0
		if(y < 0) y = 0
		attr += ',xposition=' + x + ',left=' + x + ',yposition=' + y + ',top=' + y
	}
	window.open(url, n, attr)
}

function galleryAddEvent(obj, event, handler) 
{
	var fn = handler;

	if (!obj.attachedEvents)
		obj.attachedEvents = new Array();

	if (obj.attachedEvents[event])
		tagShowRemoveEvent(obj, event);

	obj.attachedEvents[event] = fn;

	if (typeof obj.addEventListener != 'undefined') 
		obj.addEventListener(event, handler, false);
	else if (typeof obj.attachEvent != 'undefined') 
		obj.attachEvent('on' + event, handler);
}


function naviKeydown(e) {
    if (!e) {
        e = window.event;
    }
    var key = e.keyCode;
    if (e.ctrlKey) {
             if (key == 37) {
                 var p = document.getElementById('prev_photo');
                 if (p) {
                     location.href = p.href;
                 }
             } else if (key == 39) {
                 var n = document.getElementById('next_photo');
                 if (n) {
                     location.href = n.href;
                 }
             }
    }

}

