var maclistesi="";
var theText = "GoooOOOoOoOooOOOOooOOolllll!!!!!";
var timeinterval=60000;
var sirabende = 0;
var kupondan = 0;
var tlf;
var kimlik;
var sifre;
var kayitli = 0;


function nextSize(i,incMethod,textLength)
{
if (incMethod == 1) return (20*Math.abs( Math.sin(i/(textLength/3.14))) );
if (incMethod == 2) return (128*Math.abs( Math.cos(i/(textLength/3.14))));
}

function sizeCycle(text,method,dis)
{
   output = "";
   for (i = 0; i < text.length; i++)
   {
       size = parseInt(nextSize(i +dis,method,text.length));
       output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
   }
   
   try
    {
       document.getElementById("theDiv").innerHTML = output;
    }
    catch(err)
    {
    //Handle errors here
    }
   
}

function doWave(n)
{  
   sizeCycle(theText,1,n);
   if (n > theText.length) {n=0}
   setTimeout("doWave(" + (n+1) + ")", 50);
}


function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}

function gitbak(txt){
       window.open('statip.asp?mc='+ txt ,'Karşılaştırma','toolbar=0,menubar=0,directories=0,channelmode=1,location=0,resizable=1,status=0,scrollbars=0,width=340px,height=400px');
    }
    
//-----------------------------------------------------------------------
function acilis()
{


 
 var OSName="Unknown OS";
 if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
 else if (navigator.appVersion.indexOf("iPhone")!=-1) OSName="iPHONE";
 else if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
 else if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
 else if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
 else OSName="Symbian";

 kayitli = 0;

 if (OSName != "iPHONE" )
 {
   
   
    var cookieEnabled=(navigator.cookieEnabled)? true : false

    //if not IE4+ nor NS6+
    if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
    document.cookie="testcookie"
    cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)? true : false
    }

    if (cookieEnabled) //if cookies are enabled on client's browser
    {
       init();
    }
    else
    { 
        alert("Lütfen önce Cookie alabilecek ayarınızı yapın.");
        window.close();
    }

  
   
   
 }
 else window.location = "http://www.bilsag.com/iphone/index.asp";
 
}
    
    
    
    
function init()
{
     
     try
     {
        maclistesi = readCookie("maclst");
        if (maclistesi == null ) maclistesi = "";
     }
     catch(exy)
     {
        maclistesi = "";
     }

     
     yap = 0;
     
     try
     {
        kimlik = readCookie("kimlik");
        tlf    = readCookie("telefon");
        sifre  = readCookie("sifre");
        
        if (tlf == null ) tlf = "";
        if (kimlik == null ) kimlik = "";
        if (sifre == null ) sifre = "";
                
        document.getElementById("uname").value = tlf;
        document.getElementById("upass").value = sifre;
        
     }
     catch(exz)
     {
        yasli = 0;
     }
     
     acgoster();
     

}

//-----------------------------------------------------------------------
function createCookie(name,value,days) {
    days = 90;
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}
//-------------------------------------------------------------------
function kayityap(){

    var getrequest=new ajaxRequest();
    
    getrequest.onreadystatechange=function(){

    if (getrequest.readyState==4){

      if (getrequest.status==200 || window.location.href.indexOf("http")==-1){
        kimlik = getrequest.responseText;
        
        createCookie("kimlik",kimlik);
        hesapyarat();
      }
      else{
         alert("Sunucuya bağlanamadı")
      }
     }
    }
    getrequest.open("GET", "kayitip.asp", true);
    getrequest.send(null);

}






