Cufon.replace
	(
		[
            ".cufonYap"
            ,".ustMenu a"
            ,"h2"
            ,"h3"
		],
		{
			hover: true,
            fontFamily: "Futura Hv BT"
		}
	);
Cufon.replace
	(
		[
            ".cufonYapZ"
		],
		{
			hover: true,
            fontFamily: "Zurich XCn BT"
		}
	);

$(function(){

    $(".tplForm input[type=text], .tplForm input[type=password]").addClass("tb");
    $(".tplForm input[type=submit], .tplForm input[type=button]").addClass("btn");
	addDefaultTxt('.eb_adSoyad', IYS_LANG.NAME_SURNAME);
	addDefaultTxt('.eb_Email', IYS_LANG.EMAIL);
	
    // http://stackoverflow.com/questions/5411211/changing-anchors-using-this-attrtarget-blank-causes-link-to-open-in-ne/5441882#5441882
    // Select the links that start with "http" in their href
    $("a[href^=http], a[href^='www.']").each(function(){
        // Do nothing to the internal links
        if (this.href.indexOf(location.hostname) == -1){
            $(this)
                // Add a class to style external links
                .addClass("external")
                // Get our semantic on
                .attr({ "rel":"external" })
                // Do stuff on click like...
                .click(function(e){
                    // Prevent opening the link in this window
                    e.preventDefault();
                    // Open the link in a new window
                    window.open(this.href);
                    // Use Google Analytics to track this click
                    _gaq.push([ '_trackEvent', 'Referrals', 'click', this.href ]);
            });
        }
    });

    //enable_smooth_scroll(".noSmoothScroll");
    
    $(".solRefList").delay(250).slideDown(400);
    $(".solRefKatBas a").click(function (){
        if ($(".solRefList").size() > 0) {
            var $l = $(this).attr("href");
            $(".solRefList").slideUp(200, function (){ location.href = $l; });
            return false;
        }
    });
    function solRefListCur(el){
        $(".solRefList a").removeClass("current");
        $(el).addClass("current");
        setHash($(el).attr("href").split(/#/)[1]);
    }
    var hash = location.hash.replace(/#/, "");
    if (hash && $("#" + hash).size() > 0) {
        //$("#" + hash).scrollTo(0);
        //location.hash = "#";
        setHash(hash);
    }
    $(".solRefList a")
        .click(function (){
            solRefListCur($(this));
        })
        .each(function (){
            if (hash == $(this).attr("href").split(/#/)[1]) {
                $(this).click();
            }
        });
    
    // Scroll initially if there's a hash (#something) in the url 
	/*$.localScroll.hash({
		queue:true,
		offset: -85,
		duration:1000
	});*/

    $.localScroll({
		queue:true,
		duration:650,
		hash:true,
		offset: -85,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});
    
    if ($(".referans").size() > 0) {
        $(window).smartscroll(function(event, delta) {
            var parEl = window;
            var winH = $(parEl).height();
            var winTop = $(parEl).scrollTop();
            var vertFold = winH + winTop;
            var maxRatio = 0;
            var maxIdx = 0;
            $(".referans").each(function (){
                var elH = $(this).height();
                var elTop = $(this).offset().top;
                if (elTop < vertFold && elTop + elH > winTop) {
                    var vertAmt = 0;
                    if (elTop > winTop) {
                        vertAmt = vertFold - elTop;
                    } else {
                        vertAmt = elTop + elH - winTop;
                    }
                    if (vertAmt > winH) {
                        vertAmt = winH;
                    }
                    if (vertAmt > elH) {
                        vertAmt = elH;
                    }
                    if (vertAmt == 0) {
                        return;
                    }
                    var ratio = vertAmt / elH;
                    //console.log($(this).attr("id") + " : %" + (ratio * 100));
                    if (ratio > maxRatio) {
                        maxRatio = ratio;
                        maxIdx = $(this).index();
                    }
                }
            });
            solRefListCur($(".solRefList a").eq(maxIdx));
        });
    }
    
    $(".anaAltButonlar a img")
        .mouseover(function () {
            $(this).fadeTo("normal", 0.8);
        }).mouseout(function () {
            $(this).fadeTo("normal", 1);
        });
	
    $(".mo")
        .mouseover(function(){
            $(this).addClass("over");
        })
        .mouseout(function(){
            $(this).removeClass("over");
        });

	$('#eBultenAddBtn').click(function(e){
        eBulten('1');
        e.preventDefault();
    });
   	/*$('#eBultenRmvBtn').click(function(e){
        eBulten('0');
        e.preventDefault();
    });*/
    $('#eb_Email').keypress(function(){
        $('.eBultenResDiv').hide();
    });
    
    $('.yorumForm').submit(function(e){
        $(".yorumFormHata").slideUp("fast");
        var formObj = $(this);
        if (formObj.valid()) {
            $.ajax({
        		type	: 'post',
        		url		: '?act=sayfa&id='+formObj.find('input[name="haber_id"]').val()+"&jx=yorumGonder",
        		data	: formObj.serialize(),
                success: function(msg) {
                    if (msg == "") {
                        $(formObj).hide();
                        $(".yorumFormGonderildi").show();
                    } else {
                        $(".yorumFormHata").html(msg);
                        $(".yorumFormHata").slideDown("fast");
                    }
                }
        	});
        }
        e.preventDefault();
    });
    $(".yorumForm input").keydown(function (){
         $(".yorumFormHata").slideUp("fast");
    });

    $(".ustMenu a:not(.current)").hover(
        function (){
            $(this).stop(true).css({backgroundColor:"#000"}).animate({backgroundColor:"#fff"}, 500);
        },
        function (){
            $(this).stop(true).animate({backgroundColor:"#000"}, 250, function (){ $(this).css({backgroundColor:"transparent"}); });
        }
    );
    var anaGlSay = $(".anaGlDiv").size();
    
    if (anaGlSay > 0) {
        var anaGlCur = $(".anaGlDiv:visible").index();
        var anaGlHover = false;
        $(".anaGl").hover(
            function (){
                anaGlHover = true;
            },
            function (){
                anaGlHover = false;
            });
        function anaGlAnim(){
            $(".anaGlDiv, .anaGlBas, .anaGlYazi").hide();
            var cur = $(".anaGlDiv:eq(" + anaGlCur + ")");
            if (!cur.is(":visible")) {
                cur.effect("fade", {mode:"show"}, 750);//fadeIn(750);
            }
            /*cur.find(".anaGlBas").animate({"left": 0}, 500);
            cur.find(".anaGlYazi").animate({"left": 0}, 650);*/
            cur.find(".anaGlBas").delay(250).slideDown(400);
            cur.find(".anaGlYazi").delay(500).effect("fold", {mode:"show", size:8}, 600);//slideDown(400, "easeOutSine");
            anaGlCur++;
            if (anaGlCur > anaGlSay - 1) {
                anaGlCur = 0;
            }
            var pre = $(".anaGlDiv:eq(" + anaGlCur + ") .anaGlPre");
            if (pre.size() > 0) {
                var i = new Image();
                i.src = pre.text();
                $(i).load(function (){
                    pre.replaceWith('<img src="' + i.src + '" alt="' + pre.attr("title") + '" />');
                });
            }
        }
        anaGlAnim();
        setInterval(function (){
                        anaGlAnim();
                    }, 10000);
    }
    
});

var _ebActive = false;

function eBulten(_type) {
	if (!_ebActive) {
		_ebActive = true;
        $('#eBultenAddBtn').attr("disabled", "disabled");
        //$('#eBultenRmvBtn').attr("disabled", "disabled");
		$('.eBultenResDiv').hide();
		if ( $('#eb_Email').val().search(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i) == -1 ) {
			alert(IYS_LANG.INV_EMAIL);
			_ebActive = false;
            $('#eBultenAddBtn').attr("disabled", false);
            //$('#eBultenRmvBtn').attr("disabled", false);
			$('#eb_Email').focus();
			return false;
		} else {
			$('.eBultenJx').show();
			$.ajax({
                type:'post',
                url:'eBulten.php?e='+$('#eb_Email').val()+'&n='+$('#eb_adSoyad').val()+'&type='+_type,
                success: function(data) {
					//alert(transport.responseText);
					var msg = '';
					$('.eBultenJx').hide();
					_ebActive = false;
					var res = parseInt(data);
					if (isNaN(res)) {
						res = 7;
					}
					if (res == 0) {
						if (_type=='1') {
							msg = IYS_LANG.JX_EB_ADDED;
						} else {
							msg = IYS_LANG.JX_EB_DELED;
						}
					} else if (res == 1) {
						msg = IYS_LANG.INV_EMAIL;
						
					} else {
						msg = IYS_LANG["JX_EB_ERRS"+res];
					}
					
					var	cls=(res==0?'msg-ok':'msg-err');
                    alert(msg);
					$('.eBultenResDiv').removeClass('msg-err');
					$('.eBultenResDiv').removeClass('msg-ok');
					$('.eBultenResDiv').addClass(cls);
					$('.eBultenResDiv').show();
                    $('.eBultenAddBtn').attr("disabled", false);
                    //$('#eBultenRmvBtn').attr("disabled", false);
				}
			}); // end Ajax
		}
	}
}

// -----------------------------------------------------------------------------

