// service routines
// *****************************************************************************
brIE = "Microsoft Internet Explorer"; brNS = "Netscape"; brOP = "Opera"; brN = "undefined"; brM = 1 ; brV=0;
if (navigator.appName == brIE) {brN = "IE"; brV = parseFloat(navigator.appVersion.substr (navigator.appVersion.lastIndexOf("MSIE") + 4, 4)); brM = 1;}
if (navigator.appName == brNS) {brN = "NS"; brV = parseFloat(navigator.appVersion.substr(0,4)); brM = 2;}
if (navigator.userAgent.lastIndexOf(brOP)>0) {brN = "OP"; brV = parseFloat(navigator.appVersion.substr(0,4)); brM = 1;}
if (brN == 'NS' && brV >= 5) {brM = 3;}

function errorHandler(message, url, line) {
   return true;
}

// DOM routines
// *****************************************************************************
function GetObj(theObj, theDoc) {  
  var p, i, foundObj;
	foundObj = null;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function SetVis() { 
  var i,p,v,obj,args=SetVis.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=GetObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}	

function Show(TheID) { SetVis(TheID,'','show') }  
function Hide(TheID) { SetVis(TheID,'','hide') }  

function GetX(o) {
  if(brN == 'NS') {
    if(brV == 5) return(parseInt(o.style.left));
    if(brV == 4) return(o.left);
  } else { return(o.style.pixelLeft); }
}

function GetY(o) {
  if(brN == 'NS') {
		if(brV == 5) return(parseInt(o.style.top));
		if(brV == 4) return(o.top);
  } else { return(o.style.pixelTop); }
}

function GetW(o) {
if(brN == 'NS') {
		if(brV == 5) return(o.offsetWidth);		     
    if(brV == 4) return(o.clip.width);                      
  } else { 
	  if(navigator.appVersion.indexOf('MSIE 4') > 0) return(o.style.pixelWidth);
		else return(o.offsetWidth); 
	}
}
    
function Move(x, y, o) {
  if(brN == 'NS') {
    if(brV == 5) { o.style.left = x + "px"; o.style.top = y + "px"; }
    if(brV == 4) { o.left = x + "px"; o.top = y + "px";}
  } else {	
    o.style.pixelLeft = x; o.style.pixelTop = y; 
	}
}

function Size(x, y, o) {
  if(brN == 'NS') {
    if(brV == 5) { o.style.width = x + "px"; o.style.height = y + "px";}
    if(brV == 4) { o.width = x + "px"; o.height = y + "px"; }
  } else { o.style.width = x; o.style.height = y; }
}

var winW = 630, winH = 460;

function GetGeo() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winW = window.innerWidth;
    winH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }
	boxH = 750; 
	boxW = 950;
}

function Init() {
//  rbInit();
	doGeo();
	fixPNG();
}

function Resize() {
//  rbResize();
	doGeo()
}

var DoExpand = false;

function doGeo() {
	GetGeo();
	menuTop = 358; contentTop = 432; expandOffset =52;
	padX = Math.floor(winW/2 - boxW/2); if(padX<0) {padX=0}
	padY = Math.floor(winH/2 - boxH/2); if(padY<0) {padY=0}
  Move(padX, padY, GetObj("divPage"));
	if (brN!="IE") {
		contentTop = 418; expandOffset = 39
    if(GetObj("divNavigator")) {Move(0, 226, GetObj("divNavigator"))}
	}
  Move(padX+1, padY+contentTop, GetObj("divContent"));
	Show("divPage");
	Show("divContent");
  if (DoExpand) {
    Move(padX+1, padY+contentTop-expandOffset, GetObj("divContent"));
		Size(948, 285, GetObj("imgContentBack"));
	}
}

function initFlash() {
	GetGeo();
	padX = Math.floor(winW/2 - boxW/2); if(padX<0) {padX=0}
	padY = Math.floor(winH/2 - boxH/2); if(padY<0) {padY=0}
  Move(padX+1, padY+1, GetObj("divFlash"));
	Show("divFlash");
}

function SaveAs(TheUrl){
  var WinSaveAs = window.open('/saveas.asp?url=' + TheUrl ,'','left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
}

function PrintIt(TheObj){
  var prtContent = document.getElementById(TheObj);
	oldContent = prtContent.innerHTML;
  var WinPrint = window.open('','','left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
  WinPrint.document.write(prtContent.innerHTML);
  WinPrint.document.close();
  WinPrint.focus();
  WinPrint.print();
  WinPrint.close();
  prtContent.innerHTML = oldContent;
}

// Vaziyet routines
// *****************************************************************************
function vaziyet(TheCode) {
	if (TheCode=="") {imgfile="vaziyet"} else {imgfile="vaziyet_"+TheCode}
	GetObj("imgVaziyet").src="/images/vaziyet/" + imgfile + ".jpg";
	}
	
var OdemeMode = false	

function ToogleOdeme(TheThumbnail) {
//	  var prtContent = document.getElementById(TheObj);
//	oldContent = prtContent.innerHTML;
  OdemeMode = !OdemeMode;
	if (OdemeMode) {
	GetObj("divKat").innerHTML=GetObj("divKatReserved").innerHTML
	GetObj("divOdemeLink").innerHTML='&nbsp;&nbsp;Daire Planına Dönmek İçin Tıklayınız '
	} else {
	GetObj("divKat").innerHTML="<img src='" + TheThumbnail + "'>"
	GetObj("divOdemeLink").innerHTML='&nbsp;&nbsp;Ödeme Seçenekleri'
	}
}	

// Navigation routines
// *****************************************************************************
function JumpPage(TheID) {
	if (TheID!=0) {
  document.location.href='/index.asp?id=' + TheID;
	}
}

function LinkIt(TheID, TheKind) {
	todo=1;
	if (TheKind==3||TheKind==12) {todo=2 } // Ajax Popup
	if (TheKind==10) {todo=3} // Image
	if (todo==1) {document.location.href= "/index.asp?id=" + TheID;}
	if (todo==2) {ShowModalPopup("ajax.asp?id=" + TheID + '&rnd=' + Math.random(), 853, 662);}
	if (todo==3) {ShowModalPopup("ajax.asp?cmd=pic&id=" + TheID + '&rnd=' + Math.random(), 820, 620);}
}

// modal popup
// *****************************************************************************

function ShowModalPopup(TheUrl, TheWidth, TheHeight) {
  popW=TheWidth; popH =TheHeight ; 
	PosX = winW/2-popW/2 ; if (PosX<0) {PosX=0;}
	PosY = winH/2-popH/2 ; if (PosY<0) {PosY=0;}
  OdemeMode = false		
  GetGeo();
  Size(winW , winH, GetObj("divDark"));
  Size(popW , popH, GetObj("divPop"));
	Move(PosX , PosY, GetObj("divPop"));
  Show("divDark");
  Show("divPop");
  ajaxpage(TheUrl, "divPop");
	window.scrollTo(0,0);
}

function HideModalPopup() {
   ajaxpage("/empty.htm", "divPop")	
   Hide("divDark");
   Hide("divPop");
}

// ajax
// *****************************************************************************

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar)
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
  if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
		document.getElementById(containerid).innerHTML=page_request.responseText;
    }
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}


function RollMenu(TheID, TheImage) {
	tmpImg = GetObj("mi_" + TheID) 
	if (tmpImg!=null) {
		tmpImg.src = TheImage;
		}
}


// Fix PNG
// *****************************************************************************

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG() {
if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}}