﻿/*********shop*********/
var SITEURL = window.location.protocol + "//" + window.location.host + "/";
function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}
function pageLoad() {
    var tags = $('input[class*=mask],textarea[class*=mask]');
    for (var key in $.fn.keyfilter.defaults.masks) {
        tags.filter('.mask-' + key).keyfilter($.fn.keyfilter.defaults.masks[key]);
    }
}
function swapImgOn(id) {
    var src = $('#' + id).attr('src');
    src = src.split('../').join('#');
    src = src.split('.').join('_hover.');
    src = src.split('#').join('../');
    $('#' + id).attr('src', src);
}
function swapImgOff(id) {
    $('#' + id).attr('src', $('#' + id).attr('src').split('_hover.').join('.'));
}
$(function () {
    $.fn.centerImage = function (maxHeight) {
        var imgHeight = this.height();
        if (imgHeight == 0)
            imgHeight = maxHeight;
        var top = Math.round((maxHeight - imgHeight) / 2);
        this.css({ position: "relative", overflow: "hidden", top: top + "px" });
        return true;
    }

    $(".date_input").datepicker({
        dateFormat: "dd.mm.yy",
        changeMonth: true,
        showAnim: 'slideDown',
        changeYear: true,
        firstDay: 1,
        dayNames: ['Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'],
        dayNamesMin: ['Pz', 'Pzt', 'Sl', 'Ça', 'Pe', 'Cu', 'Cm'],
        dayNamesShort: ['Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt'],
        monthNames: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
        monthNamesShort: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara']
    });
});
function AutoCompleteBox(txt, url) {
    $(txt).autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                dataType: "json",
                data: "{search:'" + request.term + "',kategoriID:''}",
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return {
                            label: item.Value,
                            value: item.Key
                        }
                    }))
                }
            })
        },
        delay: 500,
        minLength: 3,
        focus: function (event, ui) {
            $(this).val(ui.item.value);
            return false;
        },
        select: function (event, ui) {
            $(this).val(ui.item.value);
            return false;
        },
        change: function (event, ui) {
            if (ui.item == null) {
                $(this).val('');
            }
        },
        open: function () {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function () {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
    });
}

