// JavaScript Document

var checkUncheckAllstate=false;
function checkUncheckAll(theForm) //checkUncheckAll(document.formname)
{
	if(checkUncheckAllstate==false) 
		checkUncheckAllstate=true;
	else 
		checkUncheckAllstate=false;
		
	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].disabled==false && theForm[z].name != 'checkall')
		{
			theForm[z].checked = checkUncheckAllstate;
		}
	}
}
function checkUncheckAll2(theForm,chk) //checkUncheckAll2(document.formname,booleen)
{
	checkUncheckAllstate=chk;
		
	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].disabled==false && theForm[z].name != 'checkall')
		{
			theForm[z].checked = checkUncheckAllstate;
		}
	}
}
function checkUncheckAll3(theForm,setid) //checkUncheckAll2(document.formname,"1,2,3,4,5,6")
{
	var sid=setid.split(",");
	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].disabled==false && theForm[z].name != 'checkall')
		{
			var ex=false;
			for(var i in sid)
			{
				if(theForm[z].name==sid[i])
				{
					ex = true;
					break;
				}
			}
			theForm[z].checked = ex;
		}
	}
}
function getavailhw()
{
	/*var sltmp=document.documentElement.scrollLeft;
	document.documentElement.scrollLeft=10000;
	var ww=document.documentElement.clientWidth+document.documentElement.scrollLeft;
	document.documentElement.scrollLeft=sltmp;
	var hh=document.documentElement.clientHeight;
	*/
	var ww=document.body.clientWidth;
	var hh=document.body.clientHeight;
	
	if(hh<document.body.clientHeight) hh=document.body.clientHeight;
	return{w:ww,width:ww,h:hh,height:hh}
}
function getoffset()
{
	this.getLeft=function(id)
	{
    var oNode = this.$(id);
    var iLeft = 0;
    
    while(oNode.tagName != 'BODY') {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }
    
    return iLeft;
	}
	this.getTop=function(id)
	{
    var oNode = this.$(id);
    var iTop = 0;
    
    while(oNode.tagName != 'BODY') {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
	}
	this.$=function(id)
	{
		return document.getElementById(id);
	}
	
	this.gobid=function(id)
	{
		return{x:this.getLeft(id),y:this.getTop(id),w:this.$(id).offsetWidth,h:this.$(id).offsetHeight};
	}
}
function addjustcenter(obj)
{	

	var left=screen.width-parseInt(obj.style.width);
	left=left/2;
	left+=document.documentElement.scrollLeft;
	var top=screen.height-parseInt(obj.style.height);
	top=top/2;
	top+=document.documentElement.scrollTop;
	
	var IE = /*@cc_on!@*/false;
	if(IE)
	{
		left+=-63;
		top+=-127;
	}
	else
	{
		left+=-8;
		top+=-75;
	}
	
	var av=getavailhw();
	left=av.x-(parseInt(obj.style.width)/2);
	top=av.y-(parseInt(obj.style.height)/2);
	
	obj.style.left=left+"px";
	obj.style.top=top+"px";
	obj.innerHTML=left+" "+top;
	
	if(document.body.style.overflow=="hidden")
	{
		document.body.style.overflow="auto";
	}
	else
	{
		document.body.style.overflow="hidden";
	}
}
function limitvalue(obj,mini,maxi)
{
	if(obj.value=="") return;
	if(obj.value < mini || obj.value > maxi)
	{
		alert("Please enter value between "+mini+" and "+maxi+".");
		obj.value="";
		obj.focus();
	}
}
function limitlength(obj,mini,maxi)
{
	if(obj.value=="") return;
	if(obj.value.length < mini || obj.value.length > maxi)
	{
		if(mini==maxi)
		{
			alert("Please enter value a fully for "+mini+"  Digit.");
		}
		else
		{
			alert("Please enter length value between "+mini+" and "+maxi+" Digit.");
		}
		obj.value="";
		obj.focus();
	}
}
function locknumeric(obj)
{
	if(obj.value=="") return;
	var value=obj.value;
	
	value=parseFloat(value);
	if(isNaN(value))
	{
		alert("Please enter numeric only.");
		obj.value="";
		obj.focus();
	}
}
function enternext(ev,obj)
{
	if(ev.keyCode==13)
	{
		obj.focus();
		obj.select();
	}
}
var vdateobj=new Object;
function vdate(obj)
{
	if(obj.value=="") return;
	
	vdateobj=obj;
	var ifrm=document.getElementById("ifrm");
	if(ifrm) ifrm.src="_inc/vdate.php?vact=vdate&date="+obj.value;
}
var dpnobj=new Object;
var dpnformatflag=0;
function displaynum(obj,formatflag,nonestrict)
{
	if(!obj) return;
	if(obj.value=="") return;
	if(!nonestrict)
	{
		if(obj.readOnly==true) return;
		if(obj.disabled==true) return;
	}
	
	dpnobj=obj;
	dpnformatflag=formatflag;
	if(!formatflag) formatflag=0;
	var value=obj.value;
	var ifrm=document.getElementById("ifrm");
	if(ifrm) ifrm.src="_inc/vdate.php?vact=displaynum&value="+value+"&formatflag="+formatflag.value;
	/*<?php
	unset($arrpost);
	$arrget=array();
	$arrget['act']="displaynum";
	$arrget['value']="JAVA"."value";
	$arrget['formatflag']="JAVA"."formatflag";
	$kjxp->exec_ajax("app.php",$arrget,$arrpost,"","","","","",false);
	?>
	var <?php $kjxp->getReturn("ret",2) ?>
	var <?php $kjxp->getVar("retv",2) ?>
	eval(retv);
	obj.value=res;*/
}
function $(id)
{
		return document.getElementById(id);
}
function getoffset()
{
	this.getLeft=function(id)
	{
    var oNode = this.$(id);
		if(!oNode) return;
		
    var iLeft = 0;
    
    while(oNode.tagName != 'BODY' && oNode.style.position!="absolute") {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;        
    }
    
    return iLeft;
	}
	this.getTop=function(id)
	{
    var oNode = this.$(id);
		if(!oNode) return;
		
    var iTop = 0;
    
    while(oNode.tagName != 'BODY' && oNode.style.position!="absolute") {
        iTop += oNode.offsetTop;
        oNode = oNode.offsetParent;
    }
    
    return iTop;
	}
	this.$=function(id)
	{
		return document.getElementById(id);
	}
	
	this.gobid=function(id)
	{
		return{x:this.getLeft(id),left:this.getLeft(id),y:this.getTop(id),top:this.getTop(id),w:this.$(id).offsetWidth,width:this.$(id).offsetWidth,h:this.$(id).offsetHeight,height:this.$(id).offsetHeight};
	}
}
function wresize()
{
}
