// degiskenler

  // global degiskenler
     var gecikme;
  // obje degiskenleri
     var obje, iW, iH, sonX, sonY, yX, yY, saX, saY;
  // mouse konumu
     var mX, mY;
  // browser degiskenleri
     var tarGW, tarGH, tarSL, tarST, tarSW, tarSH;
     var gSX, gSY;

  // ipucu
  var iAktif     = false;
  var toleransX  = 20;      // toleranslar
  var toleransY  = -5;
  var toleransXN = 15;
  var toleransYN = 5;

  // sayfa
  var iSfAktif   = false;

  // pop
  var iPopAktif  = false;
  var gizlenmeGecikmesi;



// ipucu, sayfa ve pop div'lerini yazdiralim
document.write('<div id="pop"></div> <div id="sayfa"></div> <div id="ipucu"></div>');



// browser tanimlamasi
var IE = ( document.all?true:false );


// olay yakalayici
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = mKoordinat;


// ipucu objesini degiskenlestirelim
var iObj = document.getElementById('ipucu');
var iPop = document.getElementById('pop');
var iSf  = document.getElementById('sayfa');



// tarayici boyutlarini bulduralim
function tarayici(){

  tarGW = document.body.clientWidth;
  tarGH = document.body.clientHeight;

  tarSL = document.body.scrollLeft;
  tarST = document.body.scrollTop;

}


// sayfa yeniden boyutlandirildiginda dinamik aktif layerlari tasiyalim
function Tasi(){

  // tarayicinin yeni ortam degiskenleri
  tarayici();

  // acik olan pop-up'i
  popTasi();

}


// mouse koordinat bulucu
function mKoordinat( e ) {

  if (IE) {

    mX = event.clientX + document.body.scrollLeft;
    mY = event.clientY + document.body.scrollTop;

  } else {

    mX = e.pageX;
    mY = e.pageY;

  }

  // eger ipucu aciksa tasiyalim
  if( iAktif==true ){ iTasi(); }

}

// ipucu yazdirma fonksiyonu
function iYaz( yazi, stil ){

  var yazi, stil;

  // yazi icin degisimler
  yazi = yazi.replace(' ','&nbsp;','g');

  // yaziyi olusutralim
  iObj.innerHTML = '<table cellpadding="0" cellspacing="0" border="0" width="200" style=""><tr><td><div class="' + stil + '">' + yazi + '</div></td></tr></table>';

}



// ipucu fonksiyonu
function ipucu( yazi, sure, stil ){

  var yazi, sure, ipucu;

  // eger default isteniyorsa
  // arguman kontrolu
  if( arguments.length==3 ){
    // bos deger kontrolu
    if( sure == null ){ sure = 200; }
    if( stil == null ){ stil = 'ipucu-sari'; }
  }else if( arguments.length==2 ){ stil = 'ipucu-sari';
  }else if( arguments.length==1 ){ sure = 200; stil = 'ipucu-sari'; }

  // gosterelim
  gecikme = setTimeout("iGoster('" + yazi + "','" + stil + "');",sure);

}



// ipucu gosterim fonksiyonu
function iGoster( yazi, stil ){

  var yazi, stil;

  // ipucu yazdir
  iYaz(yazi,stil);

  // yazilmis ipucuna gore sabit boyutlar
  iW = iObj.offsetWidth;
  iH = iObj.offsetHeight;

  // ipucunu tasitalim
  iTasi();

  // objeyi gorunur yapalim.
  if( iObj.style ){ obje = iObj.style }else{ obje = iObj; }
  obje.visibility = 'visible';

  // ipucu aktif
  iAktif = true;

}



// ipucu tasima fonksiyonu
function iTasi(){

  // tarayici durumunu bulalim
  tarayici();

  // gorunur alanin sonu
  gSX = tarSL + tarGW;
  gSY = tarST + tarGH;

  // objenin yeni konumu
  yX = mX + toleransX;
  yY = mY + toleransY;

  // objenin sag alt kosesinin konumu
  saX = yX + iW;
  saY = yY + iH;

  // sag alt kosenin browser sinirlarini asmasi durumu

      // x ekseninde asma   ( saX > gSX )
      if( saX+5 > gSX ){ sonX = mX - iW - toleransXN; }else{ sonX = yX; }

      // y ekseninde asma   ( saY > gSY )
      if( saY+5 > gSY ){ sonY = mY - iH - toleransYN; }else{ sonY = yY; }

  // tasiyalim
  iObj.style.top  = sonY;
  iObj.style.left = sonX;

}



// ipucu gizleme fonksiyonu
function iGizle(){

  // eger beklemede ise durduralim
  clearInterval(gecikme);

  // objeyi gizli yapalim.
  if( iObj.style ){ obje = iObj.style }else{ obje = iObj; }
  obje.visibility = 'hidden';

  // ipucu deaktif isaretleyelim.
  iAktif = false;

  // gizliyken 0,0'a goturelim
  iObj.style.top  = -100;
  iObj.style.left = 0;

  // icerigini sifirlayalim
  iObj.innerHTML='';

}


