/*  File: basic.js          */
/*  By:   Jeremy Tredway    */
/*  Ver:  2008-04-30        */

// onload routines
$j(function($) {

    $("#q, #news_email, #cta1_tbEmail, #news_extra #tbEmail").focus(function() { $(this).attr("value", ""); });
    $("a[@href^=http]").each(function() {
    if (this.href.indexOf(location.hostname) == -1 &&
        this.hostname != 'archives.itbusinessedge.com' &&
        this.hostname != 'jobs.itbusinessedge.com' &&
        this.hostname != 'www.ctoedge.com' &&
        this.hostname != 'www.securityedge.com' &&
        this.hostname != 'www.unifiedcommunicationsedge.com' &&
        this.hostname != 'www.datacenter-edge.com' &&
        this.hostname != 'www.networksecurityedge.com' ) {
            $(this).addClass('external').attr('target', '_blank');
        }
    });
    $("a img").parent().removeClass('external');
    if ($(".tabs_list").length > 0) {
        $(".tabs_list").tabs();
    }

    $(".toggle").find(".toggle_detail").css({ "display": "none" }).end().find(".toggle_trigger a").addClass("toggle_off");
    $(".toggle").find(".toggle_trigger a").each(function() {
        $(this).click(function() {
            $(this).toggleClass('toggle_off');
            $(this).parent().parent().find(".toggle_detail").toggle();
            return false;
        });
    });

    $(".mod_blog").find(".blog_toggle_detail").css({ "display": "none" }).end().find(".blog_toggle_trigger a").addClass("toggle_off");
    $(".mod_blog").find(".blog_toggle_trigger a").each(function() {
        $(this).click(function() {
            $(this).toggleClass('toggle_off');
            $(this).parent().parent().parent().find(".blog_toggle_detail").toggle();
            return false;
        });
    });

    $(".mod_topic").find(".topic_toggle_detail").css({ "display": "none" }).end().find(".topic_toggle_trigger a").addClass("toggle_off");
    $(".mod_topic").find(".topic_toggle_trigger a").each(function() {
        $(this).click(function() {
            $(this).toggleClass('toggle_off');
            $(this).parent().parent().parent().find(".topic_toggle_detail").toggle();
            return false;
        });
    });

    $(".mod_nav .browse").css({ "display": "block" });
    $(".mod_nav").find(".browse").each(function() {
        $(this).click(function() {
            $(".browse_nav").hide();
            $(this).parent().find(".browse_nav").show();
            $("html > *, .tabs_list a, .toggle_trigger a").click(function() { $(".browse_nav").hide(); });
            return false;
        });
    });

});

//
// Legacy
//
function popup(url, toolbar) {
    var boxwidth = 990;
    var boxheight = 520;
    var winl = (screen.width - boxwidth) / 2;
    var wint = (screen.height - boxheight) / 2;

    popupWindow = open(url, 'windowName', 'toolbar=' + toolbar + ',scrollbars=yes,resizable=yes,top=' + wint + ',left=' + winl + ',width=' + boxwidth + ',height=' + boxheight + '');
    if (popupWindow.opener == null) popupWindow.opener = self;
}

// Break out of iFrame for Hotmail, iframe on Thankyou page
if(parent.frames.length!=0)
    window.top.location.replace(document.location.href)
