$(document).ready(function()
{
	$("#apDiv1").slideUp();
	$("#apDiv2").slideUp();
	$("#apDiv3").slideUp();
   $("#apDiv4").mouseover(function(event)
	{
		$("#apDiv1").slideDown("show");

	});
   $("#apDiv5").mouseover(function(event)
	{
		$("#apDiv2").slideDown("show");

	});
   $("#apDiv6").mouseover(function(event)
	{
		$("#apDiv3").slideDown("show");

	});
   $("#username").mouseover(function(event)
	{
		if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Masukkan Username', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });

	});
      $("#password").mouseover(function(event)
	{
		if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Masukkan Password', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });

	});
	   $("#register").mouseover(function(event)
	{
		if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Klik disini untuk Membuat Account Baru', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });

	});
	  $("#login").mouseover(function(event)
	{
		if (document.getElementById("username").value!='' && document.getElementById("password").value!="")
		{
		if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Klik untuk Login', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
             } 
            else
	        {
				if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Penuhi semua Field yang Dibutuhkan', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
		
	        }
	});
	  
	  $("#login").click(function(event)
	{
		if (document.getElementById("username").value!="" && document.getElementById("password").value!="")
		{
		       
             } 
            else
	        {
				event.preventDefault();
	        }
	});
	  $("#nama").mouseover(function(event)
	 {
		 
		 if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Masukkan Nama', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });

		 
	 });
	    $("#alamat").mouseover(function(event)
	 {
		 
		 if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Masukkan Alamat', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
	 });
     $("#telepon").mouseover(function(event)
	 {
		 
		 if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Masukkan Telepon', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
	 });
	 
	 $("#konfirmasi").mouseover(function(event)
	 {
		 
		 if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Ketik Ulang Password', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
	 });
	 
	  $("#reset").mouseover(function(event)
	 {
		 
		 if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Klik Untuk Membersihkan Semua Isian', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
	 });
	 
	 $("#konfirmasi").keyup(function(event)
	{
		$("#hasil").hide();
		if (document.getElementById("password").value==document.getElementById("konfirmasi").value)
		{
		    document.getElementById("hasil").innerHTML="Password Sesuai";
		}
		else
		{
			document.getElementById("hasil").innerHTML="Password Tidak Sesuai";
		}
		$("#hasil").show("slow");
		
		
	});
	 
	  $("#registered").mouseover(function(event)
	{
		if (document.getElementById("username").value!='' && document.getElementById("password").value!="" && document.getElementById("nama").value!='' && document.getElementById("alamat").value!='' && document.getElementById("telepon").value!='' && document.getElementById("password").value==document.getElementById("konfirmasi").value)
		{
		if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Klik untuk Login', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
             } 
            else
	        {
				if($(this).data("qtip")) $(this).qtip("destroy");
         $(this).html('rightBottom') // Set the links HTML to the current opposite corner
            .qtip({
               content: 'Penuhi semua Field yang Dibutuhkan dan Pastikan Password serta Konfirmasinya Sesuai', // Set the tooltip content to the current corner
               position: {
                  corner: {
                     tooltip: 'leftBottom', // Use the corner...
                     target: 'rightTop' // ...and opposite corner
                  }
               },
               show: {
                  when: false, // Don't specify a show event
                  ready: true // Show the tooltip when ready
               },
               hide: 
			   {
				  when:{
					//event:'blur'  
				  },
				  ready:true
			   }, // Don't specify a hide event
               style: {
                  border: {
                     width: 10,
                     radius: 10,
					 color:'#BD4A82'
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'light' // Style it according to the preset 'cream' style
               }
		
		       });
		
	        }
	});
	  $("#registered").click(function(event)
	  {
		  
		if (document.getElementById("username").value!='' && document.getElementById("password").value!="" && document.getElementById("nama").value!='' && document.getElementById("alamat").value!='' && document.getElementById("telepon").value!='' && document.getElementById("password").value==document.getElementById("konfirmasi").value)
		{
			
			
		}
		else
		{
		    event.preventDefault();	
			
		}
		  
		  
	  });
	  
	  

});

var xmlHttp;
function getHTTPObject(){
   if (window.ActiveXObject) 
         return new ActiveXObject("Microsoft.XMLHTTP");
      else if (window.XMLHttpRequest) 
         return new XMLHttpRequest();
      else {
         alert("Your browser does not support AJAX.");
         return null;
       }
}

function post(cid,id)
{
	xmlHttp=getHTTPObject();
	var judul=document.getElementById("judul").value;
	var isi=document.getElementById("isi").value;
	if (isi!="")
	{
		document.getElementById("judul").readOnly=true;
		document.getElementById("isi").readOnly=true;
		$("#formKomentar").hide("slow");
		var params="judul="+judul+"&isi="+isi+"&id="+id+"&cid="+cid;
		 xmlHttp.open("POST","postkomentar.php",true);
		 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		 xmlHttp.setRequestHeader("Content-length", params.length);
		 xmlHttp.setRequestHeader("Connection", "close");
		 xmlHttp.onreadystatechange = setOutput;
		 xmlHttp.send(params);
	}
	else
		alert("Isi Komentar Kosong Tidak Diperkenankan");
}

function updateMerek()
{
	 xmlHttp=getHTTPObject();
	 var idKategori=document.getElementById("kategori").value;
	 document.getElementById("kategori").disabled=true;
	 var params="kategori="+idKategori;
	 xmlHttp.open("POST","updateOpsiMerek.php",true);
	 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	 xmlHttp.setRequestHeader("Content-length", params.length);
	 xmlHttp.setRequestHeader("Connection", "close");
	 xmlHttp.onreadystatechange = setMerek;
	 xmlHttp.send(params);
}

function cari()
{
	 document.getElementById('hasilcari').innerHTML="<img src='images/ajax-loader.gif' alt='loading'/>"
	 xmlHttp=getHTTPObject();
	 var idKategori=document.getElementById("kategori").value;
	 var idMerek=document.getElementById("merek").value;
	 var harga=document.getElementById("harga").value;
	 document.getElementById("kategori").disabled=true;
	 document.getElementById("merek").disabled=true;
	 document.getElementById("harga").disabled=true;
	 var params="kategori="+idKategori+"&merek="+idMerek+"&harga="+harga;
	 xmlHttp.open("POST","advsearch.php",true);
	 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	 xmlHttp.setRequestHeader("Content-length", params.length);
	 xmlHttp.setRequestHeader("Connection", "close");
	 xmlHttp.onreadystatechange = setHasilCari;
	 xmlHttp.send(params);
}

function setOutput(){
    if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
	   $("#formKomentar").show("slow");
       document.getElementById("judul").readOnly=false;
	   document.getElementById("isi").readOnly=false;
	   document.getElementById("judul").value="";
	   document.getElementById("isi").value="";
	   document.getElementById("listKomentar").innerHTML=xmlHttp.responseText;
    }
}

function setMerek()
{
	 if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
   		document.getElementById("kategori").disabled=false;
		document.getElementById("merek").innerHTML=xmlHttp.responseText;
    }
}

function setHasilCari()
{
	 if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
   		
		document.getElementById("kategori").disabled=false;
	    document.getElementById("merek").disabled=false;
	    document.getElementById("harga").disabled=false;
		document.getElementById("hasilcari").innerHTML=xmlHttp.responseText;
    }
}
