// JavaScript Document
var ecommerce 	= new Array,
	brand		= new Array,
	blasts		= new Array;

function moveImg(){
	var coords = $('portfolio').cumulativeScrollOffset();
	var newtop = coords.top + 150 + 'px';
	var newwidth = ((document.viewport.getWidth()/2) - 375 ) + 'px';
	$('popup').setStyle({ top:newtop, left:newwidth });
}

function showPopE(e,HDkey){
	moveImg();
	Event.stop(e);
	
	$('popup').show();
	$('fade').show();
	$('popup_content').innerHTML = '<img src="../img/ecommerce_large_'+ HDkey +'.jpg" alt="ecommerce '+ HDkey +'" />';
}
function showPopB(e,HDkey){
	moveImg();
	Event.stop(e);
	
	$('popup').show();
	$('fade').show();
	$('popup_content').innerHTML = '<img src="../img/brand_large_'+ HDkey +'.jpg" alt="brand site '+ HDkey +'" />';
}
function showPopBl(e,HDkey){
	moveImg();
	Event.stop(e);
	
	$('popup').show();
	$('fade').show();
	$('popup_content').innerHTML = '<img src="../img/blasts_large_'+ HDkey +'.jpg" alt="email blast '+ HDkey +'" />';
}
function closePop(e){
	Event.stop(e);
	
	$('popup').hide();
	$('fade').hide();
}
function initialize(){
	ecommerce = $$('a.ecommerce');
	ecommerce.each(
				function(e,index){
					Event.observe(e, 'click', function(e){ showPopE(e,index); }, false);
				}
	);
	brand = $$('a.brand');
	brand.each(
				function(e,index){
					Event.observe(e, 'click', function(e){showPopB(e,index); }, false);
				}
	);
	blasts = $$('a.blasts');
	blasts.each(
				function(e,index){
					Event.observe(e, 'click', function(e){ showPopBl(e,index); }, false);
				}
	);
	if ($('close_pop') != null){Event.observe('close_pop', 'click', closePop, false)};
	//var newwidth = (document.viewport.getHeight) + 'px';
	//$('fade').setStyle({ height:newwidth });
}
//Event.observe(window, 'load', initialize);
Event.observe(document, 'dom:loaded', initialize);
