
var n;
var navH='';
$=jQuery.noConflict();

$(function(){
    $("input:text, input:password, textarea").pk_input();
    if ($.browser.msie){
        //$('#haberler a, #menu a').ieffembedfix();
    }
    $('form').validationEngine();
    $('#menu a').addClass('btl btr bbl bbr b');//class="btl btr bbl bbr b
    $('#menu li.aktif a').live('click',function(){return false;})
    $('.icerik img[rel!="fancybox"]').each(function(i){
        var $img=$(this);
        var src=$(this).attr('src');
        var a=$('<a href="'+str_replace(['.thumbs/','thumbs/'],'',src)+'" rel="fancybox" title="'+(($img.attr('alt'))?$img.attr('alt'):'')+'"></a>');
        $(this).parent('p').append(a);
        a.append($img);
        
    });
    /*+++++++++++ Menu ++++++++++++*/
    /*$('#menu ul li').has('ul').addClass('hasul');
    $('li.hasul').bind('mouseenter',function(){
        n=$('ul:first',this);
        if (navH=='') navH = n.height();
        n.css({display:'block',height:'0px'});

        n.stop().animate({

            height:navH,

            queue:false

        },500,function(){

            n.css({height:'auto'});

            navH = n.height();

        });

    }).bind('mouseleave',function(){

        n.stop().animate({

            height:0,

            queue:false

        },500,function(){

            n.css({display:'none'});

        });

    });*/
    $('#menu ul').superfish();
    /* ------------- Menu --------------*/
    $('a[rel^="fancybox"]').fancybox({
        onComplete:function(){
            var $a=$('<a></a>');
            $a.attr('href',$('#fancybox-img').attr('src'));
            $a.attr('id','jqzoom');
            $a.append($('#fancybox-img'));
            $('#fancybox-content').append($a);
            $('#jqzoom').jqzoom({
                zoomType: 'always',
                lens:false,
                preloadImages: false,
                alwaysOn:false,
                zoomWidth:250,
                zoomHeight:350,
                preloadText:'Yükleniyor'
            });
        }
    });
    
    var menu=$('#menu ul:first');
    $('ul').each(function(i){
        if ($('li',$(this)).length>1){
            $('li:first',$(this)).addClass('ilk');
            $('li:last',$(this)).addClass('son');
        }
    });
    $('li').each(function(){
        var id='li_'+$(this).index();
        if ($(this).attr('id')=='undefined' || $(this).attr('id')=='')
            $(this).attr('id',id);
    });
    $('li a',menu).hover(function(){
        var p=$(this).parent('li');
        if (!p.hasClass('aktf'))
            p.addClass('aktf');
    },function(){
        var p=$(this).parent('li');
        if (!$(this).hasClass('aktf'))
            p.removeClass('aktf');
    });
    //$('li.ilk',menu).addClass('btl b');
    //$('li.son',menu).addClass('btr b');
    $('form').submit(function(){
        if ($(this).validationEngine('validate')){
            $("#loading").show();
            $.post($(this).attr('action'),$(this).serialize(),function(data){
                if (data.success){
                    $('#iletisimformu').text(data.msg).highlight();
                }
            },'json');
            return false;
        }else{
            return false;
        }
        return false;
    });
    if (images.length){
        $.supersized({
            slides:images,
            performance:3,
            slide_interval:7000
        });
    }
    if ($("#habertasiyici").length) ticker_start();
});
(function($) {
    $.fn.pk_input = function() {
        return this.each(function() {
            var $root = $(this);
            var inputValue = $root.val();
            
            function reset() {
                var value = $root.val();
                if(inputValue == value) {
                    $root.val("");
                }
            }
            
            function blur() {
                var value = $root.val();
                if(value == "") {
                    $root.val(inputValue);
                }
            }
            
            $root.focus(function() {
                  reset();
            });
            $root.blur(function() {
                  blur();
            });
        });
    }
    
    
})(jQuery);
function ticker_start() {
    tasiyici=$("#habertasiyici");
    tas=document.getElementById('habertasiyici');
    TICKER_RIGHTTOLEFT = false;
    TICKER_SPEED = 2;
    TICKER_STYLE = "font-family:Arial; font-size:12px; color:#444444";
    TICKER_PAUSED = false;
    TICKER_CONTENT = tasiyici.html();
    var tickerSupported = false;
    TICKER_WIDTH = tasiyici.css('width');
    
    var img = "<img src="+mediaurl+"images/ticker_space.gif width="+TICKER_WIDTH+" height=0>";

    // Firefox
        tas.innerHTML = "<TABLE  cellspacing='0' cellpadding='0' width='100%'><TR><TD nowrap='nowrap'>"+img+"<SPAN style='"+TICKER_STYLE+"' ID='TICKER_BODY' width='100%'>&nbsp;</SPAN>"+img+"</TD></TR></TABLE>";
        tickerSupported = true;
    // IE
    
    if(!tickerSupported) tas.outerHTML = ""; else {
        tas.scrollLeft = TICKER_RIGHTTOLEFT ? tas.scrollWidth - tas.offsetWidth : 0;
        document.getElementById("TICKER_BODY").innerHTML = TICKER_CONTENT;
        tas.style.display="block";
        TICKER_tick();
    }
}

function TICKER_tick() {
    if(!TICKER_PAUSED) tas.scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
    if(TICKER_RIGHTTOLEFT && tas.scrollLeft <= 0) tas.scrollLeft = tas.scrollWidth - tas.offsetWidth;
    if(!TICKER_RIGHTTOLEFT && tas.scrollLeft >= tas.scrollWidth - tas.offsetWidth) tas.scrollLeft = 0;
    window.setTimeout("TICKER_tick()", 30);
}

function addslashes(str) {
    str=str.replace(/\\/g,'\\\\');
    str=str.replace(/\'/g,'\\\'');
    str=str.replace(/\"/g,'\\"');
    str=str.replace(/\0/g,'\\0');
    return str;
}
function stripslashes(str) {
    str=str.replace(/\\'/g,'\'');
    str=str.replace(/\\"/g,'"');
    str=str.replace(/\\0/g,'\0');
    str=str.replace(/\\\\/g,'\\');
    return str;
}

function str_replace (search, replace, subject, count) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order
    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var i = 0,
        j = 0,
        temp = '',
        repl = '',
        sl = 0,
        fl = 0,
        f = [].concat(search),
        r = [].concat(replace),
        s = subject,
        ra = Object.prototype.toString.call(r) === '[object Array]',
        sa = Object.prototype.toString.call(s) === '[object Array]';
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i = 0, sl = s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j = 0, fl = f.length; j < fl; j++) {
            temp = s[i] + '';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length - s[i].length) / f[j].length;
            }
        }
    }
    return sa ? s : s[0];
}
                              