function AutoCompleteBoxKategori(txt, url, path, siteUrl) {
    $(txt).autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                dataType: "json",
                data: "{search:'" + request.term + "',kategoriId:'" + $(txt).attr('rel') + "'}",
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return {
                            no: item.StokNo,
                            ad: item.StokAdi,
                            resim: item.Resim,
                            adres: item.StokAdres
                        }
                    }))
                }
            })
        },
        delay: 500,
        minLength: 3,
        focus: function (event, ui) {
            $(this).val(ui.item.no);
            return false;
        },
        select: function (event, ui) {
            window.location = siteUrl + "urun/" + ui.item.adres;
            $(this).val(ui.item.no);
            return false;
        },
        change: function (event, ui) {
            if (ui.item == null) {
                $(this).val('');
            }
        },
        open: function () {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function () {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
    }).data("autocomplete")._renderItem = function (ul, item) {
        return $("<li></li>")
         .data("item.autocomplete", item)
         .append("<a style=\"line-height:50px;\" href='#'><img style=\"float:left;padding-right:3px;\" width=\"50px\" height=\"50px\" src=\"" + path + item.resim + "\"> <span>" + item.ad + "</span></a>")
         .appendTo(ul);
    };
}
function UrunAraAutoCompleteBox(txt, url, path, siteUrl) {
    $(txt).autocomplete({
        source: function (request, response) {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: url,
                dataType: "json",
                data: "{search:'" + request.term + "'}",
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return {
                            no: item.StokNo,
                            ad: item.StokAdi,
                            resim: item.Resim,
                            adres: item.StokAdres
                        };
                    }));
                }
            });
        },
        delay: 500,
        minLength: 3,
        focus: function (event, ui) {
            $(this).val(ui.item.no);
            return false;
        },
        select: function (event, ui) {
            window.location = siteUrl + "urun/" + ui.item.adres;
            $(this).val(ui.item.no);
            return false;
        },
        change: function (event, ui) {
            if (ui.item == null) {
                $(this).val('');
            }
        },
        open: function () {
            $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
        },
        close: function () {
            $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
        }
    }).data("autocomplete")._renderItem = function (ul, item) {
        return $("<li></li>")
         .data("item.autocomplete", item)
         .append("<a style=\"line-height:50px;\" href='#'><img style=\"float:left;padding-right:3px;\" width=\"50px\" height=\"50px\" src=\"" + path + item.resim + "\"> <span>" + item.ad + "</span></a>")
         .appendTo(ul);
    };
}
/*********tabs jquery plugin*********/
$.tabs = function (containerId, start) {
    var ON_CLASS = 'on';
    var id = '#' + containerId;
    var i = (typeof start == "number") ? start - 1 : 0;
    $(id + '>div:eq(' + i + ')').css({ display: "block" });
    $(id + '>ul>li:nth-child(' + (i + 1) + ')').addClass(ON_CLASS);
    $(id + '>ul>li>a').click(function () {
        if (!$(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id + '>div:visible').css({ display: "none" });
                target.css({ display: "block" });
                $(id + '>ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
            } else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};

/*********cycle.lite.1.0*********/
(function (D) { var A = "Lite-1.0"; D.fn.cycle = function (E) { return this.each(function () { E = E || {}; if (this.cycleTimeout) { clearTimeout(this.cycleTimeout) } this.cycleTimeout = 0; this.cyclePause = 0; var I = D(this); var J = E.slideExpr ? D(E.slideExpr, this) : I.children(); var G = J.get(); if (G.length < 2) { if (window.console && window.console.log) { window.console.log("terminating; too few slides: " + G.length) } return } var H = D.extend({}, D.fn.cycle.defaults, E || {}, D.metadata ? I.metadata() : D.meta ? I.data() : {}); H.before = H.before ? [H.before] : []; H.after = H.after ? [H.after] : []; H.after.unshift(function () { H.busy = 0 }); var F = this.className; H.width = parseInt((F.match(/w:(\d+)/) || [])[1]) || H.width; H.height = parseInt((F.match(/h:(\d+)/) || [])[1]) || H.height; H.timeout = parseInt((F.match(/t:(\d+)/) || [])[1]) || H.timeout; if (I.css("position") == "static") { I.css("position", "relative") } if (H.width) { I.width(H.width) } if (H.height && H.height != "auto") { I.height(H.height) } var K = 0; J.css({ position: "absolute", top: 0, left: 0 }).hide().each(function (M) { D(this).css("z-index", G.length - M) }); D(G[K]).css("opacity", 1).show(); if (D.browser.msie) { G[K].style.removeAttribute("filter") } if (H.fit && H.width) { J.width(H.width) } if (H.fit && H.height && H.height != "auto") { J.height(H.height) } if (H.pause) { I.hover(function () { this.cyclePause = 1 }, function () { this.cyclePause = 0 }) } D.fn.cycle.transitions.fade(I, J, H); J.each(function () { var M = D(this); this.cycleH = (H.fit && H.height) ? H.height : M.height(); this.cycleW = (H.fit && H.width) ? H.width : M.width() }); J.not(":eq(" + K + ")").css({ opacity: 0 }); if (H.cssFirst) { D(J[K]).css(H.cssFirst) } if (H.timeout) { if (H.speed.constructor == String) { H.speed = { slow: 600, fast: 200}[H.speed] || 400 } if (!H.sync) { H.speed = H.speed / 2 } while ((H.timeout - H.speed) < 250) { H.timeout += H.speed } } H.speedIn = H.speed; H.speedOut = H.speed; H.slideCount = G.length; H.currSlide = K; H.nextSlide = 1; var L = J[K]; if (H.before.length) { H.before[0].apply(L, [L, L, H, true]) } if (H.after.length > 1) { H.after[1].apply(L, [L, L, H, true]) } if (H.click && !H.next) { H.next = H.click } if (H.next) { D(H.next).bind("click", function () { return C(G, H, H.rev ? -1 : 1) }) } if (H.prev) { D(H.prev).bind("click", function () { return C(G, H, H.rev ? 1 : -1) }) } if (H.timeout) { this.cycleTimeout = setTimeout(function () { B(G, H, 0, !H.rev) }, H.timeout + (H.delay || 0)) } }) }; function B(J, E, I, K) { if (E.busy) { return } var H = J[0].parentNode, M = J[E.currSlide], L = J[E.nextSlide]; if (H.cycleTimeout === 0 && !I) { return } if (I || !H.cyclePause) { if (E.before.length) { D.each(E.before, function (N, O) { O.apply(L, [M, L, E, K]) }) } var F = function () { if (D.browser.msie) { this.style.removeAttribute("filter") } D.each(E.after, function (N, O) { O.apply(L, [M, L, E, K]) }) }; if (E.nextSlide != E.currSlide) { E.busy = 1; D.fn.cycle.custom(M, L, E, F) } var G = (E.nextSlide + 1) == J.length; E.nextSlide = G ? 0 : E.nextSlide + 1; E.currSlide = G ? J.length - 1 : E.nextSlide - 1 } if (E.timeout) { H.cycleTimeout = setTimeout(function () { B(J, E, 0, !E.rev) }, E.timeout) } } function C(E, F, I) { var H = E[0].parentNode, G = H.cycleTimeout; if (G) { clearTimeout(G); H.cycleTimeout = 0 } F.nextSlide = F.currSlide + I; if (F.nextSlide < 0) { F.nextSlide = E.length - 1 } else { if (F.nextSlide >= E.length) { F.nextSlide = 0 } } B(E, F, 1, I >= 0); return false } D.fn.cycle.custom = function (K, H, I, E) { var J = D(K), G = D(H); G.css({ opacity: 0 }); var F = function () { G.animate({ opacity: 1 }, I.speedIn, I.easeIn, E) }; J.animate({ opacity: 0 }, I.speedOut, I.easeOut, function () { J.css({ display: "none" }); if (!I.sync) { F() } }); if (I.sync) { F() } }; D.fn.cycle.transitions = { fade: function (F, G, E) { G.not(":eq(0)").css("opacity", 0); E.before.push(function () { D(this).show() }) } }; D.fn.cycle.ver = function () { return A }; D.fn.cycle.defaults = { timeout: 4000, speed: 1000, next: null, prev: null, before: null, after: null, height: "auto", sync: 1, fit: 0, pause: 0, delay: 0, slideExpr: null} })(jQuery)


/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/

; (function ($) {
    $.fn.superfish = function (op) {

        var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
			over = function () {
			    var $$ = $(this), menu = getMenu($$);
			    clearTimeout(menu.sfTimer);
			    $$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function () {
			    var $$ = $(this), menu = getMenu($$), o = sf.op;
			    clearTimeout(menu.sfTimer);
			    menu.sfTimer = setTimeout(function () {
			        o.retainPath = ($.inArray($$[0], o.$path) > -1);
			        $$.hideSuperfishUl();
			        if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
			    }, o.delay);
			},
			getMenu = function ($menu) {
			    var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
			    sf.op = sf.o[menu.serial];
			    return menu;
			},
			addArrow = function ($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

        return this.each(function () {
            var s = this.serial = sf.o.length;
            var o = $.extend({}, sf.defaults, op);
            o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function () {
                $(this).addClass([o.hoverClass, c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
            });
            sf.o[s] = sf.op = o;

            $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function () {
                if (o.autoArrows) addArrow($('>a:first-child', this));
            })
			.not('.' + c.bcClass)
				.hideSuperfishUl();

            var $a = $('a', this);
            $a.each(function (i) {
                var $li = $a.eq(i).parents('li');
                $a.eq(i).focus(function () { over.call($li); }).blur(function () { out.call($li); });
            });
            o.onInit.call(this);

        }).each(function () {
            var menuClasses = [c.menuClass];
            if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
            $(this).addClass(menuClasses.join(' '));
        });
    };

    var sf = $.fn.superfish;
    sf.o = [];
    sf.op = {};
    sf.IE7fix = function () {
        var o = sf.op;
        if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
            this.toggleClass(sf.c.shadowClass + '-off');
    };
    sf.c = {
        bcClass: 'sf-breadcrumb',
        menuClass: 'sf-js-enabled',
        anchorClass: 'sf-with-ul',
        arrowClass: 'sf-sub-indicator',
        shadowClass: 'sf-shadow'
    };
    sf.defaults = {
        hoverClass: 'sfHover',
        pathClass: 'overideThisToUse',
        pathLevels: 1,
        delay: 800,
        animation: { opacity: 'show' },
        speed: 'normal',
        autoArrows: true,
        dropShadows: true,
        disableHI: false, 	// true disables hoverIntent detection
        onInit: function () { }, // callback functions
        onBeforeShow: function () { },
        onShow: function () { },
        onHide: function () { }
    };
    $.fn.extend({
        hideSuperfishUl: function () {
            var o = sf.op,
				not = (o.retainPath === true) ? o.$path : '';
            o.retainPath = false;
            var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility', 'hidden');
            o.onHide.call($ul);
            return this;
        },
        showSuperfishUl: function () {
            var o = sf.op,
				sh = sf.c.shadowClass + '-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility', 'visible');
            sf.IE7fix.call($ul);
            o.onBeforeShow.call($ul);
            $ul.animate(o.animation, o.speed, function () { sf.IE7fix.call($ul); o.onShow.call($ul); });
            return this;
        }
    });

})(jQuery);

function qtipToolTiptip(id, aciklama) {
    try {
        $(id).qtip({
            content: aciklama,
            show: 'mouseover',
            hide: 'mouseout',
            style: {
                name: 'cream'
            }
        });
    }
    catch (err) {
    }
};
function StokBilgilendirmeToolTipler() {
    qtipToolTiptip($("a[rel=bilgi_hizli]"), "Hızlı Kargo");
    $('img[rel=tooltip]').each(function () {
        qtipToolTiptip($(this), $(this).attr("metin"));
    });
}

//SITEURL = window.location.protocol + "//" + window.location.host + "/";
function LoaderGoster(btn) {
    $("#divYukleniyor").remove();
    var btn = $("#" + btn).offset();
    var top = btn.top + 8;
    var left = btn.left - 47;
    var div = "<div id=\"divYukleniyor\" style=\"background-image: url(" + SITEURL + "img/loader.gif);width:43px;height:11px;position:absolute;top:" + top + "px;left:" + left + "px;\"></div>";
    $(div).appendTo('body');
}
function LoaderGizle() {
    $("#divYukleniyor").remove();
}

function BindCombo(params, metod, comboId) {
    $(comboId).children().remove();
    $.ajax({
        type: "POST",
        url: SITEURL + "Service.asmx/" + metod,
        data: params,
        contentType: "application/json; charset=utf-8",
        async: false,
        dataType: "json",
        success: function (msg) {
            $.each(msg.d, function (index, item) {
                $(comboId).append("<option value=" + item.Key + ">" + item.Value + "</option>");
            });
        },
        error: function (e, x) {
            alert("HATA " + e.d);
        }
    });
}


function AjaxCalistir(metod, prm) {
    var s = new Sonuc();
    $.ajax({
        type: "POST",
        url: SITEURL + "Service.asmx/" + metod,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: prm,
        async: false,
        success: function (data) {
            $.each(data, function (a, b, c) {
                s.durum = b.Durum;
                s.mesaj = b.Mesaj;
                s.id = c.id;
            });
        }
    });
    return s;
};
function Sonuc(durum, mesaj, id) {
    this.durum = durum;
    this.mesaj = mesaj;
    this.id = id;
};

function HizliSepet(url) {
    $.fn.colorbox({ href: url, iframe: true, width: "700px", height: "650px", close: "KAPAT" });
}
