// JavaScript Document



// PAGINATION //

$(document).ready(function(){
	
	//how much items per page to show
	var show_per_page = 5; 
	//getting the amount of elements inside content div
	var number_of_items = $('#content_pagination').children().size();
	//calculate the number of pages we are going to have
	var number_of_pages = Math.ceil(number_of_items/show_per_page);
	
	//set the value of our hidden input fields
	$('#current_page').val(0);
	$('#show_per_page').val(show_per_page);
	
	//now when we got all we need for the navigation let's make it '
	
	/* 
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
	var navigation_html = '<a class="previous_link" href="javascript:previous();">Prev</a>';
	var current_link = 0;
	while(number_of_pages > current_link){
		navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
		current_link++;
	}
	navigation_html += '<a class="next_link" href="javascript:next();">Next</a>';
	
	$('#page_navigation').html(navigation_html);
	
	//add active_page class to the first page link
	$('#page_navigation .page_link:first').addClass('active_page');
	
	//hide all the elements inside content div
	$('#content_pagination').children().css('display', 'none');
	
	//and show the first n (show_per_page) elements
	$('#content_pagination').children().slice(0, show_per_page).css('display', 'block');
	
});

function previous(){
	
	new_page = parseInt($('#current_page').val()) - 1;
	//if there is an item before the current active link run the function
	if($('.active_page').prev('.page_link').length==true){
		go_to_page(new_page);
	}
	
}

function next(){
	new_page = parseInt($('#current_page').val()) + 1;
	//if there is an item after the current active link run the function
	if($('.active_page').next('.page_link').length==true){
		go_to_page(new_page);
	}
	
}
function go_to_page(page_num){
	//get the number of items shown per page
	var show_per_page = parseInt($('#show_per_page').val());
	
	//get the element number where to start the slice from
	start_from = page_num * show_per_page;
	
	//get the element number where to end the slice
	end_on = start_from + show_per_page;
	
	//hide all children elements of content div, get specific items and show them
	$('#content_pagination').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');
	
	/*get the page link that has longdesc attribute of the current page and add active_page class to it
	and remove that class from previously active page link*/
	$('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');
	
	//update the current page input field
	$('#current_page').val(page_num);
}

// END PAGINATION //


// WORDPRESS MENU HOVER SETUP //
// menu hover setup

//menu_separator
$(".nav_menu_separator").hover(		//menu separator
  	function () { 
		//$("#nav_about_hover").delay(50).fadeOut(100);
		$("#nav_about_hover").css('visibility', 'hidden');
		$("#nav_concert_hover").css('visibility', 'hidden');
		$("#nav_media_hover").css('visibility', 'hidden');
		$("#nav_get-involved_hover").css('visibility', 'hidden');		
	}, 
	function () { }
);

//nav_erase
$("#nav_erase").hover(		//menu separator
  	function () { 
		$("#nav_about_hover").css('visibility', 'hidden');
		$("#nav_concert_hover").css('visibility', 'hidden');
		$("#nav_media_hover").css('visibility', 'hidden');
		$("#nav_get-involved_hover").css('visibility', 'hidden');		
	}, 
	function () { }
);

//nav_erase2
$("#nav_erase2").hover(		//menu separator
  	function () { 
		$("#nav_about_hover").css('visibility', 'hidden');
		$("#nav_concert_hover").css('visibility', 'hidden');
		$("#nav_media_hover").css('visibility', 'hidden');
		$("#nav_get-involved_hover").css('visibility', 'hidden');			
	}, 
	function () { }
);


//about
$("#menu-item-29").hover(		//about
  function () { 
  	//$("#nav_about_hover").fadeIn(500).css('visibility', 'visible');
	$("#nav_about_hover").css('visibility', 'visible'); }, 
	function () {}
);
$("#nav_about_hover").hover(		//concert series
  	function () { $("#nav_about_hover").css('visibility', 'visible'); }, 
	function () {	$("#nav_about_hover").css('visibility', 'hidden'); }
);
//end about

//concert series
$("#menu-item-28").hover(		//concert series
  	function () { $("#nav_concert_hover").css('visibility', 'visible'); }, 
	function () {}
);
$("#nav_concert_hover").hover(		//concert series
  	function () { $("#nav_concert_hover").css('visibility', 'visible'); }, 
	function () {	$("#nav_concert_hover").css('visibility', 'hidden'); }
);
//end concert series

//media
$("#menu-item-27").hover(		//concert series
  	function () { $("#nav_media_hover").css('visibility', 'visible'); }, 
	function () {}
);
$("#nav_media_hover").hover(		//concert series
  	function () { $("#nav_media_hover").css('visibility', 'visible'); }, 
	function () {	$("#nav_media_hover").css('visibility', 'hidden'); }
);

//get involved
$("#menu-item-24").hover(		//get involved
  	//function () { $("#nav_get-involved_hover").css('visibility', 'visible'); }, 
  	//function () {	$("#nav_get-involved_hover").css('visibility', 'hidden');  }
  	function () { $("#nav_get-involved_hover").css('visibility', 'visible'); }, 
	function () {	$("#nav_get-involved_hover").css('visibility', 'hidden');  }
);


//CHANGE THE BG IMAGE RANDOM for about page bigdaddy
$(document).ready(function() {

//* BIGDADDY *//
	//ABOUT
	//var randomImages = ['bg_core_team_.png','bg_core_team.png'];	//bg image list
	
	//random images for bigdaddy bg
	var randomImages = ['1.jpg','4.jpg','5.jpg','7.jpg','12.jpg','13.jpg','14.jpg','15.jpg','20.jpg','37.jpg','41.jpg','desiFEST_photos_1.jpg','desiFEST_photos_2.jpg','desiFEST_photos_3.jpg','desiFEST_photos_4.jpg','desiFEST_photos_5.jpg','desiFEST_photos_6.jpg','desiFEST_photos_7.jpg','desiFEST_photos_8.jpg','desiFEST_photos_9.jpg','desiFEST_photos_10.jpg','desiFEST_photos_11.jpg','desiFEST_photos_12.jpg','desiFEST_photos_13.jpg','desiFEST_photos_14.jpg','desiFEST_photos_15.jpg','desiFEST_photos_16.jpg','desiFEST_photos_17.jpg','desiFEST_photos_18.jpg','desiFEST_photos_20.jpg','desiFEST_photos_21.jpg'];	//bg image list
	
	var rndNum = Math.floor(Math.random() * randomImages.length);
	
	//CORE TEAM
	$("#bigdaddy_core_team").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//GET INVOLVED
	$("#bigdaddy_get_involved").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//MEDIA -> VIDEO
	$("#bigdaddy_media_video").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//MEDIA -> VIDEO
	$("#bigdaddy_media_photo").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//CONCERT SERIES -> 2011 LINEUP
	$("#bigdaddy_2011_lineup").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//CONCERT SERIES -> 2011 LINEUP new
	$("#bigdaddy_2011_lineup_new").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//CONCERT SERIES -> 2011 Vendors
	$("#bigdaddy_2011_vendors").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");
	
	//CONCERT SERIES -> 2011 Partners
	$("#bigdaddy_2011_partners").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");


	//CONTACT
	$("#bigdaddy_contact").css("background-image","url(/wp-content/themes/desifest/images/bigdaddy_bg/" + randomImages[rndNum] + ")").css("background-repeat","no-repeat");


//* BODY BACKGROUND *//
	var randomImages_bg = ['bg_home.png','bg1.png','bg2.png','bg3.png','bg4.png','bg4.png'];	//bg image list
	
	var rndNum_bg = Math.floor(Math.random() * randomImages_bg.length);
	$("body.allpages").css("background-image","url(/wp-content/themes/desifest/images/bg/" + randomImages_bg[rndNum_bg] + ")").css("background-repeat","no-repeat").css("background-position","top left");
	
})  




<!--CORE TEAM PROFILE SLIDESHOW-->

$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 760;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    //alert(currentPosition);
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }	
  
  
//* ABOUT SLIDER THUM Control the big one *//
$('.control_sathish')
    .bind('click', function(){
		currentPosition = 0;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_chris')
    .bind('click', function(){
		currentPosition = 1;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_2')
    .bind('click', function(){
		currentPosition = 2;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_3')
    .bind('click', function(){
		currentPosition = 3;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_4')
    .bind('click', function(){
		currentPosition = 4;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_michelle')
    .bind('click', function(){
		currentPosition = 5;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_6')
    .bind('click', function(){
		currentPosition = 6;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_7')
    .bind('click', function(){
		currentPosition = 7;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_8')
    .bind('click', function(){
		currentPosition = 8;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_piyush')
    .bind('click', function(){
		currentPosition = 9;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });

$('.control_ganesh')
    .bind('click', function(){
		currentPosition = 10;				//setup the slide 
		manageControls(currentPosition);
		// Move slideInner using margin-left
		$('#slideInner').animate({'marginLeft' : slideWidth*(-currentPosition)});
    });






//* END -- ABOUT SLIDER THUM Control the big one *//
  
  
  
  
});  /* and jQuery */






/* del this part ---- */

// menu hover setup
/*$("#nav_about").hover(
  function () { $("#nav_about_hover").css('visibility', 'visible'); }, 
  function () {	$("#nav_about_hover").css('visibility', 'hidden');  }
);

$("#nav_concert").hover(
  function () { $("#nav_concert_hover").css('visibility', 'visible'); }, 
  function () {	$("#nav_concert_hover").css('visibility', 'hidden');  }
);

$("#nav_media").hover(
  function () { $("#nav_media_hover").css('visibility', 'visible'); }, 
  function () {	$("#nav_media_hover").css('visibility', 'hidden');  }
);

$("#nav_get-involved").hover(
  function () { $("#nav_get-involved_hover").css('visibility', 'visible'); }, 
  function () {	$("#nav_get-involved_hover").css('visibility', 'hidden');  }
);
*//* ----del this part */

