// JavaScript Document
function checkAll()
{
	//if (i == 0) { // "All" checkbox selected.
	if (document.formlist.pagesidtop.checked == false)
	{
		for (i = 0; i < document.formlist.pagesid.length; i++)
		{
		document.formlist.pagesid[i].checked = false;
    	for (j=0;j< document.getElementById("baris").rows[i+1].cells.length; j++)
		{
		document.getElementById("baris").rows[i+1].cells[j].style.backgroundColor = document.formlist.apa[i].value;
		//alert(document.getElementById("baris").rows[i+1].cells[j].className);
		}
		}
	}
	else
	{
		for (i = 0; i < document.formlist.pagesid.length; i++)
		{
		document.formlist.pagesid[i].checked = true;
    	for (j=0;j< document.getElementById("baris").rows[i+1].cells.length; j++)
		document.getElementById("baris").rows[i+1].cells[j].style.backgroundColor = "#f2f7de";
		}
    }
}

function changecolor(s)
{
	if (document.formlist.pagesid.length==undefined)
	{
		if (document.formlist.pagesid.checked == true)
		{
			for (j=0;j< document.getElementById("baris").rows[s].cells.length; j++)
			{
				document.getElementById("baris").rows[s].cells[j].style.backgroundColor = "#f2f7de";
			}
		}
		else
		{
			for (j=0;j< document.getElementById("baris").rows[s].cells.length; j++)
				document.getElementById("baris").rows[s].cells[j].style.backgroundColor = document.formlist.apa.value;
		}

	}

	else

	{
		if (document.formlist.pagesid[s-1].checked == true)
		{
			for (j=0;j< document.getElementById("baris").rows[s].cells.length; j++)
			{
				document.getElementById("baris").rows[s].cells[j].style.backgroundColor = "#f2f7de";
			}
		}
		else
		{
			for (j=0;j< document.getElementById("baris").rows[s].cells.length; j++)
				document.getElementById("baris").rows[s].cells[j].style.backgroundColor = document.formlist.apa[s-1].value;
		}
	}

}



//function gotoPage & movePage punya sub paging

	function gotoPage(SortAlf,lst,ty)
	{
		if (document.formlist.goto.value!="")
		{
			movePage(document.formlist.goto.value,SortAlf,lst,ty);
		}
	}
	function movePage(Page,SortAlf,lst,ty,cntID)
	{
		document.formlist.page.value=Page;
		document.formlist.SortAlf.value=SortAlf;
		document.formlist.lst.value=lst;
		document.formlist.ty.value=ty;
		document.formlist.cntID.value=cntID;		
		document.formlist.submit();
	}




function popeditor(formname,caller)
{
	strURL = "../../contenteditor/editor.asp?" + "formname=" + formname + "&caller=" + caller;
	win = window.open (strURL ,'editor','location=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=640,height=405');
	win.focus();
	win.moveTo(0,0);


}

function show(formname,caller,content,domain)
{
	var domainname= "http://" + domain;

	content = content.replace (/img (height=[0-9]*) src=\"\.\./gi,"img " + "$1" + " src=\"" + domainname)

	//content = content.replace (/img (height=[0-9]*) src=\"http:[^0-9]*http:/gi,"img " + "$1" + " src=\"" + "http:" )

	eval("document." + formname + "." + caller ).value =  content  ;

	document.getElementById(caller + "1").innerHTML =  content  ;
}

