//------------------------------------------------------------------------------
function setupCalendar(input_fld, trigger_id)
{
 Calendar.setup(
    {
      inputField  : input_fld,
      ifFormat    : "%Y-%m-%d",
      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	=	url+pageId;
	return false;
}
//------------------------------------------------------------------------------
function loadPage(url, objAnchor, rh)
{
	/*
	get the div/span tag's id which will be the response handler
	<div id="pagination_x">
		<ul>
			<li id="li1"><a href="javascript:void(0);" onclick="loadPage(url, this);">Page 1</a></li>

	//response handler will be
	function process_pagination_x(responseText)
	{
		decide where the content has to be put
		controlLbLayer("none");
	}
	*/

	if ( objAnchor != "" )
	{
		var anchorParent = objAnchor.parentNode.parentNode.parentNode.id;
		responseHandler	=	"process_"+anchorParent;
	}
	else
	{
		responseHandler	=	"process_"+rh;
	}

	//alert(url);
	//alert(responseHandler);
	//return false;

	output			=	"text";
	process			=	"paginate_records";
	//controlLbLayer("block");
	ajaxGetRequest(url);
	return false;
}
//------------------------------------------------------------------------------
function controlLbLayer(mode)
{
	var obj = document.getElementById('lb_layer');
	if ( mode == "block" ) { controlDD(""); } else { controlDD("hidden"); }
	obj.style.display = mode;
}
//------------------------------------------------------------------------------
function controlDD(mode)
{
	var x = document.getElementsByTagName("SELECT");
	for ( i = 0; i < x.length; i++ )
	{
		x[i].style.visibility = mode;
	}
}
//------------------------------------------------------------------------------
function goBack(url)
{
	if(url == "")
		history.go(-1);
	else
		window.location	=	url;
}
//------------------------------------------------------------------------------
function goToPage(url)
{
	window.location	=	url;
}
//------------------------------------------------------------------------------
function delAlert(url)
{
	if(confirm("Are you sure to delete?"))
	{
		window.location	=	url;
	}
	else
	{
		return false;
	}
}
//------------------------------------------------------------------------------
function controlTabs(noOfTabs, curTab, className, source)
{
	for(i=1;i<=noOfTabs;i++)
	{
		obj	=	document.getElementById("tab_"+i);
		obj.className	=	'';
	}
	obj	=	document.getElementById("tab_"+curTab);
	obj.className	=	className;
	window.frames[0].location.href	=	source;
}
//------------------------------------------------------------------------------
function swapLNimg(imgObj)
{
	imgPath =	imgObj.src;
	arrImg	=	imgPath.split("_");
	cmdLN	=	document.getElementById("lcmd").src;
	//if(cmdLN.indexOf("artist") != -1 ||  cmdLN.indexOf("album") != -1 || cmdLN.indexOf("tracks") != -1 || cmdLN.indexOf("label") != -1)
	//cmdLN	=	cmdLN.replace(/artist|album|tracks|label/, "browse");
	//alert(cmdLN);
	//if(imgPath.indexOf(cmdLN) == -1)
	
	if(arrImg[0] != cmdLN)
	{
		if(arrImg[1]	==	"on.gif")
			imgObj.src	=	eval("'" + arrImg[0] + "_off.gif'");
		else
			imgObj.src	=	eval("'" + arrImg[0] + "_on.gif'");
	}
}
//------------------------------------------------------------------------------
function showImgError(imgObj, mode)
{
	if ( mode == "track" || mode == "album" )
	{
		imgObj.src = '/templates/template200705/images/album.gif';
	}
	else if ( mode == "track" || mode == "album150" )
	{
		imgObj.src = '/templates/template200705/images/album150.gif';
	}
	else if  ( mode == "artist" )
	{
		imgObj.src = '/templates/template200705/images/artist.gif';
	}
	else if  ( mode == "label" )
	{
		imgObj.src = '/templates/template200705/images/label.gif';
	}
	else if  ( mode == "dj" )
	{
		imgObj.src = '/templates/template200705/images/dj.gif';
	}
}
//------------------------------------------------------------------------------
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'");
}
//------------------------------------------------------------------------------
