//Sadece rakan girilmesini sağlayan fonksiyon
function alpha(e) {
	var numbers='1234567890';
	var k;
	k=document.all?parseInt(e.keyCode): parseInt(e.which);
	 if(numbers.indexOf(String.fromCharCode(k))!=-1);
	else{
		alert("Lütfen sadece rakam giriniz");
		return (false);
	}
}

function check_char(e) {
	var characters='abcdefghijklmnopqrstuvwxyz1234567890_?=)(/&%+é!€';
	var k;
	k=document.all?parseInt(e.keyCode): parseInt(e.which);
	if(characters.indexOf(String.fromCharCode(k))!=-1)
		return (true);
	else{
		alert("BÜYÜK harf, TÜRKÇE karakter ve BOŞLUK kullanmayınız.");
		return (false);
	}
}

function sepet_bosalt_onay(){
	if( confirm("Devam etmeniz durumunda sepetinizdeki ürünler silinecektir!!\nSilmek istediğinize emin misiniz?") ){
		return true;
	}
	return false;
}
function uye_bilgi_adres_sil_onay()
{
	if( confirm("Devam etmeniz durumunda seçtiğiniz adresler silinecektir!!\nSilmek istediğinize emin misiniz?") ){
		return true;
	}
	return false;	
}
//yeni_uye.php için alan kontrolü yapar
function firmakayit_kontrol()
{
	if(form_firmakayit.adi.value == ''){
		alert( 'Adınızı Girmeniz Zorunludur...');
		form_firmakayit.adi.focus();
		return(false);
	}
	if(form_firmakayit.soyadi.value == ''){
		alert( 'Soyadınızı Girmeniz Zorunludur...');
		form_firmakayit.soyadi.focus();
		return(false);
	}
	return(true);
}
// JavaScript Document
function ackapa() {
	var oElem = event.srcElement.nextSibling;
	if (oElem.style == null) {
		eval('oElem = document.all.u' + event.srcElement.name + ';');
	}
	if (oElem == null) {
		return true;
	}
	if (oElem.style.display == "none") {
		oElem.style.display= "block";
	}
	else {
		oElem.style.display= "none";
	}
}

//firma_ayrinti.php sayfasındaki menülerin açılıp kapanmasını sağlayan fonksiyon
function firma_ayrinti_menu_ackapa(i) {
	if(document.getElementById('alt_acik'+i).value==0){
			document.getElementById('alt_acik'+i).value = 1;
			document.getElementById('alt'+i).style.display = 'block';
			document.getElementById('ikon_ac'+i).style.display='none';
			document.getElementById('ikon_kapat'+i).style.display='block';
	}else{
			document.getElementById('alt_acik'+i).value = 0;
			document.getElementById('alt'+i).style.display = 'none';
			document.getElementById('ikon_ac'+i).style.display='block';
			document.getElementById('ikon_kapat'+i).style.display='none';
	}
}

function gotoURL(adres)
{
	window.location = adres;
}

function check_uye_bilgi()
{
	if(document.form_uye_bilgi.adi.value == ''){
		alert( 'Adınızı Girmeniz Zorunludur...');
		document.form_uye_bilgi.adi.focus();
		return(false);
	}
	if(document.form_uye_bilgi.soyadi.value == ''){
		alert( 'Soyadınızı Girmeniz Zorunludur...');
		document.form_uye_bilgi.soyadi.focus();
		return(false);
	}
	if(!emailCheck(document.form_uye_bilgi.email.value)){
		document.form_uye_bilgi.email.focus();
		return(false);
	}
	if( !(document.form_uye_bilgi.cinsiyet[0].checked || document.form_uye_bilgi.cinsiyet[1].checked) ){
		alert( 'Cinsiyet Belirtmeniz Zorunludur ...');
		document.form_uye_bilgi.cinsiyet[0].focus();
		return(false);
	}
	if(document.form_uye_bilgi.sifre.value != document.form_uye_bilgi.sifre_tekrar.value){
		alert( 'Şifrelerinizde tutarsızlık var. Lütfen bir daha giriniz...');
		document.form_uye_bilgi.sifre.focus();
		return(false);
	}
	
	if( !isDate(document.form_uye_bilgi.dogtar.value) ){
		document.form_uye_bilgi.dogtar.focus();
		return(false);
	}	
	
	return(true);
}

