function expand(frameposX,frameposY)
	{
	rand1=Math.round((Math.random()-0.5)*10);
	rand2=Math.round((Math.random()-0.5)*10);
	rand3=Math.round((Math.random()-0.5)*10);
	$("#cloudbig").stop(true,true).animate({top:frameposY-75, left:frameposX+200, width:258, height:197},300,function()
			{
			$("#cloudbig").animate({top:frameposY-70, left:frameposX+205, width:248, height:187},100);
			});
	$("#cloudsmall3").stop(true,true).animate({top:frameposY+40+rand1, left:frameposX+200+rand2, width:36, height:26},300);
	$("#cloudsmall2").stop(true,true).animate({top:frameposY+35+rand3, left:frameposX+175+rand1, width:22, height:17},300);
	$("#cloudsmall1").stop(true,true).animate({top:frameposY+30+rand3, left:frameposX+165+rand2, width:15, height:13},300);
	}
function expand2(frameposX,frameposY)
	{
	rand1=Math.round((Math.random()-0.5)*5);
	rand2=Math.round((Math.random()-0.5)*5);
	rand3=Math.round((Math.random()-0.5)*5);
	$("#cloudbig").stop(true,true).animate({top:frameposY+70, left:frameposX+0, width:258, height:197},300,function()
			{
			$("#cloudbig").animate({top:frameposY+75, left:frameposX+5, width:248, height:187},100);
			});
	$("#cloudsmall3").stop(true,true).animate({top:frameposY+55+rand1, left:frameposX+160+rand2, width:36, height:26},300);
	$("#cloudsmall2").stop(true,true).animate({top:frameposY+40+rand3, left:frameposX+175+rand1, width:22, height:17},300);
	$("#cloudsmall1").stop(true,true).animate({top:frameposY+30+rand3, left:frameposX+165+rand2, width:15, height:13},300);
	}
function contract(frameposX,frameposY)
	{
	$("#cloudbig").stop(true,true).animate({top:frameposY+58, left:frameposX+160, width:0, height:0},500);
	$("#cloudsmall3").animate({top:frameposY+58, left:frameposX+160, width:0, height:0},1000);
	$("#cloudsmall2").animate({top:frameposY+58, left:frameposX+160, width:0, height:0},800);
	$("#cloudsmall1").animate({top:frameposY+58, left:frameposX+160, width:0, height:0},600);
	}
function magnetanimation()
	{
	$("#magnet1").fadeOut(1000,function()
		{
		$("#magnet1").fadeIn(3000);
		});
	}
function showBizCard()
	{
	$("#designedby").css({"z-index":101});
	$("#bizcard").stop(true,true).animate({width:432},300,function()
		{
		$("#bizcard").animate({width:422},100);
		});
	}
function hideBizCard()
	{
	$("#designedby").css({"z-index":5});
	$("#bizcard").stop(true,true).animate({width:0},300);
	}
	
function openEnvelope()
	{
	$("#envelope").animate({left:0,bottom:0},600,function()
		{
		$("#envelopetopclosed").animate({width:435, height:0},300,function()
			{
			$("#envelopetopopen").animate({width:436, height:173, top:-164},300,function()
				{
				$("#mailtop").animate({bottom:300},500);
				$("#mailback").animate({bottom:297},500,function()
					{
					$("#mailback").css({"z-index":141});
					$("#mailtop").css({"z-index":140});
					$("#mailbottom").css({"z-index":142});
					$("#mailback").animate({bottom:207},300);
					$("#mailtop").animate({bottom:210},300,function()
						{
						$("#mailback").animate({width:410, height:0},300,function()
							{
							$("#mailbottom").animate({height:270, bottom:-60},300,function()
								{
								$("#mailtovladform").show();
								$("#trimite, #inchide").fadeTo(300,0.1);
								});
							});
						});
					});
				});
			});
		});

	}
	
function closeEnvelope(trimite)
	{
	$("#mailtovladform").fadeOut(100);
	$("#mailbottom").animate({height:0, bottom:250},300,function()
		{
		$("#mailback").animate({width:410, height:256},300,function()
			{
			$("#mailtop").animate({bottom:300},500);
			$("#mailback").animate({bottom:297},500,function()
				{
				$("#mailback").css({"z-index":131});
				$("#mailtop").css({"z-index":130});
				$("#mailbottom").css({"z-index":132});
				$("#mailtop").animate({bottom:5},500);
				$("#mailback").animate({bottom:5},500,function()
					{
					$("#envelopetopopen").animate({width:436, height:0, top:3},300,function()
						{
						$("#envelopetopclosed").animate({width:435, height:172},300,function()
							{
							if (trimite) animateTrimite();
							else animateInchide();
							});
						})
					});
				});
			});
		});

	}
	
