 $(document).ready(function(){
   
	var scroller =  $("#pageBlock").scrollable({keyboard: false, circular: false, speed:2000}).navigator(".nav1");
	var scroller2 = $(".scrollable").scrollable({keyboard: false, vertical:true, speed:400,items: '.itemsInner'}).navigator(".navi");
	
	
	//var api = $("#pageBlock").data("scrollable");
	
	//api.onBeforeSeek(function(){alert(1)});
     var delay1 = 2000;
	 startPath6 = -120;
	 startPath5 = -60;
	 startPath4 = 0;
	 startPath3 = 60;
	 startPath2 = 120;
	 startPath1 = 180;
	
 	 $("#mainPath1").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : -120,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400).bind('click', {pos:6}, rotateButtons);
		$("#mainPath2").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : -60,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400).bind('click', {pos:5}, rotateButtons);
		$("#mainPath3").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : 0,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400).bind('click', {pos:4}, rotateButtons);
		$("#mainPath4").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : 60,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400).bind('click', {pos:3}, rotateButtons);
  		$("#mainPath5").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : 120,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400).bind('click', {pos:2}, rotateButtons);
		$("#mainPath6").animate({
             path : new $.path.arc({
                   center : [0,290],
                   radius : 270,
                   start : 180,
                   end     : 180,
                   dir : -1
               })
        },delay1).animate({
    opacity: 0.65},400,loadFirstFrame).bind('click', {pos:1}, rotateButtons);
	
	//$("#navigateLeft").bind('click', {pos:6}, rotateButtons);class="hideClass"
	//$("#navigateRight").bind('click', {pos:2}, rotateButtons);
	
	$("#innerBlock1_1").load("gallery/home.html");
	
	$("#innerBlock2_1").load("gallery/dev1.html");
	$("#innerBlock2_2").load("gallery/dev2.html");
	$("#innerBlock2_3").load("gallery/dev3.html");
	$("#innerBlock2_4").load("gallery/dev4.html");
	$("#innerBlock2_5").load("gallery/dev5.html");
	$("#innerBlock2_6").load("gallery/dev6.html");
	$("#innerBlock2_7").load("gallery/dev7.html");

	$("#innerBlock3_1").load("gallery/des1.html");
	$("#innerBlock3_2").load("gallery/des2.html");
	$("#innerBlock3_3").load("gallery/des3.html");
	$("#innerBlock3_4").load("gallery/des4.html");
	$("#innerBlock3_5").load("gallery/des5.html");
	$("#innerBlock3_6").load("gallery/des6.html");
	
	$("#innerBlock4_1").load("gallery/photo1.html");
	$("#innerBlock4_2").load("gallery/photo2.html");
	$("#innerBlock4_3").load("gallery/photo3.html");
	$("#innerBlock4_4").load("gallery/photo4.html");
	$("#innerBlock4_5").load("gallery/photo5.html");
	$("#innerBlock4_6").load("gallery/photo6.html");
	$("#innerBlock4_7").load("gallery/photo7.html");
	
	$("#innerBlock5_1").load("gallery/res1.html");
	
	$("#innerBlock6_1").load("gallery/cont1.html");
 	
 });
 
 function loadFirstFrame()
 {
    $("#mainPath6").animate({
    opacity: 1},400);
 	$("#pageBlockWrapper").fadeToggle(1000);
	$("#infoText").fadeIn(1000);
 
 }
 function clearFrame()
 {
	animate({opacity: 0.65},400)	 
 }
 
 
 
 
 function rotateButtons(e){
    $("#infoText").fadeOut(400);
	
 var oldStart = eval("startPath" + e.data.pos); 
 var slotsJumped = (180 + oldStart) / 60;
 if (slotsJumped > 5){ slotsJumped = 0; }
 
	
	$(".nav1 div").each(function(index){
		 oldStart = eval("startPath" + (index + 1));
		 var newEnd = oldStart;
		 for (x=0; x < slotsJumped; x++){
		 	newEnd = newEnd - 60;
			if (newEnd == -180){ newEnd = 180; }
		 }
		 
		 if (index == 5){
		 	$(this).animate({
			opacity: 0.65},400).animate({
				path : new $.path.arc({
					   center : [0,290],
					   radius : 270,
					   start : oldStart,
					   end     : newEnd,
					   dir : -1
					   })
			},1600,function(){ 
     rotationDone(e.data.pos)
    });
		 }
		 else {
		
			$(this).animate({
			opacity: 0.65},400).animate({
				path : new $.path.arc({
					   center : [0,290],
					   radius : 270,
					   start : oldStart,
					   end     : newEnd,
					   dir : -1
					   })
			},1600);
		}
			
	
		switch (index){
			case 0:
				startPath1 = newEnd;
				break;	
			case 1:
				startPath2 = newEnd;
				break;
			case 2:
				startPath3 = newEnd;
				break;
			case 3:
				startPath4 = newEnd;
				break;
			case 4:
				startPath5 = newEnd;
				break;			
			case 5:
				startPath6 = newEnd;
				break;	
		    default:
		}	
		
			   
	});
	
	
	
	
	$(this).animate({ opacity: 1},1000);
 }
 /*
 function hoverButtons(e){
 	 $("#infoText div").each(function(){
		$(this).attr("class","hideClass");
		
	});
 	switch (e.data.pos){
		case 1:
			$("#infoBlock1").attr("class","showClass");
			break;
		case 2:
		    $("#infoBlock2").attr("class","showClass");
			break;
		case 3:	
			$("#infoBlock3").attr("class","showClass");	
			break;
		case 4:
		    $("#infoBlock4").attr("class","showClass");
			break;
		case 5:
		    $("#infoBlock5").attr("class","showClass");	
			break;
		default:
		    $("#infoBlock6").attr("class","showClass");			
		
	 }
	
 }*/
 
 function rotationDone(pos){
    $("#infoText div").each(function(){
		$(this).attr("class","hideClass");
		
	});
	
 	switch (pos){
		case 1:
			$("#infoBlock1").attr("class","showClass");
			break;
		case 2:
		    $("#infoBlock2").attr("class","showClass");
			break;
		case 3:	
			$("#infoBlock3").attr("class","showClass");	
			break;
		case 4:
		    $("#infoBlock4").attr("class","showClass");
			break;
		case 5:
		    $("#infoBlock5").attr("class","showClass");	
			break;
		default:
		    $("#infoBlock6").attr("class","showClass");			
		
	 }
	 $("#infoText").fadeIn(400);
 }

 function hoverButton(){
 	$(this).animate({top:"-=20px"},200).animate({top:"+=20px"},200).animate({top:"-=20px"},200)
.animate({top:"+=20px"},200).animate({top:"-=20px"},200).animate({top:"+=20px"},200);
 }
