var count = 0;
	
$(document).ready(function() {
	$('#tbLink').bind('keypress', function(e) {
		if(e.keyCode==13){
			submitLink();
		}
	});

	$("#btnSubmit").click(function(){
		submitLink();
	});
	
   	
	$("#tbLink").focus(function(){
		$(this).val($(this).val().replace($(this).attr("title"),""));
	});
	
	$("#tbLink").blur(function(){
		if($(this).val()=="")
			$(this).val($(this).attr("title"));
	});
	
	$(".popClose").click(function(){
		$("div.hiddenContent:visible:first").stop().slideUp(100,function(){
			$("#popWrapper").fadeOut();
		});
	});
	
	$("#popBg").click(function(){
		$("div.hiddenContent:visible:first").stop().slideUp(100,function(){
			$("#popWrapper").fadeOut();
		});
	});
	
	$("#linkHakkimizda").click(function(e){
		e.preventDefault();
		$("#popWrapper").fadeIn(200,function(){
			$("#popHakkimizda").fadeIn(100);
		});
	});
	$("#linkLogomuz").click(function(e){
		e.preventDefault();
		$("#popWrapper").fadeIn(200,function(){
			$("#popLogomuz").fadeIn(100);
		});
	});
	
	$("#linkSozlesme").click(function(e){
		e.preventDefault();
		$("#popWrapper").fadeIn(200,function(){
			$("#popSozlesme").fadeIn(100);
		});
	});

	$("#linkFeedback").click(function(e){
		e.preventDefault();
		$("#popWrapper").fadeIn(200,function(){
			$("#popFeedback").fadeIn(100);
		});
	});	
	
	$("#footerSocial").children("div").hover(function(){
		$(this).css({opacity:1});
	},function(){
		$(this).css({opacity:0.6});
	});
});

$(window).load(function(){
	var arrCookie = document.cookie.split(';');
	var i=0;

	for(i in arrCookie){
		var arrCookieParts = arrCookie[i].split('=');
		var reCookie = arrCookieParts[0].search( new RegExp("unethis"));
		if(reCookie != -1){
			var sCookieURL = arrCookieParts[1].replace("http%3A%2F%2F","http://")
			var arrCookieParts2 = arrCookieParts[0].split('|')
			sCookieShort = "http://ufalt.net/"+arrCookieParts2[1];
			
			var htmlCookieShort = '<div class="shortlink"><a target="_blank" href="'+sCookieShort+'">'+sCookieShort+'</a></div>';
			var htmlCookieCopy = '<div class="copy"><a href="javascript:void(0)" id="copyLink'+count+'" title="'+sCookieShort+'">Kopyala</a></div><div class="seperator"> | </div><div class="qr"><a href="javascript:void(0)" id="qrLink'+count+'" title="'+sCookieShort+'">Karekod</a></div>';
			var htmlCookieLong = '<div class="longlink"><a target="_blank" href="'+sCookieURL+'">'+sCookieURL.substring(0,38)+'</a></div>';
			var htmlCookieItem = '<li>'+htmlCookieShort+htmlCookieCopy+htmlCookieLong+'</li>';
			
			$("#resultBox").children("ul").prepend(htmlCookieItem);
			$("#resultBox").children("ul").find("li:first").fadeIn(200,function(){
				/*
				var buCookie = $("#resultBox").children("ul").find("li:first").children("div.copy").children("a");
				buCookie.xincopy(function(){
					$("#errorDisplay").stop().animate({top:'-60px'},200,function(){$("#errorDisplay").html("Link Kopyalandı: "+sCookieShort);});		
					$("#errorDisplay").animate({top:'0px'},400, function(){$("#errorDisplay").animate({top:'0px'},4000,function(){$("#errorDisplay").animate({top:'-60px'},400)})});
					return buCookie.attr("title");
				});
				
				var qrCookie = $("#resultBox").children("ul").find("li:first").children("div.qr").children("a");
				qrCookie.click(function(){
					var qrCookieImage = "<img src='"+sCookieShort+"+qrP'>"
					$("#qrImage").html(qrCookieImage);
					$("#qrImageB").attr("href",sCookieShort+"+qr11");
					$("#qrImageO").attr("href",sCookieShort+"+qr7");
					$("#qrImageK").attr("href",sCookieShort+"+qr3");
					$("#popWrapper").fadeIn(200,function(){
						$("#popQR").fadeIn(100);
					});
				});
				*/
			});		
			count++;
		}
	}
	if(arrCookie.length > 0){
		if($("#resultBox").is(":hidden")){
			$("#inputBoxBottom").delay(400).slideUp('fast',function(){
				$("#resultBox").slideDown('fast');
				$("#resultBoxBottom").slideDown('fast');
				copyProcess();
				qrProcess();
			})
		}
	}	
});
