function mt_uyari(mesaj) {
alert(mesaj + "mehmet");
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

/**
 * Nette Technologies | www.nette.com.tr
 * 04-2011
 */

/* Common */
var RUNNINGURL = "";
var msie6 = $.browser.msie && $.browser.version<7 ? true : false;
var usrckie='';

$(document).ready(function(){
       $(".hediye_check").click(function(){     
        if ($(".hediye_check").is(":checked")){
            $(".hediye_div").slideDown();
            $(".devam").css("visibility", "hidden");
			} else{     
            $(".hediye_div").slideUp();
			$(".devam").css("visibility", "");
			}
      });  

       $(".note_check").click(function(){     
        if ($(".note_check").is(":checked")){
			//alert("ok");
            $(".note_alan").slideDown();
			} else{     
            $(".note_alan").slideUp();
			}
      }); 

       $(".note_ad_check").click(function(){     
        if ($(".note_ad_check").is(":checked")){
			//alert("ok");
            $(".note_ad_alan").slideUp();
			} else{     
            $(".note_ad_alan").slideDown();
			}
      }); 

    });

$(window).load(function (){
    setTimeout(function (){ $("label.overlabel").overlabel(); }, 50); // chrome autofill activates after dom load + some time
	$("#sizes").attr("disabled", true);
	$(".mark_a").click(function(){
		$(".ac_div").slideToggle("slow");
		$(this).toggleClass("aktif"); return false;
	});
});

$().ready(function(){
    
    /*var headID = document.getElementsByTagName("head")[0];         
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = _staticPath+'css/style-nonvalid.css';
    cssNode.media = 'screen';
    headID.appendChild(cssNode);*/

    //$("label.overlabel").overlabel();
    sayacCalistir();
    
    usrckie = getCookie('usrckie');if(usrckie==''||usrckie==undefined){usrckie=randomString(45);setCookie('usrckie',usrckie,365);}
    if(msie6){ $('body').addClass('msie6'); }

    /*$(".tabs").children("ul").find("a").addClass("noSmoothScroll");
    enable_smooth_scroll(".noSmoothScroll");
    
    $(".tabs").tabs({ fx: { opacity: 'toggle', duration: "fast" } });*/
    
    $(".toTheTopBtn").click(function(){
        $('html, body').animate({ scrollTop: 0 }, "fast");
        return false;
    });
    
    var bezoomSets = {
        bgColor : '#5398EE',
        color : '#ffffff',
        width : 625,
        height : 350,
		marginLeft : 20,
		marginTop: 10
    };
    function addLensF(el){
        if (!$(el).data("lensAdded")) {
            $(el).addLens(50, 50);
            $(el).data("lensAdded", true);            
        }
    }
    if ($(".inZoom").size() > 0) {
        addLensF(".inZoom img:first");
        $(".inZoom a").each(function (){
            var aPar = $(this).parent("a");
            if (aPar.size() > 0) {
                $(this).addClass(aPar.attr("class"));
                $(this).attr("href", aPar.attr("href"));
                $(this).attr("title", aPar.attr("title"));
                $(this).attr("rel", aPar.attr("rel"));
                $(this).unwrap();
            }
        });
        $(".inZoom").bezoom(bezoomSets);
    }
    
    $("#dThumbs a").click(function (){
        var liPar = $(this).parents("li:first");
        liPar.siblings().removeClass("current");
        liPar.addClass("current");
        $("#dPhoto a.inZoom").stop(true, true).hide();
        var el = $("#dPhoto a.inZoom").eq(liPar.index());
        el.fadeIn();
        addLensF(el.find("img"));
        return false;
    });
    
    $(".umA.gelecek a, #navigation .nUpcoming").click(function (){
        return false;
    });
    
    if ($(".salesLi .umA").size() > 0) {
        $("#navigation .nSales").dropdownize({
            menuEl: ".salesLi .umA"
            ,hideAfter: 100
        });
    }
    
    if ($(".upcomingLi .umA").size() > 0) {
        $("#navigation .nUpcoming").dropdownize({
            menuEl: ".upcomingLi .umA"
            ,hideAfter: 150
        });
    }
    
    $(".tipChg").live("change", function (){
        var r = /tipChg_([^\s]*)/.exec($(this).attr("class"));        
        var el = $(".firmaAdDivs_" + r[1]);
        if ($(this).val() == "1") {
            el.slideUp();
        } else {
            el.slideDown();
        }
    });
    
    $(".addrKaydChg").change(function (){
        var r = /addrKaydChg_([^\s]*)/.exec($(this).attr("class"));        
        var el = $(".adresAdDivs_" + r[1]);
        var par = $(this).parents(".adresDiv:first");
        var $this = $(this);
        if ($(this).val() == "") {
            el.slideDown();
            par.find("input:text, textarea, .ilSec").val("").change();
            par.find(".tipChg:first").attr("checked", "checked").change();
        } else {
            el.slideUp();
            $.ajax({
        		type: "GET",
        		url: "ajax_fonksiyonlar.php?ac=adres",
        		data: {id:$this.val()},
        		success: function(ret){
  		            var els = null;
                    for (k in ret) {
                        els = par.find('[name="' + r[1] + 'Addr['+k+']"]');
                        if (els.size() > 0) {
                            els.filter("input:text, textarea, select").val(ret[k]);
                            if (els.is("input:radio")) {
                                els.each(function (){
                                    if ($(this).val() == ret[k]) {
                                        $(this).attr("checked", "checked").change();
                                    }
                                });
                            }
                            if (els.hasClass("ilSec")) {
                                els.change();
                            }
                            if (els.hasClass("ilceSec")) {
                                els.data("secilecekIlce", ret[k]);
                            }
                        }
                    }
        		},
                dataType: "json"
        	});
        }
    });
    
    $(".ilSec").change(function (){
        var r = /ilSec_([^\s]*)/.exec($(this).attr("class"));
        var ilceSel = $(".ilceSec_" + r[1]);
        var $this = $(this);
        ilceSel.removeOption(/.+/i);
        if ($this.val()) {
            ilceSel.addOption({"0":"İlçeler yükleniyor..."}, false);
            $.ajax({
        		type: "GET",
        		url: "ajax_fonksiyonlar.php?ac=ilceler",
        		data: {il:$this.val()},
        		success: function(ret){
                    ilceSel.removeOption(1);
                    ilceSel.addOption(ret, false);
                    if (ilceSel.data("secilecekIlce")) {
                        ilceSel.val(ilceSel.data("secilecekIlce"));
                        var sec = ilceSel.data("secilecekIlce");
                        ilceSel.data("secilecekIlce", false);
                    }
        		},
                dataType: "json"
        	});
        }
    });
    
    $(".copyAddrBillToDeliv, .copyAddrDelivToBill").click(function (e){
        var _srcPre = "";
        var _targPre = "";
        if ($(this).is(".copyAddrBillToDeliv")) {
            var _srcPre = "billAddr";
            var _targPre = "delivAddr";
        } else if($(this).is(".copyAddrDelivToBill")) {
            var _srcPre = "delivAddr";
            var _targPre = "billAddr";
        }
        $("[name^=" + _srcPre + "]").each(function () {
            var targEl = $('[name="' + _targPre + '['+$(this).attr("name").split(/\[|\]/)[1]+']"]');
            var $this = $(this);
            if ($(this).is("input:text, select, textarea")) {
                if (targEl.val() != $(this).val()) {
                    targEl.val($(this).val());
                    if ($(this).hasClass("ilSec")) {
                        targEl.change();
                    }
                    if ($(this).hasClass("ilceSec")) {
                        targEl.data("secilecekIlce", $(this).val());
                    }
                }
            } else if ($(this).is("input:radio:checked")) {
                targEl.each(function (){
                    if ($this.val() == $(this).val() && !$(this).attr("checked")) {
                        $(this).attr("checked", "checked").change();
                    }
                });
            }
        });
        e.preventDefault();
    });
    
    $("input[name='addrAyni']").change(function (){
        if ($(this).val() == "0") {
            $(".addrFat").addClass("fl");
            $(".addrFat h2 span").hide();
            $(".addrSag").show();
        } else {
            $(".copyAddrBillToDeliv").click();
            $(".addrFat").removeClass("fl");
            $(".addrFat h2 span").show();
            $(".addrSag").hide();
        }
    });
    
    $('input.customInput').customInput();
    
    $(".panelOpen").click(function (){
        var r = /panelOpen_([^\s]*)/.exec($(this).attr("class"));
        var t = $(".panel_" + r[1]);
        if ($(this).hasClass("open")) {
            $(this).removeClass("open").addClass("closed");
            t.slideUp();
        } else {
            $(this).removeClass("closed").addClass("open");
            t.slideDown();
        }
    });
    
    $("a[rel='facebox'], a[rel='colorbox']").each(function (){
        var opts = {
            slideshowStart : "sunu başlat"
            ,slideshowStop : "sunu durdur"
            ,current : "{current} / {total}"
            ,previous : "önceki"
            ,next : "sonraki"
            ,close : "kapat"
        };
        if (!$(this).hasClass("cBoxGroup")) {
            opts.rel = "nofollow";
        }
        if ($(this).hasClass("cBoxIframe")) {
            opts.iframe = true;
        }
        if ($(this).attr("href")) {
            var params = getUrlParams($(this).attr("href"));
            $.each(["width", "height"], function (k, v){
                opts[v] = params[v];
            });
        }
        if (/^#/.test($(this).attr("href"))) {
            opts.html = $($(this).attr("href")).html(); 
        }
        $(this).colorbox(opts);
    });
    
    $("#haveAdvice a").colorbox({
        iframe: true
        ,width: 720
        ,height: 720
    });
    
    $(".cBoxCloseNoCss").live("click", function(){
        $.colorbox.close();
        if (parent && parent.$) {
            parent.$.colorbox.close();
        }
        return false;
    });
    
    $(".genConf").click(function (){
        cBoxConfirm("Onay", "Emin misiniz?", $(this).attr("href"));
        return false;
    });
    
});

/* Scroll To */
var RefreshUrl,RefreshTime,pagerefresh=true,RefreshControl = function(url,time){
    RefreshUrl=url;RefreshTime=time;
    thispagerefresh=window.setTimeout(function(){if(pagerefresh){ setCookie('ScrollTo',$(window).scrollTop(),1);window.location.href=RefreshUrl; }},RefreshTime);
}
$().ready(function(){
    var ScrollToPos=getCookie('ScrollTo');
    if(ScrollToPos!='' && Number(ScrollToPos)>0){
        setCookie('ScrollTo',0,1);
        $('html, body').animate({scrollTop:Number(ScrollToPos)},1000,function(){});
    }
});