function hesapyarat()
{
   var Text;

   
    Text =        "<div  style='background-image:url(images/giris.jpg); background-repeat:no-repeat; background-position:center; width:240px; height:320px;'>";
    Text = Text + "<p align=center '><center><br><br><br><br><br><table   border=0 bgcolor=navy  width='196px'>";
    Text = Text + "  <tr >";
    Text = Text + "    <td>&nbsp;<font color=white><STRONG>Telefon Numaraniz</STRONG></font></td>";
    Text = Text + "    <td>&nbsp;<input id=telefon name=adi  type=text width= 50px><br>&nbsp;<font size=1 color=white><b>( 5xx... )</b></font></td>";
    Text = Text + "  </tr>";
    Text = Text + "  <tr>";
    Text = Text + "    <td align=center>&nbsp;<font color=yellow><STRONG>Şifreniz Telefonunuza SMS ile gönderilecektir.</STRONG></font></td>";
    Text = Text + "   <td align=center width=64px><font color=white>İlginize teşekkür<br> ederiz</font></td>"
    Text = Text + "  </tr>";
    Text = Text + "  <tr colspan=2>";
    Text = Text + "    <td align=center colspan=2>" 
    Text = Text + "       <input type='button' value='Tamam'  width=100px height=20px onclick='smsat();'></td></tr>"; 
    Text = Text + "</table></center></p></div>";
    
   
    
   document.getElementById("hepsibir").innerHTML  = Text;
}




function smsat()
{
   var Text;
   var tlf = document.getElementById("telefon").value;
   createCookie("telefon",tlf);
    
    var getrequest=new ajaxRequest();
    
    getrequest.onreadystatechange=function(){
    if (getrequest.readyState==4){
      
      if (getrequest.status==200 || window.location.href.indexOf("http")==-1){
        neoldu = getrequest.responseText;
        
        var kimo="";
        var paso="";
        var telno="";
        var bitir = 0;
        
        i = neoldu.indexOf(".");
        if ( i > 0 ) {
           tmp = neoldu.substring(i+1);
           neoldu = neoldu.substring(0,i);
           
           i = tmp.indexOf(".");
           kimo = tmp.substring(0,i);
           tmp = tmp.substring(i+1);
           
           i = tmp.indexOf(".");
           paso = tmp.substring(0,i);
           telno = tmp.substring(i+1);
        }
        
        
        if ( kimlik != kimo ){
           kimlik = kimo;
           sifre = paso;
           
           createCookie("telefon",tlf);
           createCookie("kimlik",kimlik);
           createCookie("sifre",sifre);
           
          document.getElementById("yeni").innerHTML = "<img src='images/bg/yeni0.png'  style=' position:absolute; width:64px; left:570px; top:80px; z-index:1; width:60px; height:30px;' />";
          document.getElementById("uname").value = tlf;
          document.getElementById("upass").value = sifre;
          document.getElementById("hepsibir").innerHTML="";
          sirabende=0;
          bitir = 1;
           
        }
        
        
        
        
        Text =        "<div  style='background-image:url(images/giris.jpg); background-repeat:no-repeat; background-position:center; width:240px; height:320px;'>";
        Text = Text + "<p align=center><br><br><br><br><br><table   border=0 bgcolor=navy color=white width='210px'>";
        Text = Text + "  <tr>";
        Text = Text + "    <td>&nbsp;<font color=white><STRONG>Telefon Numaranız</STRONG></font></td>";
        Text = Text + "    <td>&nbsp;<input id=telefon name=adi style='width:64px;' value='" + tlf + "'><br>&nbsp;<font size=1 color=white><b>( 5xxxxxxx )</b></font></td>";
        Text = Text + "  </tr>";
        Text = Text + "  <tr>";
        
        if ( neoldu == "OK" ) 
        {
          Text = Text + "    <td align=center>&nbsp;<font color=red><STRONG>Şifreniz Telefonunuza SMS ile gönderildi.</STRONG></font></td>";
          Text = Text + "   <td align=center><font color=white>Çıkıp, şifrenizi öğrendikten sonra tekrar giriniz.</font></td>"
          createCookie("telefon",tlf);
          document.getElementById("yeni").innerHTML = "<img src='images/bg/yeni0.png'  style=' position:absolute; width:64px; left:570px; top:80px; z-index:1; width:60px; height:30px;' />";
          document.getElementById("uname").value = tlf;
          sirabende=0;
        }
        else
        {
          Text = Text + "    <td align=center>&nbsp;<font color=red><STRONG>Şifreniz Telefonunuza gönderilemedi.</STRONG></font></td>";
          Text = Text + "   <td align=center><font color=white>Telefon numaranızın doğru olduğunu kontrol edip tekrar deneyin</font></td>"
        }
        
        Text = Text + "  </tr>";
        Text = Text + "  <tr colspan=2>";
        Text = Text + "    <td align=center colspan=2>" 
        
        
        
        Text = Text + "</table></p></div>";
        
        if ( bitir == 0 ) document.getElementById("hepsibir").innerHTML=Text;
        else {document.getElementById("hepsibir").innerHTML="";sirabende=0;acgoster();}
        
        izlem = 0;
      }
      else{
         alert("Sunucuya bağlanamadı")
      }
     }
    }
    
    sirabende = 1;
    getrequest.open("GET", "sifreyaz.asp?tlf=" + tlf + "&kim=" + kimlik, true);
    getrequest.send(null);
 }
 
 




