	// JavaScript Document
	var dbProjekt = 0;
	var wpWidth	  = 960;
	var wpHeight  = 500;
	var dbPrevImages = 0;
	var aktPrevImg   = 1;
	var idozito;

	/* -------------------------------------------------------------------------------------------- */
	/* - JQuery - */
	/* -------------------------------------------------------------------------------------------- */
	$(document).ready(function(){
		$("a").tipTip({defaultPosition: "bottom", maxWidth: "auto", edgeOffset: 10});
		$(".readonly").attr("disabled","disabled");
		
		var hx = $("header").position();
		
		$("#sections-tunnel").css("left",hx.left+"px");
		
		if($.support.transform){
			$("img.tabla").delay(1000).animate({rotate:"1080deg",left:"-5px"}, 1000);
		}
		
		$("a.preview").hover(
			function(){
				$(this).find("img").fadeIn(800);
			}, function(){
				$(this).find("img").fadeOut(200);
			}
		);
		
		$("a.nav-main-menu, a.ajanlat").live('click', function(){
			var n 	 = $(this).attr("data-kd-section");
			var obj  = $("#s" + n).position();
			var hova = hx.left - obj.left;
			
			clearTimeout(idozito);
			$("#sections-tunnel").animate({left:hova+"px"}, 1500, "easeInOutQuint");
		});
		
		// Szolgáltatások
		$("#aServices").live('click', function(){
			var n 	 = $(this).attr("data-kd-section");
			var obj  = $("#s" + n).position();
			var hova = hx.left - obj.left;
			
			clearTimeout(idozito);
			$("#serv-design").css("opacity",0);
			$("#serv-graphics").css("opacity",0);
			$("#sections-tunnel").animate({left:hova+"px"}, 1500, "easeInOutQuint",
					function(){
						$("#serv-design").animate({opacity:1},1500, 
							function(){
								$("#serv-graphics").animate({opacity:1},2000);
							}
						);
					}
			);
		});// Szolgáltatások
		
		// Meló
		$("#aMelo").live('click', function(){
			var n 	 = $(this).attr("data-kd-section");
			var obj  = $("#s" + n).position();
			var hova = hx.left - obj.left;
			
			//$("#serv-design").css("opacity",0);
			//$("#serv-graphics").css("opacity",0);
			clearTimeout(idozito);
			$("div.thumbs").css("opacity",0);
			$("div.thumbs").css("width","60px");
			$("div.thumbs").css("height","60px");
			$("div.thumbs").css("left","450px");
			$("div.thumbs").css("top","-80px");
			$("#thumb-details").css("display","none");
			
			$("#sections-tunnel").animate({left:hova+"px"}, 1500, "easeInOutQuint",
					function(){
						/*$("img.kd-pointer").css("left","50px");
						$("img.kd-pointer").css("top","50px");
						$("img.kd-pointer").animate(
							{	left:"465px",
								top: "255px"
							},1500, 
							function(){
								$("img.start-btn").animate(
									{	left: "352px",
										top:  "142px"
									}, 800,
									function(){
										$("img.start-btn").css("left","350px");
										$("img.start-btn").css("top","140px");
										*/
										mTop  = 20;
										mLeft = 10;
										db    = 0;
										for(i=0; i<dbProjekt; i++){
											j = i + 1;
											ido = 500 + i*100;
											if(db==6){
												db = 0;
												mTop += 160;
												mLeft = 10;
											}
											$("#thumb-"+j).delay(ido).animate(
																		{top:mTop+"px",
																		 left:mLeft+"px",
																		 width:"158px",
																		 height:"158px",
																		 opacity:1
																		}, 500
											);
											mLeft += 160;
											++db;
										}//for
									//}
								//);//animate btn
							//}//function
						//);//animate pointer
					}//function
			);
		});// Meló
		
		$("a.index-link").hover( 
				function(){
					$(this).find("img:first").animate({opacity:1},800);
					$(this).find("span:first").animate(
						{bottom:0,
						 height:"50%"
						},800);
				},
				function(){
					$(this).find("img:first").animate({opacity:0.5},1000);
					$(this).find("span:first").animate(
						{bottom:"-200px",
						 height:"auto"
						},800);
				}
		);
		
		$("a.index-link").live('click',function(){
			var thisPosition = $(this).parent().parent().position();
			var meloID = $(this).attr("data-kd-id");
			
			$("#thumb-details").css("display","none");
			$("#thumb-details").css("width","158px");
			$("#thumb-details").css("height","158px");
			$("#thumb-details").css("left",thisPosition.left+"px");
			$("#thumb-details").css("top",thisPosition.top+"px");
			$("#thumb-details").html("<img src='images/loading-b.gif' width='16' height='16' alt='' class='loader' /><a id='aCloseMini' href='#bezar' title=''>Bezár</a>");
			
			$("#thumb-details").fadeIn(800, function(){
				var param = "id=" + meloID;
				aktPrevImg = 1;
				setThumbPosition(thisPosition.left, thisPosition.top);
				$.ajax({
					type: "post",
					url:  "getMelo.php",
					data: param,
					error: function(jqXHR, textStatus, errorThrown){
						$("#thumb-details").html("<div class='behuzas20'><span class='info'>"+textStatus+"</span></div><a id='aCloseMini' href='#bezar' title=''>Bezár</a>");
					},
					success: function(data){
						$("#thumb-details").html(data);
						$("a[rel=kiskep]").fancybox({
							'width'			: '95%',
							'height'		: '95%',
							'transitionIn'	: 'elastic',
							'transitionOut'	: 'elastic',
							'titlePosition' : 'over',
							'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
								return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
							}
						});
					}
				})
			});//thumb-details
		});//a.index-link
		
		$("ul.melo-valaszto a").live('click', function(event){
			event.preventDefault();
			var tipus = $(this).attr("href");
			
			$("ul.melo-valaszto a").removeClass("aktiv");
			$(this).addClass("aktiv");
			
			if(tipus=="#/melo/all/"){
				$("a.index-link").children("img.felho").animate({opacity:0},800);
			}else{
				if(tipus=="#/melo/web/"){
					$("a.grafika").children("img.felho").animate({opacity:1},800);
					$("a.web").children("img.felho").animate({opacity:0},800);
				}else{
					$("a.web").children("img.felho").animate({opacity:1},800);
					$("a.grafika").children("img.felho").animate({opacity:0},800);
				}
			}
		});
		
		$("#aCloseMini").live('click',function(){
			clearTimeout(idozito);
			$("#thumb-details").fadeOut(800);
		});
		
		//Ajánlat kérése
		$("#aSender").live('click',function(){
			$("#senderInfo").html("&nbsp;&nbsp;<img id='imgAjanlatLoader' src='images/loading-b.gif' width='16' height='16' alt='Loader' />&nbsp;&nbsp;Kérem várjon...");
			$("#senderInfo").fadeIn(800,
					function(){
						$.ajax({
							type: "post",
							url: "send.php",
							data: $("#ajanlat_form").serializeArray(),
							cache: false,
							success: function(data, textStatus){
										$("#senderInfo").html(data);
										setTimeout("$('#senderInfo').fadeOut(800)", 5000);
									 },
							error:  function(jqXHR, textStatus, errorThrown){
										$("#senderInfo").html(textStatus);
									}
						});
					}
			);
		});//aSender
		
		var kdSection = document.location.hash;
		//console.log(kdSection.substring(2,3));
		var obj  = $("#s" + kdSection.substring(2,3));
		if(obj.length!=0){
			var objPos  = obj.position();
			var hova = hx.left - objPos.left;
			$("#sections-tunnel").animate({left:hova+"px"}, 800,
				function(){
					if(kdSection=="#/4/"){
						$("#aMelo").click();
					}
				}
			);
		}
		
	});
	
	function setThumbPosition(x,y){
		var tWidth  = wpWidth;
		var tHeight = wpHeight - 20;
		var tLeft   = 10;
		var tTop    = 20;
		
		$("#thumb-details").animate({
			left: tLeft+"px",
			top:  tTop+"px",
			width: tWidth+"px",
			height: tHeight+"px"
		}, 800,function(){
					$(".melo-fejlec").animate({width: tWidth+"px"},100);
					$("#iMac").fadeIn(1000, function(){
												$("div.kepsorozat").fadeIn(800);
												slider();
											});
				});
	}
	
	function slider(){
		var maxImg = dbPrevImages;
		var $aktImg = $("#aPrevImage-" + aktPrevImg);
		
		
		if(maxImg > 1){
			if(aktPrevImg < maxImg){
				++aktPrevImg;
			}else{
				aktPrevImg = 1;
			}
			
			var $nextImg = $("#aPrevImage-" + aktPrevImg);
			$aktImg.fadeOut(800, function(){
									$nextImg.fadeIn(800);
									idozito = setTimeout("slider()", 6000);
								 });
		}else{
			$aktImg.fadeIn(800);
		}
	}

