Cufon.replace
(
	[
		'.cf-title h1',
		'.cf-title h2',
		'.cf-subtitle h2',
		'.sub-menu-links a',
		'.client-book p'
	],
	{
		hover: true
	}
);

$().ready(function(){
    
    $(".news-photos a").click(function (e) {
        var selfDiv = $('<div style="cursor:pointer"><img src="' + $(this).attr("href") + '" /></div>');
        var img = new Image();
        $(img)
            .attr("src", $(this).attr("href"))
            .load(function () {
                var
                    imgW = $(img).attr("width"),
                    imgH = $(img).attr("height"),
                    winW = $(window).width(),
                    winH = $(window).height();
                var w = winW - 40;
                var h = winH - 40;
                if (imgW + 30 < winW) {
                    w = imgW + 30;
                }
                if (imgH + 50 < winH) {
                    h = imgH + 50;
                }
                selfDiv.dialog({
                    "width"     : w,
                    "height"    : h
                })
            });
        selfDiv.click(function (){
            $(this).dialog("close");
        });
        e.preventDefault();
    });
    $("ul.nav-dropdown li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible').fadeTo(600,0.90);
    
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden').fadeTo(0,1);
    
    });
    
    $("ul.nav-dropdown li ul li:has(ul)").find("a:first").append(' <img src="images/nav-arrow-multi.gif"/> ');
    
	$('.kwicks').kwicks({
		max: 120,
		duration:400
	});
    
    var fontResizeTarget = $(".content");
    /**
    * @link http://www.shopdev.co.uk/blog/text-resizing-with-jquery/
    */
    // Reset Font Size
    var originalFontSize = fontResizeTarget.css('font-size');
    $(".resetFont").click(function(){
        fontResizeTarget.css('font-size', originalFontSize);
    });
    // Increase Font Size
    $(".increaseFont").click(function(){
        var currentFontSize = fontResizeTarget.css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*1.2;
        fontResizeTarget.css('font-size', newFontSize);
        return false;
    });
    // Decrease Font Size
    $(".decreaseFont").click(function(){
        var currentFontSize = fontResizeTarget.css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*0.8;
        fontResizeTarget.css('font-size', newFontSize);
        return false;
    });
    
    $(".printBtn").click(function(){
        print();
        return false;
    });
    
    $(".sendToBtn").click(function(){
        location.href = 'mailto:?subject='+encodeURIComponent($("title").text())+'&body='+encodeURIComponent(_NETTE_LANG.TAVSIYE_YAZI+":\n\n"+$("title").text()+'\n\n'+location.href+'\n');
        return false;
    });
    
    $(".backBtn").click(function(){
        history.back();
        return false;
    });
    
    $(".hrFormBtn").click(function(e){
        e.preventDefault();
        insetWindow($(this).attr("href"),'Bağımsız Değerlendirici Formu');
    });
    
    $(".toTheTopBtn").click(function(){
        $('html, body').animate({ scrollTop: 0 }, "fast");
        return false;
    });
    $("#search").validate({
        rules: {
           q:{required:true, minlength:3, maxlength:75}
        },
        errorPlacement: function(error, element) {
            //alert(error.html());
            if (error) {
                $("#aramaFormUstErr").append(error);
                $("#aramaFormUstErr:hidden").slideDown("fast");
            } else {
                $("#aramaFormUstErr").hide("fast");
            }
            
            //element.attr("title", error.text());
            //alert(error.text());
        }
    });
    addDefaultTxt('#search input[name="q"]', _NETTE_LANG.SITE_ICI_ARAMA);
    
    if ($("#tabs")) {
        $("#tabs").tabs();
    }
    
});


var insetWindow = function(Href,Title){
    var horizontalPadding = 25;
    var verticalPadding = 25;
    var width = 750;
    var height = 600;
    $('<iframe id="externalSite" class="externalSite" frameborder="0" src="' + Href + '" />').dialog({
        title: Title,
        autoOpen: true,
        width: width-12,
        height: height,
        modal: true,
        resizable: true
    }).width(width - horizontalPadding).height(height - verticalPadding);            
}

