function loadImages() {
if (document.getElementById) {  // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) {  // Netscape 4
document.hidepage.visibility = 'hidden';
}
else {  // IE 4
document.all.hidepage.style.visibility = 'hidden';
      }
   }
}


function MM_preloadImages() { //v3.0
  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 MM_swapImgRestore() { //v3.0
  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_findObj(n, d) { //v4.01
  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() { //v3.0
  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 createRequest()
{
		var oAJAX = false;
		
		try { oAJAX = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch (e) {
			try { oAJAX = new ActiveXObject("Microsoft.XMLHTTP");} 
			catch (e2) { oAJAX = false; }
		}
		
		if (!oAJAX && typeof XMLHttpRequest != 'undefined') { oAJAX = new XMLHttpRequest(); }
		if (!oAJAX) { alert("Connection Failed !"); }
		
		return oAJAX;
}

function requestContent(type,id,prm)
{
		
		document.getElementById('lnkprm').value=prm;
		document.getElementById('GetComment').innerHTML = '';
		oRequest = createRequest();
		
		var url = "articleread_content.php?i="+id;
		
		oRequest.open("GET", url, true);
		oRequest.onreadystatechange = function ()
		{
			document.getElementById(type).innerHTML=
			"<div align='center' style='border-color:#000000;border:1px;height:100;width:100;'><br><img src='images/loading2.gif' alt='Loading...'></div>";
									
			if (oRequest.readyState == 4)
			{
				var response = oRequest.responseText;
				document.getElementById(type).innerHTML = response;
			}
		}
		oRequest.send(null);
		
}


function requestContent2(type2,id2)
{
		
		//alert(id);
		oRequest2 = createRequest();		
		var url2 = "komentar_getbyajax.php?i="+id2;
		
		oRequest2.open("GET", url2, true);
		oRequest2.onreadystatechange = function ()
		{
			document.getElementById(type2).innerHTML="<div align='center' style='border-color:#000000;border:1px;height:100;width:100;'><br><img src='images/loading2.gif' alt='Loading...'></div>";
									
			if (oRequest2.readyState == 4)
			{
				var response2 = oRequest2.responseText;
				document.getElementById(type2).innerHTML = response2;
			}
		}
		oRequest2.send(null);
		
}

function OMOvFMN(NomRow,Section,Color01,Color02){
	document.getElementById("rrx"+NomRow+"c1").style.background=Color02;
	document.getElementById("rrx"+NomRow+"c2").style.background=Color02;
	document.getElementById("s"+Section).style.background=Color01;
}

function OMOuFMN(NomRow,Section){
	document.getElementById("rrx"+NomRow+"c1").style.background='';
	document.getElementById("rrx"+NomRow+"c2").style.background='';
	document.getElementById("s"+Section).style.background='';
}

function OMOvFMNx(NomRow,Color1,Color2){
	document.getElementById("r"+NomRow+"c1").style.background=Color2;
	document.getElementById("r"+NomRow+"c2").style.background=Color1;
	document.getElementById("T"+NomRow).style.visibility='visible';
}

function OMOuFMNx(NomRow){
	document.getElementById("r"+NomRow+"c1").style.background='';
	document.getElementById("r"+NomRow+"c2").style.background='';
	document.getElementById("T"+NomRow).style.visibility='collapse';
}

/*
function OMOvFMN(NomRow,Section){
	document.getElementById("r"+NomRow+"c1").style.background='<?php echo $OnMouseOver_Color2; ?>';
	document.getElementById("r"+NomRow+"c2").style.background='<?php echo $OnMouseOver_Color2; ?>';
	document.getElementById("s"+Section).style.background='<?php echo $OnMouseOver_Color; ?>';
}

function OMOuFMN(NomRow,Section){
	document.getElementById("r"+NomRow+"c1").style.background='';
	document.getElementById("r"+NomRow+"c2").style.background='';
	document.getElementById("s"+Section).style.background='';
}*/

function CountText(frm) 
{
	txtCount 		= frm.char_count;
	txtCount.value 	= 1000-frm.massage.value.length;
	if(txtCount.value<0)
	{
		alert("Maaf, jumlah karakter sudah melebihi batas maksimal.");
	}
	else if(txtCount.value==0)
	{
		alert("Jumlah karakter sudah mencapai batas maksimal.");
	}
}

function ShowForm(type3,ShowHid,id3)
{
	if( document.getElementById('StatusVisCol').value=='' )
	{	
		if(ShowHid=='01')	{ document.getElementById('StatusVisCol').value = '1'; }
		else				{ document.getElementById('StatusVisCol').value = ''; }
		
		document.getElementById('ListAllComment').innerHTML = '';
		
		oRequest3 = createRequest();		
		var url3 = "komentarbyajax_form.php?i="+id3;
		
		oRequest3.open("GET", url3, true);
		oRequest3.onreadystatechange = function ()
		{
			document.getElementById(type3).innerHTML=
			"<div align='center' style='border-color:#000000;border:1px;height:100;width:100;'><br><img src='images/loading3.gif' alt='Loading...'></div>";
									
			if (oRequest3.readyState == 4)
			{
				var response3 = oRequest3.responseText;
				document.getElementById(type3).innerHTML = response3;
			}
		}
		oRequest3.send(null);
	}
	else
	{
		document.getElementById(type3).innerHTML = '';
		document.getElementById('StatusVisCol').value = '';
	}
}

function getfocus(rd)
{
	document.getElementById(rd).focus();
	document.getElementById(rd).select();
}

function posting_comment_fx(id4)
{

		name_pc 	= document.getElementById("name").value;
		email_pc 	= document.getElementById("email").value;
		website_pc 	= document.getElementById("website").value;
		subject_pc 	= document.getElementById("subject").value;
		captcha_pc	= document.getElementById("captcha").value;
		massage_pc	= document.getElementById("massage").value;
		
		if (massage_pc.indexOf("\n") > -1){
			while (massage_pc.indexOf("\n") > -1) massage_pc = massage_pc.replace("\n","NewLineBreak");
		}
		
		tglwkt_pc	= document.getElementById("tglwkt").value;
		type_pc		= document.getElementById("type").value;
		idtype_pc	= document.getElementById("idtype").value;
		reply_pc	= document.getElementById("reply").value;
		idreply_pc	= document.getElementById("idreply").value;
		hf1_pc		= document.getElementById("hf1").value;
		hf2_pc		= document.getElementById("hf2").value;
		
		type4		= 'GetComment';
		
		if( name_pc=='' ){ 											alert('Name empty'); 		getfocus("name"); }
		else if ( email_pc!='' &&  echeck(email_pc)==false ){ 		alert('Email Invalid'); 	getfocus("email"); }
		else if ( website_pc!='' &&  isURL(website_pc)==false ){ 								getfocus("website"); }
		else if( subject_pc=='' ){ 									alert('Subject empty'); 	getfocus("subject"); }
		else if( massage_pc=='' ){ 									alert('Massage empty'); 	getfocus("massage"); }
		else if( captcha_pc=='' ){ 									alert('Captcha empty'); 	getfocus("captcha");}
		else if( captcha_pc!=hf2_pc ){ 								alert('Captcha invalid'); 	getfocus("captcha"); }
		else
		{
		
			oRequest4 = createRequest();		
			var url4 = "komentar_getbyajax.php?i="+id4
			 +"&act_pc=1&name_pc="+name_pc+"&email_pc="+email_pc
			 +"&website_pc="+website_pc+"&subject_pc="+subject_pc+"&massage_pc="+massage_pc
			 +"&captcha_pc="+captcha_pc+"&tglwkt_pc="+tglwkt_pc+"&type_pc="+type_pc
			 +"&idtype_pc="+idtype_pc+"&reply_pc="+reply_pc+"&idreply_pc="+idreply_pc
			 +"&hf1_pc="+hf1_pc;
			
			oRequest4.open("GET", url4, true);
			oRequest4.onreadystatechange = function ()
			{
				document.getElementById(type4).innerHTML=
				"<div align='center' style='border-color:#000000;border:1px;height:100;width:100;'><br><img src='images/loading2.gif' alt='Loading...'></div>";
										
				if (oRequest4.readyState == 4)
				{
					var response4 = oRequest4.responseText;
					document.getElementById(type4).innerHTML = response4;
				}
			}
			oRequest4.send(null);
		
		}
}

function SendAsEnR_fx()
{
	if( (document.getElementById("SendAsEnR").value)!='1' )
	{
		//document.getElementById("SendAsEmailAndReply").checked=='checked';
		document.getElementById("SendAsEnR").value='1';
	} else {
		//document.getElementById("SendAsEmailAndReply").checked=='';
		document.getElementById("SendAsEnR").value='';
	}
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
			return false
		 }

		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function SendMailComment_fx(id5)
{ 

		name_pc2 	= document.getElementById("name").value;
		email_pc2 	= document.getElementById("email").value;
		website_pc2 = document.getElementById("website").value;
		subject_pc2 = document.getElementById("subject").value;
		sendAsEnR_pc2 = document.getElementById("SendAsEnR").value;
		captcha_pc2	= document.getElementById("captcha").value;
		massage_pc2	= document.getElementById("massage").value;
		
		if (massage_pc2.indexOf("\n") > -1){
			while (massage_pc2.indexOf("\n") > -1) massage_pc2 = massage_pc2.replace("\n","NewLineBreak");
		}
		
		tglwkt_pc2	= document.getElementById("tglwkt").value;
		type_pc2	= document.getElementById("type").value;
		idtype_pc2	= document.getElementById("idtype").value;
		reply_pc2	= document.getElementById("reply").value;
		idreply_pc2	= document.getElementById("idreply").value;
		hf1_pc2		= document.getElementById("hf1").value;
		hf2_pc2		= document.getElementById("hf2").value;
		
		type5		= "GetComment";
		
			 if( name_pc2=="" )			{	alert("Name empty"); 		getfocus("name"); 	} 
		else if( email_pc2=='' )		{ 	alert('Email empty'); 		getfocus("email");	}
		else if (echeck(email_pc2)==false){ alert('Email Invalid'); 	getfocus("email"); }
		else if ( website_pc2!='' &&  isURL(website_pc2)==false ){ 		getfocus("website"); }
		else if( subject_pc2=='' )		{ 	alert('Subject empty'); 	getfocus("subject");}
		else if( massage_pc2=='' )		{ 	alert('Massage empty'); 	getfocus("massage");}
		else if( captcha_pc2=='' )		{ 	alert('Captcha empty'); 	getfocus("captcha");}
		else if( captcha_pc2!=hf2_pc2 )	{ 	alert('Captcha invalid'); 	getfocus("captcha");}/**/
		else
		{ 
			oRequest5 = createRequest();
			var url5 = "komentar_getbyajax.php?i="+id5
			 +"&act_pc=2&name_pc="+name_pc2+"&email_pc="+email_pc2+"&website_pc="+website_pc2
			 +"&subject_pc="+subject_pc2+"&sendAsEnR_pc="+sendAsEnR_pc2+"&massage_pc="+massage_pc2
			 +"&captcha_pc="+captcha_pc2+"&tglwkt_pc="+tglwkt_pc2+"&type_pc="+type_pc2
			 +"&idtype_pc="+idtype_pc2+"&reply_pc="+reply_pc2+"&idreply_pc="+idreply_pc2
			 +"&hf1_pc="+hf1_pc2;/**/
			
			//alert(url5);
			
			oRequest5.open("GET", url5, true);
			oRequest5.onreadystatechange = function ()
			{
				document.getElementById(type5).innerHTML="<div align='center' style='border-color:#000000;border:1px;height:100;width:100;'><br><img src='images/loading2.gif' alt='Loading...'></div>";
										
				if (oRequest5.readyState == 4)
				{
					var response5 = oRequest5.responseText;
					document.getElementById(type5).innerHTML = response5;
				}
			}
			oRequest5.send(null);/**/
		
		}
}	


function ArtikelRating_fx(type6,id6)
{
		
		//alert(id);
		oRequest6 = createRequest();		
		var url6 = "articleread_rating.php?pg=article&subpg=read&id="+id6+"&act=rate";
		
		oRequest6.open("GET", url6, true);
		oRequest6.onreadystatechange = function ()
		{
			document.getElementById(type6).innerHTML= '. . . . . . . ';
									
			if (oRequest6.readyState == 4)
			{
				var response6 = oRequest6.responseText;
				document.getElementById(type6).innerHTML = response6;
			}
		}
		oRequest6.send(null);
		
}


function isURL(urlStr) {
	if (urlStr.indexOf(" ") != -1) {
	alert("Spaces are not allowed in a URL");
	return false;
	}
	
	if (urlStr == "" || urlStr == null) {
	return true;
	}
	
	urlStr=urlStr.toLowerCase();
	
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var atom=validChars + '+';
	var urlPat=/^http:\/\/(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
	var matchArray=urlStr.match(urlPat);
	
	if (matchArray==null) {
	//alert("The URL seems incorrect \ncheck it begins with http://\n and it has 2 .'s");
	alert("The URL seems incorrect, example : \nhttp://www.example.com/");
	return false;
	}
	
	var user=matchArray[2];
	var domain=matchArray[3];
	
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
	alert("This domain contains invalid characters.");
	return false;
	}
	}
	
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i) > 127) {
	alert("This domain name contains invalid characters.");
	return false;
	}
	}
	
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat) == -1) {
	alert("The domain name does not seem to be valid.");
	return false;
	}
	}
	
	return true;
}