function callfrm(dest){
	document.frmConsole.target = "_self"
	document.frmConsole.action = dest
	document.frmConsole.method = "POST"
	document.frmConsole.submit()
}


function callfrm2(dest){
	frmConsole.target = "_blank"
	frmConsole.action = dest
	frmConsole.method = "POST"
	frmConsole.submit()
}	

function openNew(dest,popname,width,height){
	popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=0,scrollbars=yes,location=no,alwaysRaised=yes");
	popup.focus();
}

function changerow(row){
	var b='tr_upload';
	for(i=0;i<15;i++){
		cb2 = eval(b + '' + i );
		if(i<row){
			cb2.style.display='';
		}else{			
			cb2.style.display='none';
		}
	}
}

function checkboxNum(chk) {
	var total = 0;
	var max = eval('document.frmConsole.' + chk + '.length');
	for (var idx = 0; idx < max; idx++) {
		if (eval('document.frmConsole.'+ chk +'[' + idx + '].checked') == true) {
			total += 1;
		}
	}
	return total;
}

function roll_over(img_name, img_src){
	document[img_name].src = img_src;
}

function DigitOnly(e) {
  
   var key;
   
   if(window.event){
      key = window.event.keyCode; // IE
       if (key = 13 && key != 8 && key != 9 && key != 16 && key != 17 && key != 20 && key != 35 && key != 36 && key != 46 && (key < 48) || (key > 57) && (key < 96) || (key > 105) && key != 116)  window.event.returnValue = false;
   }else{
      key = e.which; // Firefox      
       if (key = 13 && key != 8 && key != 9 && key != 16 && key != 17 && key != 20 && key != 35 && key != 36 && key != 46 && (key < 48) || (key > 57) && (key < 96) || (key > 105) && key != 116)  key = e.preventDefault();
    }

}




function EngOnly(){
	if (String.fromCharCode(event.keyCode) < '~'){
		return;
	}
	event.returnValue=false;	
}

function EngOnly2(){
	var keyblock = new Array(33,64,35,36,37,94,38,42,40,41,95,43,61,92,123,125,91,93,58,59,34,39,60,62,44,46,63,47);
	var cChr;
	cChr = window.event.keyCode;
//	alert(cChr);

	for(var i=0 ; i<keyblock.length ; i++){
		if(cChr == keyblock[i]){
			event.returnValue=false;	
		}
	}

	if (String.fromCharCode(event.keyCode) < '~'){
		return;
	}
	event.returnValue=false;	
}

function CloseWindows(){
	window.close();
}

function CheckEnter(callFunction,valueFunction){
	var cChr;
	cChr = window.event.keyCode;
	if (cChr == 13)
	{
		callFunction(valueFunction);
	}
}
function check_all(elem) {
	var f = elem.form;	
	if (!f.elements["chk[]"]) return;
	if (f.elements["chk[]"][0]) {
		for (var i=0; i<f.elements["chk[]"].length; i++)
			f.elements["chk[]"][i].checked = elem.checked;	
	} else {
		f.elements["chk[]"].checked = elem.checked;	
	}
	//check_all(elem);
}

function onUp(url, type, table, id,page) {
	callfrm(url + "&changerow=" + type + "&table=" + table + "&sortid=" + id +"&page="+page);
}

function onDown(url, type, table, id,page) {
	callfrm(url + "&changerow=" + type + "&table=" + table + "&sortid=" + id +"&page="+page);
}
function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	destination.focus()
}
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_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_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 calcAge(date, month, year) {
     month = month - 1;
     year = year - 543;

     today = new Date();
     dateStr = today.getDate();
     monthStr = today.getMonth();
     yearStr = today.getFullYear();

     theYear = yearStr - year;
     theMonth = monthStr - month;
     theDate = dateStr - date;

     var days = "";
     if (monthStr == 0 || monthStr == 2 || monthStr == 4 || monthStr == 6 || monthStr == 7 || monthStr == 9 || monthStr == 11) days = 31;
     if (monthStr == 3 || monthStr == 5 || monthStr == 8 || monthStr == 10) days = 30;
     if (monthStr == 1) days = 28;

     inYears = theYear;

     if (month < monthStr && date > dateStr) {
          inYears = parseInt(inYears) + 1;
          inMonths = theMonth - 1;
     };

     if (month < monthStr && date <= dateStr) {
          inMonths = theMonth;
     } else if (month == monthStr && (date < dateStr || date == dateStr)) {
          inMonths = 0;
     } else if (month == monthStr && date > dateStr) {
          inMonths = 11;
     } else if (month > monthStr && date <= dateStr) {
          inYears = inYears - 1;
          inMonths = ((12 - -(theMonth)) + 1);
     } else if (month > monthStr && date > dateStr) {
          inMonths = ((12 - -(theMonth)));
     };

     if (date < dateStr) {
          inDays = theDate;
     } else if (date == dateStr) {
          inDays = 0;
     } else {
          inYears = inYears - 1;
          inDays = days - (-(theDate));
     };

     var result = ['day', 'month', 'year'];
     result.day = inDays;
     result.month = inMonths;
     result.year = inYears;

     return result;
};
