// Eliminate image flicker in IE6
if($.browser.version == "6"){
	try{
		document.execCommand('BackgroundImageCache', false, true);
	}catch(e){}
}

// Callbacks for the flash navigation :
var jsReady = false;
function isReady() {
    return jsReady;
}
function pageInit() {
    jsReady = true;
 }
function thisMovie(movieName) 
{
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}
function sendToJavaScript(value) 
{
    // Flash pass javascript a value which you can do something with...
}
 function collapse() 
 {
	$("#solution_finder").height(38);
 }
 function expand() 
 {
		$("#solution_finder").height(200);
 }
 function changeState(value)
 {
   // javascript passes flash a value which flash will react to
   thisMovie("LexisNexisNav").sendToActionScript(value);
 }
 
 $("#search_terms").bind("focus", function(){
	 
	return $(this).val() === "Search Here" ? $(this).val("") : false;
 })
 $("#search_terms").bind("blur",function(){
	 
	 return $(this).val() === "" ? $(this).val("Search Here") : false;
 })
 
 // Page tweaks here 
 /* Home Page here - Carousel, news feed */
 	$(function() {
 		$("#fc_stage")[0] ?
	    $("#fc_stage").jCarouselLite({
	        visible: 1,
	        btnGo : [
	    		".1",".2",".3",".4",".5"
	        ],
	        auto:4000,
	        easing: "easeinout",
	        speed : 400,
	        afterEnd : function(elm){
			$("#fc_controls li").removeClass("selected");
			$($("#fc_controls li")[$(elm)[0].id]).addClass("selected");
	        }
	    }) : false;
	});
	if(document.getElementById("feature_carousel")){
	$(document).ready(
			function(){
			    $("#fc_controls ul").css("padding-left",($("#fc_controls").width()-$("#fc_controls ul").width())/2);
					$.fn.colorbox.settings.bgOpacity = .75;
					$('#button').colorbox({inline:true,href:"#homevideo"});
					$("#maln_trigger").bind("click",function()
						{
						var infoPanel = $(this).parent().find("#maln_content");
						if(infoPanel){
							if (infoPanel.css("display") === "none")
								
								{ 
								  $("#feature_carousel").fadeOut(100);
								  infoPanel.css("z-index",999).slideDown("slow");
								  $(this).addClass("opened");
								  }
							else
								{ infoPanel.slideUp("slow")
								$("#feature_carousel").fadeIn(100);
								$(this).removeClass("opened");

								}
						}
						}
					);
			}

	);
	}

$(document).ready(
		function(){
		// sorting of table in events page
		$("#events_calendar")[0] ? $("#events_calendar").tablesorter({textExtraction:"complex"}) : false;
		
		// adds no-image class to result set elements that are missing <div class='result_image' ... />
		$(".result_item").each(
				function(){
					tmp = $(this);
					tmp.children(".result_image").length === 0 ? tmp.addClass("no-image") : null ;
					}
				);
		
		//sets the height of all columns to that of the highest in industry insights page
		var currentTallest = 0;
		$(".list_separator").each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		}).css({"height" : currentTallest});
		
		//sets the height of all columns to that of the highest in news & events page
		var currentTallest2 = 0;
		$("#news_wrap .col dl").each(function(i){
		if ($(this).height() > currentTallest2) { currentTallest2 = $(this).height(); }
		}).css({"height" : currentTallest2});
		
		// centers the pagination controls within the div.pagination ul li.pg_controls for results pages
		var controlsWidth = parseInt($("div.pagination ul li.pg_controls").width() - ($("div.pagination ul li.pg_controls ol").width() /2)) /2;
		$("div.pagination ul li.pg_controls ol").css({"padding-left":  controlsWidth + "px"});
		
		// centers the pagination controls within the div.pagination ul li.pg_controls
		var cumulativeWidth = 0; 
		$(".pagination ol:first li").each(function(i,item){cumulativeWidth = cumulativeWidth+$(item).width()});
		$(".pagination ol:first li:first").css({"padding-left": parseInt($(".pagination ol").width() / 2)- parseInt(cumulativeWidth/2) })
		
		var padleft = parseInt($(".pagination ol").width() / 2)- parseInt(cumulativeWidth/2);
		$(".pagination ol:last").css({"height": 14 })
		if (padleft > 52)
		$(".pagination ol:last li:first").css({"padding-left": 52 })
		else
		$(".pagination ol:last li:first").css({"padding-left": parseInt($(".pagination ol").width() / 2)- parseInt(cumulativeWidth/2) })
		
		// adds class name of "last" to last item in navigation list(s) and result_set .result_item
		$(".navigation ul li:last-child:not(.navigation ul.accordion li), .result_item:last,.news_navigation dd:last, .news_result:last, .press_result:last").addClass("last");
		
		$(".back-to-top").bind("click",function(e){
			window.scrollTo(0,0);
			e.preventDefault()
			})
		});

