function checkCharDigitOnly(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;			
	var specialcharcode = new Array("33","34","35","36","37","38","39","40","41","42","44","46","58","59","60","62","63","94","124");
	for (i=0;i<specialcharcode.length;i++){		
		if(charCode==specialcharcode[i]){
			alert("Entry should not have special characters");
			return false;
		};		
	};
};

function checkOldIC(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;	
	var specialcharcode = new Array("32","33","34","35","36","37","38","39","40","41","42","44","46","47","58","59","60","62","63","94");
	for (i=0;i<specialcharcode.length;i++){		
		if(charCode==specialcharcode[i]){
			alert("Entry should not have special characters");
			return false;
		};		
	};
};

function checkDigitOnly(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;		

	if(charCode <= 57 && charCode >= 48 || charCode == 13 || charCode == 8){
		return true;
	}else{
		alert("Entry should be in digits");	
		//document.getElementById(obj.name).focus()
		return false;	
	};	
};

function checkAmountOnly(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;		

	if(charCode <= 57 && charCode >= 48 || charCode == 13 || charCode == 8 || charCode == 46){
		return true;
	}else{
		alert("Entry should be in digits");	
		//document.getElementById(obj.name).focus()
		return false;	
	};	
};


function checkDivider(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;		

	if(charCode != 124){
		return true;
	}else{
		alert("Entry should not have divider");	
		return false;	
	};	
};

function checkDigitAndSlash(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;		

	if(charCode <= 57 && charCode >= 48 || charCode == 13 || charCode == 8 || charCode == 47){
		return true;
	}else{
		alert("Entry should be in digits and slash only");	
		//document.getElementById(obj.name).focus()
		return false;	
	};	
};

function checkAddressText(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode;		
	if(charCode== 34 || charCode==38 || charCode==39 || charCode==96 ){
		return false;
	};			
};

function checkRemark1(evt,obj){
	var charCode = (evt.which) ? evt.which : event.keyCode;		
	if(charCode== 34 || charCode== 35 || charCode== 36 || charCode== 37 || charCode==38 || charCode==39 || charCode==64 || charCode==96 || charCode==124 ){
		return false;
	};			
	
	if(obj.value.length>100){
		return false;
	};
};

function formatDate(dt,type){

	switch(type){
	case 1:
		return dt.substr(3,2) + "-" + dt.substr(0,2) + "-" + dt.substr(6,4);	
		break;
	case 2:
		return dt.substr(8,2) + "-" + dt.substr(5,2) + "-" + dt.substr(0,4);	
		break;	
	};
};

function strpad(val){
	return (!isNaN(val) && val.toString().length==1)?"0"+val:val;
};

/*function Search(evt,type){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode==13){	
		if(document.frmSearchMember.txtkeyword.value==""||document.frmSearchMember.txtkeyword.value.replace(/^\s+|\s+$/g, '')==""){		
			return false		
		}

		searchMember(type)
			
  	}
}*/


/*********************************************************************/
function searchMember(type,para1,para2,para3){	

	var searchby = document.frmSearchMember.cboSearchBy.value;
	var keyword = document.frmSearchMember.txtkeyword.value;

	if(keyword==""||keyword.replace(/^\s+|\s+$/g, '')==""){
		alert("Please enter keyword");
		document.frmSearchMember.txtkeyword.focus();
		return false;	
	};

	parent.iframe_memberlisting.refreshMemberListing(searchby,keyword,type,para1,para2,para3);
};

function showAllMember(type,para1,para2,para3){	
	//alert(parent.document.getElementById("txtkeyword").value)
	document.frmSearchMember.txtkeyword.value = "";
	parent.iframe_memberlisting.refreshMemberListing('A','dummyvalue',type,para1,para2,para3);
	
};
/*********************************************************************/
function searchBranch(type){
	
	var searchby = document.frmSearchBranch.cboSearchBy.value;
	var keyword = document.frmSearchBranch.txtkeyword.value;

	
	if(keyword==""||keyword.replace(/^\s+|\s+$/g, '')==""){
		alert("Please enter keyword");
		document.frmSearchBranch.txtkeyword.focus();
		return false;	
	};

	parent.iframe_branchlisting.refreshBranchListing(searchby,keyword,type);

};

