﻿/*########################################################################*/
function defaultButton(e,buttonId)
{
    var unicode=(window.event)?event.keyCode:e.keyCode;
    if(unicode==13)
        document.getElementById(buttonId).click();
}
/*########################################################################*/


/*########################################################################*/
function disableButton(ctrId,validate)
{   
    if(validate==true)
    {
        if(Page_ClientValidate()==false)
        {
            return false;
        }
    }
        ctrId.value='Lütfen Bekleyiniz';         
        ctrId.disabled=true;     
}
/*########################################################################*/

/*########################################################################*/
function txtSil(id)
    {
        var x=document.getElementById(id);
        if(x.value=='Search By Code...' || x.value=='Ürün Ara...')
            x.value='';
    }
/*########################################################################*/    
    
/*########################################################################*/    
function txtDoldur(id,dil)
    {
        var x=document.getElementById(id);

        if(x.value=='')
        {
            if(dil=='Eng')
                x.value='Search By Code...';
            else
                x.value='Ürün Ara...'
        }
    }
/*########################################################################*/    

/*########################################################################*/
function keyKod(e)
{
  var unicode = (window.event) ? event.keyCode : e.keyCode;
  return unicode;
  
}
/*########################################################################*/

function boslukYok(e, kontrolid) {

    var karakter = (window.event) ? event.keyCode : e.keyCode;
    if (karakter == 32) {
        var reg = /\s+/;
        var txt = document.getElementById(kontrolid);
        txt.value = txt.value.replace(reg, '');
    }
}


/*########################################################################*/        
function Ara(dil)
   {
        var x=document.getElementById('txtSearch');
        x.value=x.value.replace(/^\s+|\s+$/g,"");

        if(x.value=='Search By Code...' || x.value=='Ürün Ara...' || x.value=='') 
        {
            if(dil=='Eng')
                alert('\nPlease write a product code to search for.');
            else
                alert('\nLütfen Aranacak Ürün Kodunu Yazınız.');
            return false;
        }            

        ajaxUrunKodAra(document.getElementById('txtSearch').value);
        return false;
   }
/*########################################################################*/
function nane()
{    
    if(document.getElementById('VolusionLiveChat')!=null)
    {
        document.getElementById('VolusionLiveChat').innerHTML=document.getElementById('VolusionLiveChat').innerHTML.replace('FREE chat by Volusion','');
    }
}
/*########################################################################*/

/*########################################################################*/
function link(yol)
{
    window.location=yol;
}
/*########################################################################*/

/*########################################################################*/
function KontrolAktif(id)
{
//    if(validate==true)
//    {
        if(Page_ClientValidate()==false)
        {
            document.getElementById(id).disabled=true;
            return false;
        }
//    }
    document.getElementById(id).disabled=false;
}
/*########################################################################*/

/*########################################################################*/
function OpenWin(link,winW,winH)
{
    var wleft=(screen.availWidth-winW)/2;
    var wtop=(screen.availHeight-winH)/2; 
    
    window.open(link,'','width=' + winW + ',height=' + winH + ',top='+ wtop + ',left=' + wleft + ',location=no,titlebar=no,menubar=no,status=no,toolbar=no,resizable=yes,modal=no,scrollbars=yes');           
}
/*########################################################################*/

/*########################################################################*/
function UyeBilgi(ID)
{
    var link='UyeBilgi.aspx?UsID=' + ID;
    
    var winW=900;
    var winH=650;
    
    var wleft=(screen.availWidth-winW)/2;
    var wtop=(screen.availHeight-winH)/2;
    
    window.open(link,'','width=' + winW + ',height=' + winH + ',top='+ wtop + ',left=' + wleft + ',location=no,titlebar=no,menubar=no,status=no,toolbar=no,resizable=yes,modal=no,scrollbars=yes');           
}
/*########################################################################*/

