Cufon.replace('h1', {fontFamily:'Helvetica Neue Condensed'});
Cufon.replace('.infobox-header h2', {fontFamily:'Helvetica Neue Condensed'});
Cufon.replace('#global-menubar li a', {fontFamily:'Helvetica Neue Condensed'});
Cufon.replace('#sidemenu li a', {fontFamily:'Helvetica Neue Condensed'});


var oTable;

/* Formating function for row details */
function fnFormatDetails ( nTr )
{
	var iIndex = oTable.fnGetPosition( nTr );
	var aData = oTable.fnSettings().aoData[iIndex]._aData;
	
	var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:30px;">';
	sOut += '<tr><td><b>Details:</b></td><td>'+aData[3]+'</td></tr>';
	sOut += '</table>';
	
	return sOut;
}

$(document).ready(function() {
	
	//	$.jcorners('.content-view-full .class-folder',{radius:20});
	//	$.jcorners('.infobox',{radius:20});
	//	$.jcorners('#sidemenu ul.menu',{radius:20});
	//	$.jcorners('#global-menubar li.selected',{radius:8,corners:[0,1]});

		$('#global-menubar ul.submenu').each(function() {
		      if($(this).parent().outerWidth() >= $(this).width()) {
			$(this).width($(this).parent().width());
		   }
		});
	

if($('#table_id').length>0){

	/*
	 * Insert a 'details' column to the table
	 */
	var nCloneTh = document.createElement('th');
	nCloneTh.appendChild(document.createTextNode('Details'));
	var nCloneTd = document.createElement('td');
	nCloneTd.innerHTML = '<img src="/design/wcp/images/details_open.png" title=\'Click for Details\' alt=\'Click for Details\' />';
	nCloneTd.className = "center";
	
	$('#table_id thead tr').each( function () {
		this.insertBefore( nCloneTh, this.childNodes[0] );
	} );
	
	$('#table_id tbody tr').each( function () {
		this.insertBefore(  nCloneTd.cloneNode( true ), this.childNodes[0] );
	} );
	
	/*
	 * Initialse DataTables, with no sorting on the 'details' column
	 */


oTable = $('#table_id').dataTable( {
			"sPaginationType": "full_numbers",
			'aaSorting':[[1,'asc']],
			"aoColumns": [ 
							{"bSortable":false },
			/* Provider Name */ 		null,
			/* Provider Description */ 	{ "bVisible":false },
			/* Category Description */ 	{ "bVisible":false },
			/* Address */ 			null,
			/* City */ 			null,
			/* Location Description */	{ "bVisible":false },
			/* Location Phone */		{ "bVisible":false },
			/* Contact */			{ "bVisible":false },
			/* Contact Phone */		{ "bVisible":false },
			/* Provider Phone */		null,
			/* Provider EMail */		{"fnRender":function(oObj) {return '<a href=\"mailto:' + oObj.aData[11] + '\">' + oObj.aData[11] + '</a>';}},
			/* Provider URL */		{"fnRender":function(oObj) {return '<a href=\"http://' + oObj.aData[12] + '\" target=\"_blank\">' + oObj.aData[12] + '</a>';}}
		]});

	$('td img', oTable.fnGetNodes() ).each( function () {
			$(this).click( function () {
				var nTr = this.parentNode.parentNode;
				if ( this.src.match('details_close') )
				{
					/* This row is already open - close it */
					this.src = "/design/wcp/images/details_open.png";
					oTable.fnClose( nTr );
				}
				else
				{
					/* Open this row */
					this.src = "/design/wcp/images/details_close.png";
					oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
				}
			} );
		} );
}

});

