$().ready(function() {
	$("body").append("<div id='dialog' style='display:none; zindex:9999999' ></div>");  //dialog da kullanmak için görünemz bir div atılıyor.
	/*
	$(document).bind('beforeReveal.facebox', function() {
    var height = $(window).height() - 250;
    $('#facebox .content').css('max-height', height + 'px');
    //$('#facebox').css('top', ($(window).scrollTop() + 50) + 'px');
	});
*/
	
	
});

function my_alert(icerik){
  jQuery.facebox(icerik);
  // $( "#dialog" ).html(icerik);  
  // $( "#dialog" ).dialog({ minWidth: 450 , closeOnEscape: true, modal: true  });
  //tb_show('','?height=300&width=300&inlineId=dialog');
};

/**
 *
 * @access public
 * @return void
 **/
function sozlesme_goster(){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sozleme_getir',
		success:function(cevap){
			//jQuery.facebox(cevap);
			
			//$( "#dialog" ).html(cevap);
			//$( "#dialog" ).dialog({ minWidth: 450 , closeOnEscape: true, modal: true  });
			my_alert(cevap);
		}
	})
}

/**
 *
 * @access public
 * @return void
 **/
function teslimat_saati_getir_il(){
	$('#divTeslimatSaatleri').html('');
	obj = document.getElementById('x_il');
	document.getElementById('x_ilce').style.visibility = 'hidden';
	stamp = new Date();
	teslimat_getIlce(obj.value, 'x_ilce');
	document.getElementById('x_ilce').style.visibility = '';
	
	/*$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=teslimat_saati_getir&il_id='+obj.value+'&t='+stamp,
		success:function(cevap){
			if (cevap != '') {
				c = cevap.split('|');
				if(c[0]!=1) {
					teslimat_getIlce(obj.value, 'x_ilce');
				 	document.getElementById('x_ilce').style.visibility = '';
				}
		    	$('#divTeslimatSaatleri').html(c[1]);
			}
		}
	})*/
}

function teslimat_saati_getir(ilce,tarih , forCheckout){
	t =(tarih == null)? '':'&tarih='+tarih;
	$('#divTeslimatSaatleri').html('<img src="images/loading.gif" alt="" />');
	// obj = document.getElementById('x_ilce');
	if (ilce != '') {
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=teslimat_saati_getir&ilce_id='+ilce+t+'&forCheckout='+forCheckout+'&t='+stamp,
		success:function(cevap){
				$('#divTeslimatSaatleri').html(cevap);
				
				checkoutSepetUpdate();
		}
	})
	}
}

function checkoutSepetUpdate() {
	$('#checkout_sepet').html('<img src="images/loading.gif" alt="" />');
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=checkoutSepetUpdate&t='+stamp,
		success:function(cevap){
				$('#checkout_sepet').html(cevap);
		}
	})
}


function getIlce(il, ilceField) {
	if(il=='') return;
	
	$.ajax({
		   type: 'POST',
		   url: '_ajax.php',
		   data: 'islem=ilce_ver&il='+ il,	   
		   success: function(sonuc) {	
		   		document.getElementById(ilceField).options.length = 1;			
				ilce = document.getElementById(ilceField);
				ilcedizi = sonuc.split("|");
				for(i=0;i<ilcedizi.length;i++) {				
					elm = ilcedizi[i].split('='); 
					ilce.options[ilce.options.length] = new Option(elm[1],elm[0]);
				}
				
		   }
	});

}

function teslimat_getIlce(il, ilceField) {
	if(il=='') return;
	
	$.ajax({
		   type: 'POST',
		   url: '_ajax.php',
		   data: 'islem=teslimat_ilce_ver&il='+ il,	   
		   success: function(sonuc) {	
		   		document.getElementById(ilceField).options.length = 1;			
				ilce = document.getElementById(ilceField);
				ilcedizi = sonuc.split("|");
				for(i=0;i<ilcedizi.length;i++) {				
					elm = ilcedizi[i].split('='); 
					opt = new Option(elm[1] + ' ' + elm[2],elm[0]);
					if(elm[2] != '') opt.style.color = "#800";
					ilce.options[ilce.options.length] = opt;
				}
				
		   }
	});

}



