// JavaScript Document 
$(document).ready(function(){  


		
	$('.popupButton').hoverIntent(function() {
		//$(this).delay(200)
		var btnvalue =  $(this).attr("id");  
		var divValue =  ("#" + btnvalue); 
		var imgSrc = 	(btnvalue) + ".png"
		var imgPath =   "<img src=" +'"projects/skills/' + imgSrc +'"/>';
		var xmlSrc =    (btnvalue) + ".xml" 
		var xmlPath =   "projects/xml/" + xmlSrc; 

		$.ajax({
			type: "GET",
			url: xmlPath,
			dataType: "xml",
			success: function(xml) {
				$(xml).find('index').each(function(){
	 
					var paragraph1 = $(this).find('paragraph1').text();
                    var html = '<div id="popup">';
					html +=	   '<img src="projects/skills/' + imgSrc +'"/>'; 
					html +=	   '<div class="xmldoc">' + paragraph1 + '</div>'; 
					html +=		'</div>';
					$(divValue).append(html).children('#popup').hide().fadeIn(200);
					$('#popup').center();//.delay(200);
				});
			}
		});
	}, function() {
		$('#popup').remove();
	});
	
	$('.popupButton').click(function() { 
		$('#popup').remove();
		return false;
	});
}); 

jQuery.fn.center = function () {  
    this.css("position","absolute");  
    this.css("top", ( $(window).height() - this.height() ) / 1.50+$(window).scrollTop() + "px");  
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");  
    return this;  
}
