// JavaScript Document
// JavaScript Document
var xmlHttp
function shout(nama,pesan,web)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser tidak support HTTP Request")
	}
var url="shoutbox.php"
url=url+"?cmd=save&nama="+nama
url=url+"&pesan="+pesan
url=url+"&web="+web
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function shoutit(nama,pesan,web)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser tidak support HTTP Request")
	}
var url="shout.php"
url=url+"?cmd=save&nama="+nama
url=url+"&pesan="+pesan
url=url+"&web="+web
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function shouts(nama,pesan,web)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser tidak support HTTP Request")
	}
var url="shoutboxs.php"
url=url+"?cmd=save&nama="+nama
url=url+"&pesan="+pesan
url=url+"&web="+web
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function searchit(kunci)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) { alert ("Browser tidak support HTTP Request") }
	var url="page/search.php"
	url=url+"?cmd=cari&cari="+kunci
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=searchChange
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
var please_wait = "<center><br><br><img src=images/loader.gif><br>Please Wait.....<center>";

function open_url(url, targetId, syarat) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){ alert ("Browser tidak support HTTP Request") }
	content = document.getElementById(syarat).value;
	url=url+ escape(content)
	url=url+"&sid="+Math.random()
	var e=document.getElementById(targetId);if(!e)return false;
	xmlHttp.onreadystatechange = function() { response(url, e); }
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function response(url, e) {
  if(xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") {
	e.innerHTML = (xmlHttp.status == 200 || xmlHttp.status == 0) ? xmlHttp.responseText : "Broken Link, silahkan hubungi Webmaster dengan menyampaikan kode error : " + xmlHttp.status+" "+xmlHttp.statusText;
  }
  if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
	e.innerHTML=please_wait
  }
}
function searchChange()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("search-output").innerHTML=xmlHttp.responseText
	}
}
function formChange()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
	document.getElementById("MyForm").innerHTML=xmlHttp.responseText
	}
if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")	{
	document.getElementById("MyForm").innerHTML="<center>Please Wait.....<br><img src=images/loading.gif></center>"
	}
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("output").innerHTML=xmlHttp.responseText
	}
if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{
	document.getElementById("loader").innerHTML="<center><img src=\"images/loading.gif\"/><br/>Menyimpan data,<br> please wait...</center>"
	}
}
function GetXmlHttpObject()
{
var xamlHttp=null;
try
	{
	xmlHttp=new XMLHttpRequest();
	}
	catch (e)
		{
		try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
				{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
		}			
return xmlHttp;
}

function createform(formnya,e) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser tidak support HTTP Request")
	}
  theObject = document.getElementById("MyForm")
  link = document.getElementById(e)

  theObject.style.position = "absolute";
  theObject.style.visibility = "visible";
  theObject.style.height = "100px";
  theObject.style.width = "100px";  

  var posx = 0;
  var posy = 0;
  posx = findX(link) + document.body.scrollLeft;
  posy = findY(link) + document.body.scrollTop;
  theObject.style.left = posx + "px";
  theObject.style.top = posy + "px";
  var url = formnya+e;
  url=url+"&sid="+Math.random()
  xmlHttp.onreadystatechange = formChange
  xmlHttp.open("GET", url,true);
  xmlHttp.send(null);
}
function closetask() {
  theObjects = document.getElementById("MyForm");
  theObjects.style.visibility = "hidden";
  theObjects.style.height = "0px";
  theObjects.style.width = "0px";   
}

function findX(obj){
  var curleft = 0;
  if (obj.offsetParent){
	while (obj.offsetParent){
	  curleft += obj.offsetLeft;
	  obj = obj.offsetParent;
	}
  } else if (obj.x){
	curleft += obj.x;
  }
  return curleft;
}

function findY(obj) {
  var curtop = 0;
  if (obj.offsetParent){
	curtop += obj.offsetHeight;
	while (obj.offsetParent){
	  curtop += obj.offsetTop;
	  obj = obj.offsetParent;
	}
  } else if (obj.y){
	curtop += obj.y;
	curtop += obj.height;
  }
  return curtop;
}


function submitform(what,elm) {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
	{
	alert ("Browser tidak support HTTP Request")
	}
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
  		var detect = "page/"+what+".php?";
  		detect=detect+"&sid="+Math.random()
		xmlHttp.open("POST",detect,true)
		xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttp.onreadystatechange=submitChange
		var param = 'query=' + document.getElementById(elm).value;
		xmlHttp.send(param);
	}
}
function submitChange()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("submission").innerHTML=xmlHttp.responseText
	}
if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")	{
	document.getElementById("submission").innerHTML="<center>Please Wait.....<br><img src=images/loader.gif></center>"
	}
}