// Init tc_home
// Pre-DOM: Load Global resource files/libraries that are NOT dependent on the DOM being ready
// Load js
init.preload.js('app/playlist.js');
init.preload.js('lib/jquery/plugin/jquery.validate.js');
init.preload.js('lib/zeroclipboard.js');
init.preload.js('app/google-analytics.js');

// Load css
init.preload.css('http://assets.resultspage.com/autosuggest/autosuggest.css', 'screen', true);
init.preload.css('landing.css');
init.preload.css('sIFR-screen.css', 'screen');
init.preload.css('sIFR-print.css', 'print');
init.preload.js('lib/sifr.js');
init.preload.js('lib/sifr-config.js');
init.preload.js('app/landing.js');
init.preload.js('app/episode.js');
init.preload.js('app/VideoPlayerWidget.js');
init.preload.js('http://www.google.com/jsapi?key=ABQIAAAAX7k1ruZcsl_gLAfK1O23ZxQgu_kS7LEKzqaYNjQvP583S7mG8BQQxq9RuSvRNxn5h0b8XMwLtc0niQ', true);
init.preload.js('app/maps/google.js');
init.preload.js('lib/maps/mapiconmaker_packed.js');
init.preload.js('app/maps/markerfactory.js');
init.preload.js('app/maps/staticmap.js');
init.preload.js('app/social.js');
if (browser.msie7) {
  init.preload.css('ie7.css');
} else if (browser.msie6) {
  init.preload.css('ie6.css');
  init.preload.js('lib/supersleight.js'); // IE 6 only
}

// Post-DOM: Load all js files/libraries that ARE dependent on the DOM being ready
function moduleReady(){ // include items here that are not Global
/* 2011-07-29 MLIU - JS to add click tracking to lead module */
$('body').bind('click', function(el) {
    /* for debugging el.preventDefault(); */
    if ($(el.target).parents().is('#top-module')) {
        var module = "Lead Promo Box";
        var href = el.target.href;
        var title = el.target.title;
        var rel = el.target.rel;
        var origin = window.location;
        // for debugging
        //console.log(module + ", " + href + ", " + title + ", " + rel + ", " + origin);
        SNI.TC.Omniture.omModuleTrack(module, title, rel, href, origin, '');
    }
});
    
/* 2011-02-18 MLIU - Javascript to contain Facebook Like button functionality */
	window.fbAsyncInit = function() {
        FB.init({
            appId  : SNI.Social.FB.fbAdminID,
            status : true, // check login status
            cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true,  // parse XFBML
            channelUrl : 'http://www.travelchannel.com/static_files/assets/html/fbchannel.html'
        });
        init_event_catchers();
	};
  
	(function() {
		var e = document.createElement('script'); e.async = true;
		e.src = document.location.protocol +
		'//connect.facebook.net/en_US/all.js#xfbml=1';
		document.getElementById('fb-root').appendChild(e);
	}());

	init_event_catchers = function() {
		FB.Event.subscribe('edge.create', function(href, widget) {
            omniClickEvent(true, "Daily Escape:FB Like:" + mdManager.getParameter("title"), "event11");
		});
		FB.Event.subscribe('edge.remove', function(href, widget) {
			// placeholder
		});
	}
}
