/* ON LOAD */
$(document).ready(function() {
    Cufon.replace('h1, h2, h3, h4, h5, .btn, table th, .widget.screenshot a span');
    Cufon.replace('#navigation li a.act', {
		color: '#edc6a8',
		hover: {color: '#edc6a8'}
	});	
    Cufon.replace('#navigation li a', {
		color: '-linear-gradient(#d8a370, #7f5330)',
		textShadow: '0 1px black',
		hover: {
			color: '#edc6a8'
			}
		});
	Cufon.replace('#navigation li a.act', {
		color: '#edc6a8',
		hover: {color: '#edc6a8'}
	});	
	Cufon.replace('#footer-wrapper h3', {
		textShadow: '0 1px black'
		});


	// This is DataTables initialization
		if ($.fn.dataTable) {
						
			/* Init DataTables, thanks to Datatable forums */
			$('#statustable').dataTable({
				"sPaginationType": "full_numbers",
				"iDisplayLength": 25,
				"bFilter": true,
				"bLengthChange": false,
				"bSort": true,
				"sDom": 'rtiplf'
			});

			/* Ajax connector */
			/*$('td:not(.readonly)', oTable.fnGetNodes()).editable( '../examples_support/editable_ajax.php', {
						"callback": function( sValue, y ) {
							var aPos = oTable.fnGetPosition( this );
							oTable.fnUpdate( sValue, aPos[0], aPos[1] );
						},
						"submitdata": function ( value, settings ) {
							return {
								"row_id": this.parentNode.getAttribute('id'),
								"column": oTable.fnGetPosition( this )[2]
							};
						},
					"height": "14px"
					});*/

		}
});

/* SCORE SETTINGS */
$(function() {

	$('.score-bg').animate({width: 'toggle'},{duration: 2000});

});

/* BACK TO TOP */
$(function() {
	$('#back-top a').click(function(){
			
		$('html, body').animate({scrollTop: '0'}, 1000);
			
		return false;
	});
});

/* FANCYBOX */
$(document).ready(function() {
	
	$("a.grouped_elements").fancybox({
			'transitionIn'		: 'fade',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});

$(document).ready(function() {	
	
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div').width($('#mask').width());
	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();
		
		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');
		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});
	
});



