$(document).ready(function(){ 

	var clearMePrevious = "";
	$(".text-input").focus(function(){
		if($(this).val() == "Search")
		{
			clearMePrevious = $(this).val();
			$(this).val("");
		}
	});
	
	$(".text-input").blur(function(){
		if($(this).val()== "")
		{
			$(this).val(clearMePrevious);
		}
	});
	
	$("#gallery-img a").live('click', function() {
		popup_slide($(this).attr("href"));
		return false;
	});
	
	$(".slideshow").click(function(){
		open_pop_up_resul("http://www.turkishculture.org/slide/slide.html");
		return false;
	});
	
	$("#gallery-paging a").live('click', function() {
		var str = $(this).attr("rel");
		var str = str.split(',');
			id = str[0];
		var page = str[1];		
		//var page = $(this).attr("rel");
		$.ajax({
			type: 'GET',
			url: "http://www.turkishculture.org/ajax.php",
			data: "id="+id+"&page_no="+page+"&action=get_gallery_img",
			dataType:'html',
			contentType: "application/x-www-form-urlencoded; charset=utf-8",
			cache: false,
			global: false,
			beforeSend: function(result)
			{
				
			},
			success: function(result) {
				$("#page-img-gallery").html(result);
			}
		});	   
		return false;
	});
	
	/*
	var off = $("#page-content").offset();
	if(off)
	{
		$.scrollTo(150, 800, {duration:3000} );
	}
	
	$("#up").click(function(){
		$.scrollTo(0, 800, {duration:3000} );
		return false;
	});
	*/

  var active = "";
   $(".balloon").hover(function(){
		var str = $(this).attr("title");
			str = str.split(",");
		var region = str[0];
		$(".p_"+region).show();
   },function(){
		$(".popup").hide();
   });


  $(".popup-click").click(function(){
		var str = $(this).attr("title");
			str = str.split(",");
		var c_id = str[1];
		$.ajax({
				type: 'GET',
				url: 'http://www.turkishculture.org/calendar-ajax.php?id='+c_id,
				data: '',
				cache: false,
				contentType: "application/json; charset=utf-8",
				success: function(result) {
					$("#content").html(result);
					$.scrollTo("#content", 800, {duration:3000} );
				}
			});		
	 });

   $("#cat_name").change(function(){
   		$.ajax({
			type: 'GET',
			url: 'http://www.turkishculture.org/ajax.php',
			data: 'action=get_sub_name&cat_name='+$(this).val(),
			cache: false,
			contentType: "application/json; charset=utf-8",
			success: function(result) 
			{
				$("#sub_name").html(result);
			}
		});	
   });	
	
  $(".submmit-button").click(function(){
		if($("#search").val().length < 2)
		{
			alert("You must enter at least two characters...!");
			return false;	
		}
	});	
	
   $("#frmSearch").submit(function(){
		if($("#search").val().length < 2)
		{
			alert("You must enter at least two characters...!");
			return false;	
		}
	});

   $("#frm-quick-search").submit(function(){
		if($("#anyword").val().length < 2)
		{
			alert("You must enter at least two characters...!");
			return false;	
		}
	});	 		 
	

  });
  
  
  function popup_slide(url)
  {                                	
  		
		window.open(url, "img", "screenX=40,screenY=30,top=30,left=40,height=600,width=800,directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes").focus();
  }
  
  function open_pop_up_resul(location)
  {                                	
  		window.open(location, "slide", "screenX=40,screenY=30,top=30,left=40,height="+(700)+",width="+(840)+",directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes").focus();
  }
  
   
	 
	 
   
