var x = 0;

$(document).ready(function(){
$("body").prepend('<div id="module"><div id="text-area"></div><div id="moduleclose"><span>Close</span></div></div><div id="moduleshadow"></div>');
	$('.icon').each(function(index,element){
		x=index*50;
		var y = x + 255;
		setTimeout(function(){$(element).animate({'top' : 0},250);},x);
		setTimeout(function(){$(element).animate({'top' : 50});},y);
	});
$('#content').slideDown();

$('.icon').mouseenter(function(){
$(this).stop();
$(this).animate({'top' : 0}).find('span').fadeIn('fast');

});


$('.icon').mouseleave(function(){
$(this).animate({'top' : 50}).find('span').fadeOut('fast');

});
var rh =  $(window).height() - 100;
$('#twitter').click(function(){window.open('http://twitter.com/blazedd');});
$('#facebook').click(function(){window.open('http://facebook.com/blazedd');});
$('#wordpress').click(function(){window.open('http://blog.blazed-designs.com');});
$('#skype').click(function(){responda('skype:blazeddesigns?add','Add Me on Skype');});
$('#gtalk').click(function(){responda('gtalk:chat?jid=blazeddesigns@gmail.com','Add me on Google Talk');});
$('#msn').click(function(){responda('msnim:chat?contact=j_yarbor@hotmail.com','Add me on MSN Live');});
$('#resume').click(function(){
moduleOpen('<h1>My Resum&egrave;</h1><embed src="resume.pdf" width="900" height="'+rh+'"></embed>');
});

$("#module #moduleclose span").click(function(){moduleClose();});
$("#moduleshadow").click(function(){moduleClose();});
$(document).bind('keydown', function(e) {if (e.keyCode == 27){moduleClose();} return true});
	  
$('a[rel="module"]').click( function() {
link = $(this).attr('href');
title = $(this).attr('title');
if(title==''){title=link}
report = link.match(/\..+?$/);
if(report=='.jpg' || report == '.jpeg' || report == '.png' || report == '.gif' || report == '.bmp'){
$('<img />').attr('src',link).load(function(){
 moduleOpen("<h1>"+title+"</h1>", $(this));
});
}else{
$.get(link, function(data) {moduleOpen("<h1>"+title+"</h1>"+data) });
}
return false;
});	
	
	
$(window).bind('resize', function() {
$("#module").css({top:	$(window).scrollTop() + ($(window).height() / 25),
left:	$(window).width() / 2 - ($("#module").width()/2)});
});

}); // end jquery doc ready

function respond(fill){
if($('#fill').is(':visible')){$('#fill').fadeOut();
setTimeout(function(){$('#fill').html(fill).fadeIn();},255)
}else{
$('#fill').html(fill).fadeIn();}
}
function responda(href,title,target){
if(target == 'true'){var targeter = 'target="blank'}else{ var targeter = '';}
var link = '<a href="'+href+'" title="'+title+'" '+targeter+' class="button"><div>'+title+'</div></a>';
$('#fill').html(link).fadeIn();
}



function moduleOpen(html,img){
$("#module #text-area").html(html).append(img);
if(img){$("#module #text-area").css('text-align','center');}
$("#moduleshadow").fadeIn("fast");
$("#module").css({top:	$(window).scrollTop() + ($(window).height() / 25),
left:	$(window).width() / 2 - ($("#module").width()/2)}).fadeIn("fast");
return false;
}



function moduleClose(){
$("#moduleshadow").fadeOut("fast");
$("#module").fadeOut("fast");
setTimeout(function(){$("#module #text-area").empty();$("#module #text-area").css('text-align','left');},200);
return false;
}