
preload_ajax = new Image();
preload_ajax.src = "ajax/trans.png";
preload_ajax.src = "ajax/loading1.gif";
preload_ajax.src = "ajax/loading2.gif";
preload_ajax.src = "ajax/loading3.gif";
preload_ajax.src = "ajax/loading4.gif";
preload_ajax.src = "ajax/loading5.gif";
preload_ajax.src = "ajax/loading6.gif";
preload_ajax.src = "ajax/loading7.gif";
preload_ajax.src = "ajax/loading8.gif";
preload_ajax.src = "ajax/loading9.gif";
preload_ajax.src = "ajax/loading10.gif";
preload_ajax.src = "ajax/loading11.gif";
preload_ajax.src = "ajax/loading12.gif";
function AJAXFunction(){
	var xmlHttp;
	try
	{
		// Firefox, Opera8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// IE
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Browser anda tidak mendukung AJAX...!");
				return false;
			}
		}
	}
}


function getHttp(){
	theHttp = null;
	try{theHttp=new XMLHttpRequest();}
	catch (e){try{theHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e){theHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
	return theHttp;
}

function getHeader(){
	xhead = getHttp();
	xhead.onreadystatechange=function(){
		if(xhead.readyState==4){
			document.getElementById('header').innerHTML=xhead.responseText;
		}
	}
	xhead.open("GET","ajax/header.php",true);
	xhead.send(null);
}

function getModule(xx,yy){
	if(yy==undefined) yy='';
	gmod = getHttp();
	gmod.onreadystatechange=function(){
		if(gmod.readyState==4){
			document.getElementById('frame').innerHTML=gmod.responseText;
		}else{
			document.getElementById('frame').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"ajax/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table>";
		}
	}
	gmod.open("GET","modules/"+xx+".php"+yy,true);
	gmod.send(null);
}

function goModule(xx,yy){
	if(yy==undefined) yy='';
	xmod = getHttp();
	xmod.onreadystatechange=function(){
		if(xmod.readyState==4){
			document.getElementById('content').innerHTML=xmod.responseText;
		}else{
			document.getElementById('content').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"ajax/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table>";
		}
	}
	xmod.open("GET","modules/"+xx+"/index.php"+yy,true);
	xmod.send(null);
}

function goModule(xx,yy){
	if(yy==undefined) yy='';
	xmod = getHttp();
	xmod.onreadystatechange=function(){
		if(xmod.readyState==4){
			document.getElementById('contents').innerHTML=xmod.responseText;
		}else{
			document.getElementById('contents').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"ajax/loading2.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table>";
		}
	}
	xmod.open("GET","modules/"+xx+".php"+yy,true);
	xmod.send(null);
}

function goForm(f){
	var formData = '', elem = '';
	for(var s=0; s<f.elements.length; s++){
		elem = f.elements[s];
		if(formData != ''){
			formData += '&';
		}
		formData += elem.name+"="+escape(elem.value);
	}
	xmlReq = getHttp();
	xmlReq.onreadystatechange = function(){
		if(xmlReq.readyState == 4){
			document.getElementById('content').innerHTML = xmlReq.responseText;
		}
	}
	xmlReq.open(f.method, f.action, true);
	xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlReq.send(formData);
	return false;
}

function getForm(f){
	var formData = '', elem = '';
	for(var s=0; s<f.elements.length; s++){
		elem = f.elements[s];
		if(formData != ''){
			formData += '&';
		}
		formData += elem.name+"="+escape(elem.value);
	}
	xmlReq2 = getHttp();
	xmlReq2.onreadystatechange = function(){
		if(xmlReq2.readyState == 4){
			document.getElementById('frame').innerHTML = xmlReq2.responseText;
		}
	}
	xmlReq2.open(f.method, f.action, true);
	xmlReq2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlReq2.send(formData);
	return false;
}

function topImage(){
	var x1 = getHttp();
	x1.onreadystatechange=function(){
		if(x1.readyState==4){
			document.getElementById("topImage").innerHTML=x1.responseText;
		}
	}
	x1.open("GET","core/right/topimage.php",true);
	x1.send(null);
	t=setTimeout("topImage()",5000);
}
//kaswadi
var cm=null;
document.onclick = new Function("show(null)")
function getPos(el,sProp) {
	var iPos = 0
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos
}

function show(el,m) {
	if (m) {
		m.style.display='';
		m.style.pixelLeft = getPos(el,"Left")
		m.style.pixelTop = getPos(el,"Top") + el.offsetHeight
	}
	if ((m!=cm) && (cm)) cm.style.display='none'
	cm=m
}


function getHttp(){
	theHttp = null;
	try{theHttp=new XMLHttpRequest();}
	catch (e){try{theHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e){theHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
	return theHttp;
}

function getHeader(h){
	if(h=='start'){
		m = 'nomenu';
	}else{
		m = 'menu';
	}
	xhead = getHttp();
	xhead.onreadystatechange=function(){
		if(xhead.readyState==4){
			document.getElementById('header').innerHTML=xhead.responseText;
		}
	}
	xhead.open("GET","includes/header_"+m+".php",true);
	xhead.send(null);
}

function getFooter(){
	xfoot = getHttp();
	xfoot.onreadystatechange=function(){
		if(xfoot.readyState==4){
			document.getElementById('footer').innerHTML=xfoot.responseText;
		}
	}
	xfoot.open("GET","includes/footer.php",true);
	xfoot.send(null);
}

function goModule(xx,yy){
	if(yy==undefined) yy='';
	xmod = getHttp();
	xmod.onreadystatechange=function(){
		if(xmod.readyState==4){
			document.getElementById('content').innerHTML=xmod.responseText;
		}else{
			document.getElementById('content').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"includes/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table><br /><br /><br />";
		}
	}
	xmod.open("GET","modules/"+xx+".php"+yy,true);
	xmod.send(null);
}

function goSubModule(xx,yy){
	if(yy==undefined) yy='';
	xmod = getHttp();
	xmod.onreadystatechange=function(){
		if(xmod.readyState==4){
			document.getElementById('subcontent').innerHTML=xmod.responseText;
		}else{
			document.getElementById('subcontent').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"includes/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table><br /><br /><br />";
		}
	}
	xmod.open("GET","modules/"+xx+".php"+yy,true);
	xmod.send(null);
}

function logModule(mm){
	mmod = getHttp();
	mmod.onreadystatechange=function(){
		if(mmod.readyState==4){
			document.getElementById('membership').innerHTML=mmod.responseText;
		}else{
			document.getElementById('membership').innerHTML="<br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"ajax/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table>";
		}
	}
	mmod.open("GET","modules/"+mm+".php",true);
	mmod.send(null);
}

function goForm(f){
	var formData = '', elem = '';
	for(var s=0; s<f.elements.length; s++){
		elem = f.elements[s];
		if(formData != ''){
			formData += '&';
		}
		if(elem.type == "checkbox"){
			if(elem.checked == true) formData += elem.name+"="+escape(elem.value);
		}else{
			formData += elem.name+"="+escape(elem.value);
		}
	}
	xmlReq = getHttp();
	xmlReq.onreadystatechange = function(){
		if(xmlReq.readyState == 4){
			document.getElementById('content').innerHTML = xmlReq.responseText;
		}
	}
	xmlReq.open(f.method, f.action, true);
	xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlReq.send(formData);
	return false;
}

function goSearch(f){
	var formData = '', elem = '';
	for(var s=0; s<f.elements.length; s++){
		elem = f.elements[s];
		if(formData != ''){
			formData += '&';
		}
		formData += elem.name+"="+escape(elem.value);
	}
	xmlReqs = getHttp();
	xmlReqs.onreadystatechange = function(){
		if(xmlReqs.readyState == 4){
			document.getElementById('subcontent').innerHTML = xmlReqs.responseText;
		}else{
			document.getElementById('subcontent').innerHTML="<br /><br /><br /><table align=\"center\"><tr><td style=\"font-family: Arial, Verdana; font-size: 11px;font-weight: bold;background: #fff; color: #333; padding: 5px 10px; border: 1px outset #fff;\"><img src=\"includes/loading.gif\" width=\"16\" height=\"16\" align=\"absmiddle\">&nbsp;loading...</td></tr></table><br /><br /><br />";
		}
	}
	xmlReqs.open(f.method, f.action, true);
	xmlReqs.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlReqs.send(formData);
	return false;
}

function loginForm(f){
	var formData = '', elem = '';
	for(var s=0; s<f.elements.length; s++){
		elem = f.elements[s];
		if(formData != ''){
			formData += '&';
		}
		formData += elem.name+"="+escape(elem.value);
	}
	xmlReq3 = getHttp();
	xmlReq3.onreadystatechange = function(){
		if(xmlReq3.readyState == 4){
			document.getElementById('membership').innerHTML = xmlReq3.responseText;
		}
	}
	xmlReq3.open(f.method, f.action, true);
	xmlReq3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlReq3.send(formData);
	return false;
}

function goCalendar(){
	var xcal = getHttp();
	xcal.onreadystatechange=function(){
		if(xcal.readyState==4){
			document.getElementById("block_calendar").innerHTML=xcal.responseText;
		}
	}
	xcal.open("GET","calblock.php?month="+document.the_cal.month.value+"&year="+document.the_cal.year.value,true);
	xcal.send(null);
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function struktur_data(op,id,judul){
	ajaxwin4=dhtmlwindow.open("ajaxbox4", "ajax", "modules/struktur?act=struktur_data&op="+op+"&id="+id, judul, "width=500px,height=180px,center=1,resize=1,scrolling=1");
}

function struktur_asdep(id){
	ajaxwin2=dhtmlwindow.open("ajaxbox2", "ajax", "modules/struktur_asdep.php?id="+id, "Diagram Struktur", "width=610px,height=420px,top=0px,left=0px,resize=1,scrolling=1");
}

function asdep_data(id){
	ajaxwin1=dhtmlwindow.open("ajaxbox1", "ajax", "modules/struktur_data.php?op=profile&id="+id, "Profile", "width=500px,height=180px,top=0px,left=610px,resize=1,scrolling=1");
}
//kaswadi
function popup(tujuan,judul,id,w,h,op){
	ajaxwin3=dhtmlwindow.open("ajaxbox3", "ajax", "modules/struktur?act="+tujuan+"&op="+op+"&id="+id, judul, "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=0");
}
function sial(){
	ajaxwin5=dhtmlwindow.open("ajaxbox5", "ajax", "modules/struktur?act=struktur", "STRUKTUR ORGANISASI", "width=620px,height=420px,center=1,resize=0,scrolling=0");
}
function popup2(tujuan,judul,id,w,h,op){
	ajaxwin3=dhtmlwindow.open("ajaxbox3", "ajax", "modules/struktur?act="+tujuan+"&op="+op+"&id="+id, judul, "width="+w+"px,height="+h+"px,center=1,resize=1,scrolling=1");
}
///

function launch_ajax(mod){
	getHeader(mod);
	goModule(mod);
	getFooter();
	MM_preloadImages('includes/trans.png','includes/loading.gif','images/bgmenu.jpg','images/bgnav.gif','images/bgmenu2.jpg','images/structure_anime_r2_c6_f2.gif','images/structure_anime_r4_c2_f2.gif','images/structure_anime_r4_c5_f2.gif','images/structure_anime_r4_c9_f2.gif','images/structure_anime_r4_c12_f2.gif','images/structure_anime_r4_c16_f2.gif','images/structure_anime_r6_c2_f2.gif','images/structure_anime_r6_c5_f2.gif','images/structure_anime_r6_c9_f2.gif','images/structure_anime_r6_c12_f2.gif','images/structure_anime_r6_c16_f2.gif','images/structure_anime_r8_c2_f2.gif','images/structure_anime_r8_c5_f2.gif','images/structure_anime_r8_c9_f2.gif','images/structure_anime_r8_c12_f2.gif','images/structure_anime_r8_c16_f2.gif','images/structure_anime_r10_c2_f2.gif','images/structure_anime_r10_c5_f2.gif','images/structure_anime_r10_c9_f2.gif','images/structure_anime_r10_c12_f2.gif','images/structure_anime_r10_c16_f2.gif','images/structure_anime_r12_c5_f2.gif','images/structure_anime_r12_c12_f2.gif');
}

