$(document).ready(function(){
    $('body').append('<div id="popup2" style="width:500px; height:500px;"><img src="images/serhat_yilsonu.jpg" alt="serhat"  class="abPopupKapat" /></div>');
    $('#popup2').abPopup
    ({
       'acilis'         : 'otomatik',
       'pozisyon'       : 'ortala,ortala',
       'arkaplan'       : '#333',
       'arkaplanSaydam' : '0.6',
       'htmlTag'        : '.abPopupKapat',
       'siyahCerceve'   : true,
       'esc'            : true,
       'cookieGun'      : 1
    });
});
   

    
    /**
     * * -------------------------------------------------------------------------------------------------------
     * Bu jQuery eklentisi Aycan BULBUL(http://www.aycan.net/cookieli-popup-eklentisi/) tarafından yapilmistir.
     * Eklenti Adi  : Cookie'li popup uygulaması  
     * Yazar        : Aycan BULBUL, ab@aycan.net
     * Tarih        : Tarih 27 Mayıs 2011
     * * -------------------------------------------------------------------------------------------------------
     * Kullanim klavuzu
     * jQuery('#abPopup').abPopup(); // basit kullanim
     *
     * jQuery('#abPopup').abPopup
     * ({
     *      ### Acilis ###
     *      'acilis'         : otomatik veya tiklama
     *      'pozisyon'       : ortala,ortala veya ortal,top,50px
     *      'arkaplan'       : opsiyonel
     *      'arkaplanSaydam' : opsiyonel (arkaplanin saydamlik derecesi)
     *      ### Kapanis ###
     *      'htmlTag'        : opsiyonel (#buton, .buton vs.)
     *      'siyahCerceve'   : true veya false (Arka plana tiklayinca kapanma)
     *      'esc'            : true veya false (Esc tusuna basinca kapatma)
            'cookieGun'      : gun adedi girilebilir. orn : 1 , 8 , 10 vb.
     * });
     * * -------------------------------------------------------------------------------------------------------
     **/


    (function(jQuery){
         jQuery.fn.abPopup = function(veriAkisi)
         {

            var varsayilan =
            {
                /*acilis*/
                acilis         :'otomatik',
                pozisyon       :'ortala',
                arkaplan       :'#000',
                arkaplanSaydam :'0.3',
                /*kapanis*/
                htmlTag        :'#ab-kapat',
                siyahCerceve   : true,
                esc            : true,
                cookieGun      : 1
            };

            var ayarlar = jQuery.extend(varsayilan, veriAkisi);

            return this.each
            (
                function()
                {
                    var obje = jQuery(this);
                    jQuery(obje).css({
                       'position': 'absolute',
                       'z-index' : '9999',
                       'display' : 'none'
                    });
                    /**
                     * Tanimlanmis acilis degerine gore islem yapiyoruz
                     * acilis = direk ise sayfa yuklendiginde popup aciliyor
                     **/
                    var deger2 = varsayilan.acilis.split(",");

                    switch (deger2[0]) {
                        case 'otomatik':
                            cookieKontrol(varsayilan.cookieGun);
                            break;

                        case 'tiklama':
                            /*sayfanin genisligini ve yuksekligini aliyoruz */
                          jQuery('#' + deger2[1]).click(function(){
                            cookieKontrol(varsayilan.cookieGun);
                              
                          });
                                break;
                        default:
                            alert('Yanlış bir veri girdiniz. Girilecek Degerler :  "otomatik" veya "tiklama"');
                            break;
                    }
                    
                    /*cookie kontrol*/
                    function cookieKontrol(cookieGun)
                    {
                        if(varsayilan.cookieGun == 0)
                        {
                            arkaPlan(); 
                        }
                        else
                        {
                            if($.cookie('popup')== 0 || $.cookie('popup')== null )
                            {
                                /**
                                *Popup acildiktan sonra cookie degerine 2 atiyoruz ve acildi anlamina geliyor :)
                                **/
                                $.cookie('popup',cookieGun,{expires: cookieGun});
                                /**
                                * Popup actiriyoruz
                                **/
                                arkaPlan();
                            }
                            else
                            {

                            }
                        }

                        
                    }

                    /*Arkaplan actiriyoruz*/
                    function arkaPlan()
                    {
                        window.ekran_genisligi  = jQuery('body').width();
                        window.ekran_yuksekligi = jQuery('body').height();
                        window.ekran_yuksekligi2 = jQuery(document).height();
                    /*sayfanin genisligini ve yuksekligini aliyoruz */
                        /*Eger sitenin yuksekligi ekranin yuksekliginden kucukse siteninin yuksekligini ekraninn yuksekligine esitliyoruz.*/
                        if(ekran_yuksekligi <= ekran_yuksekligi2 )
                        {
                            ekran_yuksekligi = ekran_yuksekligi2;
                        }
                        /*aldigimiz degerleri body taginin icine ekledigimiz div'e veriyoruz*/
                        jQuery('body').append('<div id="ab-popup-kararti" style="width:' + ekran_genisligi + 'px; height:' + ekran_yuksekligi + 'px; position:absolute; top:0; left:0; background:' + varsayilan.arkaplan + '; display:none; z-index:9998;"></div>');
                        /*arka zemini karartiyoruz*/
                        jQuery('#ab-popup-kararti').fadeTo('fast',varsayilan.arkaplanSaydam);
                        /*acilacak popup'un pozisyonunu belirliyoruz*/
                        jQuery(obje).delay(200).fadeIn('fast');
                        jQuery(obje).css('position','fixed');
                        pozisyonBelirle();
                    }
                    /*Pozisyonu belirlileme*/
                    function pozisyonBelirle()
                    {
                        /* cift gonderilen deger varsa parcaliyoruz */
                        var deger1 = varsayilan.pozisyon.split(",");

                        /* 1. deger. ( ':' iki noktadan onceki deger) */
                        switch (deger1[1]){

                            case 'top':
                            /*yatay olarak ortaliyoruz*/
                            yatayOrtala();
                            /*Verilen top degerini atiyoruz*/
                            var obje_genislik = obje.width();
                            jQuery(obje).css({
                                'top' : deger1[2]
                            });
                            break;

                            case 'ortala':
                                /*yatay olarak ortaliyoruz*/
                                yatayOrtala();
                                /*dikey olarak ortaliyoruz*/
                                dikeyOrtala();
                            break;

                            default:
                                /*yatay olarak ortaliyoruz*/
                                yatayOrtala();
                                /*dikey olarak ortaliyoruz*/
                                dikeyOrtala();
                                break;
                        }
                        jQuery(obje).delay(250).fadeIn('slow');
                    }
                    /*Diket olarak ortalama fonksiyonu*/
                    function dikeyOrtala()
                    {
                        /*Eger acilacak popup'un yuksekligi ekran yusekliginden buyuk ise dikey olarak ortalama yapmiyoruz*/
                        if(jQuery(obje).height() > ekran_yuksekligi)
                        {
                            yatayOrtala();
                        }
                        else
                        {
                            jQuery(obje).css({
                                'top':'50%',
                                'margin-top':-jQuery(obje).height()/2
                            });
                        }
                    }
                    /*Yatay olarak ortalama fonksiyonu*/
                    function yatayOrtala()
                    {
                      jQuery(obje).css({
                            'left':'50%',
                            'margin-left':-jQuery(obje).width()/2
                        });
                    }

                    /*Kapatma*/
                    /*html tagina tiklaninca kapatma*/
                    jQuery(varsayilan.htmlTag).click(function(){
                        kapat();
                    });
                    /*siyah cerceveye tiklaninca kapatma*/
                    switch (varsayilan.siyahCerceve) {

                       case true:
                            jQuery('#ab-popup-kararti').live('click',function(){
                                kapat();
                            })
                            break;

                        default:
                            break;
                    }
                    /*esc'yw tiklaninca kapatma*/
                    switch (varsayilan.esc) {

                        case true:
                            jQuery(document).bind('keydown',function Kapat(e){
                                if (e.keyCode == 27) {
                                    kapat();
                                }
                            });
                            break;

                        default:
                            break;
                    }
                    /*kapatma fonksiyonu*/
                    function kapat()
                    {
                        jQuery(obje).delay(100).slideUp('fast');
                        jQuery('#ab-popup-kararti').delay(0).fadeOut('fast');
                            jQuery('#ab-popup-kararti').remove();

                    }

                }
            );
        };
    })(jQuery);
    
    
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */



jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

