	var tableWidget_tableCounter = 0;
	var tableWidget_arraySort = new Array();
	var tableWidget_okToSort = true;
	var activeColumn = new Array();
	var arrowImagePath = "images/";	// Path to arrow images
	var TMP_CLIENT = new Array();
	var TempVar = new Array();
	var hidden;
	var TransactionType='';//{ex,e,q,p,o}
	function CheckPlayCountDown(){
	  return (document.all.sound.src == 'Images/CountDown.mp3' && document.all.sound.loop != '0')?(true):(false); 	 		
	}
	function PlaySoundCountDown() {
	  document.all.sound.src = 'Images/CountDown.mp3';
	}	
	function StopSoundCountDown() {
	  document.all.sound.loop = '0';
	}		
	function CountDown(){
		if(parent.document.getElementById("CountDownNo"))
			if(parseInt(parent.document.getElementById("CountDownNo").innerHTML)  > 0){
				parent.document.getElementById("CountDownNo").innerHTML = parseInt(parent.document.getElementById("CountDownNo").innerHTML) - 1;
				setTimeout('parent.CountDown()', 1000);
				if(!CheckPlayCountDown())
					PlaySoundCountDown();
			}else 
				parent.logout('Your session has been timed out');
		else
			return true;
	}
	function ShowCountDown(){
		parent.CommonLayerPopupLayer_generate('CountDown','Warning','<br><table width=100% cellpadding=3 cellspacing=3><tr><td style="font-size:15px;"><b>This session will expire in <span id=CountDownNo style="font-size:30px;color:red;">10</span> seconds.</b></td></tr><tr><td align=right><input type=button class=buttonstyle onclick=parent.StopCountDown(); value=Cancel></td></tr></table>','350','80',350,200,Array(1),'',1,'parent.StopCountDown();');
		setTimeout('parent.CountDown()', 3000);
		LoadingLayerClose();
	}
	function StopCountDown(){
		appoinment_MakeSession('tmp',1);
		hidePopupDiv('CountDown');
		StopSoundCountDown();
		return true;
	}
	function do_print(fileName){
		window.open(fileName,'_target');
	}
	function PrintFieldSet(){
		for(i=0;i < document.body.all.tags( 'FIELDSET' ).length; i++){
			obj = document.body.all.tags( 'FIELDSET' )[i];
			obj.style.borderColor='#000000';
			obj.style.borderWidth='1px';
		}	
	}
