//BCNTV Global Object
 if (typeof BCNTV == "undefined" || !BCNTV) {
    var BCNTV = {};
}

BCNTV.mainNavigation = {
    state: null,
    init: function() {
		$("div#mainNav li").mouseenter(function() {
			$(this).children("ul").show();
			$(this).children("a").addClass("selected");
		}).mouseleave(function() {
			$(this).children("ul").hide();
			$(this).children("a").removeClass("selected");
		});
		
		// Add right-arrow pointers to all second-level menus with child menus
		$.each($("#mainNav ul.secondCMSListMenuUL li"), function() {
			if($(this).children("ul").length > 0) {
				$(this).children("a").addClass('submenu');
			}
		});
		
		// Adjust 'top' positions of third-level menus
		$("#mainNav ul.secondCMSListMenuUL li").mouseenter(function() {
			$(this).children("ul").css('top', $(this).position().top);
		});
		
		// Adjust 'left' positions of third-level menus
		$.each($("#mainNav ul.thirdCMSListMenuUL"), function() {
			$(this).css('left', $(this).parent().parent().width()-10);
		});
	}
}

BCNTV.util = {
    hasConsole: false,
    writeLog: true,
    init: function(){
        if (window.console) {
            this.hasConsole = true;
        }
    },
    log: function(msg){
        if(this.writeLog == true){
            if(this.hasConsole == true){
                window.console.log(msg);
            }
            else{
                alert(msg);
            }        
        }
    },
    rand:function(){
        return Math.floor(Math.random()*100000);
    },
    cufon:function() {
    	Cufon.replace('h1');
    	Cufon.replace('h2');
		Cufon.replace('h3');
		Cufon.replace('h4');
    	//Cufon.replace('div#mainNav');
    }
}

BCNTV.ie = {
    pngSupport:function(){
        $(document).pngFix();        
    }
};



//jQuery Ready
$(document).ready(function(){
    if ($.browser.msie && $.browser.version == 6){
        BCNTV.ie.pngSupport();
    }
    
    // BCNTV Utility Functions
    BCNTV.util.init();
	BCNTV.util.cufon();
	
	// BCNTV Main Navigation
	BCNTV.mainNavigation.init();
    
    // Toggle logging on and off globally here.
    BCNTV.util.writeLog = false;
      
});