/*########################################################################*/
function ulkeBilgi(ulke,DropSehirId,TextSehirId)
{
   
    if(document.getElementById(ulke).value=='Türkiye')
    {  
        document.getElementById(DropSehirId).style.display='block';
        //document.getElementById(DropSehirId).value='';
        document.getElementById(TextSehirId).style.display='none';
        document.getElementById(TextSehirId).value=document.getElementById(DropSehirId).value
    }    
   else
   {
        document.getElementById(DropSehirId).style.display='none';
        document.getElementById(TextSehirId).style.display='block';
        document.getElementById(TextSehirId).value='';
   }
   
}
/*########################################################################*/

/*########################################################################*/
function sehirGir(sehir,id)
{
    document.getElementById(id).value=sehir;    
}
/*########################################################################*/

/*########################################################################*/
function aktifGrupMenu(id)
{    
    var oncekiMenu=document.getElementById('menuAdi');
    
    if(oncekiMenu.value!='')
        aktifGrupMenuGeri(oncekiMenu.value)
        
    document.getElementById('altMenuAdi').value='';
    
    oncekiMenu.value=id;
    
    id=id.replace(/_./g," ");

    document.getElementById(id).style.backgroundColor='#848484';
    document.getElementById(id).style.backgroundImage='url(/AkgunWeb/Images/bleftDark.gif)';
    document.getElementById(id + 'tr').style.backgroundImage='url(/AkgunWeb/Images/bos.gif)';
    document.getElementById(id + 'tl').style.backgroundImage='url(/AkgunWeb/Images/tsol.gif)';
    document.getElementById(id + 'br').style.backgroundImage='url(/AkgunWeb/Images/brightDark.gif)';   
    
    document.getElementById(id + 'tr').style.color='#fff';
    document.getElementById(id + 'tr').style.fontWeight='bold';
    document.getElementById(id + 'tr').style.textDecoration='underline';
}
/*########################################################################*/

/*########################################################################*/
function aktifGrupAltMenu(id)
{      
    var oncekiMenu=document.getElementById('altMenuAdi');
    
    if(oncekiMenu.value!='')
        aktifGrupAltMenuGeri(oncekiMenu.value)
    
    oncekiMenu.value=id;
    
    id=id.replace(/_./g," ");
    
    document.getElementById(id + 'A').style.backgroundColor='#848484';
    document.getElementById(id + 'A').style.backgroundImage='url(/AkgunWeb/Images/bleftDark.gif)';
    document.getElementById(id + 'trA').style.backgroundImage='url(/AkgunWeb/Images/bos.gif)';
    document.getElementById(id + 'tlA').style.backgroundImage='url(/AkgunWeb/Images/tsol.gif)';
    document.getElementById(id + 'brA').style.backgroundImage='url(/AkgunWeb/Images/brightDark.gif)';   
    
    document.getElementById(id + 'trA').style.color='#fff';
    //document.getElementById(id + 'trA').style.fontWeight='bold';
    document.getElementById(id + 'trA').style.textDecoration='underline';
}
/*########################################################################*/

/*########################################################################*/
function aktifGrupMenuGeri(id)
{         
    id=id.replace(/_./g," ");

    document.getElementById(id).style.backgroundColor='#e0e0e0';
    document.getElementById(id).style.backgroundImage='url(/AkgunWeb/Images/bleftSilver.gif)';
    document.getElementById(id + 'tr').style.backgroundImage='url(/AkgunWeb/Images/bos.gif)';
    document.getElementById(id + 'tl').style.backgroundImage='url(/AkgunWeb/Images/tleftSilver.gif)';
    document.getElementById(id + 'br').style.backgroundImage='url(/AkgunWeb/Images/brightSilver.gif)';   
    
    document.getElementById(id + 'tr').style.color='#666';
    document.getElementById(id + 'tr').style.fontWeight='normal';
    document.getElementById(id + 'tr').style.textDecoration='none';
}
/*########################################################################*/

