// JavaScript Document

function buyut(what){
	document.getElementById(what).style.display='block'
	document.getElementById('karanlik').style.display='block'
	ortala (what)
}

function kapat(what){
	if (document.getElementById(what)) document.getElementById(what).style.display='none'
	document.getElementById('karanlik').style.display='none'
	if (what.id) what.style.display='none'
}

function ortala(what){
	cont=document.getElementById(what);
	var ch=cont.offsetHeight;
	var cw=cont.offsetWidth;
	var wh=winHeight()
	var ww=winWidth()
	var tp=(wh-ch)/2 + getScrollXY()[1]
	var lf=(ww-cw)/2;
	if (tp>0){cont.style.top =tp+"px";} else {cont.style.top ="0px";}
	if (lf>0){cont.style.left=lf+"px";} else {cont.style.left="0px";}
}

function winWidth() {
   if (window.innerWidth) return window.innerWidth;
   else if (document.documentElement) return document.documentElement.offsetWidth;
   else if (document.body.clientWidth) return document.body.clientWidth;
}
 
function winHeight() {
   if (window.innerHeight) return window.innerHeight;
   else if (document.documentElement) return document.documentElement.offsetHeight;
   else if (document.body.clientHeight) return document.body.clientHeight;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


