	$(document).ready(function() {
		$('#load').hide();
		$('#close').hide();
	});
//alarm js başlangıcı
$(".alarm").click(function () {
	$(".ekrandiv").css("display","block");
});
  
$(".ekrandiv").click(function () {
	$(".ekrandiv").css("display","none");
});
//alarm js sonu

//arama js başlangıcı  
$('#target').keyup(function() {
	$('#load').fadeIn();
var testquery = $(this).val(); 

$.ajax({
	type: 'GET',
	dataType: 'html',
	url: 'http://www.pillirobot.com/searchquery.php',
	data: 'q=' + encodeURI(testquery),
	cache: true, 
  	success: function(ajaxCevap) {$('#sonuc').html(ajaxCevap).hide();},
	complete:function() { $('#sonuc').fadeIn(); $('#load').fadeOut();$('#close').fadeIn(); }
});
});
$('#target').focus(function() { 
	if ($("#target").val().length != 0){
	$('#sonuc').fadeIn();
	$('#close').fadeIn();
	}
})
$(document).click(function(e){
	if($(e.target).is('#sonuc, #target, #sonuc *'))return;
		$('#sonuc').fadeOut();
		$('#close').fadeOut();
});
$("#close").click(function() {
	$('#close').fadeOut();
	$("input#target").val('');
	$('#target').focus();
	$('#sonuc').html('').fadeOut();;
});
	
	
	$('form[name=q]').submit(function(){
		v = $("#target").val().replace(/ /g,'-');
	if((v != "")&&(v.length >2 )){
	var url = "http://www.pillirobot.com/oyun/" + v +'/';    
	window.location = url;
	}
	return false;
		});
/*
$("#ara").click(function() {
	v = $("#target").val().replace(/ /g,'-');
	if((v != "")&&(v.length >2 )){
	var url = "http://www.pillirobot.com/oyun/" + v +'/';    
	window.location = url;
}
});
$('#target').keyup(function(e) {
	if(e.keyCode == 13) {
		v = $("#target").val().replace(/ /g,'-');
		if((v != "")&&(v.length >2 )){
			var url = "http://www.pillirobot.com/oyun/" + v +'/';    
			 window.location = url;

		}
	}
});*/
//arama js sonu  
