var imageFlow = new ImageFlow();

$(function(){
  $('#team').children('li').each(function(){
	$(this).bind({
	  mouseenter:listHover,
	  mouseleave:listLeft,
	  //click:teamClickHwnd
	  click:function() {getBios($(this).attr('value'));}
	});
  });
  
  imageFlow.init({
	ImageFlowID:'team-pictures',
	captions:false,
	reflections:false,
	reflectionP: 0.4,
	opacity:true,
	imageScaling:true,
	imagesHeight:1,
	startID:2,
	startAnimation:true,
	imageFocusM:2,
	imagesM:1,
	onClick:null,
	opacityArray:[10,5,0],
	slider:false,
	beforeSlide:beforeSlide
  });

  $('#team-pictures').children('img').remove();
});


function listHover(){
 // teamClickHwnd();
  $(this).children('.name-title').css('background-color','#eaf2f9');
  $('body').css('cursor','pointer');
}

function listLeft(){
  $(this).children('.name-title').css('background-color','#ffffff');
  $('body').css('cursor','default');
}

function beforeSlide(imageID) {
  var images = $('#team-pictures_images').children('img');
  var id = $(images[imageID]).attr('id');
  var activeLi = $('#team').children('li[value=' + id + ']');
    $('#team').children('li').mouseleave();
    activeLi.children('.name-title').css('background-color','#eaf2f9');
    var name = $('#name'+id).html();
    var position = $('#position'+id).html();
    var details = $('#details'+id).html();
    title = '<span class="bold">' + name + '</span>' + ' - ' + position;
    $('#team-desc-box').html(details);
    $('.content-col-right').children('.team-name').html(title);
}

function getBios(profile_id){
        var id = (profile_id)?profile_id:$(this).attr('value');
        if(!id){id=10;}
        
        teamClickHwndNew(id);
        var name = $('#name'+id).html();
        var position = $('#position'+id).html();
        var details = $('#details'+id).html();
        var title = '<span class="bold">' + name + '</span>' + ' - ' + position;
        $('#team-desc-box').html(details);
        $('.content-col-right').children('.team-name').html(title);
}

function teamClickHwndNew(id){
  var firstName = id;
  var images = $('#team-pictures_images').children('img');

  try {
	for(var i = 0; i < images.length; i++){
	  if(firstName == $(images[i]).attr('id')){
		imageFlow.glideTo(i);
		break;
	  }
	}
  } catch (error) {
  // error handling code goes here...
  } finally {
	// GC
	firstName = null;
	images = null;
  }
}


function teamClickHwnd(){
  var firstName = $(this).attr('value');
  var images = $('#team-pictures_images').children('img');
  try {
     // alert(firstName)
	for(var i = 0; i < images.length; i++){
	  if(firstName == $(images[i]).attr('alt')){
		imageFlow.glideTo(i);
		break;
	  }
	}
  } catch (error) {
  // error handling code goes here...
  } finally {
	// GC
	firstName = null;
	images = null;
  }
}

//$(document).ready(function(){
//    $(document).pngFix({blankgif: 'http://webcanada.muhammad-jehanzeb.dev.webcanada.com/assets/blank.gif'} );
//
//});

//$(function(){$('.pngfix').pngFix({blankgif: 'http://webcanada.muhammad-jehanzeb.dev.webcanada.com/assets/blank.gif'});});

//$(document).ready( function( ) { $(window).load( function( )
//{
//$(document).pngFix( {blankgif: 'http://webcanada.muhammad-jehanzeb.dev.webcanada.com/assets/blank.gif'} );
//} ); } );

