$(document).ready(function(){
 $('#head h1').click(function(){
  location.href = '/';
  });
  
  $('#pronto-publications ul li').each(function(){
  	img = $(this).find('img');
  	$(this).find('.image-bw').width(img.width()).height(img.height());
  	$(this).mouseover(function(){  		
  		if ($(this).hasClass('playing')) {
  			return;
  		}
  		$(this).removeClass('mouse-out').addClass('playing');
  		$(this).find('.image-bw').animate({"opacity":1}, 800, function(){
  			$(this).parent().removeClass('playing');
  			//alert(this.tagName);
  			if ($(this).parent().hasClass('mouse-out')) {  				
  				$(this).animate({"opacity":0}, 800, function(){
  					$(this).parent().removeClass('mouse-out');
  				});
  			}
  		}); 		
  		
  	}).mouseout(function(event){
  			event = window.event ? window.event : event;
            target = event.target ? event.target : event.srcElement;
            
  			if (target.tagName != 'DIV') {
  				return;
  			}
  			//alert(this.tagName);
  			if ($(this).hasClass('playing')) {  				
  				$(this).addClass('mouse-out');
  			} else {
  				
  				$(this).find('.image-bw').animate({"opacity":0}, 800, function(){
  					
  					$(this).parent().removeClass('playing');
  				});
  			}
  		}).click(function(){
  		//	alert($(this).find('a').attr('href'));
                        if ($(this).find('a').attr('href')=='') return false;
  			new_win = window.open($(this).find('a').attr('href'),"_blank","");

                        //qqq.location.href = $(this).find('a').attr('href');
                        //return true;
  		}); 
  });
  
  $('#nc-add-form .fields .more a').click(function(){
  		oneShowed = false;
  		counter = 0;
		$('#nc-add-form .fields .files').find('.file').each(function(){
			counter++;
			if (!oneShowed) {
				$(this).show().removeClass('file').addClass('added');
				$(this).parent().css('height',(parseInt($(this).parent().css('height'))+20)+'px');
				oneShowed = true;
			}			
		});			
		
		if (counter == 1){
			$(this).parent().parent().remove();
		}			
	});
 });

 
 function ge(e){
 	return document.getElementById(e); 
 }
 
function createOption(n, v, s){
	o = createElementE('option', {'text' : n, 'value' : v});
	if (s)
		o.selected = true;
	return o;
}
 
function is_object (_var){
    return typeof _var == 'object';
}
function createElementE(t, a, s){
    el = document.createElement(t);

    if(is_object(a))
        for(_a in a)
            el[_a] = a[_a];

    if(is_object(s))
        for(_s in s)
            el.style[_s] = s[_s];

    return el;
}

