var atime = 1;

function more_file_alb() {

	if(atime+1 <= 6) {
		
	atime++;
	count++;

	var photos = document.getElementById("photos");
	var br = document.createElement("br");
	var span = document.createElement("span");
	var input = document.createElement("input");
	var text = document.createTextNode(count + ". ");

	br.setAttribute("id","br" + count);
	span.setAttribute("id","span" + count);
	input.setAttribute("id","file" + count);
	input.setAttribute("type","file");
	input.setAttribute("name","file" + count);

	photos.appendChild(br);
	photos.appendChild(span);
	span.appendChild(text);
	photos.appendChild(input);
	
	slowShow("#br" + count,500);
	slowShow("#span" + count,500);
	slowShow("#file" + count,500);
	slowShow("#text" + count,500);
	
	document.getElementById("photo").setAttribute("value",count);
	
	}

}

function less_file_alb() {

	document.getElementById("photos").removeChild(	document.getElementById("br" + count)	);
	document.getElementById("photos").removeChild(	document.getElementById("span" + count)	);
	document.getElementById("photos").removeChild(	document.getElementById("file" + count)	);
	
	count--;
	atime--;
	
	document.getElementById("photo").setAttribute("value",count);

}

function album() {

	var nome = document.getElementById("nome");
	var warning = document.getElementById("warning");
	var warning2 = document.getElementById("warning2");
	var result = true;
	
	if(nome.value == "") {
		document.getElementById("warning").setAttribute('style','display: none');
		slowShow("#warning2",1000);
		result = false;
	}
	else {
		document.getElementById("warning2").setAttribute('style','display: none');
		slowShow("#warning",1000);
	}

	return result;

}

/* js */

function links(id) {
	var link = document.getElementById(id).getElementsByTagName("a");
	for (var i = 0; i < link.length; i++)
		link[i].setAttribute("target","_blank");
}

function slowShow(x,y) { $(x).hide(); $(x).hide(function(){$(x).fadeIn(y); return false;}); }

$(function(){
$("#navigation a").not(".active").hover(
    function(){$("span",this).fadeIn("slow");},
    function(){$("span",this).fadeOut('fast');});
});

$(document).ready(function() {

	$("#contact textarea").css('resize','none');

	$("a[rel=p]").fancybox({
			'opacity'			: true,
			'overlayShow'		: true,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'titlePosition'		: 'outside',
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.75,
			'titleFormat'		: function() { return ''; }
		});

	if(document.getElementById("cssdesignawards-small")!=undefined)links("cssdesignawards-small");

	$(".gallery").stop().animate({"opacity": "1"}, "slow");
	$(".gallery").hover(
		function() {
			$(this).stop().animate({"opacity": "0.3"}, "slow");
		},
		function() {
			$(this).stop().animate({"opacity": "1"}, "slow");
		}
	);
	
	$(".gallery2 a").not(".photo").stop().animate({"opacity": "1"}, "slow");
	$(".gallery2 a").not(".photo").hover(
		function() {
			$(this).stop().animate({"opacity": "0.3"}, "slow");
		},
		function() {
			$(this).stop().animate({"opacity": "1"}, "slow");
		}
	);
	
//	$("a[rel^='prettyPhoto']").prettyPhoto();

    $('#box').cycle({
		fx: 'fade',
		timeout: 5000,
		next: '#box'
	});

	if (document.getElementById("login") != undefined)
		slowShow("#login",3000);
	if (document.getElementById("content") != undefined)
		slowShow("#content",2000);
	if (document.getElementById("footer") != undefined)
		slowShow("#footer",500);
	
	if (document.getElementById("social") != undefined)
		links("social");
		
	if (document.getElementById("nav_port") != undefined)
		document.getElementById("nav_port").getElementsByTagName("a")[0].setAttribute('onclick','return false');
		
	/* admin */
	
	if (
		document.getElementById("more_alb") != undefined &&
		document.getElementById("less_alb") != undefined
		) {
	document.getElementById("more_alb").onclick = more_file_alb;
	document.getElementById("less_alb").onclick = less_file_alb;
	}

});
