/*
$Id: js_functions.inc.js 2885 2007-09-17 23:31:05Z fesh $
*/
function popup_image(image_url, title) {
	var winl = (screen.width - 200)/2;
	var wint = (screen.height - 300)/2;
	var settings ='top='+wint+',';
	settings +='left='+winl+',';
	settings +='width=200, ';
	settings +='height=300, ';
	settings +='scrollbars=no,';
	settings +='resizable=yes';

	title = title.replace(/\s/g, '%20');

	win=window.open('/image_popup.php?image_url='+image_url+'&title='+title, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function popup_gallery(g, i, w, h) {
	var winl = (screen.width - 700)/2;
	var wint = (screen.height - 500)/2;
	var settings ='top='+wint+',';
		settings +='left='+winl+',';
		settings +='width=700, ';
		settings +='height=500, ';
		settings +='scrollbars=no,';
		settings +='resizable=yes';

	win=window.open('/gallery_popup.php?g='+g+'&i='+i+'&w='+w+'&h='+h, 'image',settings);

	if(parseInt(navigator.appVersion) >= 4) {
	   win.window.focus();
	}
}

/* preload images */
if (document.images) {
	var spacerOn = new Image();
	spacerOn.src = "images/spacer.gif";
}

Element.addMethods({
  wrap: function(element, tagName) {
    element = $(element);
    var wrapper = document.createElement(tagName);
    element.parentNode.replaceChild(wrapper, element);
    wrapper.appendChild(element);
    return Element.extend(wrapper);
  }
});

Event.observe(window, "load", function() {
	$$(".modal").each(function(i) { 
		new Control.Modal(i, {iframe: true, width: 380, height: 210, opacity: 0.5});
	});
	$$('hr').each(function(i) {
		i.wrap('div').addClassName('hr');
	});
	
	var req = new Ajax.Request("/news_by_ajax.php", { method: 'get', asynchronous: false });
	var news = eval(req.transport.responseText);
	var news2go = '<ul>';
	for (i = 0; i < news.length; i++)
		news2go += '<li>' + news[i].image_caption + '</li>';
	news2go += '</ul>';
	$('newsticker').innerHTML = news2go;
	
	new at.bartelme.newsticker();
});

if (top.location!= self.location) {
top.location = self.location.href
}