function sifrebak()
{
   
   var Text;
   var tlf = document.getElementById("uname").value;
   var sifre = document.getElementById("upass").value;
       
    var getrequest=new ajaxRequest();
    
    getrequest.onreadystatechange=function(){
    if (getrequest.readyState==4){
      
      if (getrequest.status==200 || window.location.href.indexOf("http")==-1){
        neoldu = getrequest.responseText;
        
        i=neoldu.indexOf(".");
        if ( i > 0 ){
           kimlik = neoldu.substring(i+1);
           neoldu = neoldu.substring(0,i);
        }

                            
        if ( neoldu == "NOK" )
        {
            alert("Telefon Numarası ile Şifre uyumsuz. Lütfen tekrar deneyin!!!");
        }
        else if ( neoldu == "TOK" )
        {
            Text =        "<div  style='background-image:url(images/giris.jpg); background-repeat:no-repeat; background-position:center; width:240px; height:320px;'>";
            Text = Text + "<p align=center><br><br><br><br><br><table   border=0 bgcolor=navy color=white width='210px'>";
            
            Text = Text + "  <tr>";
            Text = Text + "     <td colspan=2>&nbsp;<font color=red size=3>Abonelik süreniz doldu. </font></td>";
            Text = Text + "  </tr>";
            
            Text = Text + "  <tr><!-- Row 1 -->";
            Text = Text + "    <td>&nbsp;<font color=white><STRONG>Telefon Numaranız</STRONG></font></td>";
            Text = Text + "    <td>&nbsp;<input id=telefon name=adi style='width:64px;' value='" + tlf + "'></td>";
            Text = Text + "  </tr>";
            Text = Text + "  <tr><!-- Row 2 -->";
            Text = Text + "    <td>&nbsp;<font color=white><STRONG>Şifreniz</STRONG></font></td>";
            Text = Text + "    <td>&nbsp;<input id=sifre name=sifre style='width:64px;' value='" + sifre + "'></td>";
            Text = Text + "  </tr>";
            Text = Text + "  <tr><!-- Row 3 -->";
            Text = Text + "    <td>&nbsp;<font color=white><STRONG>Adınız</STRONG></font><font size=3 color=red>?</font></td>";
            Text = Text + "    <td>&nbsp;<input id=isim name=isim style='width:64px;'></td>";
            Text = Text + "  </tr>";
            
            
            Text = Text + "  <tr><!-- Row 4 -->";
            Text = Text + "   <td>&nbsp;<font color=white><STRONG>Abonelik Seçiminiz</STRONG></font><font size=3 color=red>?</font></td>";
            Text = Text + "    <td>";
            Text = Text + "      <select id='secim'>";
            Text = Text + "          <option value='6.00' selected >1 aylık 6 TL</option>";
            Text = Text + "          <option value='12.00'>3 aylık 12 TL</option>";
            Text = Text + "          <option value='24.00'>6 aylık 24 TL</option>";
            Text = Text + "      </select></td>";
            Text = Text + "  </tr>";
            Text = Text + "  <tr>";
            Text = Text + "    <td colspan=2>";   
            Text = Text + "     &nbsp;<font color=red size=3>Aboneliğinizi yenilemek için;<input type=button id=Button2 name=sifre width=100px height=20px value='Yenile' onclick='yenile();'>";
            Text = Text + "     <br />";
            Text = Text + "     Şimdilik işlem yapmamak istiyorsanız programdan çıkın.</font></td>";
            Text = Text + "  </tr>";
             
            Text = Text + "</table></p></p>";

            document.getElementById("hepsibir").innerHTML=Text;
        }
        else if ( neoldu == "OK" )
        { 
           try{
             eraseCookie("telefon");
           }
           catch(a1){}           
           createCookie("telefon",document.getElementById("uname").value);
           
           try{
             eraseCookie("kimlik");
           }
           catch(a1){}           
           createCookie("kimlik",kimlik);

           try{
             eraseCookie("sifre");
           }
           catch(a2){}
           createCookie("sifre",sifre);
           
           document.getElementById("tahmin").innerHTML = "<a href='javascript:tahminler();'><img src='images/bg/tahmin.png' style=' position:absolute;  left:10px; top:640px; z-index:1; width:162px; height:63px;' /></a>";
           kayitli = 1;
           alert("Hoşgeldiniz. \"Tahminler\" listemizle kazancınız bol olsun.." );
           
           document.getElementById("bagla").innerHTML = " <img src='images/bg/tus0.png'  style=' position:absolute; width:64px; left:506px; top:80px; z-index:1; width:60px; height:30px;' />";
           document.getElementById("yeni").innerHTML = "<img src='images/bg/yeni0.png'   style=' position:absolute; width:64px; left:570px; top:80px; z-index:1; width:60px; height:30px;' />";

        }

      }
      else{
         alert("Sunucuya bağlanamadı")
      } 
     }
    }
    getrequest.open("GET", "sifrebul.asp?tlf="+tlf + "&kim=" + kimlik + "&psw=" + sifre, true);
    getrequest.send(null);
}