/**
 *	Dil değiştirme fonksiyonu
 **/
function dil_degistir(dil){
	obj_form = document.getElementById('frm_dil');
	if (obj_form && obj_form.x_dil) {
		obj_form.x_dil.value = dil;
		obj_form.submit();
	}
}


/**
 *	Seçilen önceki bir siparişteki ürünü sepete atar
 */
function siparisten_sepete(siparis_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=siparisten_sepete&siparis_id='+siparis_id,
		success:function(cevap){
			if(cevap != '') my_alert(cevap);
		    sepet_guncelle();
			$('#sepet2').slideDown('fast');	
		}
	})
}

/**
 *	Önceki siparişlerim kısmında sipariş ayrıntısı getirir
 */
function siparis_ayrinti_getir(siparis_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=siparis_ayrinti_getir&siparis_id='+siparis_id,
		success:function(cevap){
			// jQuery.facebox(cevap);
			//$( "#dialog" ).html(cevap);
			//$( "#dialog" ).dialog({ minWidth: 450 , closeOnEscape: true, modal: true  });
			my_alert(cevap);
			
		}
	})
}

/**
 *	Yeni adres eklemek için form oluşturur
 */
function form_yeni_adres(satir_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=yeni_adres_formu&satir_id='+satir_id,
		success:function(cevap){
		    my_alert(cevap);
		}
	})
}

/**
 *	Yeni adres ekleme formu için kontroller içerir
 */
function formKontrolAdres(form){
	if (form.adi.value == "" || form.adi.value == "NULL") {
		alert("Lütfen adres ismini giriniz!");
		form.adi.focus();
		return false;
	}
	if (form.adres.value == "" || form.adres.value == "NULL") {
		alert("Lütfen adres bilgisini giriniz!");
		form.adres.focus();
		return false;
	}
	if (form.a_il.value == "" || form.a_il.value == "NULL") {
		alert("Lütfen il seçiniz!");
		form.a_il.focus();
		return false;
	}
	if (form.a_ilce.value == "" || form.a_ilce.value == "NULL") {
		alert("Lütfen ilçe seçiniz!");
		form.a_ilce.focus();
		return false;
	}
	if (form.telefon.value == "" || form.telefon.value == "NULL") {
		alert("Lütfen telefon giriniz!");
		form.telefon.focus();
		return false;
	}
	return true;
}

/**
 *	Kişinin favori ürün listesine ürün ekler
 */
function favorileme_ekle(urun_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=favorileme_ekle&urun_id='+urun_id+'&t='+stamp,
		success:function(cevap){
			my_alert(cevap);
		}
	})
}

/**
 *	Kişinin favori ürün listesineden ürün siler
 */
function favorilerimden_cikar(urun_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=favorilemden_cikar&urun_id='+urun_id+'&t='+stamp,
		success:function(cevap){
			$('#divFv_'+urun_id).slideUp(300);
		}
	})
}

/**
 *  Verilen değerin eposta olup olmadığını kontrol eder
 */
function checkemail(object_value) {
	if (object_value.length == 0)
		return false;

	if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
		return false;

	return true;
}

/**
 *  Verilen isimdeki html nesnesinin display özelliğine verilen değeri set eder
 */
function setDisplay(objId, displayValue) {
	obj = document.getElementById(objId);
	if(obj)
		obj.style.display = displayValue;
}

/**
 *  Verilen ürünü sepete ekler
 */
function sepete_ekle(form_id,opt, onay){
	if(onay == null ) onay = 0;
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepete_ekle&x_urun_adet='+$('#x_urun_adet_'+form_id).val()+'&'+opt+'&onay='+onay+'&t='+stamp,
		success:function(cevap){
			//cal();
		    sepet_guncelle();
			$('#sepet2').slideDown('fast');	
			
			if (cevap != '') {
				if(cevap.indexOf('|') == -1) {
					my_alert(cevap);
					return;
				}
				yeni_cevap = cevap.split('|');
				if(yeni_cevap[0]=='1') {
					//jQuery.facebox("onay sorusu gelecek : "  + yeni_cevap[1] );
					$( "#dialog" ).html(yeni_cevap[1]);
					$( "#dialog" ).dialog({
						resizable: false,modal: true,minWidth:350,
						buttons: {
							"EVET": function() {
								$( this ).dialog( "close" );
								tedarik_edilince_gonder(yeni_cevap[2]);
							},
							"HAYIR": function() {
								$( this ).dialog( "close" );
							}
						}
					});

				}
				else {
					my_alert(yeni_cevap[1]);
				}
			} 
		}
	})
	
}

