
$(document).ready(function () {


    // ---- Slidedeck -------------------------------------------------------------------------------------------------

    /*var $HomeDeck = $('.slidedeck').slidedeck({
        start: 1,
        autoPlay: true,
        cycle: true
    });
    $('#slidedeck_frame .index').prepend('0');*/
    $('.easyAccordion').easyAccordion({
        autoStart: true,
        slideInterval: 4000
    });


    // ---- Tabs ----------------------------------------------------------------------------------------------------------

    $(".tab-content").hide(); // Hide all content
    $("ul.tabs li:first").addClass("active").show(); // Activate first tab
    $(".tab-content:first").show(); // Show first tab content
    $("ul.tabs li").click(function () { // onClick
        $("ul.tabs li").removeClass("active"); // Remove any "active" class
        $(this).addClass("active"); // Add "active" class to selected tab
        $(".tab-content").hide(); // Hide all tab content
        var activeTab = $(this).find("a").attr("href"); // Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); // Fade in the active content
        return false; // Prevent the default link behaviour
    });


    // ---- ListColumnizer ----------------------------------------------------------------------------------------------------------

    jQuery.fn.columnizeList = function () {
        $(this).addClass("col1").clone().removeClass("col1").addClass("col2").insertAfter(this);
        $(this).parent().find(".col1 li:odd").remove();
        $(this).parent().find(".col2 li:even").remove();

    };
    $("#tab1 .columnizeList").columnizeList();
    $("#tab2 .columnizeList").columnizeList();
    $("#newsletter-side ul").columnizeList();
    $("#australia ul").columnizeList();
    $(".columnizeList,#australia ul").find('li:first').addClass('first');
    $(".columnizeList,#australia ul").find('li:last').addClass('last');



    // ---- Search ----------------------------------------------------------------------------------------------------------

    $('.menu-search div').hide();
    $('.menu-search').hover(function () {
        $('.menu-search div').fadeIn('fast');
    }, function () {
        $('.menu-search div').fadeOut('fast');
    })


    // ---- PreFilled   ----------------------------------------------------------------------------------------------------------

    $.fn.preFilled = function () {
        $(this).focus(function () {
            if (this.value == this.defaultValue) {
                this.value = "";
            }
        }).blur(function () {
            if (!this.value.length) {
                this.value = this.defaultValue;
            }
        });
    };

    $("#email-side").preFilled();


    // ---- Clickable Boxes   ----------------------------------------------------------------------------------------------------------

    $(".clickable").click(function () {
        window.location = $(this).find("a:first").attr("href");
    });


    // ---- Main Menu   ----------------------------------------------------------------------------------------------------------

    $('#main-menu > li ul').each(function () {
        $(this).parent('li').hover(function () {
            $(this).addClass('hover');
        }, function () {
            $(this).removeClass('hover');
        });
    });


    $('#main-menu > li a').not('#main-menu li li a').addClass('submenu').wrapInner('<span />');
	$('#side-menu span').next().addClass('subnav');
});

var baseText = null;

function showPopup(h,w) 
{
	var popUp = document.getElementById("popupcontent");
    popUp.style.top = "80px";
	popUp.style.left = "20%";
	popUp.style.width = w + "px";
	popUp.style.height = h + "px";
	if (baseText == null) baseText = popUp.innerHTML;
	popUp.innerHTML = baseText  + "<div id=\"statusbar\"><button type=\"button\" onclick=\"hidePopup(); return false;\"> Close </button></div>";
	var sbar = document.getElementById("statusbar");
	sbar.style.marginTop = (parseInt(h)-470) + "px";
	popUp.style.visibility = "visible";
		
} 

function hidePopup()
{	
	var popUp = document.getElementById("popupcontent");
	if (baseText == null) baseText = popUp.innerHTML;
	popUp.style.visibility = "hidden";
	return false;
}

function register(filen) 
{
    var msg = confirm("Do you want to register to receive all future advisories?");


    if (msg == true) {
        window.location = '../Account/NewRegister.aspx';
    }
    else {
        window.open('./' + filen, '_blank');
    }

}

var confirmText = null;

function showConfirm(h, w, filen) {
    var confirm = document.getElementById("confirmbox");
    var advfile = filen;
    confirm.style.top = "100px";
    confirm.style.left = "35%";
    confirm.style.width = w + "px";
    confirm.style.height = h + "px";
    if (confirmText == null) confirmText = confirm.innerHTML;
    confirm.innerHTML = confirmText + "<div id=\"statebar\"><p><input type=\"button\" value=\"Yes\" onclick=\"yesPopup('" + advfile + "'); return false;\">  </input>" +
                        "<input type=\"button\" value=\"No\" onclick=\"noPopup('"+advfile+"'); \">  </input></p></div>";
    var sar = document.getElementById("statebar");
    sar.style.marginTop = (parseInt(h)-60) + "px";
    confirm.style.visibility = "visible";

}

function yesPopup(filen) {
    var confirm = document.getElementById("confirmbox");
    if (confirmText == null) confirmText = popUp.innerHTML;
    confirm.style.visibility = "hidden";
    window.location = '../Advisory/NewRegister.aspx?id='+filen;
    return false;
}

function noPopup(filen) {
    var confirm = document.getElementById("confirmbox");
    if (confirmText == null) confirmText = popUp.innerHTML;
    confirm.style.visibility = "hidden";
    window.open('./' + filen, '_blank');
    return false;
}





   

    



