	jQuery(document).ready(function() {
		var count = 0;
		var current = 0;
		var isMoving = false;
		var firstOne;
		var lastOne;
		jQuery.getJSON(THEMEPATH+'/assets/js/config.json', function(config) {
			//jQuery('.result').html('<p>' + config.bgColor + '</p>');
			jQuery.getJSON(THEMEPATH+'/assets/js/operas.json',function(data){
				jQuery("#feature").append('<div id="feature-bg" style="height:264px;width:100%;margin:0;"><div id="slider" style="width:960px;overflow:hidden;margin:0 auto;"><ul style="margin:0;padding:0;width:960px;"></ul></div></div>');
				for(var c in data){
					count++;
				}
				for(var i in data){
					jQuery("#feature #feature-bg #slider ul").append('<li class="slide" id="opera'+data[i].id+'" style="background:url('+THEMEPATH+'/'+data[i].image+') no-repeat top right;height:264px;width:960px;float:left;display:inline;font-family:Arial, Helvetica, sans-serif;margin:0;"><p style="margin:90px 0 0 0; padding:0;"><span class="year-text" style="color:#'+config.yearColor+';font-size:22px;line-height:48px;height:49px;float:left;display:inline;margin: 0 0 0 170px;padding:0;">'+data[i].season+'</span><span class="season-text" style="color:#'+config.seasonColor+';float:left;display:inline;font-size:48px;line-height:48px;text-transform:uppercase;margin:0;padding:0;">Season</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.nameColor+';margin:0 0 0 170px;font-size:20px;padding:0;">'+data[i].name+'</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.dateColor+';margin:0 0 0 170px;font-size:18px;padding:0;">'+data[i].date+'</span><br style="clear:both;"/><a href="'+data[i].link+'" class="more-info" style="color:#'+config.linkColor+';margin:5px 0 0 170px;text-decoration:none; text-transform:uppercase;font-size:11px;line-height:20px">&gt;&nbsp;More Info</a></p></li>');
					if(data[i].id == 0){
						firstOne = i;
					}else if(data[i].id == (count-1)){
						lastOne = i;	
					}
				}
				appendFirst(firstOne);
				prependLast(lastOne);
				jQuery('#feature #feature-bg #slider ul').css({'width':(count+2)*960+'px','margin-left':-960});
				jQuery("#feature #feature-bg").prepend('<div id="feature-nav" style="position:absolute;top:0;left:0;height:148px;width:100%;"><div style="width:960px; height:148px; margin:0 auto;"><a href="#" style="font-size:30px;opacity: 0.25;filter: alpha(opacity=25); text-decoration:none; float:left;display:inline; text-align:center; margin:116px 0 0 0;line-height:32px; padding:0; height:32px;width:32px; border:3px solid #'+config.arrowColor+'; color:#'+config.arrowColor+';" id="feature-left-arrow">&lt;</a><a href="#" style="font-size:30px; position:absolute; margin:116px 0 0 884px; float:right;display:inline; line-height:32px; padding:0;z-index:960; height:32px;opacity: 0.25;filter: alpha(opacity=25);width:32px;  border:3px solid #'+config.arrowColor+'; color:#'+config.arrowColor+'; text-decoration:none; text-align:center; " id="feature-right-arrow">&gt;</a></div></div>');
				jQuery('#feature #feature-bg #feature-nav div a#feature-left-arrow').click(function(){
					if(isMoving==false){
						isMoving = true;
						if(current>0){
							jQuery("#feature #feature-bg #slider ul").animate({marginLeft:-960+(current-1)*(-960)},960,'easeInOutCubic',function(){current--;isMoving=false;});
						}else{
							jQuery("#feature #feature-bg #slider ul").animate({marginLeft:0},960,'easeInOutCubic',function(){current=(count-1);isMoving=false;jQuery("#feature #feature-bg #slider ul").css({'margin-left':(count*(-960))});});
						}
					}else{
						
					}
				});
				jQuery('#feature #feature-bg #feature-nav div a#feature-right-arrow').click(function(){
					if(isMoving==false){
						isMoving = true;
						if(current<(count-1)){
							jQuery("#feature #feature-bg #slider ul").animate({marginLeft:-960+(current+1)*(-960)},960,'easeInOutCubic',function(){current++;isMoving=false;});
						}else{
							jQuery("#feature #feature-bg #slider ul").animate({marginLeft:(-960+(count*-960))},960,'easeInOutCubic',function(){current=0;isMoving=false;jQuery("#feature #feature-bg #slider ul").css({'margin-left':-960});});
						}
					}else{
						
					}
				});
				function prependLast(tempName){
					jQuery("#feature #feature-bg #slider ul").prepend('<li class="slide" id="opera-1" style="background:url('+THEMEPATH+'/'+data[tempName].image+') no-repeat top right;height:264px;width:960px;float:left;display:inline;font-family:Arial, Helvetica, sans-serif;margin:0;"><p style="margin:90px 0 0 0; padding:0;"><span class="year-text" style="color:#'+config.yearColor+';font-size:22px;line-height:48px;height:49px;float:left;display:inline;margin: 0 0 0 170px;padding:0;">'+data[tempName].season+'</span><span class="season-text" style="color:#'+config.seasonColor+';float:left;display:inline;font-size:48px;line-height:48px;text-transform:uppercase;margin:0;padding:0;">Season</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.nameColor+';margin:0 0 0 170px;font-size:20px;padding:0;">'+data[tempName].name+'</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.dateColor+';margin:0 0 0 170px;font-size:18px;padding:0;">'+data[tempName].date+'</span><br style="clear:both;"/><a href="'+data[tempName].link+'" class="more-info" style="color:#'+config.linkColor+';margin:5px 0 0 170px;text-decoration:none; text-transform:uppercase;font-size:11px;line-height:20px">&gt;&nbsp;More Info</a></p></li>');
				}
				function appendFirst(tempName){
					jQuery("#feature #feature-bg #slider ul").append('<li class="slide" id="opera'+count+'" style="background:url('+THEMEPATH+'/'+data[tempName].image+') no-repeat top right;height:264px;width:960px;float:left;display:inline;font-family:Arial, Helvetica, sans-serif;margin:0;"><p style="margin:90px 0 0 0; padding:0;"><span class="year-text" style="color:#'+config.yearColor+';font-size:22px;line-height:48px;height:49px;float:left;display:inline;margin: 0 0 0 170px;padding:0;">'+data[tempName].season+'</span><span class="season-text" style="color:#'+config.seasonColor+';float:left;display:inline;font-size:48px;line-height:48px;text-transform:uppercase;margin:0;padding:0;">Season</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.nameColor+';margin:0 0 0 170px;font-size:20px;padding:0;">'+data[tempName].name+'</span><br style="clear:both;"/><span class="name-text" style="color:#'+config.dateColor+';margin:0 0 0 170px;font-size:18px;padding:0;">'+data[tempName].date+'</span><br style="clear:both;"/><a href="'+data[tempName].link+'" class="more-info" style="color:#'+config.linkColor+';margin:5px 0 0 170px;text-decoration:none; text-transform:uppercase;font-size:11px;line-height:20px">&gt;&nbsp;More Info</a></p></li>');
				}
			});
		});
	});

