$(document).ready(function () {

    // Open new window settings
    $("a[rel='external']").attr("target", "_blank");


    var b = $("#bin").attr("value");
    if (b != undefined) {
        //add BIN link
        $('a[href*="www.visa-assurances.fr"]').each(function () {
            var url = $(this).attr("href") + "?bin=" + b;
            $(this).attr("href", url);
        });
        //add BIN link
        $('a[href*="www.visaassurances.com"]').each(function () {
            var url = $(this).attr("href") + "?bin=" + b;
            $(this).attr("href", url);
        });
    }

    // Pod hover settings

    $(".pod").hoverIntent({
        sensitivity: 3,
        interval: 100,
        over: makeTall,
        timeout: 500,
        out: makeShort
    });

    $(".homePodsInf .pod").hoverIntent({
        sensitivity: 3,
        interval: 100,
        over: makeTallInf,
        timeout: 500,
        out: makeShortInf
    });

    $(".show").addClass('showArmed'); // Add class to make hover work



	$("a[rel='login']").click(function () {
        $(this).attr("href", $(this).attr("href") + "?url=" + encodeURIComponent(document.location));
    });

    // ColorBox settings
    
    $("span.helpInfo1").colorbox({
    width: "650",
    inline: true,
    href:".extraInfo1",
    rel: "nofollow",
    opacity: "0.4",
    onCleanup: function () { if ($.browser.msie && $.browser.version.substr(0, 1) == 8) { $('.main-css')[0].href = $('.main-css')[0].href; } }
    });

    $("span.helpInfo2").colorbox({
    width: "650",
    inline: true,
    href:".extraInfo2",
    rel: "nofollow",
    opacity: "0.4",
    onCleanup: function () { if ($.browser.msie && $.browser.version.substr(0, 1) == 8) { $('.main-css')[0].href = $('.main-css')[0].href; } }
    });
    
    
    

    //	$("a[rel='login']").colorbox({width:"650", height:"300", iframe:true, scrolling:false, current:"{current} of {total}", opacity:"0.6"});
/*
    $("a[rel='login']").colorbox({
        width: "650",
        height: "300",
        iframe: true,
        scrolling: false,
        title: false,
        fixed: true,
        rel: "nofollow",
        opacity: "0.6",
        onCleanup: function () { if ($.browser.msie && $.browser.version.substr(0, 1) == 8) { $('.main-css')[0].href = $('.main-css')[0].href; } }
    });
*/

    // Shim to clear wide advantages button

    $(".advButton").before("<p style='margin:0 0 30px 0;'>&nbsp;</p>");


    // Carousels

    //$(".carousel").jcarousel();
    var carouselData = $(".carousel");
    if (carouselData != null && carouselData != undefined && carouselData.length > 0) {
        carouselData.jcarousel();
    }

    // Hide fields on focus - normal

    $('input.txt').each(function () {
        var defaultVal = $(this).attr('title');
        $(this).focus(function () {
            if ($(this).val() == defaultVal) {
                $(this).removeClass('labelHighlight').val('');
            }
        })
			    .blur(function () {
			        if ($(this).val() == '') {
			            $(this).addClass('labelHighlight').val(defaultVal);
			        }
			    })
			    .blur().addClass('labelHighlight');
    });
    $('form').submit(function () {
        $('input.txt').each(function () {
            var defaultVal = $(this).attr('title');
            if ($(this).val() == defaultVal) {
                $(this).val('');
            }
        });
    });


    // swap infinite grey images


    $(".infPodWide, .infPod").hover(
			  function () {
			      $(this).children(".offerImgLink").children(".offerGrey").fadeOut(1000);
			  },
			  function () {
			      $(this).children(".offerImgLink").children(".offerGrey").fadeIn(1000);
			  }
			);



    // Nav show/hide

    $(".extraNavShow").addClass("extraNavShowArmed");

    $(".extraNavReveal").hide();

    $(".extraNavShow").click(function () {
        $(this).next(".extraNavReveal").slideToggle(50);
        $(this).toggleClass('extraNavShowOn');
    });


    // Reflections on carousel (if needed)

    // $(".carousel img").reflect();
    
    
    
    
    $(".calEventsTable th:first-child").addClass("firstTh");
    $(".calEventsTable th:last-child").addClass("lastTh");

    $(".calEventsTable table td:first-child").addClass("firstTd");
    $(".calEventsTable table td:last-child").addClass("lastTd");

  
    
    
    //add in colorbox popup
    $(".lightboxImage").colorbox({ rel: 'lightboxImage', photo: 'true' });



$(".ddlNavigation ul").hide();

    $(".ddlNavigationList").hover(
        function() {
            $(this).children("ul").show();
        }, function() {
            $(this).children("ul").hide();
        }); 







});        // end of document ready



		// Functions for pod hover

		function makeTall(){  
					
					$(this).children(".show").animate({"height":137},200);
					$(this).children(".show").addClass('activeTall');	
					
					}
					
		function makeTallInf(){  
					
					$(this).children(".show").animate({"height":120},200);
					$(this).children(".show").addClass('activeTall');	
					
					}

		function makeShort(){ 
					
					$(this).children(".show").animate({"height":37},200);
					$(this).children(".show").removeClass('activeTall');	
					
					}

		function makeShortInf(){ 
					
					$(this).children(".show").animate({"height":10},200);
					$(this).children(".show").removeClass('activeTall');	
					
					}

		// Cufon settings

 //       Cufon.replace('.topNav a', {hover: true});
 //       Cufon.replace('.button');
 //       Cufon.replace('.buttonTest');
 //       Cufon.replace('h1');
 //       Cufon.replace('h2', {hover: true});
 //       Cufon.replace('.prizes h2');
 //       Cufon.replace('.prizes h3');
 //		Cufon.replace('.show a');
 //		Cufon.replace('.hlBox p');
 //		Cufon.replace('.st_sharethis_custom');
 //		Cufon.replace('.stTitle');
 //		Cufon.replace('.pod label');
 //		Cufon.replace('.hpBannerPromo p');
		


