﻿// author: Altay Karakuş @2006, 29 Ağustos, Merzifon
var wdows = new Array();

function wdow(url, name, cls, width, height)
{
	this.url			= url;	
	this.name			= name;
	this.cls			= cls;	
	this.width			= width;
	this.height			= height;
	this.page			= null;

// add reference to global array
	wdows[wdows.length] = this;
	this.index				= wdows.length-1;

    this.id					= "wdow_" + this.index;
    this.base				= document.createElement("<div class='"+this.cls+"'>");
	this.base.id			= this.id;
	this.base.index	= this.index;

// methotds
	this.insert			= wdow_insert;
	this.write			= wdow_write;
	this.visible		= wdow_visible;
	this.clear			= wdow_clear;
	this.addClose		= wdow_addClose;
	this.show			= wdow_show;
	this.putPage		= wdow_putPage;
	this.dispose		= wdow_dispose;
	this.goUrl          = wdow_goUrl;
	this.recalculate    = wdow_recalculate;    
	this.insert();
}

function wdow_insert()
{
	document.body.appendChild(this.base);	
	this.visible(false);
}

function wdow_visible(what)
{
	this.base.style.visibility = (what) ? "visible" : "hidden" ;
}

function wdow_putPage()
{	
	this.write("<iframe onload ='back("+this.index+");' name='"+this.id+"_frm' scrolling='no' style='border:none; width:" + (this.width-3) + "; height:" + this.height + ";'></iframe>");
	this.page = eval(this.id +"_frm");
}

function wdow_goUrl()
{   
   //showD(details(eval("w1.page"),w1.page));
   this.page.location = this.url;      
}

function showD(str)
{
    var wo = window.open("..\/details.htm","details","width=650, height=500, status=yes, resizable=yes, scrollbars=yes");        
    var s="<html>";
        s+="<head>";
	    s+="    <meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-9\"/>";
	    s+="    <link rel=\"stylesheet\" type=\"text/css\" href=\"../css/details.css\" >";	
        s+="</head>";
        s+="<body leftmargin=0 topmargin=0>";
        s+="<div id=base>"+str+"</div>";        
        s+="</body>";
        s+="</html>";
        wo.document.write(s); 
}

function back(index)
{
		var w = wdows[index]
		var rs = eval(w.id + "_rs");
			  rs.src  = "images/oki.gif";	
			  w.page.document.body.onunload=function(){ startback(w.index)};
}

function startback(index)
{
		var w = wdows[index]
		var rs = eval(w.id + "_rs");
			rs.src  = "images/rs.gif";		
}

function wdow_addClose(str)
{
	this.write("<table id='"+this.id+"_tbl' style=' width:100%;'><tr><td align=left width=15 height=15><img id='"+this.id+"_rs' src='images/rs.gif' width=15 height=15  border=0 /></td><th>"+this.name+"</th><td width=15 align=right><a href='javascript:void(0);' style='cursor:hand;' onclick='wdows[" + this.index + "].dispose()'>" + str + "</a></td></tr></table>");
}

function wdow_write(str)
{
	this.base.innerHTML+=str;
}

function wdow_clear()
{
	this.base.innerHTML="";
}

function wdow_dispose()
{
	document.body.removeChild(this.base);
	wdows[this.index] = null;
	closeFilterPage();
	window.onresize     = null;
}

function wdow_show(x, y, w, h)
{
	this.base.style.left	= x;
	this.base.style.top		= y;

	if(w>0)
		this.base.style.width	= w;
    else
		this.base.style.width	= this.width;

	if(h>0) 
		this.base.style.height	= h;
    else
		this.base.style.height	= this.height;

    filterPage();
	this.visible(true);
	this.addClose("Kapat");
	this.putPage();	
	this.goUrl();
	window.onresize     = this.recalculate;
}

function filterPage(){
    var f = (document.all)? document.all["sct"]: sct;
        f.style.width   = (document.body.clientHeight>window.screen.width)?document.body.clientWidth:window.screen.width;
        f.style.height  = (document.body.clientHeight>window.screen.height)?document.body.clientHeight:window.screen.height;
        f.style.left    = document.body.scrollLeft;
        f.style.top     = document.body.scrollTop;        
        f.style.visibility = "visible";    
        hideUnwanted(true);        
}

function hideUnwanted(will){
    var sl = document.getElementsByTagName("select");    
        for(var k=0; k<sl.length; k++)
        {
            sl[k].style.visibility =(will)? "hidden" : "visible";
        }
}

function closeFilterPage(){
    var f = (document.all)? document.all["sct"]: sct;
        f.style.width   = 0;
        f.style.height  = 0;
        f.style.left    = 0;
        f.style.top     = 0;        
        f.style.visibility = "hidden";
        hideUnwanted(false);
}
var w1 = null;
function getOyVer(id)
{	
	w1 = new wdow("oyver.aspx?@="+id, "Oy Ver", "eh", 300, 200); 	
	var leftPoint = document.body.scrollLeft    + (document.body.clientWidth-w1.width)/2;	
	var topPoint = document.body.scrollTop      + (document.body.clientHeight-w1.height)/2;	
	    w1.show(leftPoint, topPoint, 0, 0);
}
function wdow_recalculate()
{
	var leftPoint = document.body.scrollLeft    + (document.body.clientWidth-w1.width)/2;	
	var topPoint = document.body.scrollTop      + (document.body.clientHeight-w1.height)/2;	
	    closeFilterPage()
	  	w1.base.style.left	= leftPoint;
	    w1.base.style.top		= topPoint;
	    filterPage();
}
function details(obj,name)
{
	var str = new String();
	    str+="<table class=a>";
		str+="<tr><th colspan=3>" + name + "</th>";
		var j=0;
		for(var i in obj)
		{
			s2 =   name +"."+ i;
			str+="<tr><td class='"+(j%2)+"' style='cursor:hand;'>" + name + "." + i + "</td>";
			str+="<td class='c"+(j%2)+"'>:</td>"
			s3 = ( typeof(obj[i]) == "string" || typeof(obj[i]) == "function"  ) ? "<textarea cols=85 rows=5>" + obj[i]+"</textarea>" : obj[i]; 
			str+="<td class='c"+(j%2)+"'>"+ s3 +"</td></tr>";
			j++;
		}
		str+="</table>";
    return str;
} 

function refreshFrame(target, url)
{
    target.location = url;
}