// Get the absolute URL for SIFR
var theHost = jQuery.url.attr("host");
theHost = theHost + '/ofr2009';


// SIFR

var baskerville = { src: 'http://' + theHost + '/flash/baskerville.swf' };

// End get the absolute URL for SIFR

//SIFR config
// Next, activate sIFR:
sIFR.activate(baskerville);

sIFR.replace(baskerville, {
    selector: '#headerTitle ',
    css: [
			'.sIFR-root { color: #ffffff;font-size: 20px}',
			],
    wmode: 'transparent',
    fitExactly: false
});

sIFR.replace(baskerville, {
    selector: '.h1headerstyle',
    css: [
			'.sIFR-root { color: #000000;font-size: 28px;letter-spacing: -0.5;}',
			],
    wmode: 'transparent',
    fitExactly: true

});



// END SIFR



/*
* jqModal - Minimalist Modaling with jQuery
*   (http://dev.iceburg.net/jquery/jqModal/)
*
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
* 
* $Version: 03/01/2009 +r14
*/
(function($) {
    $.fn.jqm = function(o) {
        var p = {
            overlay: 90,
            overlayClass: 'jqmOverlay',
            closeClass: 'jqmClose',
            trigger: '.jqModal',
            ajax: F,
            ajaxText: '',
            target: F,
            modal: F,
            toTop: F,
            onShow: F,
            onHide: F,
            onLoad: F
        };
        return this.each(function() {
            if (this._jqm) return H[this._jqm].c = $.extend({}, H[this._jqm].c, o); s++; this._jqm = s;
            H[s] = { c: $.extend(p, $.jqm.params, o), a: F, w: $(this).addClass('jqmID' + s), s: s };
            if (p.trigger) $(this).jqmAddTrigger(p.trigger);
        });
    };

    $.fn.jqmAddClose = function(e) { return hs(this, e, 'close'); };
    $.fn.jqmAddTrigger = function(e) { return hs(this, e, 'jqmShow'); };
    $.fn.jqmShow = function(t) { return this.each(function() { t = t || window.event; $.jqm.open(this._jqm, t); }); };
    $.fn.jqmHide = function(t) { return this.each(function() { t = t || window.event; $.jqm.close(this._jqm, t) }); };

    $.jqm = {
        hash: {},
        open: function(s, t) {
            var h = H[s], c = h.c, cc = '.' + c.closeClass, z = (parseInt(h.w.css('z-index'))), z = (z > 0) ? z : 3000, o = $('<div></div>').css({ height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, 'z-index': z - 1, opacity: c.overlay / 100 }); if (h.a) return F; h.t = t; h.a = true; h.w.css('z-index', z);
            if (c.modal) { if (!A[0]) L('bind'); A.push(s); }
            else if (c.overlay > 0) h.w.jqmAddClose(o);
            else o = F;

            h.o = (o) ? o.addClass(c.overlayClass).prependTo('body') : F;
            if (ie6) { $('html,body').css({ height: '100%', width: '100%' }); if (o) { o = o.css({ position: 'absolute' })[0]; for (var y in { Top: 1, Left: 1 }) o.style.setExpression(y.toLowerCase(), "(_=(document.documentElement.scroll" + y + " || document.body.scroll" + y + "))+'px'"); } }

            if (c.ajax) {
                var r = c.target || h.w, u = c.ajax, r = (typeof r == 'string') ? $(r, h.w) : $(r), u = (u.substr(0, 1) == '@') ? $(t).attr(u.substring(1)) : u;
                r.html(c.ajaxText).load(u, function() { if (c.onLoad) c.onLoad.call(this, h); if (cc) h.w.jqmAddClose($(cc, h.w)); e(h); });
            }
            else if (cc) h.w.jqmAddClose($(cc, h.w));

            if (c.toTop && h.o) h.w.before('<span id="jqmP' + h.w[0]._jqm + '"></span>').insertAfter(h.o);
            (c.onShow) ? c.onShow(h) : h.w.show(); e(h); return F;
        },
        close: function(s) {
            var h = H[s]; if (!h.a) return F; h.a = F;
            if (A[0]) { A.pop(); if (!A[0]) L('unbind'); }
            if (h.c.toTop && h.o) $('#jqmP' + h.w[0]._jqm).after(h.w).remove();
            if (h.c.onHide) h.c.onHide(h); else { h.w.hide(); if (h.o) h.o.remove(); } return F;
        },
        params: {}
    };
    var s = 0, H = $.jqm.hash, A = [], ie6 = $.browser.msie && ($.browser.version == "6.0"), F = false,
i = $('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({ opacity: 0 }),
e = function(h) { if (ie6) if (h.o) h.o.html('<p style="width:100%;height:100%"/>').prepend(i); else if (!$('iframe.jqm', h.w)[0]) h.w.prepend(i); f(h); },
f = function(h) { try { $(':input:visible', h.w)[0].focus(); } catch (_) { } },
L = function(t) { $()[t]("keypress", m)[t]("keydown", m)[t]("mousedown", m); },
m = function(e) { var h = H[A[A.length - 1]], r = (!$(e.target).parents('.jqmID' + h.s)[0]); if (r) f(h); return !r; },
hs = function(w, t, c) {
    return w.each(function() {
        var s = this._jqm; $(t).each(function() {
            if (!this[c]) { this[c] = []; $(this).click(function() { for (var i in { jqmShow: 1, jqmHide: 1 }) for (var s in this[i]) if (H[this[i][s]]) H[this[i][s]].w[i](this); return F; }); } this[c].push(s);
        });
    });
};
})(jQuery);
/*
BEGIN - Javascript code supporting ajax functionalities.
*/

var NotesCookie = false;
var PrintCartCookie = false;
var LinkCartCookie = false;
var dldInProgress = false;
var basepath = '/';
var notesUrl = "";
var printUrl = "";
var LinksUrl = "";
var mailerUrl = "";
var feedbackUrl = "";
var downloadsUrl = "";
var exitUrl = "";
var options = false;

function establishPgId() {
    var contentClass = $('body').attr("class");
    var rg = new RegExp("pg\\d+");
    var res = rg.exec(contentClass);
    contentClass = res;
    return res;
}


function isInNotepad() {
    var pg = $('body').attr('class');
    var rg = new RegExp("pg\\d+");
    var res = rg.exec(pg);
    pg = res;
    var MyCookie = NotesCookie;
    return (MyCookie && MyCookie.indexOf('###' + pg) > -1);
}

function setNotepadPageStatus() {
    if (isInNotepad()) {
        $('li.note > #notes').text('Edit');
    }
}


function isInCart() {
    var value = PrintCartCookie;
    return (value != null && value.indexOf(establishPgId()) > -1)
}

function isInLinkCart() {
    var value = LinkCartCookie;
    return (value != false && value.indexOf(establishPgId()) > -1);
}

function setCartPageStatus() {
    if (isInCart()) {
        var el = $('li#addBasketLink > a.view');
        $('li#addBasketLink').html("");
        $('li#addBasketLink').append("<span style=\"padding-left: 15px;\">&nbsp;</span>");
        $('li#addBasketLink').append(el);
    }
}

function setLinkCartStatus() {
    if (isInLinkCart()) {
        $('li.linkBasketAdd > #linkbasket').remove();
        $('li.linkBasketAdd > span.slashsep').remove();
    }
}

function getPageFromLink(link) {
    var pg = $(link).attr('href');
    var rg = new RegExp("pg\\d+");
    var res = rg.exec(pg);
    return res;
}
function displayPopup() {
    $('body').append('<div id="dialog" class="jqmWindow"><img class="close" style="float:right;" src="' + basepath + 'images/buttons/closeX.gif" alt="Close window" title="Close window"/><div class="content"></div><div id="splash"><div class="h2headerstyle">Processing...</div><img src="' + basepath + 'images/loading.gif" /></div></div>');
    $('#dialog').jqm({ onShow: showEvent, modal: true }).jqmShow();
    $('div.jqmOverlay').click(function() { ClosePopup(); });
    $('.close').click(function() { ClosePopup(); });
}
function showEvent(hash) {
    SetSplashStatus(true);
    hash.w.show();
    $.get(options['url'], options['params'], function(data) {
        loadEvent(data);
    }
	);
}
function loadEvent(data) {
    $('#dialog > div.content').html(data);
    SetSplashStatus(false);
    if (options['CancelAction']) {
        $(options['CancelAction']).click(function() {
            ClosePopup();
            return false;
        });
        $(options['CancelAction']).show();
    }
    if (options['DoAction']) {
        $(options['DoAction']).click(submitEvent);
    }

    if (options['loadCallback']) {
        options['loadCallback']();
    }
}

function submitEvent(data) {
    SetSplashStatus(true);
    var fields = $('#dialog > div.content').find(":input");
    var inputs = getAjaxFormFields(fields);
    $.post(options['url'], inputs, function(data) {
        loadEvent(data);
        if (options['submitCallback'] != null) {
            options['submitCallback']();
        }
    });
    return false;
}
function ClosePopup() {
    $('#dialog').jqmHide();
    $('#dialog').remove();
}

function getAjaxFormFields(fields) {
    var inputs = new Object();
    inputs['ajax'] = 1;
    for (i = 0; i < fields.length; i++) {
        if (fields[i].name != '') {
            if ((fields[i].type == 'radio' || fields[i].type == 'checkbox')) {
                if (fields[i].checked) inputs[fields[i].name] = fields[i].value;
            }
            else
                inputs[fields[i].name] = fields[i].value;
        }
    }
    return inputs;
}

function SetSplashStatus(visible) {
    if (visible) {
        $('#splash').show();
        $('#dialog > div.content').hide();
    }
    else {
        $('#splash').hide();
        $('#dialog > div.content').show();
    }
}
/*
END - Javascript code supporting ajax functionalities.
*/



// FLASH FUNCTIONS


// EXTERNAL SLIDE MAP FUNCTION
function sliding() {
    if ($("#flash_lead_hp").hasClass("opn")) {
        $(".flash_top").animate({
            top: "-390px"
        }, 500, function() { $("#flash_lead_hp").removeClass("opn"); });
        $("#mapWrapper").animate({
            height: "35px"
        }, 500);
    } else {
        $(".flash_top").animate({
            top: "0px"
        }, 500, function() { $("#flash_lead_hp").addClass("opn"); });
        $("#mapWrapper").animate({
            height: "425px"
        }, 500);
    };
};

// Marketing redirect
function marketing() {
    location.href = 'http://' + theHost + '/diamond-related-businesses/'
};

// Marketing redirect
function rough() {
    location.href = 'http://' + theHost + '/rough-diamond-sales/'
};

// Marketing redirect
function exploration() {
    location.href = 'http://' + theHost + '/exploration-review/'
};

// Marketing redirect
function mining() {
    location.href = 'http://' + theHost + '/mining-review/'
};
// Case study
function casestudy() {
    location.href = 'http://' + theHost + '/2009-review/casestudy.html'
};


function production() {
    location.href = 'http://' + theHost + '/2009-review/production.html'
};

function driving() {
    location.href = 'http://' + theHost + '/2009-review/driving.html'
};

function video() {
    location.href = 'http://' + theHost + '/2009-review/everlon.html'
};

function canada() {
    location.href = 'http://' + theHost + '/mining-review/canada.html'
};

function SA() {
    location.href = 'http://' + theHost + '/mining-review/dbcm.html'
};

function botswana() {
    location.href = 'http://' + theHost + '/mining-review/debswana.html'
};

function namibia() {
    location.href = 'http://' + theHost + '/mining-review/namdeb.html'
};





// END FLASH FUNCTIONS


// ON READY

$(document).ready(function() {


    // GET COOKIED SELECTIONS FOR HOME PAGE
    //
    // Get customised selection and change nav accordingly
    if ($.cookie("choices")) {
        var returnedChoices = $.cookie("choices");
        returnedChoices = returnedChoices.split(",");
    };


    // change home page modules
    $("div.home_module").each(function(i) {
        if ($.cookie("choices")) {
            if (returnedChoices[i] != "selected") {
                $(this).hide();
            };
        };

    });


    // End get customised selection and change nav accordingly





    // TOP NAV EXPANDABLE

    $("#top_nav li.home_nav a").live("click", function() {

        if ($(this).hasClass("open")) {
            $(this).css("background-image", "url('http://" + theHost + "/images/homepage/plus.gif')")
                            .css("color", "#FFF");
            $("#top_nav li:first a").css("background-color", "#34788C");
            $("#customisePanel").animate({
                height: "0px"
            }, 500);
            $(this).removeClass("open");


        } else {
            $(this).css("background-image", "url('http://" + theHost + "/images/homepage/minus.gif')")
                            .css("color", "#4e4e4e");
            $("#top_nav li:first a").css("background-color", "#F2F2F2");
            $("#customisePanel").animate({
                height: "132px"
            }, 500);
            $(this).addClass("open");

        };
        return false;
    });

    // SUSTAINABILITY BACKGROUND

    if ($(".sustainability a").hasClass("selected")) {
        $("#top_nav").css("background-color", "#2A6070");


    };
    if (!$(".sustainability a").hasClass("selected")) {
        $("#top_nav .sustainability").hover(
                          function() {
                              $("#top_nav").css("background-color", "#2A6070");
                          },
                          function() {
                              $("#top_nav").css("background-color", "#34788C");
                          }
                        );



    };
    // END SUSTAINABILITY BACKGROUND



    // if there's a hash
    if (location.hash == "#customise") {
        $("#top_nav li:first a").addClass("open").css("background-color", "#F2F2F2").css("color", "#4e4e4e").css("background-image", "url('http://" + theHost + "/images/homepage/minus.gif')");
        $("#customisePanel").animate({
            height: "132px"
        }, 500);
    };

    // END TOP NAV EXPANDABLE









    //SEARCH BUTTON FIX

    $("input#searchSubmit").css("height", $("#searchFld").height() + 4);
    $("input#searchSubmit").val('Search');

    //END SEARCH BUTTON FIX









    //MATCH HOME PAGE MODULE HEIGHT
    //
    //$('.home_module').css("min-height","242px");
    var highestCol = new Array($('.module1').height(), $('.module2').height(), $('.module3').height(), $('.module4').height(), $('.module5').height(), $('.module6').height(), $('.module7').height(), $('.module8').height());

    highestCol.sort(function(a, b) { return a - b })


    $('.home_module').height(highestCol[7]);



    //CLICKABLE HOMEPAGE MODULES

    $("div.home_module").hover(
                  function() {
                      $(this).prepend('<div class="home_overlay"></div>');
                      $("div.home_overlay").height(highestCol[7]);
                      $("div.home_overlay").width("229px");
                      $("div.home_overlay").css({ 'position': 'absolute', 'top': '0', 'left': '0', 'z-index': '9999', 'background-color': '#CCC', 'padding-bottom': '20px' });

                  },
                  function() {
                      $(this).find("div.home_overlay").remove();
                  }
                );



    $("div.home_module").live("click", function() {
        location.href = $(this).find("a").attr("href"); ;
    });

    //END CLICKABLE HOMEPAGE MODULES



    // CUSTOMISE SLIDE DOWN HOMEPAGE

    $('#customisePanel ul li a').live("click", function() {
        if ($(this).attr('class') == "selected") {
            $(this).removeClass("selected")
        }
        else {
            $(this).addClass("selected")
        }

    });

    // save the selection in a cookie
    $("#customisePanel a[title='Save']").live("click", function() {
        var choices = new Array();
        $('#customisePanel ul li a').each(function(i) {
            if ($(this).hasClass("selected")) {
                choices[i] = "selected";
            }
            else {
                choices[i] = "notSelected";
            };
        });
        $.cookie('choices', choices, { expires: 365, path: '/' });
        // Get customised selection and change nav accordingly
        var returnedChoices = $.cookie("choices");
        returnedChoices = returnedChoices.split(",");





        // change home page modules
        $("div.home_module").each(function(i) {
            if ($.cookie("choices")) {
                if (returnedChoices[i] != "selected") {
                    $(this).hide();
                }
                else {
                    $(this).show();
                };
            };

        });
        // End get customised selection and change nav accordingly

        // close panel once saved
        $("#top_nav li:first a").css("background-color", "#34788C").css("background-image", "url('http://" + theHost + "/images/homepage/plus.gif')")
                            .css("color", "#FFF").removeClass("open");
        $("#customisePanel").animate({
            height: "0px"
        }, 500);


        return false;
    });

    //cancel selection
    // end save the selection in a cookie
    $("#customisePanel a[title='Clear']").live("click", function() {
        $('#customisePanel ul li a').removeClass("selected");
        return false;
    });

    // END CUSTOMISE SLIDE DOWN HOMEPAGE


    // Tick or untick items in home page customised section depending on saved selection

    $('#customisePanel ul li a').each(function(i) {
        if ($.cookie("choices")) {
            if (returnedChoices[i] == "selected") {
                $(this).addClass('selected');
            } else {
                $(this).removeClass('selected');
            };
        };
    });

    // End tick or untick items in home page customised section depending on saved selection



    //ADDISON DEFAULT ACCORDION

    if ($('#accordion').length != 0) {

        $('#accordion .h3headerstyle').next("div").not('#directorsContainer2').each(function() {
            $(this).attr("rel", $(this).height());
        });




        // Open first one
        $('#accordion .h3headerstyle:first').not('.finance .h3headerstyle:first').not(".governance_accordion h3:first").addClass("open");
        $('.governance_accordion .h3headerstyle:first').next("div").css("height", "0");


        $('#accordion .h3headerstyle').not('#accordion .h3headerstyle:first')
                .each(function() {
                    $(this).next("div").css("height", "0");


                });
        $('.finance .h3headerstyle:first').next("div").css("height", "0");
        $('#accordion .h3headerstyle').live("click", function() {
            accordion($(this), ".h3headerstyle");
        });
    };

    // END ADDISON DEFAULT ACCORDION


    // FINANCE ACCORDION

    if ($('#financeAccordion').length != 0) {

        $('#financeAccordion .h2headerstyle').next("div").each(function() {
            $(this).attr("rel", $(this).height());
        });


        // Open first one
        $('#financeAccordion .h2headerstyle:first').addClass("open");



        $('#financeAccordion .h2headerstyle').not('#financeAccordion .h2headerstyle:first')
                .each(function() {
                    $(this).next("div").css("height", "0");


                });
        $('#financeAccordion .h2headerstyle').live("click", function() {
            accordion($(this), ".h2headerstyle");
        });
    };

    //on hitting enter key , triggers a click event on the DIV tag
    $("a.Income").keydown(function(e) {
        if (e.keyCode == '13') {
            
            $("a.Income").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });

    $("a.BalanceSheet").keydown(function(e) {
        if (e.keyCode == '13') {
           
            $("a.BalanceSheet").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });

    $("a.CashFlows").keydown(function(e) {
        if (e.keyCode == '13') {
          
            $("a.CashFlows").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });

    $("a.Notes").keydown(function(e) {
        if (e.keyCode == '13') {
            
            $("a.Notes").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });

    $("a.Other").keydown(function(e) {
        if (e.keyCode == '13') {
           
            $("a.Other").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });

    $("a.Production").keydown(function(e) {
        if (e.keyCode == '13') {
            
            $("a.Production").trigger('click');
            //accordion($(this), $(".h3headerstyle"));
        }
    });
    //    $("a.testa").click(function(e) {
    //        e.preventDefault();
    //        alert("click");
    //        accordion($(this), $(".h3headerstyle"));
    //    });

    // Accordion function with options - pass in the object (Header) thats been clicked

    function accordion(element, header, type, index) {
        var height = element.next("div").attr('rel');

        // For scrollto
        if (type == "open") {
            if (!element.hasClass("open")) {
                element.next("div").animate({
                    height: height
                }, 500, function() { $(window).scrollTo($(header).eq(index), 800) }).prev(header).addClass("open");
            } else {
                $(window).scrollTo($(header).eq(index), 800).prev(header).addClass("open");
            };
        }
        // End for scrollto


        else {
            if (element.hasClass("open")) {
                element.next("div").animate({
                    height: "0"
                }, 500).prev(header).removeClass("open");
            } else {
                element.next("div").animate({
                    height: height
                }, 500).prev(header).addClass("open");
            };
        };
    };

    // End Accordion function with options - pass in the object (Header) thats been clicked


    // END FINANCE ACCORDION









    // LIGHTBOXES

    // CONTACT US link and form

    $('a[title="Contact us"]').live("click", function() {

        /* Contact info */
        $.facybox({ ajax: 'http://' + theHost + '/scripts/contact-us/contact-info.html' });
        return false;

        /* email form */
        /*$.facybox({ ajax: 'http://'+theHost+'/scripts/email/email_form.html' });

                   return false;
        */

    });

    // Acknowledgements link

    $('a[title="Acknowledgements"]').live("click", function() {

        /* Acknowledgements */
        $.facybox({ ajax: 'http://' + theHost + '/scripts/acknowledgements/acknowledgements.html' });
        return false;

    });

    /*             // PRINT BASKET




                 // view
    $('a[title="View print basket"]').live("click",function(){
    $.ajax({
    url: 'http://'+theHost+'/scripts/print-basket/index.asp',
    success: function(data){
    $.facybox(data);
    // select all
    $("#select_all").live("click",function(){
    if ($(".print_select").is(':checked')){
    $(".print_select").attr("checked",false);
    } else {
    $(".print_select").attr("checked",true);
    };
    $("#clear_all").css("cursor","pointer").live("click",function(){
    $(".print_select").attr("checked",false);
    });
    });
    // alternate backgrounds on print basket

                            $("#print_basket_box #print_list ul li").each(function(){
    if ($("#print_basket_box #print_list ul li").index(this)=="0"){
    $(this).css("background-color","#FFF");
    }else{
    if ($("#print_basket_box #print_list ul li").index(this)%2){
    //odd
    $(this).css("background-color","#e0e0e0");
    }else{
    //even
    $(this).css("background-color","#FFF");
    };
    };
    });
    }
    });


                    return false;


                });





    // EMAIL PAGE

                 $('a[title="Email this page"]').live("click",function(){
    $.ajax({
    url: 'http://'+theHost+'/scripts/email-page/email-page.html',
    success: function(data){
    $.facybox(data);
    $("#email_page_box").css("height",$("#email_page_box").height()+50);
    $("#email_page_form .link").html($.url.attr("source"));
    $("#email_page_box #send").mouseover(function(){$(this).css("cursor","pointer")}).live("click",function(){
    $.post("http://"+theHost+"/scripts/email-script/default.aspx", { link: $("#email_page_box .link").html(), theirEmail: $("#theirEmail").val(),yourName: $("#yourName").val(), theirName: $("#theirName").val(), yourMessage: $("#yourMessage").val(),emailPage: $("#emailPage").val()  } );

                        $("#email_page_box").html('<p style="padding-top:20px;">Thank you for reading the De Beers Financial and Operating Review 2009 online.</p><p>The form is submitted - your contact will receive an email shortly</p>');


                    });

                    }

                 });

                 return false;

                });



                // FEEDBACK

                 $('a[title="Feedback"]').live("click",function(){
    $.ajax({
    url: 'http://'+theHost+'/scripts/feed-back/feed-back.html',
    success: function(data){
    $.facybox(data);
    $("#feed_back_box").css("height",$("#feed_back_box").height());
    $("#feed_back_box .link").html($.url.attr("source"));
    $("#feed_back_box #send").mouseover(function(){$(this).css("cursor","pointer")}).live("click",function(){
    $.post("http://"+theHost+"/scripts/email-script/default.aspx", { overall_impression: $("#overall_impression").val(),compare: $("#compare").val(), lookingFor: $("#lookingFor").val(), yourMessage: $("#yourMessage").val(),emailPage: $("#emailPage").val()  } );

                        $("#feed_back_box").html('<p style="padding-top:20px;">Thank you for reading the De Beers Financial and Operating Review 2009 online.</p><p>The form is submitted.</p>');
                        
    });

                    }
    });


                    return false;


                });*/

    // Order form

    $('a#order_form').live("click", function() {
        $.ajax({
            url: 'http://' + theHost + '/scripts/order-form/order-form.html',
            success: function(data) {
                $.facybox(data);
                $("#email_page_box").css("height", $("#email_page_box").height());
                $("#email_page_box .link").html($.url.attr("source"));
                $("#email_page_box #send").mouseover(function() { $(this).css("cursor", "pointer") }).live("click", function() {
                    $("#email_page_box").html('<p style="padding-top:20px;">Thank you for reading the De Beers Financial and Operating Review 2009 online.</p><p>The form is submitted.</p>');
                    return false;
                });

            }
        });


        return false;


    });


    // close box - cancel button
    $("#facybox #cancel").live("click", function() {
        $(document).trigger('close.facybox');
    });

    // END LIGHTBOXES



    //DROP DOWN FIX



    $('#top_nav li.performance_overview ul li.item_two').mouseover(function() {
        $('#top_nav li.performance_overview ul li.item_two ul').css("display", 'block');
        $(this).find("a").css("background", "#2a6070 url('http://" + theHost + "/images/bg/nav_arrow_down_hover.gif') 4px 8px no-repeat");
    });
    $('#top_nav li.performance_overview ul li.item_two').mouseout(function() {
        $('#top_nav li.performance_overview ul li.item_two ul').css("display", "none");
        $(this).find("a").css("background", "transparent url('http://" + theHost + "/images/bg/nav_arrow_down.gif') 3px 8px no-repeat");
    });

    $('#top_nav li.performance_overview ul li.item_three').mouseover(function() {
        $('#top_nav li.performance_overview ul li.item_three ul').css("display", 'block');
        $(this).find("a").css("background", "#2a6070 url('http://" + theHost + "/images/bg/nav_arrow_down_hover.gif') 4px 8px no-repeat");
    });
    $('#top_nav li.performance_overview ul li.item_three').mouseout(function() {
        $('#top_nav li.performance_overview ul li.item_three ul').css("display", "none");
        $(this).find("a").css("background", "transparent url('http://" + theHost + "/images/bg/nav_arrow_down.gif') 3px 8px no-repeat");
    });

    $('#top_nav li.performance_overview ul li.item_four').mouseover(function() {
        $('#top_nav li.performance_overview ul li.item_four ul').css("display", 'block');
        $(this).find("a").css("background", "#2a6070 url('http://" + theHost + "/images/bg/nav_arrow_down_hover.gif') 4px 8px no-repeat");
    });
    $('#top_nav li.performance_overview ul li.item_four').mouseout(function() {
        $('#top_nav li.performance_overview ul li.item_four ul').css("display", "none");
        $(this).find("a").css("background", "transparent url('http://" + theHost + "/images/bg/nav_arrow_down.gif') 3px 8px no-repeat");
    });


    $('#top_nav li.performance_overview ul li ul').css("margin-top", "-23px");






    //END DROP DOWN FIX

    // FOOTER
    $("#footer ul li a:last").css("background-image", "none");

    // END FOOTER


    //DIRECTORS PERSONAL INFORMATION


    $("a#actiongo").click(function() {
        if ($("#personalinfo").height() == '27') {
            $("#personalinfo").animate({
                height: "250px"
            }, 500);


        } else if ($("#personalinfo").height() == '250') {
            $("#personalinfo").animate({
                height: "27px"
            }, 500);


        }
    });

    // DIRECTORS IMAGES

    // hide description
    $(".legend").hide();
    $(".legend").eq(0).addClass("show");



    $("#directorList li").live("click", function() {
        var part1 = $(this).find("img").attr("title").split("?");
        $("#largeImage img").attr("src", part1[0]);
        if ($(".legend").hasClass("displayed")) {
            $(".legend").hide().removeClass("show").removeClass("displayed");
            $(".legend").eq($("#directorList li").index(this)).height($(this).attr("title")).show().addClass("show").addClass("displayed");
        } else {
            $(".legend").hide().removeClass("show");
            $(".legend").eq($("#directorList li").index(this)).addClass("show");
        };

    });



    // Sliding Info Box


    // set the height for the container
    var directorsContainerHeight = $("#directorsContainer").height() - $(".legend").eq(0).height();

    var highestColDirector = new Array();



    $(".legend").each(function(i) {
        highestColDirector[i] = $(this).height();
    });

    highestColDirector.sort(function(a, b) { return a - b })

    //$("#directorsContainer").css("height",directorsContainerHeight+highestColDirector[16]);

    // End set the height for the container


    $(".legend").each(function() {
        // set the height for each info box
        $(this).attr("title", $(this).height());
        $(this).css("height", "0");
    });
    $("#board_info").live("click", function() {
        if ($("div.show").hasClass("displayed")) {
            $("#board_info").removeClass("greenBar").addClass("greyBar");
            $("div.show").animate({ height: "0" }, 500, function() { $(this).css("display", "none") }).removeClass("displayed");
            $(this).css("background-image", "url('../images/icons/director_plus.gif')");

        } else {
            $("#board_info").removeClass("greyBar").addClass("greenBar");

            $("div.show").animate({ height: $("div.show").attr("title") }, 500).addClass("displayed");
            $(this).css("background-image", "url('../images/icons/director_minus.gif')");
            $("#directorsContainer").css("height", "auto");
        };
    });


    $("#directorList li").hover(
              function() {
                  ground = $(this).find("img").attr("src");
                  var part2 = $(this).find("img").attr("title").split("?");
                  $(this).find("img").attr("src", part2[1]);
                  $("#directorName").html($(this).find("img").attr("alt"));

              },
              function() {
                  $(this).find("img").attr("src", ground);
              }
            );





    // END DIRECTORS IMAGES







    //DIRECTORS PERSONAL INFORMATION


    $("a#actiongo").click(function() {
        if ($("#personalinfo").height() == '27') {
            $("#personalinfo").animate({
                height: "250px"
            }, 500);


        } else if ($("#personalinfo").height() == '250') {
            $("#personalinfo").animate({
                height: "27px"
            }, 500);


        }
    });

    // EXCO IMAGES

    // hide description
    $(".legend2").hide();
    $(".legend2").eq(0).addClass("show2");



    $("#directorList2 li").live("click", function() {
        var part1 = $(this).find("img").attr("title").split("?");
        $("#largeImage2 img").attr("src", part1[0]);
        if ($(".legend2").hasClass("displayed")) {
            $(".legend2").hide().removeClass("show2").removeClass("displayed");
            $(".legend2").eq($("#directorList2 li").index(this)).height($(this).attr("title")).show().addClass("show2").addClass("displayed");
        } else {
            $(".legend2").hide().removeClass("show2");
            $(".legend2").eq($("#directorList2 li").index(this)).addClass("show2");
        };

    });

    // Sliding Info Box


    // set the height for the container
    var directorsContainerHeight = $("#directorsContainer2").height() - $(".legend2").eq(0).height();

    var highestColDirector = new Array();



    $(".legend2").each(function(i) {
        highestColDirector[i] = $(this).height();
    });

    highestColDirector.sort(function(a, b) { return a - b })



    // End set the height for the container


    $(".legend2").each(function() {
        // set the height for each info box
        $(this).attr("title", $(this).height());
        $(this).css("height", "0");
    });
    $("#board_info2").live("click", function() {
        if ($("div.show2").hasClass("displayed")) {
            $("#board_info2").removeClass("greenBar").addClass("greyBar");
            $("div.show2").animate({ height: "0" }, 500, function() { $(this).css("display", "none") }).removeClass("displayed");
            $(this).css("background", "#1F1F1F url('../images/icons/director_plus.gif') no-repeat 455px center");





        } else {
            $("#board_info2").removeClass("greyBar").addClass("greenBar");

            $("div.show2").animate({ height: $("div.show2").attr("title") }, 500).addClass("displayed");
            $(this).css("background-image", "url('../images/icons/director_minus.gif')");
            $("#directorsContainer2").css("height", "auto");
        };
    });


    $("#directorList2 li").hover(
              function() {
                  ground = $(this).find("img").attr("src");
                  var part2 = $(this).find("img").attr("title").split("?");
                  $(this).find("img").attr("src", part2[1]);
                  $("#directorName2").html($(this).find("img").attr("alt"));

              },
              function() {
                  $(this).find("img").attr("src", ground);
              }
            );


    // executive committee height minus details height

    $('#directorsContainer2').attr("title", "367");


    // end executive committe height
    //
    // paragraph of info box width


    // END EXCO IMAGES



    // BOARD DIRECTORS HIDE
    $("#board_directors").live("click", function() {

        if ($(this).hasClass("showing")) {
            $(this).removeClass("showing");
            $("#directorsContainer").slideUp("slow");
        } else {
            $(this).addClass("showing");
            $("#directorsContainer").slideDown("slow");
        };
    });

    $("#directorsContainer2").hide();
    $("#board_directors2").live("click", function() {

        if ($(this).hasClass("showing")) {
            $(this).removeClass("showing");
            $("#directorsContainer2").slideUp("slow");
        } else {
            $(this).addClass("showing");
            $("#directorsContainer2").slideDown("slow");
        };
    });


    // END BOARD DIRECTORS HIDE






    //TEXTAREA DISSAPEAR
    $("textarea").live("click", function() {
        $(this).val("");
    });
    $(":text").live("click", function() {
        $(this).val("");
    });
    // END TEXT AREA


    // VIDEO ON STRATEGIC REVIEW
    $(".video").mouseover(function() {
        $(this).css("cursor", "pointer");
    });
    $(".video").live("click", function() {
        $.facybox({ ajax: 'http://' + theHost + '/flash/video-popup.html' });

        $(".popup").css("position", "absolute").css("top", "-150px");
        return false;
    });

    // END VIDEO ON STRATEGIC REVIEW
    //AJAX FUNCTIONALITIES INITIALISERS BEGIN HERE
    var x = document.location.href.replace('http://', '');
    var y = $('div#titleHeader > a').attr('href');

    basepath = x.substring(x.indexOf('/'), x.lastIndexOf('/') + 1) + y.replace('index.html', '');
    //define urls
    notesUrl = basepath + 'scripts/notepad.asp';
    printUrl = basepath + 'scripts/print.aspx';
    linksUrl = basepath + 'scripts/links.asp';
    mailerUrl = basepath + 'scripts/email.aspx';
    exitUrl = basepath + 'scripts/exit.asp';
    feedbackUrl = basepath + 'scripts/feedback.aspx';
    downloadsUrl = basepath + 'scripts/downloads.asp';
    $('#print_all').click(function() {
        $('input.sa01').attr('checked', $(this).attr('checked'));
    });
    $('#delete_all').click(function() {
        $('input.sa02').attr('checked', $(this).attr('checked'));
    });
    $('#email_all').click(function() {
        $('input.sa03').attr('checked', $(this).attr('checked'));
    });

    $('a.printButton').click(function() {
        window.print();
    });
    PrintCartCookie = $.ajax({ type: 'GET', url: printUrl, async: false, data: { ajax: 1, ajxcmd: 'getcookie' }, dataType: 'text' }).responseText;


    $('li#emailPageLink a').click(function() {
        options = { url: mailerUrl, params: { ajax: 1, pg: getPageFromLink('li#emailPageLink a') }, CancelAction: '#CancelSend', DoAction: '.ActionSend' };
        displayPopup();
        return false;
    });

    $('li#feedbackLink a').click(function() {
        options = { url: feedbackUrl, params: { ajax: 1 }, CancelAction: '#CancelSend', DoAction: '.ActionSend' };
        displayPopup();
        return false;
    });



    // Cookie js finds if persistent cookies are enabled
    setCartPageStatus();
    ////AJAX FUNCTIONALITIES INITIALISERS END HERE

    // FEEDBACK FORM TRACKING

    $(".feedBackTrack").live("mousedown", function() {

        sc_trackFeedBack(2);
        return true;
    });

    // Email page

    $('.emailPageTrack').live("mousedown", function() {

        sc_trackEmailPage(2);
        return true;

    });
    isSafari3 = false;
    if (window.devicePixelRatio) {
        $('#searchSubmit').css('position', 'relative').css('top', '2px');
    };

});