/*########################################################################*/
function aktifGrupAltMenuGeri(id)
{      
    id=id.replace(/_./g," ");

    //document.getElementById(id + 'A').style.backgroundColor = '#8B0000';
    document.getElementById(id + 'A').style.backgroundColor = '#e0e0e0';
    document.getElementById(id + 'A').style.backgroundImage='url(/AkgunWeb/Images/bleftAlt.gif)';
    document.getElementById(id + 'trA').style.backgroundImage='url(/AkgunWeb/Images/bos.gif)';
    document.getElementById(id + 'tlA').style.backgroundImage='url(/AkgunWeb/Images/tleftAlt.gif)';
    document.getElementById(id + 'brA').style.backgroundImage='url(/AkgunWeb/Images/brightAlt.gif)';   
    
    document.getElementById(id + 'trA').style.color='#666';
    document.getElementById(id + 'trA').style.textDecoration='none';
}
/*########################################################################*/

/*########################################################################*/
function PreLoad()
{
    var myimages=new Array()
    for (i=0;i<PreLoad.arguments.length;i++)
    {
    myimages[i]=new Image()
    myimages[i].src=PreLoad.arguments[i]    
    //alert(PreLoad.arguments[i]);   
    }
}
/*########################################################################*/

/*########################################################################*/
function ajaxNesnesi()
{
    var xmlHttp=null;
    try
    {
        //ie7 firefox opera vesaire için
        xmlHttp=new XMLHttpRequest();
    }
    catch(e)
    {
      //explorer ie6 ve daha eskileri için
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            //alert('IE6+');
        }
        catch(e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
             //alert('IE5+');
        }  
    }    
    return xmlHttp;
}
/*########################################################################*/

/*########################################################################*/
function ajaxUrunKodAra(kod)
{
    var dil="Tr";
    
    if(window.location.href.indexOf("/Eng/")!=-1)
        dil="Eng";
        
    var xmlHttp;
    xmlHttp=ajaxNesnesi();
    
    if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
      xmlHttp.onreadystatechange=function()
        {
           
            if(xmlHttp.readyState==4)
              {                                                              
                
                if(xmlHttp.responseText=="<table style='margin:0px auto 0px auto;'></tr></table>")
                {   
                    if(dil=='Eng')                 
                        document.getElementById("altgrupDiv").innerHTML='No result returned from the search for: ' + kod;
                     else
                        document.getElementById("altgrupDiv").innerHTML=kod + ' kodu bulunamadı.';
                        
                    document.getElementById("urunlerDiv").innerHTML=xmlHttp.responseText;
                }
                else
                {
                    if(dil=='Eng')
                        document.getElementById("altgrupDiv").innerHTML='Your search result is below:'
                    else
                        document.getElementById("altgrupDiv").innerHTML='Arama sonucu aşağıdadır:'
                        
                    document.getElementById("urunlerDiv").innerHTML=xmlHttp.responseText;                    
                }
              }
                           
              else
              {                                  
                document.getElementById("urunlerDiv").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Loading...";                        
                document.getElementById("altgrupDiv").innerHTML='';
                document.getElementById("sayfaDiv").style.display='none';
              }
        }
      var url="/AkgunWeb/Katalog/urunAra.aspx?kod=" + kod + "&dil=" + dil + "&sid=" + Math.random();
      
      var midyat=window.location.href.toLowerCase();        
      if(midyat.indexOf("/midyat/")!=-1)
        url="/AkgunWeb/Midyat/urunAra.aspx?kod=" + kod + "&dil=" + dil + "&sid=" + Math.random();   
      xmlHttp.open("GET",url,true);
      xmlHttp.send(null);    
        
}
/*########################################################################*/