function tedarik_edilince_gonder(opt) {
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=tedarik_edilince_gonder&'+opt+'&t='+stamp,
		success:function(cevap){		
		}
	});
	
}

/**
 *
 * @access public
 * @return void
 **/
function sepet_goster(){
	obj_sepet = document.getElementById('theLayer');
	if (obj_sepet) {
		if (obj_sepet.style.visibility != 'visible') {
			// obj_sepet.style.visibility = 'visible';
			sepet_guncelle();
			//Diğer sayfalarda kapalı gelmesi için sepetin açık olduğunu SESSION a işliyor
			stamp = new Date();
			$.ajax({
				type:'POST',
				url:'_ajax.php',
				data:'islem=sepet_durum&durum=acik'
			})
		}
	}
}

/**
 *
 * @access public
 * @return void
 **/
function sepet_tutar(){
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepet_tutar&t='+encodeURI(new Date()),
		success:function(cevap){
			$('#divSepetTutar').fadeOut("fast", function() {
			    $('#divSepetTutar').html(cevap);
			});
			$('#divSepetTutar').fadeIn("fast");
		}
	})
}

/**
 *
 * @access public
 * @return void
 **/
function sepet_form(){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepet_form',
		success:function(cevap){
			my_alert(cevap);
		}
	})
}

/**
 *
 * @access public
 * @return void
 **/
function sepet_kaydet(){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:$('#frmSepetAdi').serialize()+'&islem=sepet_kaydet',
		success:function(cevap){
			$.facebox.close(); 
		    my_alert(cevap);
		}
	})
}

/**
 *  Verilen ürünü sepetten çıkarır
 */
function sepetten_cikar(id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepetten_cikar&x_id='+id,
		success:function(cevap){
		    //jQuery.facebox(cevap);
		    sepet_guncelle();
		}
	})
}

/**
 *  Sepet bilgisini günceller
 */
function sepet_guncelle(){
	obj_sepet = document.getElementById('theLayer');
	// if (obj_sepet.style.visibility != 'hidden' && obj_sepet.style.visibility != 'hide') {
		if(1==1) {
		//$('#td_sepet_icerik2').html('<img src="images/loading.gif" alt="" />');
		$.ajax({
			type:'POST',
			url:'_ajax.php',
			data:'islem=sepet_guncelle&time='+new Date(),
			success:function(cevap){
			    obj_sepet_icerik = document.getElementById('td_sepet_icerik2');
			    if (obj_sepet_icerik) {
			    	obj_sepet_icerik.innerHTML = cevap;
			    }
			    sepet_tutar();
				if( $('#checkout_sepet').length != 0) {
					checkoutSepetUpdate();		
					// teslimat saatleri baştan çağırılıyor		
					data=$('#x_teslimat_adresi option:selected').val();
					if(data!='') siparis_saati_getir(data,'',1);
				}
			}
		})
	}
	//yeni_sepet_guncelle();
}

/**
 * sag altaki sepeti günceller
 */
function yeni_sepet_guncelle(){
	obj_sepet = document.getElementById('stack');
	if (obj_sepet) {
		stamp = new Date();
		$.ajax({
			type:'POST',
			url:'_ajax.php',
			data:'islem=yeni_sepet_guncelle',
			success:function(cevap){
			    $('#stack').html(cevap);

				/*var vertical = 0;
				var horizontal = 0;
				var $el=$(this);
				$el.next().children().each(function(){
					$(this).animate({top: '-' + vertical + 'px', left: horizontal + 'px'}, openspeed);
					vertical = vertical + 55;
					//horizontal = (horizontal+.75)*2;
				});
				$el.next().animate({top: '-50px', left: '10px'}, openspeed).addClass('openStack')
				   .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed);
				$el.animate({paddingTop: '0'});*/
			}
		})
	}
}


