/*
  _   _   _   _   _   _   _   _   _   _   _   _  
 / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ 
( X | H | T | M | L | K | I | T | C | H | E | N )
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ 
 
http://www.xhtmlkitchen.com

Client:     Fatih Turan - http://www.fatihturan.com
Author: 	Fatih Turan
Last-Edit: 	18:21 05.09.2008

*/

/*-------------------------------------------------------------------------
=GLOBAL FUNCTIONS
-------------------------------------------------------------------------*/
$(document).ready(function() {

    $("div#search input").focus(function() {  
        if ($("div#search input").val() == 'Aranacak terimi girin...') {
            $("div#search input").val("");
        }
    });
    
    $("div#search input").blur(function() {
        if ($("div#search input").val() == '') {
            $("div#search input").val("Aranacak terimi girin...");
        }
    });	

    $("div#photos div a").each(function(){ 
        var old_src = $(this).find("img").attr("src");
        var new_src = old_src.replace(/_s/, "");
        $(this).attr("href", new_src);
    });
    
	function filterPath(string) {
	return string
	  .replace(/^\//,'')
	  .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
	  .replace(/\/$/,'');
	}
	
	$('a[href*=#]').each(function() {
	if ( filterPath(location.pathname) == filterPath(this.pathname)	&& location.hostname == this.hostname && this.hash.replace(/#/,'') ) {
		var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
		var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
		if ($target) {
		 var targetOffset = $target.offset().top;
		 $(this).click(function() {
		   $('html, body').animate({scrollTop: targetOffset}, 400);
		   return false;
		 });
		}
	}
	});

//    $("div#photos div a").each(function(i){
//    
//        var old_src = $(this).find("img").attr("src");
//        var new_src = old_src.replace(/_s/, "_m");
//        var preview = "<div id=\"preview\"><img src=\"\" alt=\"\" /><span></span></div>";
//        
//		$(this).mouseover(function(){
//            $(this).append(preview);
//            $("div#preview").css({display: "block", top: -183, left: -92});
//            $("div#preview img").attr("src", new_src);
//		});
//        
//        $(this).mouseout(function() {
//            $("div#preview img").remove();
//            $("div#preview").css({display: "none"});
//            $("div#preview").remove();
//        });
//		
//    });

    /*$("a#root").click(function() {
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });*/
 
});

$("div.works").ready(function() {
	
	$("div.work > a").mouseover(function() {
		$(this).children().css({opacity: .5});
	});
	
	$("div.work > a").mouseout(function() {
		$(this).children().css({opacity: 1});
	});
		
});



/*-------------------------------------------------------------------------
=LIGHTBOX CONFIGURATION
-------------------------------------------------------------------------*/
$(function() {
  $('a[@rel*=lightbox]').lightBox({
      imageLoading: '../wp-content/themes/emerald/images/lightbox/loading2.gif',
      imageBtnClose: '../wp-content/themes/emerald/images/lightbox/close.gif',
      imageBtnPrev: '../wp-content/themes/emerald/images/lightbox/prev.gif',
      imageBtnNext: '../wp-content/themes/emerald/images/lightbox/next.gif',
      imageBlank: '../wp-content/themes/emerald/images/lightbox/blank.gif',
      txtImage: 'Görsel:',
      txtOf: '/',
      keyToClose: 'k',
      keyToPrev: 'o',
      keyToNext: 's'
  });
  
	$('div#photos div a').lightBox({
      imageLoading: '../wp-content/themes/emerald/images/lightbox/loading2.gif',
      imageBtnClose: '../wp-content/themes/emerald/images/lightbox/close.gif',
      imageBtnPrev: '../wp-content/themes/emerald/images/lightbox/prev.gif',
      imageBtnNext: '../wp-content/themes/emerald/images/lightbox/next.gif',
      imageBlank: '../wp-content/themes/emerald/images/lightbox/blank.gif',
      txtImage: 'Fotoğraf:',
      txtOf: '/',
      keyToClose: 'k',
      keyToPrev: 'o',
      keyToNext: 's'
	});
	
});