function yenile()
{
   var Text;
   var tlf   = document.getElementById("telefon").value;
   var sifre = document.getElementById("sifre").value;
   var isim = document.getElementById("isim").value;
   
   while (isim.indexOf(" ") > -1)
   {
      i = isim.indexOf(" ");
      isim = isim.substring(0,i) + "+" + isim.substring(i+1);
   }
   

   
   try {
       var tur = document.getElementById("secim").selectedIndex;
       para = document.getElementById("secim")[tur].value;
    }
    catch(ee){
       para = "6.00";
    }
    
    window.location = "gsmodeme.asp?bd="+para + "&tl=" + tlf + "&ad=" + isim;
    


   
}            
            
            
//--------------------------------------------------------------------
function ekle(txt)
{
  
  k = maclistesi.indexOf(txt);
  if ( k > -1 )
  {
    maclistesi = maclistesi.substring(0,k) + maclistesi.substring(k+4);
  }
  else
  {
    maclistesi = maclistesi + txt + "-";
  }
  document.getElementById("sectiklerim").innerHTML=maclistesi;
   
   try
   {
   eraseCookie("maclst");
   }
   catch (abc)
   {
   }
   
   try
   {
   createCookie("maclst",maclistesi);
   }
   catch (aaa)
   {
   }
   
}


function gecmisisil(){
   maclistesi = "";
   document.getElementById("sectiklerim").innerHTML=maclistesi;
   try
   {
   eraseCookie("maclst");
   }
   catch (abc)
   {
   }
   
   try
   {
   createCookie("maclst",maclistesi);
   }
   catch (aaa)
   {
   }
}
 