/**
 *  Sepet bilgisini günceller
 */
function sepet_bosalt(){
    
    var res = confirm("Siparis Sepetini Silmek İstiyormusunuz ? ");
    if(res == true){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepet_bosalt',
		success:function(cevap){
		    sepet_guncelle();
		}
	})
        
    }    
}

/**
 *  Verilen ürünün sipariş miktarı textindeki değeri azaltır
 */
function miktar_azalt(text_id){
	obj = document.getElementById(text_id);
	if (obj)
		if (parseInt(obj.value) > 1)
			obj.value = parseInt(obj.value) - 1;
}

/**
 *  Verilen ürünün sipariş miktarı textindeki değeri artırır
 */
function miktar_artir(text_id){
	obj = document.getElementById(text_id);
	if (obj)
		obj.value = parseInt(obj.value) + 1;
}

/**
 *  Sepet içindeki ürün miktarını azaltır
 */
function sepet_adet_azalt(urun_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepet_miktar_azalt&urun_id='+urun_id+'&t='+stamp,
		success:function(){
			cal();
			sepet_guncelle();
		}
	})
}

/**
 *  Sepet içindeki ürün miktarını azaltır
 */
function sepet_adet_artir(urun_id){
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=sepet_miktar_artir&urun_id='+urun_id+'&t='+stamp,
		success:function(cevap){
			if (cevap != '') {
				//yeni_cevap = cevap.split('|');
				my_alert(cevap);
			} else {
				cal();
				sepet_guncelle();
			}
		}
	})
}

/**
 *
 * @access public
 * @return void
 * Ürün navigasyon barındaki linke tıklanınca alt kategorileri listeyen fonksiyon
 **/
function navigasyon_alt_kategori_getir(kategori_id, link){
	var offset = $(link).offset();
	obj_div = document.getElementById('kategori_navigasyon_list');
	if (obj_div) {
		obj_div.style.left = offset.left;
		obj_div.style.top = offset.top+20;
		obj_div.innerHTML = "Yükleniyor!..";
		obj_div.style.display = "block";
		stamp = new Date();
		$.ajax({
			type:'POST',
			url:'_ajax.php',
			data:'islem=navigasyon_alt_kategori_getir&kategori_id='+kategori_id,
			success:function(cevap){
			    if (obj_div) {
					alert(cevap);
			    	obj_div.innerHTML = cevap;
			    }
			}
		})
	}
	//alert(offset.left+','+offset.top);
}

function substr_count (haystack, needle, offset, length) {
// Returns the number of times a substring occurs in the string
//
// version: 1004.2314
// discuss at: http://phpjs.org/functions/substr_count    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// +   bugfixed by: Onno Marsman
// *     example 1: substr_count('Kevin van Zonneveld', 'e');
// *     returns 1: 3
// *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);    // *     returns 2: 0
// *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
// *     returns 3: false
var pos = 0, cnt = 0;
 haystack += '';
needle += '';
if (isNaN(offset)) {offset = 0;}
if (isNaN(length)) {length = 0;}
offset--;
while ((offset = haystack.indexOf(needle, offset+1)) != -1){
    if (length > 0 && (offset+needle.length) > length){
        return false;
    } else{            cnt++;
    }
}
return cnt;}

function str_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace
    //
    // version: 1004.2314
    // discuss at: http://phpjs.org/functions/str_replace    // +   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 = r instanceof Array, sa = s instanceof 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];
}




/*  **********************************************************************
Üst Menu
  ********************************************************************** */
  
	function megaHoverOver(){
		$(this).find('> ul').stop().fadeTo('fast', 1).show();
	}
	
	function megaHoverOut(){ 
	  $(this).find('ul:first').stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}
$().ready(function() {
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$(".subnav > ul").css({'opacity':'0'});
	$("li.subnav").hoverIntent(config);
	
	$(".subnav2 > ul").css({'opacity':'0'});
	$("li.subnav2").hoverIntent(config);
	
});
	
	
function divOpen() {
	//$('#extreme_menu_div').slideUp('fast').show();
	//$('#extreme_menu_div').stop().fadeTo('fast', 1).show();
	$('#extreme_menu_div').stop().fadeTo('fast', 1).show();
	}