/*########################################################################*/
function ajaxUlkeler(rol)
{
if(rol=='0')
   { return;}

var objSelect=document.getElementById('uyeUlke');
objSelect.options.length=0;

var xmlHttp;
xmlHttp=ajaxNesnesi();
if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
  xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
          {         
             var temp=new Array();
             
             temp=xmlHttp.responseText.split(',');
             
             objSelect.options[objSelect.length]=new Option('Hepsi','');
             
             for(i=0;i<temp.length;i++)
             {                
                objSelect.options[objSelect.length]=new Option(temp[i],temp[i]);
             }
          }
         else(xmlHttp.readyState!=4)
         {           
            //document.getElementById("uyeListesi").innerHTML="<br />Lütfen Bekleyiniz... <br />Yükleniyor..";
         }
    }
    
  var url="/AkgunWeb/AdminArea/ulkeler.aspx?roltip=" + rol + "&sid=" + Math.random();  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }
/*########################################################################*/

/*########################################################################*/
function ajaxUyeler(rol,ulke,sayfa)
{

if(rol=='0')
   { return;}

var xmlHttp;
xmlHttp=ajaxNesnesi();
if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
  xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
          {     
            document.getElementById("uyeListesi").innerHTML=xmlHttp.responseText;
          }
          else
          {
            document.getElementById("uyeListesi").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Lütfen Bekleyiniz... <br />Yükleniyor..";            
          }
    }
  var url="/AkgunWeb/AdminArea/uyeler.aspx?roltip=" + rol + "&ulke=" + ulke + "&sayfa=" + sayfa + "&sid=" + Math.random();  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }
/*########################################################################*/

/*########################################################################*/  
  function ajaxUyeSayfalama(rol,ulke)
  {
    
    if(rol=='0')
    {return;}
    
    var xmlHttp;
    xmlHttp=ajaxNesnesi();  
    
    if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
  xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
          {     
                var adet=xmlHttp.responseText;
                document.getElementById("divUyeSayfa").style.display='none';
                var objSelect=document.getElementById('selectSayfa');
                objSelect.options.length=0;
                
                if(adet>50)
                {
                    document.getElementById("divUyeSayfa").style.display='block';
                    
                    var sayfa=adet/50;
                    if(adet%50!=0)
                        sayfa++;              
                    
                    for(i=1;i<=sayfa;i++)
                    {
                        objSelect.options[objSelect.length]=new Option(i,i);
                    }                
                }              
          }
          else
          {
            //document.getElementById("uyeListesi").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Lütfen Bekleyiniz... <br />Yükleniyor..";            
            
          }
    }
  var url="/AkgunWeb/AdminArea/UyeSayfa.aspx?roltip=" + rol + "&ulke=" + ulke + "&sid=" + Math.random();  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null); 
  }
/*########################################################################*/

/*########################################################################*/
function ajaxUyeBul(eposta,ad,soyad,sayfa)
{

var xmlHttp;
xmlHttp=ajaxNesnesi();
if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
  xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
          {     
            document.getElementById("uyeListesi").innerHTML=xmlHttp.responseText;
          }
          else
          {
            document.getElementById("uyeListesi").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Lütfen Bekleyiniz... <br />Yükleniyor..";            
          }
    }
  var url="/AkgunWeb/AdminArea/uyeBul.aspx?eposta=" + eposta + "&ad=" + ad + "&soyad=" + soyad + "&sayfa=" + sayfa + "&sid=" + Math.random();  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }
/*########################################################################*/

/*########################################################################*/  
  function ajaxUyeBulSayfalama(eposta,ad,soyad)
  {   
   
    var xmlHttp;
    xmlHttp=ajaxNesnesi();  
    
    if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }
    
  xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
          {     
                var adet=xmlHttp.responseText;
                document.getElementById("divUyeSayfa").style.display='none';
                var objSelect=document.getElementById('selectSayfa');
                objSelect.options.length=0;
                
                if(adet>50)
                {
                    document.getElementById("divUyeSayfa").style.display='block';
                    
                    var sayfa=adet/50;
                    if(adet%50!=0)
                        sayfa++;              
                    
                    for(i=1;i<=sayfa;i++)
                    {
                        objSelect.options[objSelect.length]=new Option(i,i);
                    }                
                }              
          }
          else
          {
            //document.getElementById("uyeListesi").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Lütfen Bekleyiniz... <br />Yükleniyor..";            
            
          }
    }
  var url="/AkgunWeb/AdminArea/UyeBulSayfa.aspx?eposta=" + eposta + "&ad=" + ad + "&soyad=" + soyad + "&sid=" + Math.random();  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);            
 
  }