//--------------function untuk popup---------------------
function openIT(panjang, tinggi) {
	theurl="map/map.htm"
	wname ="details"
	W=panjang;
	H=tinggi;
	windowCERRARa 		= "i/close_a.gif"
	windowCERRARd 		= "i/close_d.gif"
	windowCERRARo 		= "i/close_o.gif"
	windowTIT 	    	= "<font face=verdana size=1><strong>&nbsp;&nbsp;MAYORA Tbk. Location Map<strong></font>"
	windowBORDERCOLOR   	= "#E7B413"
	windowBORDERCOLORsel	= "#E7B413"
	windowTITBGCOLOR    	= "#E7B413"
	windowTITBGCOLORsel 	= "#E7B413"
	openchromeless(theurl, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
}


function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel) {

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) isie=true
	else											     isie=false

	if (isie) { H=H+20+2; W=W+2; }

	s = ",width="+W+",height="+H;

	if (isie) {
		var parameters = escape( theURL+"|"+windowCERRARa+"|"+windowCERRARd+"|"+windowCERRARo+"|"+windowTIT+"|"+windowBORDERCOLOR+"|"+windowBORDERCOLORsel+"|"+windowTITBGCOLOR+"|"+windowTITBGCOLORsel)

		splashWin = window.open( "" , wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"+s)

		splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
		splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

		splashWin.document.open("text/html", "replace");
		splashWin.document.write("<html><style type='text/css'>\n");
		splashWin.document.write("body                  { border: 1px solid #E7B413; overflow: hidden; margin: 0pt;}");
		splashWin.document.write("#stillloadingDiv 	{ position: absolute; left: 0px; top: 0px; width: 600px; height: 19px; z-index: 1; background-color: #E7B413; layer-background-color: #C0C0C0; clip:rect(0,100%,19,0);}");
		splashWin.document.write("</style>\n");
		splashWin.document.write("<body onload=\"top.document.location.replace('chromeless.html?"+parameters+"')\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no'>");
		splashWin.document.write("<div id=stillloadingDiv><table width=600 height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;L o a d i n g . . .</font></td></tr></table></div>");
		splashWin.document.write("</body></html>");
		splashWin.document.close();

	}
	else    var splashWin = window.open(theURL, wname, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1"+s, true)

	splashWin.focus();
}
//-------------------- CHROMELESS OPEN WINDOW --------------------
function openwinnowin(theurl, wname, W, H) {
	if (is.ie) r = ",resizable=0"
	else       r = ",resizable=1"
	s = ",width="+W+",height="+H;

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	var splashWin = window.open("", wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0"+r+s)

	splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
	splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

	splashWin.document.open("text/html", "replace");
	splashWin.document.write("<html><style type='text/css'>\n");
	splashWin.document.write("#lineLDiv 		{ position: absolute; left:         0px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineRDiv		{ position: absolute; left: "+(W-1)+"px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineBDiv 		{ position: absolute; left:         0px; top: "+         (H-1)+"px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#lineTDiv 		{ position: absolute; left:         0px; top:                  0px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#stillloadingDiv 	{ position: absolute; left:         0px; top: "+Math.ceil(H/2)+"px; width: "+W+"px; height: "+H+"px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,"+W+",19,0);}");
	splashWin.document.write("</style>\n");
	splashWin.document.write("<body onload=\"self.document.location.href='"+theurl+"'\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no' style='border: 0px; overflow: hidden; margin: 0pt;'>");
	splashWin.document.write("<div id='lineLDiv'></div>");
	splashWin.document.write("<div id='lineRDiv'></div>");
	splashWin.document.write("<div id='lineBDiv'></div>");
	splashWin.document.write("<div id='lineTDiv'></div>");
	splashWin.document.write("<div id=stillloadingDiv><table width=513 height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;L o a d i n g . . .</font></td></tr></table></div>");
	splashWin.document.write("</body></html>");
	splashWin.document.close();

	splashWin.focus();

	eval(wname+"=splashWin")
}

var isinit     = false;
var mywindowok = true;

var param = parent.location.search.toString()
    param = unescape( param.substring(1, param.length) )

if ( param.split("|").length>=9 ) {
	theURL 	    	    = param.split("|")[0]
	windowCERRARa 	    = param.split("|")[1]
	windowCERRARd 	    = param.split("|")[2]
	windowCERRARo 	    = param.split("|")[3]
	windowTIT 	    = param.split("|")[4]
	windowBORDERCOLOR   = param.split("|")[5]
	windowBORDERCOLORsel= param.split("|")[6]
	windowTITBGCOLOR    = param.split("|")[7]
	windowTITBGCOLORsel = param.split("|")[8]
}
else {  // For debug
	theURL="about:blank"
	windowCERRARa 		= "img/close_a.gif"
	windowCERRARd 		= "img/close_d.gif"
	windowCERRARo 		= "img/close_o.gif"
	windowTIT 	    	= "<font face=verdana size=1>&nbsp; window title</font>"
	windowBORDERCOLOR   	= "#000000"
	windowBORDERCOLORsel	= "#FF8A00"
	windowTITBGCOLOR    	= "#d7dcd9"
	windowTITBGCOLORsel 	= "#ffffff"
}

var windowCERRARImg_a = new Image(); windowCERRARImg_a.src=windowCERRARa;
var windowCERRARImg_d = new Image(); windowCERRARImg_d.src=windowCERRARd;
var windowCERRARImg_o = new Image(); windowCERRARImg_o.src=windowCERRARo;


function whaitborders() {
	if ( parent.chromewinb && parent.chromewinl && parent.chromewinr ) {
		parent.chromewinb.document.bgColor=windowBORDERCOLOR
		parent.chromewinl.document.bgColor=windowBORDERCOLOR
		parent.chromewinr.document.bgColor=windowBORDERCOLOR
	} else {
		setTimeout('whaitborders()', 100);
	}
}
whaitborders()

//////////////////////////////////////////////////////////////// MOUSE MOVE //////

function mouseSTATUS() {
	this.x       = null;
	this.y       = null;
	this.bt      = "up";
	this.oldx    = null;
	this.oldy    = null;
	this.dx      = null;
	this.dy      = null;
	this.screeny = null;
	this.screenx = null;

	this.element = null;
	this.event   = null;
}

var mouse = new mouseSTATUS();

function actualizateMouseSTATUS(e) {
	if (!e) var e = event
	if ( (e.type=="mousedown" || e.type=="mouseup") && e.button!=1) return true

	var x=e.x+document.body.scrollLeft
	var y=e.y+document.body.scrollTop

	mouse.x   = x;
	mouse.y   = y;

	     if ( e.type == "mousedown" ) mouse.bt = "down";
	else if ( e.type == "mouseup" )   mouse.bt = "up";

	if (window.event) {
		mouse.screenx=window.event.screenX;
		mouse.screeny=window.event.screenY;
	} else {
		mouse.screenx=-1;
		mouse.screeny=-1;
	}

}


function initMouseEvents() {
	document.onmousedown = actualizateMouseSTATUS
	document.onmousemove = actualizateMouseSTATUS
	document.onmouseup   = actualizateMouseSTATUS
	document.onselectstart = selectstart
	document.ondragstart   = new Function("actualizateMouseSTATUS(event); return false;")
}

function selectstart(){
	if ( event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "TEXTAREA") { return false; } 
	else { mouse.bt="up"; return true; }
}

initMouseEvents()

//////////////////////////////////////////////////////////////// WINDOW DRAG //////

var mywindowbt    ="up";
var wincloseSTATUS="up";

var ofx=0;
var ofy=0;
var opx=0;
var opy=0;
var px=0;
var py=0;

var wcpx1=-1, wcpy1=-1;
var wcpx2=-1, wcpy2=-1;

var wclosechanged = false;

function initToMoveWin() { 
	if (mywindowok) {
		if (wincloseSTATUS=="up" && ( mywindowbt=="up" || mywindowbt=="over") ) {
			if (isinit) {
				wcpx1 = document.all["mywindowCLOSE"].style.pixelLeft=document.body.clientWidth-18
				wcpy1 = document.all["mywindowCLOSE"].style.pixelTop =4
				wcpx2 = wcpx1 + 11 - 1 
				wcpy2 = wcpy1 + 11 - 1
				if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2) { 
					if (wclosechanged == false) {
						document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_o.src
						wclosechanged = true
					}
						
				} else if (wclosechanged == true) {
					document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_d.src
					wclosechanged = false
				}
			}
		}

		     if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "up"   && mouse.bt =="up"    ) { mywindowbt = "over" }
		else if ( ( mouse.y  > 22 || mouse.y <  1 ) && mywindowbt == "over" && mouse.bt =="up"    ) { mywindowbt = "up"   }
		else if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "over" && mouse.bt == "down" ) { 
			self.window.focus();
	
			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 ) { 
				wincloseSTATUS="down"
				document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_a.src
			} else {
				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLORsel
				document.body.style.borderColor = windowBORDERCOLORsel
				parent.chromewinb.document.bgColor=windowBORDERCOLORsel
				parent.chromewinl.document.bgColor=windowBORDERCOLORsel
				parent.chromewinr.document.bgColor=windowBORDERCOLORsel
				ofx =  mouse.x;
				ofy =  mouse.y;
				opx =  mouse.x;
				opy =  mouse.y;
			}	
			mywindowbt="down"; 
		}
		else if ( mouse.bt =="up" && mywindowbt == "down" ) { 
			mywindowbt="up"; 
			ofx=0; 
			ofy=0; 
			opx=0; 
			opy=0; 

			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 && wincloseSTATUS=="down" ) { top.window.close() }

			wincloseSTATUS="up"
		
			if ( document.all["mywindowTITLE"] ) {
				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLOR
				document.body.style.borderColor = windowBORDERCOLOR
				parent.chromewinb.document.bgColor=windowBORDERCOLOR
				parent.chromewinl.document.bgColor=windowBORDERCOLOR
				parent.chromewinr.document.bgColor=windowBORDERCOLOR
			}

		}
		else if ( mywindowbt == "down" && wincloseSTATUS == "up") {
			var m_scrx = mouse.screenx;
			var m_scry = mouse.screeny;
			opx = px + ofx - m_scrx;
			opy = py + ofy - m_scry;
			px = m_scrx - ofx;
			py = m_scry - ofy;
			top.window.moveTo(px , py);
		}
	}
	setTimeout('initToMoveWin()',20);
}
initToMoveWin()