function divClose() {
	//$('#extreme_menu_div').slideDown('fast').show();
	//$('#extreme_menu_div').stop().fadeTo('fast', 0).show();
	$('#extreme_menu_div').stop().fadeTo('fast', 0, function() {
		  $(this).hide();
	  });

}
if(dil=="tr") {
	img_src = 'images/ustmenu_urunler1.png';
	img_src1 = 'images/ustmenu_urunler1a.png';
	
	img_src_hover = 'images/ustmenu_urunler-hover1.png';
} else {
	img_src = 'images/ustmenu_urunler1_en.png';
	img_src1 = 'images/ustmenu_urunler1a_en.png';
	
	img_src_hover = 'images/ustmenu_urunler-hover1_en.png';
}
		
/*
var t=setTimeout("urunler_yan_son()",500);
		
function urunler_yan_son() {
	if($('#extreme_parent').attr('src') == img_src ) $('#extreme_parent').attr('src',img_src1);
	else $('#extreme_parent').attr('src',img_src);
	t=setTimeout("urunler_yan_son()",1000);
}
*/

$().ready(function() {
/* $('#extreme_parent').hover(
			function() {
				$('#extreme_menu_div').slideDown('fast').show();
				$('#extreme_parent').attr('src','images/tasarim2/ustmenu_urunler-hover1.png');
			},
			function() {
				$('#extreme_parent').attr('src','images/tasarim2/ustmenu_urunler1.png');

			}
		);
		*/
		
				
		if(dil=="tr") {
			//img_src = 'images/ustmenu_urunler1.png';
			// img_src1 = 'images/ustmenu_urunler1a.png';			
			//img_src_hover = 'images/ustmenu_urunler-hover1.png';
			
			img_src = 'images/ustmenu_urunler1.gif';
			img_src1 = 'images/ustmenu_urunler1.gif';
			img_src_hover = 'images/ustmenu_urunler1.gif';
		} else {
			img_src = 'images/ustmenu_urunler1_en.png';
			img_src1 = 'images/ustmenu_urunler1a_en.png';
			
			img_src_hover = 'images/ustmenu_urunler-hover1_en.png';
		}
		
		

		/*		
		$('#extreme_parent').hoverIntent( {  over:function() {
				$('#extreme_menu_div').slideDown('fast').show();
				$('#extreme_parent').attr('src',img_src_hover);
				clearTimeout(t);
			},   
     timeout: 500, // number = milliseconds delay before onMouseOut    
     out:function() {
				$('#extreme_parent').attr('src',img_src);
				t=setTimeout("urunler_yan_son()",500);
			}   
		});
		*/
		
		$('#extreme_parent').hover( function() {
				$('#extreme_menu_div').slideDown('fast').show();
				$('#extreme_parent').attr('src',img_src_hover);
				clearTimeout(t);
			},
			function() {
			}
		);

		$('#extreme_menu_div').hover(
			function() {

			},
			function() {
				$('#extreme_menu_div').slideUp('fast').show();
			}
		);


		$(".subnav2 > ul").each(function(index) {
			 toplamLi = $('li', this).length;
			 ortalama = Math.ceil(toplamLi/2);
			$(this).append("<div style='width:230px; float:left'></div>");
			$(this).append("<div style='width:230px; float:left; margin-left:5px;'></div>");
			d1 = jQuery('div:first',this);
			d2 = jQuery('div:last',this);
				solToplam = 0;
				$("> li", this).each(function() {
					adet = $('li', this).length + 1;
					if((solToplam+adet)<=ortalama) {
						solToplam += adet;
						$(this).appendTo(d1);
					} else $(this).appendTo(d2);
				});
		});
	
		
		$("#txt_quick_search").autocomplete("_ajax.php", {
		minChars: 3,
		max:100,
		width:$("#txt_quick_search").width,
		matchContains: true,
		selectFirst: false
	});
});
		
/* *************   ÜST MENÜ SONU **************** */

