function IsWindowClosing() 
{
	if (window.event.clientX < 0 && window.event.clientY < 0)
	{
   		//alert("Window is closing...");
		return true;
	}
	else
	{
		return false;
	}
		
}

function refreshParentWin(leaveOn)
{
	if(opener && !opener.closed)
	{		
		window.opener.location.href = window.opener.location.href;
	}
	else
	{
		alert("Parent window is not available");			
	}
	
	//If leaveOn is not set, current window will be closed after the parent is refreshed.
	if(!leaveOn)
		window.close();
}

function changeDiv(id, method)
{
	var itm = null;
	if (document.getElementById) {
		itm = document.getElementById(id);
	} else if (document.all)     {
		itm = document.all[id];
	} else if (document.layers)   {
		itm = document.layers[id];
	}
	
	if (itm.style)
	{
		if ( method == 'show' )
		{
			itm.style.display = "";
		}
		else
		{
			itm.style.display = "none";
		}
	}
	else
	{
		itm.visibility = "show";
	}
}

function allNumeric(sText)
{
	var ValidChars = "0123456789";
	var aNum=false;
	var Char;	
 
	for (i = 0; i < sText.length && aNum == false; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			aNum = true;
			
			
		}
	}
	return aNum;
		   
}

function donothing()
{
}
	
function trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = rtrim(TRIM_VALUE);
	TRIM_VALUE = ltrim(TRIM_VALUE);
	
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function rtrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;

} //End Function

function ltrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
		break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
	
} //End Function
function setFocus(fieldid)
{
	document.getElementById(fieldid).focus();
}

function ConfirmDelete(del_path)
{
	if (confirm("Are you sure you want to delete the selected item?"))
	{
		window.location.href = (del_path);
	}
}

	function pagination(page,total_pages) {
		var t = document.getElementById('page1');
		var res;
		if (page=="previous") {
			res=Table.pagePrevious(t);
		}
		else if (page=="next") {
			res=Table.pageNext(t);
		}
		else {
			res=Table.page(t,page);
		}
		var currentPage = res.page+1;
		$('.pagelink').removeClass('currentpage');
		$('#page'+currentPage).addClass('currentpage');

		for(var i=1; i<=total_pages; i++)
			document.getElementById('page'+i).className = "link";

		document.getElementById('page'+(page+1)).className = "link_big";
	}
