/**
 * @author (equ Dj)
 * v. 1.00
 */
 
$( document ).ready(function(){
	
	$('#text').val('scrie aici...');
	$('#text').blur(function(){ 
							 if($(this).val() == ''){
							 	$(this).val('scrie aici...'); 
							 }}).focus(function(){$(this).val('');});	
	$('#info a').click(function(){
								$('#info').fadeOut(550);
								});
	$('#projects').empty();
	
	$.ajax({
		   type:'post',
		   cache:false,
		   dataType:'xml',
		   url:'index.xml',
		   success:function(xml){
					$(xml).find('site').each(function(){
							var name = $(this).attr('title');
							var th = $(this).attr('icon');
							var path= $(this).attr('url');
									  
							$('#projects').append('<li><a target="_blank" href="http://despre.md'+path+'"><img src="'+th+'" />&nbsp;'+name+'</a></li>');
					});


			   },
			error:function(){
				$('#projects').empty().text('An error has occured. Please try again');
				}   
		   });
	
	$('.up a').bind('click',function(){
							  var topval = $('#scroll').css('top');
							  if(parseInt(topval) == 0){$('#scroll').css('top', 0);}
							  else{ $('#scroll').css('top', parseInt(topval)+146); }
							  });
 	$('.down a').bind('click',function(){
							  var topval = $('#scroll').css('top'); //line *80
		  					  var nrli = $('#projects li').size();
							  var k = Math.ceil((nrli / 3))*146; 
							  if(parseInt(topval) == -k){$('#scroll').css('top', -k);}
							  else{ $('#scroll').css('top', parseInt(topval)-146);}
							  });

});