function showAllBranch(type){
	document.frmSearchBranch.txtkeyword.value = "";
	parent.iframe_branchlisting.refreshBranchListing('A','dummyvalue',type);
};
/*********************************************************************/
function searchDivision(type){
	
	var searchby = document.frmSearchDivision.cboSearchBy.value;
	var keyword = document.frmSearchDivision.txtkeyword.value;
	
	if(keyword==""||keyword.replace(/^\s+|\s+$/g, '')==""){
		alert("Please enter keyword");
		document.frmSearchDivision.txtkeyword.focus();
		return false;	
	};

	parent.iframe_divisionlisting.refreshDivisionListing(searchby,keyword,type);

};

function showAllDivision(type){
	document.frmSearchDivision.txtkeyword.value = "";	
	parent.iframe_divisionlisting.refreshDivisionListing('A','dummyvalue',type);
};
/*********************************************************************/

function showinfo(obj,thetext,showoption,h,w){

  var xpos;
  var ypos;

  if(showoption==1){
	  
    document.getElementById("divinfocontent").innerHTML = thetext;
	document.getElementById("divbox").style.visibility = "visible";
	document.getElementById("divinfocontent").style.height = h + 'px';
	document.getElementById("divinfocontent").style.width = w + 'px';
  }else{
    document.getElementById("divbox").style.visibility = "hidden";    
  };
  xpos = findPosX(obj);
  ypos = findPosY(obj);  
  
  document.getElementById("divbox").style.left = xpos + obj.offsetWidth + 10 + 'px';
  document.getElementById("divbox").style.top = ypos - 5 + 'px';
  
};

function findPosX(obj){
	var curleft=0;
	if(document.getElementById||document.all){
		while(obj.offsetParent)
		{
			curleft+=obj.offsetLeft;
			obj=obj.offsetParent;
		};
	}
	else if(document.layers){
		curleft+=obj.x;
	};
	return curleft;
};

function findPosY(obj){
	var curtop=0;
	if(document.getElementById||document.all){
		while(obj.offsetParent){
			curtop+=obj.offsetTop;
			obj=obj.offsetParent;
		};
	}
	else if(document.layers){
		curtop+=obj.y;
	};
	return curtop;
};

function gotopage(pagelink,maxpage){
	//alert(document.getElementById('txtpagenum').value)
	var page = document.getElementById('txtpagenum').value;
	if(Number(page)>Number(maxpage)){
		alert("Page number entered cannot be more than max page.");
		document.getElementById('txtpagenum').focus();
	}else{		
		location.href = pagelink + "&page=" + page;	
	};
};

function ajax_gotopage(filter,pageNum,maxPage){
	var page = document.getElementById('txtpagenum').value;
	if(Number(page)>Number(maxPage)){
		alert("Page number entered cannot be more than max page.");
		document.getElementById('txtpagenum').focus();
	}else{
		str  = "filter=" + filter + "&";
		str += "pageNum=" + page + "&";
	
		ajax_RefreshBookingData("engine_refreshbookingdata.php", str);
	};	
};

function pad(str, len, pad, dir) {
 	var STR_PAD_LEFT = 1;
	var STR_PAD_RIGHT = 2;
	var STR_PAD_BOTH = 3;

	if (typeof(len) == "undefined") { var len = 0; };
	if (typeof(pad) == "undefined") { var pad = ' '; };
	if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; };
 	if (typeof(str) == "number") { str = str.toString(); };
 
	if (len + 1 >= str.length) {

		switch (dir){
 
			case STR_PAD_LEFT:
				str = Array(len + 1 - str.length).join(pad) + str;
				break;
 
			case STR_PAD_BOTH:
				var right = Math.ceil((padlen = len - str.length) / 2);
				var left = padlen - right;
				str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
				break;
 
			default:
				str = str + Array(len + 1 - str.length).join(pad);
				break;
 
		}; 
 
	};
 
	return str;
};