$().ready(function() {	
	// *****  üst slider ********* 

	
	$("#vitrinslider").scrollable({
			size: 4,
		circular: true, 
		speed: 200,	
		items: '#vitrinslidernavi',  
		next: 'div.slidenext',
		prev: 'div.slideprev',
		keyboard:false
	}).navigator(".navi").autoscroll(5000);

	
	
	// anasayfa tab
	// $('#container-4').tabs({ fxFade: true, fxSpeed: 'fast' });
});



/*
// ses çalmak için gerekli kodlar
// javascripte cal()  dediğinnde beep sesini çlıyor.isteğe bağlı olarak () içine istenilen mp3 yazılarak başka şeyde çalınabilir
*/
function thisMovie1(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
function cal(dosya) {
	return;
	if(typeof dosya == 'undefined') dosya = "Till_beep.mp3";
	thisMovie1("ses").cal(dosya);
}



// ***************************************

		jQuery(function( $ ){

			sepetHoverOldu = false;
/*			
			$('#sepet_ac').hoverIntent( {  over:function() {
				if(sepetHoverOldu==false) $('#sepet2').slideDown('fast');
			},   
     timeout: 1000, // number = milliseconds delay before onMouseOut    
     out:function() {
				if(sepetHoverOldu == false ) {
					
					// $('#sepet2').slideUp('fast');
					// sepetHoverOldu = false;
					
				}

			}   
		});
*/

			$('#sepet_ac').click(
				function( event ){
					$('#sepet2').toggle();
				}
			);
			
			$( "#sepet_kapat" ).click(
				function( event ){
					$('#sepet2').slideUp( 'fast' );
				}
			);
			
			
			/*
			$('#sepet2').hover(
			function() {
				sepetHoverOldu = true;
			},
			function() {
				container.slideUp( 2000 );
				sepetHoverOldu = false;
			}
			);
			*/
			$('#sepet2').hoverIntent( {  over:function() {
				sepetHoverOldu = true;
			},   
     timeout: 1000, // number = milliseconds delay before onMouseOut    
     out:function() {
					// $('#sepet2').slideUp('fast').show();
					sepetHoverOldu = false;
			}   
		});

		
			
		
		// button1 class lı butonlar jquery-ui button ları
		$(".button1").button();
		
		
		sepet_guncelle();
 
		});



function kullaniciGirisiYap(form) {
 	return true;
}

function forgot_pwd() {
	//jQuery.facebox('<img src="images/loading.gif" alt="" />');
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=form_forgot_pwd&t='+stamp,
		success:function(cevap){
			my_alert(cevap);
		}
	})
}

function post_forgot_pwd(form) {
	if (!checkemail(form.x_eposta.value)) {
		$('#divForgotPwdInfo').html('Lütfen geçerli bir eposta adresi giriniz!');
	} else {
		stamp = new Date();
		$.ajax({
			type:'POST',
			url:'_ajax.php',
			data:$('#frmForgotPwd').serialize()+'&islem=send_forgot_pwd&t='+stamp,
			success:function(cevap){
				$('#divForgotPwdInfo').html(cevap);
			}
		})
	}
}


function urune_mesaj(urunId) {
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=urune_mesaj&urunId='+urunId+'&t='+stamp,
		success:function(cevap){
			my_alert(cevap);
		}
	})
}

function post_urune_mesaj(form) {
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:$('#urune_mesaj_form').serialize()+'&islem=post_urune_mesaj&t='+stamp,
		success:function(cevap){
			my_alert(cevap);
		}
	})
}

function ajaxSort(bu,alan,yon) {	
	if(yon=='ASC') yon= 'DESC';
	else yon = 'ASC';
	gorunum =$(bu).parent().parent().parent().attr('gorunum');
	if(gorunum =='') gorunum = 'list_view';
	table = $(bu).parent().parent().parent();
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'idler='+$(table).attr('rel')+'&order='+alan+'&yon='+yon+'&islem=ajaxSort&'+'&gorunum='+gorunum+'&t='+stamp,
		success:function(cevap){
			$(table).parent().html(cevap);
		}
	})
}

function nasil_buldunuz() {	
	stamp = new Date();
	$.ajax({
		type:'POST',
		url:'_ajax.php',
		data:'islem=nasil_buldunuz',
		success:function(cevap){
			my_alert(cevap);
		}
	})
}