//////////////////////////////////////////////////////////////// WRITE TITLE //////

function init() {
	document.all["mywindowTITLE"].innerHTML='<table width=100% height=20 border=0 cellpadding=0 cellspacing=0><tr><td valign=middle align=left>'+windowTIT+'</td></tr></table>'
	document.all["mywindowTITLE"].style.backgroundColor  = windowTITBGCOLOR
	document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_d.src

	setTimeout('parent.main.location.replace("'+theURL+'")',200)

	isinit=true
}

function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel) {

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) isie=true
	else											     isie=false

	if (isie) { H=H+20+2; W=W+2; }

	s = ",width="+W+",height="+H;

	if (isie) {
		var parameters = escape( theURL+"|"+windowCERRARa+"|"+windowCERRARd+"|"+windowCERRARo+"|"+windowTIT+"|"+windowBORDERCOLOR+"|"+windowBORDERCOLORsel+"|"+windowTITBGCOLOR+"|"+windowTITBGCOLORsel)

		splashWin = window.open( "" , wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"+s)

		splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
		splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

		splashWin.document.open("text/html", "replace");
		splashWin.document.write("<html><style type='text/css'>\n");
		splashWin.document.write("body                  { border: 1px solid #000000; overflow: hidden; margin: 0pt;}");
		splashWin.document.write("#stillloadingDiv 	{ position: absolute; left: 0px; top: 0px; width: 100%px; height: 19px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,100%,19,0);}");
		splashWin.document.write("</style>\n");
		splashWin.document.write("<body onload=\"top.document.location.replace('chromeless.html?"+parameters+"')\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no'>");
		splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;c o n t a c t i n g . . .</font></td></tr></table></div>");
		splashWin.document.write("</body></html>");
		splashWin.document.close();

	}
	else    var splashWin = window.open(theURL, wname, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1"+s, true)

	splashWin.focus();
}

//////////////////////////////////////////////////////////////// CHROMELESS OPEN WINDOW //////
// Se genera una variable global con el nombre del wname... el nuevo objeto creado es eval(wname)
function openwinnowin(theurl, wname, W, H) {
	if (is.ie) r = ",resizable=0"
	else       r = ",resizable=1"
	s = ",width="+W+",height="+H;

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	var splashWin = window.open("", wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0"+r+s)

	splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) )
	splashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) )

	splashWin.document.open("text/html", "replace");
	splashWin.document.write("<html><style type='text/css'>\n");
	splashWin.document.write("#lineLDiv 		{ position: absolute; left:         0px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineRDiv		{ position: absolute; left: "+(W-1)+"px; top:                  0px; width:     1px; height: "+H+"px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,1,"+H+",0);}");
	splashWin.document.write("#lineBDiv 		{ position: absolute; left:         0px; top: "+         (H-1)+"px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#lineTDiv 		{ position: absolute; left:         0px; top:                  0px; width: "+W+"px; height:     1px; z-index: 2; background-color: #000000; layer-background-color: #000000; clip:rect(0,"+W+",1,0);}");
	splashWin.document.write("#stillloadingDiv 	{ position: absolute; left:         0px; top: "+Math.ceil(H/2)+"px; width: "+W+"px; height: "+H+"px; z-index: 1; background-color: #C0C0C0; layer-background-color: #C0C0C0; clip:rect(0,"+W+",19,0);}");
	splashWin.document.write("</style>\n");
	splashWin.document.write("<body onload=\"self.document.location.href='"+theurl+"'\" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll='no' style='border: 0px; overflow: hidden; margin: 0pt;'>");
	splashWin.document.write("<div id='lineLDiv'></div>");
	splashWin.document.write("<div id='lineRDiv'></div>");
	splashWin.document.write("<div id='lineBDiv'></div>");
	splashWin.document.write("<div id='lineTDiv'></div>");
	splashWin.document.write("<div id=stillloadingDiv><table width=100% height=22 cellspacing=0 cellpadding=0><tr><td align=left valign=middle width=100%><FONT size=1 face=verdana color=#000000>&nbsp;&nbsp;l o a d i n g . . .</font></td></tr></table></div>");
	splashWin.document.write("</body></html>");
	splashWin.document.close();

	splashWin.focus();

	eval(wname+"=splashWin")
}
//end function for popup!!