function animateTrimite()
	{
	$.post("assets/scripts/sendmailtovlad.php",$("#mailtovladform").serializeArray());
	$("#seseal").fadeIn(1000,function()
		{
		$("#envelope").animate({left:100, bottom:1500},1500,function()
			{
			$(this).css({"bottom":"350px","left":"-1000px"});
			$("#seseal").hide();
			showMailCloud();
			});
		});
	}
	
function animateInchide()
	{
	$("#envelope").animate({left:-1000, bottom:350},600);
	}
	
function showMailCloud()
	{
	$("#mailcloud").fadeIn(1000, function()
		{
		setTimeout("$('#mailcloud').fadeOut(1000)",4000);
		});
	}
////////////////////////
$(document).ready(function()
	{
	setInterval('magnetanimation()',6000);
	$("#trimite, #inchide").hide()
	$("#navdece").hover(function()
		{
		expand(-29,49);
		$("#textdece").fadeIn(1000);
		},function()
		{
		contract(-29,49);
		$("#textdece").stop(true,true).hide();
		});
	$("#navunde").hover(function()
		{
		expand(-40,102);
		$("#textunde").fadeIn(1000);
		},function()
		{
		contract(-40,102);
		$("#textunde").stop(true,true).hide();		
		});
	$("#navcand").hover(function()
		{
		expand(-39,155);
		$("#textcand").fadeIn(1000);
		},function()
		{
		contract(-39,155);
		$("#textcand").stop(true,true).hide();
		});
	$("#navcat").hover(function()
		{
		expand(-52,208);
		$("#textcat").fadeIn(1000);
		},function()
		{
		contract(-52,208);
		$("#textcat").stop(true,true).hide();
		});
	$("#navce").hover(function()
		{
		expand(-59,261);
		$("#textce").fadeIn(1000);
		},function()
		{
		contract(-59,261);
		$("#textce").stop(true,true).hide();
		});
	$("#navcine").hover(function()
		{
		expand(-42,314);
		$("#textcine").fadeIn(1000);
		},function()
		{
		contract(-42,314);
		$("#textcine").stop(true,true).hide();
		});
	$("#navevenimentese").hover(function()
		{
		expand2(610,7);
		$("#textevenimentese").fadeIn(1000);
		},function()
		{
		contract(610,7);
		$("#textevenimentese").stop(true,true).hide();
		});
	$("#navevenimentelatino").hover(function()
		{
		expand2(770,7);
		$("#textevenimentelatino").fadeIn(1000);
		},function()
		{
		contract(770,7);
		$("#textevenimentelatino").stop(true,true).hide();
		});
	$("#navdanslaevenimente").hover(function()
		{
		expand(-22,387);
		$("#textdanslaevenimente").fadeIn(1000);
		},function()
		{
		contract(-22,387);
		$("#textdanslaevenimente").stop(true,true).hide();
		});
	$("#navvalsulmirilor").hover(function()
		{
		expand(-45,440);
		$("#textvalsulmirilor").fadeIn(1000);
		},function()
		{
		contract(-45,440);
		$("#textvalsulmirilor").stop(true,true).hide();
		});
	$("#navpentrucopii").hover(function()
		{
		expand(-40,493);
		$("#textpentrucopii").fadeIn(1000);
		},function()
		{
		contract(-40,493);
		$("#textpentrucopii").stop(true,true).hide();
		});
	$("#gototop").hover(function()
		{
		$("#uparrow").stop(true,true).animate({bottom:130},300,function()
			{
			$("#uparrow").animate({bottom:114},300,function()
				{
				$("#uparrow").animate({bottom:123},250,function()
					{
					$("#uparrow").animate({bottom:114},180,function()
						{
						$("#uparrow").animate({bottom:119},120,function()
							{
							$("#uparrow").animate({bottom:114},70);
							});
						});
					});
				});
			});
		},function()
			{
			$("#uparrow").stop(true,true).css("bottom","114px")
			});
	$("#designedby").hover(showBizCard,hideBizCard);
	$("#mailtovlad").click(function()
		{
		openEnvelope();
		return false;
		});
	$("#trimite, #inchide").click(function()
		{
		if ($(this).attr("id")=="trimite") trimite=1;
		else trimite=0;
		closeEnvelope(trimite);
		return false;
		});
	$("#trimite, #inchide").hover(function()
		{
		$(this).stop(true,true).fadeTo(300,1);
		},function()
		{
		$(this).stop(true,true).fadeTo(300,0.2);
		});
	});
