$(document).ready(function() {

$('#element_info').corner({tl: { radius: 30 }, tr: { radius: 30 }, bl: { radius: 30 }, br: { radius: 30 }});
$('#close_element_info').corner();

$('.open_element').click(function(){	
	var fileName = $(this).parents("tr").attr('id');
	var listTypes = new Array('air_list', 'earth_list', 'fire_list', 'water_list');
	var dirTypes = new Array('air_elements', 'earth_elements', 'fire_elements', 'water_elements');
	var dirType = '';
	for (var i = 0; i < listTypes.length; i++){
   		if ($('#resources_elements_list').hasClass(listTypes[i]))
			dirType = dirTypes[i];	
	}	
	if (!fileName || !dirType) return;	
	var fileFullPath = window.location.protocol  + '//' + window.location.host + '/resources/' + dirType + '/' + fileName + '.html';
	
	$('#element_info_cont').show();
	
	var contHeight = $('#element_info_cont').innerHeight();		
	var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	if (isIE6) contHeight = document.documentElement.clientHeight ;

	var popupHeight = contHeight*0.85;
	y = $(window).scrollTop() + (contHeight - popupHeight)/2;
	$('#element_content').css({'background' : '#FFF url(../images/loading.gif) no-repeat center fixed' , 'height' : popupHeight*0.94 + 'px'});	
	$('#element_info').css({'top' : y+'px' , 'height' : popupHeight+'px'}).fadeIn(1000, function(){
		$.ajax({
			   type: "GET",
			   url: (fileFullPath),		  
			   success: function(data){	
					$('#text_cont').css('height' , popupHeight*0.94 + 'px').html(data);
					$('#text_cont').fadeIn(1000, function(){
						$('#element_content').css({'background' : '#FFF'});									  
					});			
			   }		 
			 });
	});	
	return false;
});		

$('#close_element_info').mouseover(function(){
      $(this).css('color','red');
	  $(this).css('border-color','red');
}).mouseout(function(){
       $(this).css('color','#000');
       $(this).css('border-color','#000');	   
});

$('#close_element_info').click(function(){	
	$('#element_info_cont').fadeOut(600, function(){		
		$('#element_info').hide();
		$('#text_cont').empty().hide();												   
	});	

});

});