/* $(document).ready(function(){
	$("a.popup").each(function(){
		$myHref = $(this).attr('rel');
		$(this).attr({'rel': $(this).attr('href')}); // Set 'rel' to current 'href'

		$(this).click(function(){
			window.open($(this).attr('rel'), "popup", "status = 1, width = 600, height=600, status=1, scrollbars=1, resizable=1, left = 100, scrollbars = 1");
			return false;
		});
	});
});
*/

$(document).ready(function(){
	$("a.popup").each(function(){ // For each popup link,
		$(this).attr({'rel': $(this).attr('href')}); // Set 'rel' to current 'href',
		$(this).attr({'href': 'javascript:void(0);'}); // and change the href to anchor to the top of the popup div.
	});
	$("#popup .close").attr({'href': 'javascript:void(0);'});
});
$(document).ready(function(){
	$("a.popup").click(function(){
		$popup = $("#popup");
		$this = $(this); // Capture current anchor.
		var alt = $(this).attr('title');
		$("#popup p strong").text( alt );
		$("#popup p img").attr({'src': $this.attr('rel')});
		$(this).addClass("visited");
		$popup.fadeIn('slow');
	});
	$("#popup .close").click(function(){
		$("#popup").fadeOut('slow');
	});
});

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

function doPopups() {
   if (!document.getElementsByTagName) return false;
   var links = document.getElementsByTagName("a");
   for (var i=0; i < links.length; i++) {
	 if (links[i].className.match("popup_teaser")) {
       links[i].onclick = function() {
         window.open(this.href, "", "top=300,left=400,width=230,height=220");
         return false;
       }
     }
   }
 }

addEvent(window, "load", doPopups);
