// ------------------------------------------------
// Disable RightClick
// ------------------------------------------------
<!--Hide Rightclick function-->
window.defaultStatus = "Copyright © Kejora Harta Bhd. All Rights Reserved."
<!--Disable Context Menu-->

document.oncontextmenu = function(){return false}
if(document.layers) 
{
    window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown = function(e){
        if(e.target==document)return false;
    }
}
else {
    document.onmousedown = function(){return false}
}

// ------------------------------------------------
// CheckBox Validation (checking)
// ------------------------------------------------
function checkData() {
	 var Selected = false;
	 for (i = 0; i < document.check.classes.length; i++) {
	 if (document.check.classes[i].checked)
	 Selected = true;
	 }
	 if (!Selected) {
	 alert("No checkboxs selected.");
	 return (false);
	 }
	}

// ------------------------------------------------
// Rollover Table Highlight Color
// ------------------------------------------------
function switchClass(obj,strClassName) {
	obj.className	= strClassName;
}

// ------------------------------------------------
// Color Picker(popup side)
// ------------------------------------------------

function setCode(val){
if(window.opener.document.popupform.colorcode.value.length == 7){setcolor(val)}
}

function showColor(val){
window.opener.document.popupform.colorcode.value = val
     window.opener.document.popupform.selcolor.style.backgroundColor=val
window.close();

}

// ------------------------------------------------
// Jump Menu
// ------------------------------------------------

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


// ------------------------------------------------
// Popup windows
// ------------------------------------------------

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// ------------------------------------------------
// Dropmenu
// ------------------------------------------------

	var imgPlus = new Image();
	var imgMinus = new Image();
	
	imgPlus.src = "images/plus.gif";
	imgMinus.src = "images/minus.gif";



	function ToggleScopeCat(Scope)
	{
		var oTable = document.all["tbl" + Scope];
		var oImg = document.all["img" + Scope];
		if (oTable && oTable.style.display == "block")
		{	
			oImg.src = imgPlus.src;
			oTable.style.display = "none";
		}
		else
		{
			oImg.src = imgMinus.src;
			oTable.style.display = "block";
		}
	}

// ------------------------------------------------
// Dropmenu without images
// ------------------------------------------------

       function Toggle(Scope)
	{
		var oTable = document.all["tbl" + Scope];
		if (oTable && oTable.style.display == "block")
		{	
			oTable.style.display = "none";
		}
		else
		{
			oTable.style.display = "block";
		}
	}

// ------------------------------------------------
// Dropmenu Hide Table 
// ------------------------------------------------

       function Toggleselected(Scope)
{
		var oTable = document.all["tblhidden"];
		if (Scope == "hidden")
		{
			oTable.style.display = "block";
		}
		else
		{
			oTable.style.display = "none";
		}
	}

// ------------------------------------------------
// Checkfield when click on img
// ------------------------------------------------


var checkflag = "false";
function check(field) {
if (checkflag == "false") {
field.checked = true;
checkflag = "true"; }
else {
field.checked = false;
checkflag = "false"; }
}


// ------------------------------------------------
// CheckAll when click
// ------------------------------------------------

function CheckAll()
  {
  for (var i=0;i<document.frm.elements.length;i++)
    {
    var e = document.frm.elements[i];
    if (e.name != 'allbox')
      e.checked = document.frm.allbox.checked;
    }
  }

// ------------------------------------------------
// Check CheckAll when click
// ------------------------------------------------

function CheckCheckAll()
{
	var TotalBoxes  =  0;
	var TotalOn  =  0;
	for(var i = 0;i<document.frm.elements.length;i++)
	{
		var e  =  document.frm.elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox'))
		{
			TotalBoxes++;
		if (e.checked)
		{
			TotalOn++;
		}
		}
	}
	if (TotalBoxes==TotalOn)
	{document.check.frm.checked = true;}
	else
	{document.check.frm.checked = false;}
}

// ------------------------------------------------
// toggle radio button (FrameSet)
// ------------------------------------------------

function leapToFrame (link){
   var new_url=link;
   if (  (new_url != "")  &&  (new_url != null)  )
      parent.viewframe.location=new_url;
   else
      alert("\nYou must make a selection.");
}


// ------------------------------------------------
// toggle radio button (All FrameSet)
// ------------------------------------------------

function leapToAllFrame (link){
   var new_url=link;
   if (  (new_url != "")  &&  (new_url != null)  )
      parent.window.location=new_url;
   else
      alert("\nYou must make a selection.");
}

// ------------------------------------------------
// toggle radio button
// ------------------------------------------------

function leapTo (link){
   var new_url=link;
   if (  (new_url != "")  &&  (new_url != null)  )
      window.location=new_url;
   else
      alert("\nYou must make a selection.");
}


// ------------------------------------------------
// Print Page
// ------------------------------------------------

function printPage() {
  if (confirm("Ok To Print Page?")) { 
   window.parent.printaction.focus();
   window.print();
 }
}


// ------------------------------------------------
// Open Center Popup Windows
// ------------------------------------------------
var win = null;
function NewWindow(mypage,myname,w,h,scroll,resize,tool,menu,s){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+',toolbar='+tool+',menubar='+menu+',status='+s+''
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}


// ------------------------------------------------
// Empty Trash
// ------------------------------------------------
function verify(){
    msg = "Are you absolutely sure that you want to delete this record?";
    return confirm(msg);
    }



// ------------------------------------------------
// Auto Resize
// ------------------------------------------------
function fitPic(s, p){
window.open('picture.html?'+s+'?'+p,'fitWindow','height=100,width=100,top=100,left=100,z-lock=1,resizable=1');
}

function fit(){
	if(navigator.appName.indexOf('Microsoft')>=0)
		window.resizeBy(document.images[0].width-document.body.clientWidth, document.images[0].height-document.body.clientHeight);
	else window.resizeBy(document.images[0].width-window.innerWidth, document.images[0].height-window.innerHeight);
}