/*########################################################################*/


/*########################################################################*/  
  function ajaxAltgrup(anagrup,altgrup,sayfa)
  {
    var dil="Tr";
    if(window.location.href.indexOf("/Eng/")!=-1)
        dil="Eng"
        
    anagrup=anagrup.replace(/_./g," "); 
    
    var altgrupAd="0yok0";
    var sahife=-1;
    
    if(altgrup!=null)
       altgrupAd=altgrup.replace(/_./g," ");  
       
    if(sayfa!=null)
        sahife=sayfa;
        
    var xmlHttp;
    xmlHttp=ajaxNesnesi();

    if(xmlHttp==null)
        {
            alert("Tarayıcınız AJAX destekleiyor");
            return;
        }
    
      xmlHttp.onreadystatechange=function()
        {
           
            if(xmlHttp.readyState==4)
              {     
                    if(altgrupAd=="0yok0")
                    {
                        document.getElementById("altgrupDiv").innerHTML=xmlHttp.responseText;                                                      
                    }
                    else
                    {
                        document.getElementById("urunlerDiv").innerHTML=xmlHttp.responseText;
                        aktifGrupAltMenu(altgrup);
                    }                   
              }
                           
              else
              {                                  
                    if(altgrupAd=="0yok0")
                        {
                            document.getElementById("urunlerDiv").innerHTML="";
                            document.getElementById("sayfaDiv").style.display='none';
                            document.getElementById("altgrupDiv").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Loading...";            
                        }
                    else
                       {
                           document.getElementById("urunlerDiv").innerHTML="<img src='/AkgunWeb/Images/loading.gif' border='0' /><br />Loading...";            
                       }               
              }
        }
            
      var url="/AkgunWeb/Katalog/koleksiyon.aspx?anagrup=" + anagrup + "&altgrup=" + altgrupAd + "&sayfa=" + sahife + "&dil=" + dil + "&sid=" + Math.random();  

      var midyat=window.location.href.toLowerCase();        
      if(midyat.indexOf("/midyat/")!=-1)
        url="/AkgunWeb/Midyat/koleksiyon.aspx?anagrup=" + anagrup + "&altgrup=" + altgrupAd + "&sayfa=" + sahife + "&dil=" + dil + "&sid=" + Math.random();  
      
      xmlHttp.open("GET",url,true);
      xmlHttp.send(null);
  }
/*########################################################################*/

/*########################################################################*/  
  function ajaxAltgrupSayfa(anagrup,altgrup,sayfa)
  {
    
    alert(altgrup);
    
    anagrup=anagrup.replace(/_./g," ");
    altgrup = altgrup.replace(/_./g, " ");
    
    var xmlHttp;
    xmlHttp=ajaxNesnesi();  
    
    if(xmlHttp==null)
    {
        alert("Tarayıcınız AJAX destekleiyor");
        return;
    }

    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            var adet = xmlHttp.responseText;
            document.getElementById("sayfaDiv").style.display = 'none';
            var objSelect = document.getElementById('selectSayfa');
            objSelect.options.length = 0;

            alert(adet);
            if (adet > 20) {
                document.getElementById("sayfaDiv").style.display = 'block';

                var sayfa = adet / 20;
                if (adet % 20 != 0)
                    sayfa++;

                for (i = 1; i <= sayfa; i++) {
                    objSelect.options[objSelect.length] = new Option(i, i);
                }
            }
        }
    }
  var url="/Katalog/koleksiyon.aspx?anagrupEng=" + anagrup + "&altgrupEng=" + altgrup + "&sayfa=" + sayfa + "&sid=" + Math.random();
  document.write(url);
  
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null); 
  }
/*########################################################################*/


