$(document).ready(function() { 
    
    // activate the modal overlay
    
    $('#modal').jqm({ ajax: '@href',
                      trigger: 'a.modal_trigger',
                      target: '#remote_content' 
    });
    
    // remove the last border from the global nav
    $("#global_nav li:last a").css("border","none");
    
    // replace the no flash button with a text link
    
    var noflashCopy = $("#noflash_link input[@type='submit']").val()
    $("#noflash_copy").append(noflashCopy);
    $("#noflash_copy").click(function(){
        $("#noflash_link").submit();  
    });
    $("#noflash_copy").css({cursor: "pointer",
                            textDecoration: "underline"});
    $("#noflash_link").hide();
                      
    // generate popups for global nav items
                      
    $("a[@rel=popup]").click(function(){
           popupWindow = window.open(this.href,this.title,'menu=no,toolbar=no,width=500px,height=600,scrollbars=1,resizable=0,directories=no,location=no,screenX=0,screenY=0,top=48,left=48');
           popupWindow.focus()
           return false;
    })

    $("a[@rel=external]").click(function(){
           popupWindow = window.open(this.href,this.title,'width=800,height=600,toolbar=yes,status=yes,location=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes');
           popupWindow.focus()
           return false;
    })
    
    // submit user's flash version with the FAQ form
    
    var flash = deconcept.SWFObjectUtil.getPlayerVersion();
    $("input#flash").val(flash.major + '.' + flash.minor + '.' + flash.rev);
    
    // Popup window close button
    
    $("#popup_close_button").css("cursor","pointer");
    
    $("#popup_close_button").click(function() {
        window.close();
    });
    
    // Un-comment for prechecked Opt-ins
    
    /*
        if (!$("div").hasClass("error")) {
            $("input[@name=primary_opt_in]").attr("checked", "checked");
        }
    */
    
});   

function openWindow(link) {
  window.open(link, '_blank', 'width=800,height=600,toolbar=yes,status=yes,location=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes');
}    

function spintrack() {
	var s=s_gi(s_account);
	s.linkTrackVars='events';
	s.linkTrackEvents='event15';
	s.events='event15';
	s.tl(this, 'o', 'Sweeps | Main Content | Spin Button');
}    