// Popup window kodu
var win= null;
function NewWindow(mypage,myname,w,h,scroll){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars='+scroll+',';
settings +='resizable=yes';
win=window.open(mypage,myname,settings);
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
} 
function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}



// Form Kontrolleri
function kontrol_odeme(){
if (!payment.p_ad.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Adı ve Soyadınızı yazınız...!"); payment.p_ad.focus(); return; }
if (!payment.p_evtel.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Sabit telefon yazınız...!"); payment.p_evtel.focus(); return; }
if (!payment.p_ceptel.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Cep Telefonunu yazınız...!"); payment.p_ceptel.focus(); return; }
if (!payment.p_adres.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Adresinizi yazınız...!"); payment.p_adres.focus(); return; }
if (!payment.p_il.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen İl seçiniz...!"); payment.p_il.focus(); return; }
if (!payment.p_ilce.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen İlçeyi yazınız...!"); payment.p_ilce.focus(); return; }

payment.submit();
}

function kontrol_uyeguncelle(){
if (!uyekayit.u_ad.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Adınızı ve Soyadınızı yazınız....!"); uyekayit.u_ad.focus(); return; }
if (!uyekayit.u_email.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen E-Mail'inizi yazınız...!"); uyekayit.u_email.focus(); return; }
if (!uyekayit.u_tckimlik.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen T.C. Kimlik No yazınız...!"); uyekayit.u_tckimlik.focus(); return; }
uyekayit.submit();
}

function kontrol_uyesifre(){
if (!uyekayit.u_sifre1.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Şifreyi yazınız...!"); uyekayit.u_sifre1.focus(); return; }
if (!uyekayit.u_sifre2.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Şifre Doğrulamayı yazınız....!"); uyekayit.u_sifre2.focus(); return; }
uyekayit.submit();
}

function kontrol_sifrehatirlat(){
if (!uyekayit.u_email.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Geçerli bir E-Mail adresi yazınız...!"); uyekayit.u_email.focus(); return; }
uyekayit.submit();
}

function kontrol_uyeyeni(){
if (!uyekayit.u_ad.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Üye Adı ve Soyadını yazınız....!"); uyekayit.u_ad.focus(); return; }
if (!uyekayit.u_email.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Üye E-Mail'ini yazınız...!"); uyekayit.u_email.focus(); return; }
if (!uyekayit.u_sifre1.value!="")   { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Şifreyi yazınız...!"); uyekayit.u_sifre1.focus(); return; }
if (!uyekayit.u_sifre2.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Şifre Doğrulamayı yazınız....!"); uyekayit.u_sifre2.focus(); return; }
uyekayit.submit();
}

function kontrol_yorumyaz(){
if (!uyekayit.mesaj.value!="") { alert("HATA...\nBilgilerde eksiklik var\n Lütfen mesajınızı yazınız....!"); uyekayit.mesaj.focus(); return; }
uyekayit.submit();
}

function kontrol_siparis(){
if (!payment.p_cardname.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Kart Sahibinin Adınızı ve Soyadını yazınız...!"); payment.p_cardname.focus(); return; }
if (!payment.p_cardno.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Kredi Kartı Numarasını yazınız...!"); payment.p_cardno.focus(); return; }
if (!payment.p_carday.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Kredi Kartınızın Son Kullanma Tarihini seçiniz....!"); payment.p_carday.focus(); return; }
if (!payment.p_cardyil.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Kredi Kartınızın Son Kullanma Tarihini seçiniz...!"); payment.p_cardyil.focus(); return; }
if (!payment.p_cardcv2.value!="") { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Kredi Kartınızın Güvenlik Kodunu yazınız...!"); payment.p_cardcv2.focus(); return; }
if (!payment.p_onay.checked!=false) { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Sözleşmeyi onaylayınız...!"); payment.p_onay.focus(); return; }
payment.submit();
}

function kontrol_siparis2(){
if (!payment.p_onay.checked!=false) { alert("BİLGİLERDE EKSİKLİK VAR\n\nLütfen Sözleşmeyi onaylayınız...!"); payment.p_onay.focus(); return; }
payment.submit();
}



function changeBG(id, bgClass) {
document.getElementById(id).className = bgClass;
}

function changeBG2(id1, id2, bgClass1, bgClass2) {
document.getElementById(id1).className = bgClass1;
document.getElementById(id2).className = bgClass2;
}

function secimyap(id, id2, tdclass, id3, id4, tdclass2, secim_id, secim_ad, secim_anahtar) { // beden seçimlerindeki classı değiştirmek için
document.getElementById(id).className = tdclass;
document.getElementById(id2).style.color = '#fff';
document.getElementById(id3).className = tdclass2;
document.getElementById(id4).style.color = '';
document.sec_form.sec1.value = id;
document.sec_form.sec2.value = id2;
document.basket.secim_id.value = secim_id;
document.basket.secim_ad.value = secim_ad;
document.getElementById("bedensecim").innerHTML = secim_ad+' '+secim_anahtar+' seçtiniz...';

}

function secimyap2(fiyat) { // paket sayfasında toplam fiyat gosterim
document.getElementById("fiyattoplam").innerHTML = fiyat;
}

function tabgoster(d1, d2, d3) { // ürün tab değişimi
document.getElementById("resim").style.display = d1;
document.getElementById("3d").style.display = d2;
document.getElementById("video").style.display = d3;
}

function adet_guncelle(islem) {
if(islem == "1") {
	document.basket.f_miktar.value = (document.basket.f_miktar.value * 1) + 1;
} else {
	if(document.basket.f_miktar.value == "1") {
	} else {
		document.basket.f_miktar.value = (document.basket.f_miktar.value * 1) - 1;
	}
} 
}



// Yukarı Fonksiyonu
$(document).ready(function() {  
$('a[rel*=top]').click(function(){  
        $('html, body').animate({scrollTop:0}, 'slow');  
         return false;  
    });  
}); 

// Yukari Fonksiyonu 2
var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:100, scrollto: 0, scrollduration:500, fadeduration:[500, 100]},
	controlHTML: '<img src="/images/up.png" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
	controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'En Üste Git'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

scrolltotop.init()