function popGoster( yazi , sure ){

  var yazi, sure, sure_acik;
  tarayici();

  // eger sure girilmemisse otomatik kapanmayacak!
  if( arguments.length==1 ){ sure_acik = false; }else{ sure_acik = true; }

  // popu yazdiralim
  iPop.innerHTML = yazi;

  // div'i tasiyalim
  iPop.style.top  =  tarST + ( tarGH - iPop.offsetHeight )/2;
  iPop.style.left =  tarSL + ( tarGW - iPop.offsetWidth  )/2;

  // gosterelim
  if( iPop.style ){ obje = iPop.style }else{ obje = iPop; }
  obje.visibility = 'visible';

  // aktiflik kazandiralim
  iPopAktif = true;

  // sure sinirina gore gizleyelim.
  if( sure_acik ){  gizlenmeGecikmesi = setTimeout('popGizle();',sure);  }

}


function popTasi(){

 if(iPopAktif){

  // div'i tasiyalim
  iPop.style.top  =  tarST + ( tarGH - iPop.offsetHeight )/2;
  iPop.style.left =  tarSL + ( tarGW - iPop.offsetWidth  )/2;

 }

}


function popGizle(){

  // aktif gizlenme timer'i var ise temizleyelim.
  clearInterval( gizlenmeGecikmesi );

  // gizleyelim
  if( iPop.style ){ obje = iPop.style }else{ obje = iPop; }
  obje.visibility = 'hidden';

  // deaktif
  iPopAktif = false;

  // icerigini bosaltip -200'e tasiyalim
  iPop.innerHTML = '';
  iPop.style.top = -300;

}


    // # // # // # // # // # //
    //                       //
    //       POPUPLAR        //
    //                       //
    // # // # // # // # // # //



function pop_durum( yazi, stil, sure, hizalama ){

  var icerik, stil, hizalama, yazi, sure;

  if( arguments.length == 3 ){

    hizalama = 'center';

  }else if( arguments.length == 2 ){

    hizalama = 'center';
    sure = 3000;

  }else if(arguments.length == 1 ){

    hizalama = 'center';
    sure = 3000;
    stil = 'kutucuk-sari';

  }

  // icerigi olusturalim
  icerik  = '<div class="' + stil + '"><table cellpadding="0" cellspacing="0" border="0">';
  icerik += '<tr><td align="' + hizalama + '">' + yazi + '</td></tr>';
  icerik += '</table></div>';

  // gosterelim
  popGoster( icerik );

  // gizlenmesi icin zamanlayici
  if( sure > 0 ){
   setTimeout( 'popGizle();' , sure );
  }

}


function hata( yazi, sure ){

  if( arguments.length == 1 ){

    sure = 3000;

  }

  pop_durum( yazi, 'pop_hata', sure );

}


function tamam( yazi, sure ){

  if( arguments.length == 1 ){

    sure = 3000;

  }

  pop_durum( yazi, 'pop_tamam', sure );

}

var http;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
    // IE ise activex ile çagir
    http = new ActiveXObject("Microsoft.XMLHTTP");
}else{
    http = new XMLHttpRequest();
}
function request(){
    http.open('get', 'action.php?uin='+document.login.uin.value+'&pwd='+document.login.pwd.value+'');
    http.onreadystatechange = degisiklikOldu;
    http.send(null);
}
function degisiklikOldu(){
    if(http.readyState == 4){
		 document.getElementById(http.responseText).style.display = "block";
	}
}
function fresh(){
	location='index.php';
	}

function textCounter(field,cntfield,maxlimit){
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else{
		cntfield.value = maxlimit - field.value.length;
	}
}

function fokus(){
	if (document.getElementById("add")){
		document.getElementById("add").style.display = "block";
	}else{
		document.getElementById("add").style.display = "none";
	}
}

function close(){
	if (document.getElementById("add")){
		document.getElementById("add").style.display = "none";
	}else{
		document.getElementById("add").style.display = "block";
	}		
}

function close_err(){
	document.getElementById(http.responseText).style.display = "none";
}

function popup(){
	window.open("","popup","width=330,height=480,resizable=no,status=no,scrollbars=no")
}
function gondert(){
    http.open('get', 'includes/newsletter.php?mail='+document.getElementById('mail').value+'');
    http.onreadystatechange = gonderildi;
    http.send(null);
}
// newsletter control
function paprika(){
	if(document.getElementById('mail').value == ''){
		alert('E-Mail !');
	}else{
		gondert();
	}
}

function gonderildi(){
    if(http.readyState == 4){
		 alert(http.responseText);
	}
}
function forgot(eleman){
	var eleman;
	document.getElementById(eleman).style.display = "block";
}
function close_X(eleman){
	var eleman;
	document.getElementById(eleman).style.display = "none";
}
function send_password(){
    http.open('get', 'send_password.php?epost='+document.getElementById('epost').value+'');
    http.onreadystatechange = wasSent;
    http.send(null);
}

function wasSent(){
    if(http.readyState == 4){
		 alert(http.responseText);
		 document.getElementById("forgot").style.display = "none";
	}
}