
// บัตรประชาชน
function chkID(id) {
    if(id.length != 13) return false;
    for(i=0, sum=0; i < 12; i++)

        sum += parseFloat(id.charAt(i))*(13-i);
    if((11-sum%11)%10!=parseFloat(id.charAt(12))) return false;
    return true;
}

function GoTop() {
	document.getElementById('TableContainer').scrollTop = 0;
}
// -end บัตรประชาชน

HoverRow = function() {
	if (document.all) {
 		var table_rows = 0;
		var allTableTags=document.getElementsByTagName("table"); 
		for (i=0; i<allTableTags.length; i++){ 
		 	if (allTableTags[i].className=="scrollTable") { 
			  	table_body = allTableTags[i].getElementsByTagName("tbody");
				table_rows = table_body[0].getElementsByTagName("tr");
			    i = allTableTags.length + 1;
			} 
		} 
		for (var i=0; i<table_rows.length; i++) {
			if (table_rows[i].className != "title" && table_rows[i].className != "total") {
				table_rows[i].onmouseover=function() {this.className += " hoverMe";}
			    table_rows[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" hoverMe\\b"), "");}
			}
		}
	 }
}
if (window.attachEvent) window.attachEvent("onload", HoverRow);


function copy(inElement) {
	if (inElement.createTextRange) {
		var range = inElement.createTextRange();
		if (range && BodyLoaded==1)
		range.execCommand('Copy');
  } else {
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) {
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="/js/_clipboard.swf" FlashVars="clipboard='+escape(inElement)+'" width="0" height="0" type="application/x-shockwave-flash" allowScriptAccess="always"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
}


function pantallaCompleta(pagina) {
	if (navigator.appName == "Microsoft Internet Explorer"){
		window.open(pagina, '', 'fullscreen=yes, scrollbars=auto, resizable=yes').focus();
	}else{
		window.open(pagina, '', 'width=' + (screen.width-5) + ',height=' + (screen.height-30) + ', scrollbars=auto, resizable=yes, ').focus();
	}
}

function num_format( obj ){
	var value = obj
	var svals = value.split( "." );
	var sval = svals[0];
	var n = 0;
	var result = "";
	var c = "";
	for ( a = sval.length - 1; a >= 0 ; a-- ){
		c = sval.charAt(a);
		if ( c != ',' ){
			n++;
			if ( n == 4 ){
				result = "," + result;
				n = 1;
			};
			result = c + result;
		};
	};
	if ( svals[1] ){
		result = result + '.' + svals[1];
	}
	return result;
}

