var currentSponsor = 0;
$(document).ready(function() { 
	if ($('#sponserUl').length) { 
		$.getJSON('/themes/main/assetReader.php?prefix=sponsors', function(data) { 
			$.each(data, function (i, item) { 
				$('#sponserUl').append('<li class="slide_'+i+'"><a href="/content/4080/Sponsors/"><img border="0" src="/assets/' + item + '" /></a></li>');
			});
			$('#sponserUl li').hide();
			$('#sponserUl li:first').show();
			setInterval(advanceSponsors, 3000);
		});
	}
	function advanceSponsors() {
		currentSponsor++;
		if (!$('#sponserUl .slide_' + currentSponsor).length) {
			currentSponsor = 0;
		}
		$('#sponserUl li:visible').fadeOut('fast', function() {
			$('#sponserUl .slide_' + currentSponsor).fadeIn('fast');
		});
	}
	if ($('#photoUl').length) { 
		$.getJSON('/themes/main/assetReader.php?prefix=photo_hp', function(data) { 
			$.each(data, function (i, item) { 
				$('#photoUl').append('<li class="slide_'+i+' index"><img src="/assets/' + item + '" /></li>');
			});

                    	$('ul#photoUl').innerfade({
                        speed: 1000,
                        timeout: 5000,
                        type: 'sequence',
                        containerheight: 	'455px',
                        slide_timer_on: 	'no',
                        slide_ui_parent: 	'photoUl',
                        slide_ui_text:		'null',
                       	pause_button_id: 	'pause_button',
                       	slide_nav_id:		'photoUl'
                    	});
                    	$.setOptionsButtonEvent();
                    
                        
                   		$("#pause_button").click(function() {
                   			$.pause();
                        });
                        $("#next_button").click(function() {
                    		$.next();
                        });
                        
                        $("#prev_button").click(function() {
                        	$.prev();
                        });
                        
                    	$("#first_button").click(function() {
                        	$.first();
                        });
                        
                    	$("#last_button").click(function() {
                        	$.last();
                        });
				
		});
	}

});