﻿// JScript File
// JScript File


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
var hero = false;
//var hero2 = true;

//******************************************************
// Scroll a göre yer belirlerme Fonksiyonu
function DivRelocate(DivID)
{
          var scrolledX, scrolledY;
          if( self.pageYOffset )
          {
            scrolledX = self.pageXOffset;
            scrolledY = self.pageYOffset; 
          } 
          else if( document.documentElement && document.documentElement.scrollTop )
          {
            scrolledX = document.documentElement.scrollLeft;
            scrolledY = document.documentElement.scrollTop;
          }
          else if( document.body )
          {
            scrolledX = document.body.scrollLeft;
            scrolledY = document.body.scrollTop;
          }

          var centerX, centerY;
          if( self.innerHeight ) {
            centerX = self.innerWidth;
            centerY = self.innerHeight;
          } else if( document.documentElement && document.documentElement.clientHeight ) {
            centerX = document.documentElement.clientWidth;
            centerY = document.documentElement.clientHeight;
          } else if( document.body ) {
            centerX = document.body.clientWidth;
            centerY = document.body.clientHeight;
          }

          var leftOffset = scrolledX + (centerX - 400) / 2;
          var topOffset = scrolledY + (centerY - 200) / 2;

          document.getElementById(DivID).style.top = topOffset + "px";
          document.getElementById(DivID).style.left = leftOffset + "px";
}


  
  window.onscroll = function ()
  {      
      if(hero)  
       {
         DivRelocate("TeklifCikar");            
       } 
       
      /*else
      {
          var x = document.body.scrollLeft;
          var y = document.body.scrollTop;
          var currX = "X-coordinate: " + x + "\n";
          var currY = "Y-coordinate: " + y;
          window.alert(currX + currY);
      }
      */  
        
  }
  
   

// GElişmiş Arama Yapısı
function ShowMeTheLayer( DivId, mission , Divtrans)
{
    var layer = window.document.getElementById(DivId);
    var tlayer = window.document.getElementById(Divtrans);
    
    if( mission == 'block' )
    {
        hero = true;
        
        if(navigator.appName=="Netscape")
        {
            tlayer.style.height = window.document.body.scrollHeight+"px";
            DivRelocate(DivId);
        }
        else
        {
            DivRelocate(DivId);
        }
    }    
    else
        hero = false;
      
    layer.style.display = mission;
    tlayer.style.display = mission;
}


function ddInit(e)
{
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.TeklifCikar : document.getElementById("TeklifCikar");  
  hotDog=isIE ? event.srcElement : e.target;  
  var SicakKopek;
  if(hero)
  {             
         while ( hotDog.id!="titleBar" && hotDog.tagName!=topDog )
         {
            SicakKopek = hotDog;
            hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
            if( hotDog == null )
            {
                hotDog = SicakKopek;
                break;
            }    
                
         }              
  }  
        
    if (hotDog.id=="titleBar")
    {
        
        offsetx=isIE ? event.clientX : e.clientX;
        offsety=isIE ? event.clientY : e.clientY;
        nowX=parseInt(whichDog.style.left);
        nowY=parseInt(whichDog.style.top);
        ddEnabled=true;
        document.onmousemove=_dd;
    }
}

function _dd(e)
{
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog)
{
  
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}	

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");





// **********************************************************************************
// Ödeme.aspx te sözlesme nin sayfada ortada cikmasini icin [16.01.2008]
// **********************************************************************************
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
var myDivTop = 0;
var obj = "";

// -- Div in sayfanin ortasinda cikmasini saglar
function DivCenterView(background,display)
{
    objTran = document.getElementById(background);
    objDisp = document.getElementById(display);
    
    if( objTran!=null || objDisp!=null)
    {
        bodyWidth = 0;
        bodyHeight = 0;
        browserType = 0;
        bodyDispWidth = 0;
        
        if(navigator.appName.indexOf("Microsoft Internet Explorer")>-1)
            browserType = 1;
        if(navigator.appName.indexOf("Netscape")>-1)
            browserType = 2;
        if(navigator.appName.indexOf("Opera")>-1)
            browserType = 3;

        switch(browserType)
        {
            case 1: //-- IE
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.body.clientWidth;
                bodyHeight = document.body.clientHeight+10;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = document.documentElement.clientWidth;
                bodyDispHeight = document.documentElement.clientHeight+10;                    
                break;
            case 2: //-- NS
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.body.clientWidth;
                bodyHeight = document.body.clientHeight+0;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = window.innerWidth;
                bodyDispHeight = window.innerHeight+10;
                break;
            case 3: //-- OP
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.documentElement.clientWidth;
                bodyHeight = document.documentElement.clientHeight+10;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = document.body.clientWidth;
                bodyDispHeight = document.body.clientHeight+10;
                break;
            default : break;
        }              
                           
        //-- Ortada cikan div in genisligi/uzunlugu
        if(objDisp!=null)
        {
            dispWidth = parseInt(objDisp.style.width);
            dispHeight = parseInt(objDisp.style.height);            
        }

        //-- Arkaplanda cikan div in genisligi BODY nin gercek genisligine/uzunluguna ataniyor
        if(objTran!=null)
        {
            objTran.style.width = bodyWidth+"px";
            objTran.style.height = bodyHeight+"px";
        }
        
        //-- Ortada cikan div in SOL/YUKARIDAN dan uzakligi hesaplaniyor (ortalama)                        
        if(objDisp!=null)
        {
            objDisp.style.left = ((bodyDispWidth-dispWidth)/2)+"px";
            objDisp.style.top = ((bodyDispHeight-dispHeight)/2)+"px";
        }

        if(objTran!=null)
        {
            objTran.style.display = "block";
        }
        
        if(objDisp!=null)
        {
            objDisp.style.display = "block";         
            //-- Ortada cikan div in konumlandirilmasi icin atamalar yapiliyor (ortalama)
            ObjPositionNow(display);
            SetDivPosition();
        }
    }      
}