function maclistesiyap(liste){

   maclistesi = liste;
   kupondan = 1;
   sirabende = 0;
   acgoster();
}



function secimiac()
{
    var getrequest=new ajaxRequest();
    var ek;
    

    
    getrequest.onreadystatechange=function(){
    if (getrequest.readyState==4){
      
      if (getrequest.status==200 ){
        document.getElementById("hepsibir").innerHTML=getrequest.responseText;
        izlem = 0;
      }
      else{
         alert("Sunucuya bağlanamadı ")
         menu1();
      }
     }
    }
    
    ek = "bgn"
    try{
       var tur = document.getElementById("tercihim").selectedIndex;
       ek = document.getElementById("tercihim")[tur].value;
    }
    catch(eee){
       ek = "bgn";
    }
    
    

    sirabende = 1;
      getrequest.open("GET", "secsorip.asp?ne=" + ek + "&mc=" + maclistesi, true);
      getrequest.send(null);
    
}





                
function tahminler(){
var mygetrequest=new ajaxRequest()

mygetrequest.onreadystatechange=function(){

 if (mygetrequest.readyState==4){
  
  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("hepsibir").innerHTML=mygetrequest.responseText;

  }
  else{
    alert("An error has occured making the request")
  }
 }
}

ek = "tum";
try{
   var tur = document.getElementById("tercih").selectedIndex;
   ek = document.getElementById("tercih")[tur].value;
 
}
catch(ee){
   ek = "tum";
}

ektrh = "-"
try{
   var tar = document.getElementById("tarih").selectedIndex;
   ektrh = document.getElementById("tarih")[tar].value;
 
}
catch(eee){
   ektrh = "-";
}


sirabende = 1;
mygetrequest.open("GET", "secsorip.asp?tur=" + ek + "&trh=" + ektrh, true)
mygetrequest.send(null)



}


function stat(macno){
   window.open("statip.asp?mc=" + macno,"Maç İstatistik Verileri","width=300px,height=500px,addressbars=0,toolsbar=0,resizable=1"); 
}



function yorumabak(){
var mygetrequest=new ajaxRequest()


mygetrequest.onreadystatechange=function(){

 if (mygetrequest.readyState==4){
  
  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("hepsibir").innerHTML=mygetrequest.responseText;

  }
  else{
    alert("An error has occured making the request")
  }
 }
}


sirabende = 1;
mygetrequest.open("GET", "yorumlar.asp", true);
mygetrequest.send(null);



}

//-------------------------------------------------------------------
   
 function aceskisinigoster()
 {
   var tur = document.getElementById("tercih").selectedIndex;
   ek = document.getElementById("tercih")[tur].value;

    window.location='yorumlar.asp?tur=' + ek;
 }
     





     
     
function acgoster(){

var mygetrequest=new ajaxRequest()
//var mygetrequest=new XMLHttpRequest();
mygetrequest.onreadystatechange=function(){

 if (mygetrequest.readyState==4){
  
  if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
  if (sirabende == 0 ){
    document.getElementById("hepsibir").innerHTML=mygetrequest.responseText;
    }

  }
  else{
    alert("An error has occured making the request")
  }
 }
}

if ( maclistesi == "" ) kupondan = 0;

if ( kupondan == 1 ) {
  ek = "sec";
  kupondan = 0;
  ektrh = "-";
}
else {
ek = "tum";
try{
   var tur = document.getElementById("tercih").selectedIndex;
   ek = document.getElementById("tercih")[tur].value;
 
}
catch(ee){
   ek = "tum";
}


ektrh = "-"
try{
   var tar = document.getElementById("tarih").selectedIndex;
   ektrh = document.getElementById("tarih")[tar].value;
 
}
catch(eee){
   ektrh = "-";
}
}

mygetrequest.open("GET", "skrc.asp?tur=" + ek + "&trh=" + ektrh + "&mc=" + maclistesi + "&kyt=" + kayitli, true)
mygetrequest.send(null)

setTimeout("acgoster();",timeinterval);
}



