$(document).ready(function() { 
    
    // activate the modal overlay
    
    $('#modal').jqm({ ajax: '@href',
                      trigger: 'a.modal_trigger',
                      target: '#remote_content' 
    });
	
	
	if ($("div").hasClass("zippy_buttons")) {
		document.getElementById("zippy_button").style.display='none';
	}
    
    // 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=widget_popup]").click(function(){
           popupWindow = window.open(this.href,this.title,'menu=no,toolbar=no,width=700px,height=470,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();
    });

	if (document.forms.form0) {
			$("form[@name=form0]").addClass("no_thanks_form"); 
	}    
    // Un-comment for prechecked Opt-ins
	/*
	if (document.forms.tb2) {
		 if (document.forms.tb2.opt_in_2.value == 'other'){
			$("div#opt_in_2_other").css({display: "block"});
		 }
		 else{
			$("div#opt_in_2_other").css({display: "none"}); 
			 }
	}
	*/
    if (!$("div").hasClass("error")) {
        $("input[@name=primary_opt_in]").attr("checked", "checked");
    }
	
    $("select[@name=opt_in_2]").change(function() {
		 if (document.forms.tb2.opt_in_2.value == 'other'){
         	$("div#opt_in_2_other").css({display: "block"});
		}
	 	else{
			$("div#opt_in_2_other").css({display: "none"}); 
			document.forms.tb2.opt_in_2_other.value = ''
		 }
    });	
    
    $("#div-show_question_8").parent().css("padding-bottom", "0");
    
});   

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 popIt(link) {
	popupWindow=window.open(link,'popup','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();	
	
}

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');
}    