// **********************************************************************************
// Odeme.aspx sayfasindaki ortada cikan sozlesme Div i icin [17.01.2008]
// **********************************************************************************
// -- Div icin Scroll Cekildikce Yeniden Konumlandirilmasini Saglar

// -- Baslangicta DIV in nerede oldugunu almaya yarar .
function ObjPositionNow(prmObj)
{
    obj = prmObj;
    if(obj!="" && document.getElementById(obj))
    {
        myDivTop = parseInt(document.getElementById(obj).style.top);    
        window.onscroll = SetDivPosition;        
    }
}

// -- DIV i yeni konumuna alir .
function SetDivPosition()
{
    if (myDivTop!=0)
    {
        GetY = (document.all) ? document.body.scrollTop : window.pageYOffset;   
        GetY = (GetY==0 && document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : GetY ;
        GetY = (GetY==0 && document.body) ? document.body.scrollTop : GetY ;
        
        if (ie4up){
     	   document.all[obj].style.pixelTop = myDivTop + GetY ;
        }
        else if (ns6up){
     	   document.getElementById(obj).style.top = myDivTop + GetY + "px";
        }
        else if (ns4up) {
     	   document.layers[obj].top = myDivTop + GetY + "px";
        }    
     }
}

// **********************************************************************************
// Odeme.aspx sayfasindaki ortada cikan Div in kapatilması icin [25.01.2008]
// **********************************************************************************
// -- Div icin kapatma islemi gerceklestirir. 
// -- (Test Icin kullanildi ama hazir ekrandaki DIV i kapatmak icin kullanilabilir.)
function DivCenterViewClose(background,display)
{
    if(background!="" && document.getElementById(background))
        document.getElementById(background).style.display = "none";
    if(display!="" && document.getElementById(display))
        document.getElementById(display).style.display = "none";        
    window.onscroll = null;
    window.onresize = null;
}
// **********************************************************************************


function DivCenterViewNoAbsolute(background,display,l,t,z)
{
    objTran = document.getElementById(background);
    objDisp = document.getElementById(display);
    objDisp.style.position="absolute";
    objDisp.style.left=l+"px";
    objDisp.style.top=t+"px";
    objDisp.style.zIndex=z;
    
    if( objTran!=null || objDisp!=null)
    {
        bodyWidth = 0;
        bodyHeight = 0;
        browserType = 0;
        bodyDispWidth = 0;
        
        if(navigator.appName.indexOf("Microsoft Internet Explorer")>-1)
            browserType = 1;
        if(navigator.appName.indexOf("Netscape")>-1)
            browserType = 2;
        if(navigator.appName.indexOf("Opera")>-1)
            browserType = 3;

        switch(browserType)
        {
            case 1: //-- IE
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.body.clientWidth;
                bodyHeight = document.body.clientHeight+10;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = document.documentElement.clientWidth;
                bodyDispHeight = document.documentElement.clientHeight+10;                    
                break;
            case 2: //-- NS
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.body.clientWidth;
                bodyHeight = document.body.clientHeight+0;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = window.innerWidth;
                bodyDispHeight = window.innerHeight+10;
                break;
            case 3: //-- OP
                //-- Body nin acilan bir browserdaki GERCEK genisligi/uzunlugu
                bodyWidth = document.documentElement.clientWidth;
                bodyHeight = document.documentElement.clientHeight+10;
                //-- Body nin acilan bir browserdaki GORUNEN genisligi/uzunlugu
                bodyDispWidth = document.body.clientWidth;
                bodyDispHeight = document.body.clientHeight+10;
                break;
            default : break;
        }              
                           
        //-- Ortada cikan div in genisligi/uzunlugu
        if(objDisp!=null)
        {
            dispWidth = parseInt(objDisp.style.width);
            dispHeight = parseInt(objDisp.style.height);            
        }

        //-- Arkaplanda cikan div in genisligi BODY nin gercek genisligine/uzunluguna ataniyor
        if(objTran!=null)
        {
            objTran.style.width = bodyWidth+"px";
            objTran.style.height = bodyHeight+"px";
        }
        
        //-- Ortada cikan div in SOL/YUKARIDAN dan uzakligi hesaplaniyor (ortalama)                        
        if(objDisp!=null)
        {
            objDisp.style.left = ((bodyDispWidth-dispWidth)/2)+"px";
            objDisp.style.top = ((bodyDispHeight-dispHeight)/2)+"px";
        }

        if(objTran!=null)
        {
            objTran.style.display = "block";
        }
        
        if(objDisp!=null)
        {
            objDisp.style.display = "block";         
            //-- Ortada cikan div in konumlandirilmasi icin atamalar yapiliyor (ortalama)
            ObjPositionNow(display);
            SetDivPosition();
        }
    }      
}

// **********************************************************************************