/*

	Javascript for jQuery/JSON "Tooltip" Tutorial
	--------------------------------------
*/


// Image Preloader
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
   
  }
}

//Actual jQuery starts here on document ready
$(document).ready(function() {
	
		
	$('a.tooltip').hover(function(){ //when hover starts
		

		//Get the ID of the current tooltip
		active_tooltip = $(this).attr('rel');
		
		//var item=banner_data[active_tooltip];
		var item=$("input:hidden[id$='hdnvalue" + active_tooltip + "']").attr("value");
		var tempItem = item.split('###');
		var tempSubItem = tempItem[0].split('$$$');
		
		//Replace the HTML in the header with data from JSON array		
		$('div#peoplename').html(tempSubItem[0]);	
		$('div#peopleposition').html(tempSubItem[1]);
		var vSpec=tempSubItem[2];
		if (vSpec.length>0)
		{
			vSpec=vSpec.replace('&','&amp;');
		}
		var vLegal=tempSubItem[3];
		if (vLegal.length>0)
		{
		vLegal=vLegal.replace('&','&amp;');
		}
		if (vLegal.length>0)
		{
		    $('#Expertise').html('<div class=\"div-heading\">Expertise</div><div class=\"div-value\">' + vLegal + '</div>');
		}
		else
		{   
		    $('#Expertise').html('');
		}
		if (vSpec.length>0)
		{
		    $('#Specialization').html('<div class=\"div-heading\">Specialization</div><div class=\"div-value\">' + vSpec + '</div>');
		}
		else
		{   
		    $('#Specialization').html('');
		}
		if (tempSubItem[4].length>0)
		{
		    $('#Phone').html('<div class=\"div-heading\">Ph (direct)</div><div class=\"div-value\">' + tempSubItem[4] + '</div>');
		}
		else
		{   
		    $('#Phone').html('');
		}
		if (tempSubItem[5].length>0)
		{
		    $('#Mobile').html('<div class=\"div-heading\">Mobile</div><div class=\"div-value\">' + tempSubItem[5] + '</div>');
		}
		else
		{   
		    $('#Mobile').html('');
		}  
		if (tempSubItem[6].length>0)
		{
		    $('#Email').html('<div class=\"div-heading\">Email</div><div class=\"div-value\">' + tempSubItem[6] + '</div>');
		}
		else
		{   
		    $('#Email').html('');
		}
//		var myHeight=(parseInt($("#Expertise").height())+parseInt($("#Specialization").height())+parseInt($("#Phone").height())+parseInt($("#Mobile").height())+parseInt($("#Email").height()));
//		if (myHeight>190)
//		{
//		    $('#banner').height(myHeight);
//		}
//        else		
//        {
//            $('#banner').height("190");
//        }
		$('#bannerimg').html("<img src='"+ tempItem[1] + "' title='" + tempSubItem[0] + "' />");
		
	},
	function(){ //When hover ends

		//Get the ID of the current tooltip
		active_tooltip = $(this).attr('rel');
		
		//var item=banner_data[active_tooltip];
		var item=$("input:hidden[id$='hdnvalue" + active_tooltip + "']").attr("value");
		var tempItem = item.split('###');
		var tempSubItem = tempItem[0].split('$$$');
		
		//Reset banner to defaults
		$('div#peoplename').html(tempSubItem[0]);
		$('div#peopleposition').html(tempSubItem[1]);
		$('#Expertise').html('');
		$('#Specialization').html('');
//		$('#Specialization').html('<div class=\"div-heading\">Industry Focus</div><div class=\"div-value\">' + vSpec + '</div>');
		$('#Phone').html('<div class=\"div-heading\">Ph (direct)</div><div class=\"div-value\">' + tempSubItem[4] + '</div>');
		$('#Mobile').html('<div class=\"div-heading\">Mobile</div><div class=\"div-value\">' + tempSubItem[5] + '</div>');
		$('#Email').html('<div class=\"div-heading\">Email</div><div class=\"div-value\">' + tempSubItem[6] + '</div>');
		$('#bannerimg').html("<img src='"+ tempItem[1] + "' alt='" + tempSubItem[0] + "' title='" + tempSubItem[0] + "' />");		
//		if ($('#banner').height()>190)
//		    $('#banner').height("190");	
	});	
});
