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 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 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 ViewPhoto(id,ftype,type){		
	window.open("preview_image.php?id=" + id + "&ftype=" + ftype + "&type=" + type,"","width=500,height=400,left=200,top=20,scrollbars=yes")		
}

function showPic(pic,action,obj){
	var xpos
	var ypos
	
	xpos = findPosX(obj)
  	ypos = findPosY(obj)
	
	document.getElementById("bigpic").style.left = (xpos-349).toString() + "px"
	document.getElementById("bigpic").style.top  = (ypos-150).toString() + "px"

	switch(action){
		case "in":
			document.getElementById("bigpic").style.visibility = "visible"	
			//document.getElementById("dishpic").innerHTML = "<img src='images/" + pic + ".jpg" + "' />"
			document.getElementById("dishpic").innerHTML = "<img src='cms/images/dphoto/" + pic + ".jpg" + "' />"						
			
			break
		case "out":
			document.getElementById("bigpic").style.visibility = "hidden"
			document.getElementById("dishpic").innerHTML = ""	
			break
	}	
}
