﻿secs = 2;
menuHover = false;

function resetTimer() {
    secs = 2;
}

function timer() {
    try {
        if (secs == 2) {
            clearTimeout(dd);
        }
    }
    catch (err) { }

    if (secs > 0) {
        secs -= 1;
        dd = setTimeout("timer(" + secs + ")", 1000);

        if (menuHover == true)
            secs = 2;

        if (secs == 0)
            document.getElementById('property-drop-menu').style.display = 'none';
    }
}

function recordOutboundLink(link, category, action) {
    try {
        var pageTracker = _gat._getTracker("UA-2975905-40");
        pageTracker._trackEvent(category, action);
        setTimeout('window.location = "' + link.href + '"', 100);
    } catch (err) { }
}

function recordView(link,category, action) {
    if ($(link).attr('class') == "closed") {
        try {
            var pageTracker = _gat._getTracker("UA-2975905-40");
            pageTracker._trackEvent(category, action);
        } catch (err) { }
    }
}

function imIn() {
    menuHover = true;
}

function imOut() {
    menuHover = false;
}


function showDiv(divNo) {

    document.getElementById('tab1').style.display = 'inline';
    document.getElementById('tab2').style.display = 'inline';
    document.getElementById('tab3').style.display = 'inline';
    document.getElementById('tab4').style.display = 'inline';

    document.getElementById('think-content').style.display = 'none';
    document.getElementById('cfp-content').style.display = 'none';
    document.getElementById('core-content').style.display = 'none';
    document.getElementById('vebra-content').style.display = 'none';

    switch (divNo) {
        case 1:
            document.getElementById('think-content').style.display = 'inline';
            document.getElementById('tab1').style.display = 'none';
            break;
        case 2:
            document.getElementById('cfp-content').style.display = 'inline';
            document.getElementById('tab2').style.display = 'none';
            break;
        case 3:
            document.getElementById('core-content').style.display = 'inline';
            document.getElementById('tab3').style.display = 'none';
            break;
        case 4:
            document.getElementById('vebra-content').style.display = 'inline';
            document.getElementById('tab4').style.display = 'none';
            break;
        default:
            //code to be executed if n is different from case 1 and 2
    }

}

function openPopup(url, w, h) {
    width = w;
    height = h;
    x = parseInt(screen.width / 2.0) - (width / 2.0);
    y = parseInt(screen.height / 2.0) - (height / 2.0);

    var win = window.open(url, "editorPopup", "top=" + y + ",left=" + x + ",scrollbars=no,dialog=yes,minimizable=no,modal=yes,width=" + width + ",height=" + height + ",resizable=no");
}

function deleteZoneContent(ZoneArea, PageID) {

    ret = vmcms.DeleteContent.DeleteZone(ZoneArea, PageID, OnComplete, OnTimeOut, OnError);
    return (true);

}

function OnComplete(args) {
    alert(args);
}

function OnTimeOut(args) {
    alert("ERROR : Service call timed out. Possbily content area has no content.");

}

function OnError(args) {
    alert("Error calling service method.");
}

$(document).ready(function () {

    $("div.process #content2 img").click(function () {
        $.fn.colorbox({ href: '/graphics/the_process.jpg' });
    });

    $("ul.mainMenu li").hover(function () {
        $(this).addClass("hover");
        $('ul:first', this).css('visibility', 'visible');
    }, function () {
        $(this).removeClass("hover");
        $('ul:first', this).css('visibility', 'hidden');
    });

    $('#scroll').before('<div id="scrollNav">').cycle({
        fx: 'scrollLeft',
        speed: 1000,
        timeout: 8000,
        pager: '#scrollNav'
    });

    $(".video").colorbox({ width: "528", height: "385", iframe: true, scrolling: false });
    $(".coverage").colorbox();
    $(".mapLink").colorbox({ width: "580px", height: "580px", iframe: true });
    $(".colorbox").colorbox({ width: "600", height: "400", iframe: true, scrolling: false });

});

$(document).ready(function () {
    $("div.item h3").addClass("closed").next("div").css({ display: "none" });
    $("div.item h3").click(function () {
        $(this).toggleClass("closed").toggleClass("open").next("div").slideToggle();
    });
    var i = 0;
    $("div.children ul li").each(function (i) {
        i++;
        if (i > 3) {
            i = 1;
        }
        $(this).addClass("item" + i);
    });
});

