//------------------------------------------------------------------------------
function setupCalendar(input_fld, trigger_id)
{
 Calendar.setup(
    {
      inputField  : input_fld,
      ifFormat    : "%Y-%m-%d",
      button      : trigger_id
    }
  );
}
//------------------------------------------------------------------------------
function setupCalendarFront(input_fld, trigger_id)
{
 Calendar.setup(
    {
      inputField  : input_fld,
      ifFormat    : "%d/%m/%Y",
      button      : trigger_id
    }
  );
}
//------------------------------------------------------------------------------
function navigatePaging(url, page, totalPages)
{
	if(!isNumeric(page))
	{
		alert('Please enter only numbers'); page.focus(); return false;
	}
	pageId	=	trimAll(page.value);
	if(pageId > totalPages || pageId < 1)
	{
		alert('Invalid Page'); page.focus(); return false;
	}
	//window.location	=	url+pageId+"/";
	window.location.href	=	url+pageId;
	return false;
}
//------------------------------------------------------------------------------
function goBack(url)
{
	if(url == "")
		history.go(-1);
	else
		window.location.href	=	url;
}
//------------------------------------------------------------------------------
function goToPage(url)
{
	window.location.href	=	url;
}
//------------------------------------------------------------------------------
function delAlert(url)
{
	if(confirm("Are you sure to delete?"))
	{
		window.location.href	=	url;
	}
	else
	{
		return false;
	}
}
//------------------------------------------------------------------------------
function confirmAlert(url)
{	
	if(confirm("Are you sure to publish?"))
	{
		//window.location.href 	=	""+url+"";
		document.location = url;
	}
	else
	{
		return false;
	}
}

//------------------------------------------------------------------------------
function swapImage(imgObj, id)
{
	imgPath	=	imgObj.src;
	if(id != undefined)
	{
		if(imgPath.indexOf(id.toLowerCase()) > 0)
		{
			return true;
		}
	}
	arrPath	=	imgPath.split("_");

	if(arrPath[1]	==	"on.gif")
		imgObj.src	=	eval("'" + arrPath[0] + "_off.gif'");
	else
		imgObj.src	=	eval("'" + arrPath[0] + "_on.gif'");
}
//------------------------------------------------------------------------------
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;

	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}

	if (isNaN(key)) return true;
	keychar = String.fromCharCode(key);

	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}
//------------------------------------------------------------------------------
function controlLbLayerFun(mode)
{
	var obj = document.getElementById('lb_layer');
	if ( mode == "block" ) { controlDDFun(""); } else { controlDDFun("hidden"); }
	obj.style.display = mode;
}
//------------------------------------------------------------------------------
function controlDDFun(mode)
{
	var x = document.getElementsByTagName("SELECT");
	for ( i = 0; i < x.length; i++ )
	{
		//x[i].style.visibility = mode;
	}
}
//------------------------------------------------------------------------------
//controlBlock('card', 'block');
//controlBlock('card', 'none');
function controlBlock(eltId, mode)
{
	var obj = document.getElementById(eltId);
	obj.style.display = mode;
}
//------------------------------------------------------------------------------