function noflashdropdown(obj){
	//menus in no-flash dropdown navigation

	//1-based arrays for legibility
	var Menus = new Array();
	Menus[1] = new Array();
	Menus[2] = new Array();

	// set URLs for menu items here
	// Industry
	Menus[1][1]="http://lexisnexis.com/risk/financial-services.aspx";
	Menus[1][2]="http://lexisnexis.com/risk/government-law-enfrcement.aspx";
	Menus[1][3]="http://lexisnexis.com/risk/healthcare.aspx";
	Menus[1][4]="http://lexisnexis.com/risk/insurance.aspx";
	Menus[1][5]="http://lexisnexis.com/risk/retail-ecommerce.aspx";
	// Need
	Menus[2][1]="http://lexisnexis.com/risk/data-analytics.aspx";
	Menus[2][2]="http://lexisnexis.com/risk/fraud-detection-prevention.aspx";
	Menus[2][3]="http://lexisnexis.com/risk/identity-verification-authentication.aspx";
	Menus[2][4]="http://lexisnexis.com/risk/receivables-management.aspx";
	Menus[2][5]="http://lexisnexis.com/risk/screening.aspx";

	if (obj!=""){
		args = obj.split(",");
		if (Menus[args[0]][args[1]] != undefined){
			document.location = Menus[args[0]][args[1]];
		}
	}
}

// functions for new navigation added by Engauge

$('.nav_secondary li:empty').hover(transparent, transparent)
function transparent(){//this eliminates the hover state in empty cells in the navigation
    $(this).css({'background': 'transparent', 'cursor': 'default'});
}
$('.nav_secondary li:empty').html('\u00a0')//add &nbsp; to empty cells for IE to get it right

  // top navigation 
  $('.nav_primary').mouseenter(function() {
    $(this).children('a.top_link').css({'background-color': '#ED1C24'});
    $(this).children('a.top_link').css({'color': '#fff'});
//    $(this).children('a.top_link').css({'font-weight': 'bold'});
    $(this).children('.nav_secondary').stop(true, true).show();
    }
  );
  $('.nav_primary').mouseleave(function() {
    $(this).children('a.top_link').css({'background-color': 'transparent'});
    $(this).children('a.top_link').css({'color': '#000'});
    $(this).children('a.top_link').css({'font-weight': 'normal'});
    $('.nav_tertiary_description').stop(true, true).hide();
    $(this).children('.nav_secondary').stop(true, true).hide();
    }
  );  
  $('.nav_tertiary_item').mouseenter(function() {
    $('.nav_tertiary_description').stop(true, true).hide();
    if ($(this).next('.nav_tertiary_description')) {
      $(this).next('.nav_tertiary_description').stop(true, true).show();
    } else {
      $('.nav_tertiary_description').stop(true, true).hide();
    }
    return false;
  });
  $('.description_close').click(function() {
    $(this).closest('.nav_tertiary_description').stop(true, true).hide();
    return false;   
  });
    
    //hide description when hovering over product index
    $('#product_index').hover(function(){
        hideDesc()
    })
    function hideDesc()
    {
       $('.nav_tertiary_description').hide() 
    }

//make red callout in heros and navigation links for the entire area

if($(".hero_blurb").length > 0)  
     {  
         $('.hero_blurb').biggerlink();
     }
if($(".category_hero_blurb").length > 0)  
    {  
       $('.category_hero_blurb').biggerlink();
    }
if($(".nav_tertiary_item").length > 0)  
    {  
       $('.nav_tertiary_item').biggerlink();
    }
if($("#product_index").length > 0)  
    {  
        $('#product_index').biggerlink();
    }