//yeni_uye.php için alan kontrolü yapar
function check_yeni_uye()
{
	if(document.form_uye.kadi.value == ''){
		alert( 'Kullanıcı Adını Girmeniz Zorunludur...');
		document.form_uye.kadi.focus();
		return(false);
	}
	if(document.form_uye.adi.value == ''){
		alert( 'Adınızı Girmeniz Zorunludur...');
		document.form_uye.adi.focus();
		return(false);
	}
	if(document.form_uye.soyadi.value == ''){
		alert( 'Soyadınızı Girmeniz Zorunludur...');
		document.form_uye.soyadi.focus();
		return(false);
	}
	if(!emailCheck(document.form_uye.email.value)){
		document.form_uye.email.focus();
		return(false);
	}
	if( !(document.form_uye.cinsiyet[0].checked || document.form_uye.cinsiyet[1].checked) ){
		alert( 'Cinsiyet Belirtmeniz Zorunludur ...');
		document.form_uye.cinsiyet[0].focus();
		return(false);
	}
	if(document.form_uye.sifre.value == ''){
		alert( 'Şifre Girmeniz Zorunludur...');
		document.form_uye.sifre.focus();
		return(false);
	}
	if(document.form_uye.sifre_tekrar.value == ''){
		alert( 'Şifre(Tekrar) Girmeniz Zorunludur...');
		document.form_uye.sifre_tekrar.focus();
		return(false);
	}
	if(document.form_uye.sifre.value != document.form_uye.sifre_tekrar.value){
		alert( 'Şifrelerinizde tutarsızlık var. Lütfen bir daha giriniz...');
		document.form_uye.sifre.focus();
		return(false);
	}
	if( !isDate(document.form_uye.dogtar.value) ){
		document.form_uye.dogtar.focus();
		return(false);
	}	
	return(true);
}

function check_uye_bilgi_adres_form()
{
	if(document.form_adres.bolge_no.value == -1){
		alert("Bölge seçmediniz!");
		document.form_adres.bolge_no.focus();
		return(false);
	}
	if(document.form_adres.adres.value == ""){
		alert("Adres girmediniz!");
		document.form_adres.adres.focus();
		return(false);
	}
	if(document.form_adres.tel.value == ""){
		alert("Telefon girmediniz!");
		document.form_adres.tel.focus();
		return(false);
	}
	if (((document.form_adres.tel.value / document.form_adres.tel.value) != 1) && (document.form_adres.tel.value != 0)) {
		alert("Lütfen telefon alanına sadece rakam giriniz!") ;
		document.form_adres.tel.focus();
		return false ;
	}
	var TestLength=document.form_adres.tel.value ;
	if (TestLength.length < 7) {
		alert("Telefon numaranızın 7 rakamdan oluşması gerekmektedir!") ;
		document.form_adres.tel.focus();
		return false ;
	}
	if(document.form_adres.kod.value == ""){
		alert("Telefon kodunuzu girmediniz!");
		document.form_adres.kod.focus();
		return(false);
	}
	var TestLength2=document.form_adres.kod.value ;
	if (TestLength2.length < 3) {
		alert("Telefon alan kodunuzun 3 rakamdan oluşması gerekmektedir!") ;
		document.form_adres.kod.focus();
		return false ;
	}
	if (((document.form_adres.kod.value / document.form_adres.kod.value) != 1) && (document.form_adres.kod.value != 0)) {
		alert("Lütfen telefon alan koduna sadece rakam giriniz!") ;
		document.form_adres.kod.focus();
		return false ;
	}
	if(document.form_adres.adi.value == ".... Adresim"){
		alert("Adres Başlığı Girmediniz!");
		document.form_adres.adi.focus();
		return(false);
	}
}

function fatura_goster()
{
	document.getElementById("t_fatura").style.display  = "block";
}

function fatura_gizle()
{
	document.getElementById("t_fatura").style.display  = "none";
}

