$(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);'});
	$("a#close").click(function(){
		$("#overlay").fadeOut('slow');
		$("#promo-wrapper").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);
