//Fungsi garis item
function blackLine(x){
	x.style.border="solid 1px #000000";	
}
//Fungsi garis putih
function whiteLine(x){
	x.style.border="solid 1px #cccccc";	
}


// Validation for login
function ValidityLogin(theform){
	if(theform.login_username.value== ""){
		alert("Isikan Form Login Dengan Benar\nTextbox Username belum terisi...");
		theform.login_username.focus();
		return (false);
		}
	
	if(theform.login_password.value == ""){
		alert("Isikan Form Login Dengan Benar\nTextbox Password belum terisi...");
		theform.login_password.focus();
		return (false);
		}
		
	return (true);		
	}	

// Validation for inserting smiley
function ValiditySmiley(theform){
	if(theform.nama_shoutbox.value== ""){
		alert("Isikan Form Smiley Dengan Benar\nTextbox Nama belum terisi...");
		theform.nama_shoutbox.focus();
		return (false);
		}

	if(theform.alamat_shoutbox.value== ""){
		alert("Isikan Form Smiley Dengan Benar\nTextbox Alamat belum terisi...");
		theform.alamat_shoutbox.focus();
		return (false);
		}
		
	if(theform.comment_shoutbox.value== ""){
		alert("Isikan Form Smiley Dengan Benar\nTextbox Comment belum terisi...");
		theform.comment.focus();
		return (false);
		}

	if(theform.email_shoutbox.value!="")
		{
			 if ((theform.email_shoutbox.value.indexOf(" ")!=-1)) {
	   	    	alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
				theform.email_shoutbox.select();
				theform.email_shoutbox.focus();
			    return false;
			    }

		 	if ((theform.email_shoutbox.value.indexOf("@")==-1)) {
				 alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
			   	 theform.email_shoutbox.select();
			   	 theform.email_shoutbox.focus();
			  	 return false;
			 	}

		 	if (theform.email_shoutbox.value.indexOf("@")<2) {
			   	 alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
				 theform.email_shoutbox.select();
				 theform.email_shoutbox.focus();
				 return false ;
                 }	

		 	 if ((theform.email_shoutbox.value.indexOf(".",theform.email_shoutbox.value.indexOf("@")) - theform.email_shoutbox.value.indexOf("@")) < 2 ) {
				 	alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
				    theform.email_shoutbox.select();
				    theform.email_shoutbox.focus();
				    return false;
					}
 
 			if ((theform.email_shoutbox.value.length - theform.email_shoutbox.value.indexOf(".",theform.email_shoutbox.value.indexOf("@"))) < 2 ) {
				 	alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
			 		theform.email_shoutbox.select();
					theform.email_shoutbox.focus();
				 	return false;
				    }

			if (theform.email_shoutbox.value.charAt(theform.email_shoutbox.value.length-1) == "." ) {
		 			alert("Isikan Form Smiley Dengan Benar\nPenulisan Email kurang benar...");
				    theform.email_shoutbox.select();
				    theform.email_shoutbox.focus();
				    return false;
				   }
		 }


	return (true);		
	}	
	
//Function untuk smiley	
function MasukinSmiley(text){
	var txtarea = document.Smile.comment_shoutbox;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}	
}
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

//Functionn untuk menampilkan galeri
function perbesar_gambar(sasaran){
	window.open("library/perbesar.php?gambar="+sasaran,"pembesaran","toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=no,height=600,width=900,");
}