///////////////////End of table functions////////////////
/****************************************Drag & Drop***********************************/
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  eve=event.srcElement;
	while(!eve || eve.tagName!='DIV'){
		  if(eve.parentElement)
			eve=eve.parentElement;
		  else
			break;	
	  } 
  whichDog= eve;  
  hotDog=isIE ? event.srcElement : e.target;
  if(hotDog.parentElement && document.getElementById('LayerTitleBar'))
	while (hotDog.id!="LayerTitleBar" && hotDog.tagName!=topDog){
			hotDog=(isIE) ? (hotDog.parentElement) : (hotDog.parentNode);
				
	}  
  if (hotDog.id=="LayerTitleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){	
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}
//document.onmousedown=ddInit;
if(document.attachEvent) document.attachEvent('onmousedown',ddInit)
//document.onmousedown=Function("(event.srcElement.id=='titleBar')?(ddInit()):(ddEnabled=false);");
document.onmouseup=Function("ddEnabled=false");
function close_layer(layer){
	document.getElementById(layer).style.zIndex=-1;
	document.getElementById(layer).style.visibility="hidden";
}	
function show_layer(layer)
{
	document.getElementById(layer).style.zIndex=3;
	//fadeIn(document.getElementById(layer));
	//document.getElementById(layer).style.visibility="show";
	document.getElementById(layer).style.visibility="visible";
}
/*************************************End of Drag & Drop********************************/
////////////////////////Global Functions///////////////////////////
function explodeArray(str,delimiter) {
	var tempString=new String(str); 
	tempArray=new Array(1); 
	var Count=0; 
	if(tempString.indexOf(delimiter)==-1){
		tempArray[0] = tempString;
		return tempArray;
	}
	while (tempString.indexOf(delimiter)>0) { 
	tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter)); 
	tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
	Count=Count+1 
	} 
	
	tempArray[Count]=tempString; 
	return tempArray;
} 
/*function strReplace(chr_find,chr_replace,str){
	for(i=0; i<str.length; i++){
		if(str.charAt(i) == chr_find)
			str = setCharAt(str, i, chr_replace);
	}
	return str;
}*/
function strReplace(chr_find,chr_replace,str){	
	while(str.search(chr_find) != -1)
		str = str.replace(chr_find, chr_replace);		
	return	str;
}
function setCharAt(str,index,char) {
	if(index > str.length-1) return str;
	return str.substr(0,index) + char + str.substr(index+1);
}
function SetStartTime()
{
		timer=new Date();
		Seconds=(timer.getSeconds());
		Milliseconds=(timer.getMilliseconds());
}
function SetEndTime()
{
	timer=new Date();
	sec=parseFloat(timer.getSeconds())-Seconds;
	milsec=parseFloat(timer.getMilliseconds())-Milliseconds;
	window.status='JS='+((sec>=0?sec:(60-sec))+':'+(milsec>=0?milsec:(1000-milsec)));
}
function TestTimer()
{
	SetStartTime();
	setTimeout('SetEndTime();',2500);
}
//SetStartTime();
//TestTimer();
function move(fbox, tbox)
{
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	
	for (i = 0; i < tbox.options.length; i++)
	{
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
	for(i = 0; i < fbox.options.length; i++)
	{
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if (fbox.options[i].selected && fbox.options[i].value != "")
		{
			//document.frm_Main.RemoveButton.disabled=false;
			//document.frm_Main.Export.disabled=false;
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
		}
		else
		{
			arrFbox[fLength] = fbox.options[i].text;
			fLength++;
		}
	}
	//arrFbox.sort();
	//arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	
	var c;
	for(c = 0; c < arrFbox.length; c++)
	{
		var no = new Option();
		no.value = arrLookup[arrFbox[c]];
		no.text = arrFbox[c];
		fbox[c] = no;
	}
	for(c = 0; c < arrTbox.length; c++)
	{
		var no = new Option();
		no.value = arrLookup[arrTbox[c]];
		no.text = arrTbox[c];
		tbox[c] = no;
	  }
}
function Reverse_Date(input,chrin,chrout){
	value=explodeArray(input,chrin);
	output=value[2]+chrout+value[1]+chrout+value[0];
	return output;
}
function date_diff(Sdate,Edate)
{
	//Edatef = new Date();
	if (!Edate) {
		Edatef = new Date();
	} else {
		var EdateVal = Reverse_Date(Edate,'/','/');
		Edatef = new Date('20'+EdateVal);
	}
	var SdateVal = Reverse_Date(Sdate,'/','/');
	Sdatef = new Date('20'+SdateVal);
	var one_day=1000*60*60*24;
	
	date_diff_val = Math.ceil((Sdatef.getTime()-Edatef.getTime())/(one_day))
	
	return date_diff_val;
}
function is_numeric(input) {
        	if( input.length == 0 ) {						
        		return false;				
        	}        	
			for( var i = 0; i < input.length; ++i ) {		
        		var c = input.charAt(i);
					if( c < '0' || c > '9') {
						if(c != '.'){
            				return false;
						}
            		}					
            	}
			return true;	
 }
 function is_int(input) {
        	if( input.length == 0 ) {						
        		return false;				
        	}        	
			for( var i = 0; i < input.length; ++i ) {		
        		var c = input.charAt(i);
					if( c < '0' || c > '9') {
            			return false;
            		}					
            	}
			return true;	
 }
 function number_format(number, decimals, point, separator)
{
	decimals=2;point='.';separator=',';
	if(!isNaN(number))
	{
		point = point ? point : '.';
		number = number.split('.');
		if(separator)
		{
			var tmp_number = new Array();
			for(var i = number[0].length, j = 0; i > 0; i -= 3)
			{
				var pos = i > 0 ? i - 3 : i;
				tmp_number[j++] = number[0].substring(i, pos);
			}
			number[0] = tmp_number.reverse().join(separator);
		}
		if(decimals && number[1]){
			number[1] = ((number[1].substr(0, decimals)));
			tmp = number.join(point);
			if(String(number[1]).length!=decimals)
				for(k=0;k<String(number[1]).length;k++)
					tmp+='0';
		}else
			tmp=number.join(point)+'.00';
			
		return(tmp);
	}
	else return(null);
}
function is_int(input) {
        	if( input.length == 0 ) {						
        		return false;				
        	}        	
			for( var i = 0; i < input.length; ++i ) {		
        		var c = input.charAt(i);
					if( c < '0' || c > '9') {
            			return false;
            		}					
            	}
			return true;	
 }
 function in_array(needle,haystack) {
	var bool = false;
	for (var i=0; i<haystack.length; i++) {
	  if (haystack[i]==needle) {
	   bool=true;
	  }
	}
	return bool;
}
function RemoveFirstChar(str){
	return str.substr(1, str.length);
}
function fadeOut(oDiv) {
	oDiv.style.filter="blendTrans(duration=1)";
    // Make sure the filter is not playing.
    if (oDiv.filters.blendTrans.status != 1) {
        oDiv.filters.blendTrans.apply();
        oDiv.style.visibility="hidden";
        oDiv.filters.blendTrans.play();
    }
}
function fadeIn(oDiv) {
    oDiv.style.filter="blendTrans(duration=2)";
    // Make sure the filter is not playing.
    if (oDiv.filters.blendTrans.status != 2) {
        oDiv.filters.blendTrans.apply();
        oDiv.style.visibility="visible";
        oDiv.filters.blendTrans.play();
    }
}

function copy_elements(frm_Source, frm_Dest){
	str = '';
	for( i = 0; i < eval(frm_Source).all.tags( 'INPUT' ).length; i++ ){
		obj = eval(frm_Source).all.tags( 'INPUT' )[i];
		if(obj.type!='submit' && obj.type!='button' ){
			if(obj.type=='checkbox' && obj.checked==true)	{
				dest_input = '<input name="'+obj.name+'" id="'+obj.name+'" value="'+obj.value+'" type="'+obj.type+'" checked="'+obj.checked+'" class="noprint">';
			}
			else	{
				dest_input = '<input name="'+obj.name+'" id="'+obj.name+'" value="'+obj.value+'" type="'+obj.type+'"  class="noprint">';
			}
				eval(frm_Dest).innerHTML = eval(frm_Dest).innerHTML + dest_input;
		}
	}
}
function copy_whole_elements(frm_Source, Dest){
	eval(Dest).innerHTML = eval(Dest).innerHTML + eval(frm_Source).innerHTML;
	eval(Dest).style.display='none';
}
function setScrolltop(bstop){  
	document.body.scrollTop=bstop;
}
function CheckCN(msg){
	if(document.getElementById('CNNO').value.length < 9){
		alert(msg);
		document.getElementById('CNNO').focus();
		return false;
	}
}
function CheckWeight(msg){
	if(is_numeric(document.getElementById('fld_Weight').value) && document.getElementById('fld_Weight').value > 0){
		return true;
	}else{
		alert(msg);
		document.getElementById('fld_Weight').focus();
		return false;
	}
}