function check_siparis_onay1()
{
	if(document.form_siparisonay.odemesekli_no.value == -1){
		alert("Ödeme sekli seçmediniz!");
		document.form_siparisonay.odemesekli_no.focus();
		return(false);
	}
	if( document.form_siparisonay.faturafis[1].checked ){//Fatura istenmişse
		if( document.form_siparisonay.firmatur[0].checked ){//Gerçek Kişiyse
			if(document.form_siparisonay.firma_adres.value == ""){
				alert("Firma adresi girmek zorundasınız!");
				document.form_siparisonay.firma_adres.focus();
				return(false);
			}
			if(document.form_siparisonay.is_adi_soyadi.value == ""){
				alert("Ad, soyad girmek zorundasınız!");
				document.form_siparisonay.is_adi_soyadi.focus();
				return(false);
			}
			if(document.form_siparisonay.tckimlikno.value == ""){
				alert("TC Kimlik Numarınızı girmek zorundasınız!");
				document.form_siparisonay.tckimlikno.focus();
				return(false);
			}
		}
		else{//Tüzel Kişiyse
			if(document.form_siparisonay.firma_adres.value == ""){
				alert("Firma adresi girmek zorundasınız!");
				document.form_siparisonay.firma_adres.focus();
				return(false);
			}
			if(document.form_siparisonay.firmaadi.value == ""){
				alert("Firma adı girmek zorundasınız!");
				document.form_siparisonay.firmaadi.focus();
				return(false);
			}
			if(document.form_siparisonay.vergidaire.value == ""){
				alert("Vergi Dairenizi girmek zorundasınız!");
				document.form_siparisonay.vergidaire.focus();
				return(false);
			}
			if(document.form_siparisonay.vergino.value == ""){
				alert("Vergi Numarınız girmek zorundasınız!");
				document.form_siparisonay.vergino.focus();
				return(false);
			}
		}
	}
	return(true);
}
function kontrol_siparis1()
{
	flag = true;
	if(document.getElementsByName("adres_no").length > 1){	
		for(i=0; i<document.getElementsByName("adres_no").length; i++){
			if(form_siparisonay1.adres_no[i].checked){
				flag = false;
			}
		}
	}
	else if(document.getElementsByName("adres_no").length == 1){
		if(form_siparisonay1.adres_no.checked){
			flag = false;
		}
	}
	else{
		alert("Kayitli herhangi bir teslimat adresiniz bulunamadi!!!")
		form_siparisonay1.action = 'uye_bilgi_adres_form.php';
		return(true);
	}
	if(flag){
		alert("Teslimat adresi seçmediniz ...");
		return(false);
	}
	return(true);
}
//E-mail checking

<!-- Changes:  Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

/* 1.1.2: Fixed a bug where trailing . in e-mail address was passing
            (the bug is actually in the weak regexp engine of the browser; I
            simplified the regexps to make it work).
   1.1.1: Removed restriction that countries must be preceded by a domain,
            so abc@host.uk is now legal.  However, there's still the 
            restriction that an address must end in a two or three letter
            word.
     1.1: Rewrote most of the function to conform more closely to RFC 822.
     1.0: Original  */

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email adresiniz dogru görünmüyor (@ ve . isaretlerine dikkat ediniz)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("Email adresinizde girmis oldugunuz kullanici adi dogru görünmüyor")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Internet kayitli olmayan adres girdiniz ...")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Internet kayitli olmayan adres girdiniz ...")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("E-mail adresinizin uzantisi dogru görünmüyor ...")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="E-mail adresinizde hata !!!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}
//  End -->

function movein(which){
which.style.background='#8CBAE8'

}

function moveout(which){
which.style.background='#F0F1F2'

}

function movein2(which){
which.style.background='#8CBAE8'

}

function moveout2(which){
which.style.background='#00CCFF'

}

function mhHover(tbl, idx, cls)
{
	var t = document.getElementById(tbl);
	if (t == null) return;
	var d = t.getElementsByTagName("TD");
	if (d == null) return;
	if (d.length <= idx) return;
	d[idx].className = cls;
}

function arama_sonuc_goster()
{
	if(form_anasayfa.a_bolge_no.value != -1 || form_anasayfa.a_falan_no.value != -1){
		if(form_anasayfa.a_bolge_no.value == -1){
			url = 'arama_sonuc_firma.php?falan_no=' + (form_anasayfa.a_falan_no.value).toString(10);
			gotoURL(url);
		}
		else if(form_anasayfa.a_falan_no.value == -1){
			url = 'arama_sonuc_firma.php?bolge_no=' + (form_anasayfa.a_bolge_no.value).toString(10);
			gotoURL(url);
		}
		else{
			url = 'arama_sonuc_firma.php?bolge_no=' + (form_anasayfa.a_bolge_no.value).toString(10) + '&falan_no=' + (form_anasayfa.a_falan_no.value).toString(10);
			gotoURL(url);
		}
	}
	else{
		return false;
	}
}
function gbg()//gonderim bolgelerini goster - gbg
{

	if(document.getElementById('acik').value==0)
	{//goster
		document.getElementById('acik').value = 1;
		document.getElementById('gbg_tum_gb').style.display = "block";
	}
	else
	{//gizle
		document.getElementById('acik').value = 0;
		document.getElementById('gbg_tum_gb').style.display = "none";
	}
}

/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year BAŞI
var dtCh= ".";
var minYear=1890;
var maxYear=2007;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Tarih formatı gg.aa.yyyy şeklinde olmalıdır")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Lütfen geçerli bir ay giriniz")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Lütfen geçerli bir gün giriniz")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert(minYear+" ve "+maxYear+" arasında geçerli bir yıl giriniz")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Lütfen geçerli bir tarih giriniz")
		return false
	}
return true
}
/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year SONU