//= require <jquery>
//= require "plugins/jquery.easing.1.3"
//= require "plugins/jquery.flash"
//= require "plugins/jquery.metadata"
//= require "bk/utilities"

// setup namespace
var BK = BK || {};

// debug non-implemented links
$.fn.debug_links = function() {
  return this.each(function() {
		$(this).click(function() {
			alert("Sorry, this link is not implemented yet.");
			return false;
		});
	});
};

// WebTrends tracking for pdf and other downloadable files
$.fn.track_file_outbound = function() {
	return this.each(function() {
	$(this).click(function() {
			dcsMultiTrack('DCS.dcsuri', $(this).attr("href"));
			return true;
		});
	});
};

function track_video_start(urlPath) {
	dcsMultiTrack('DCS.dcsuri', urlPath + '/start');
}

function track_video_complete(urlPath) {
	dcsMultiTrack('DCS.dcsuri', urlPath + '/complete');
}

function track_restaurant_search(restaurantLoc) {
	dcsMultiTrack('DCS.dcsuri', CulturePrefix + 'restaurant-locator/index.html?loc=' + restaurantLoc);
}

// Functions applied on page load and on the inserted DOM in any XHR request,
// don't forget to scope the Selectors.
BK.onload = function() {
	var scope = scope || $(document);

	$('a[href=BK_TEST]', scope).debug_links();
	$('a[href^=http],a[href$=3g2],a[href$=3gp],a[href$=asf],a[href$=asx],a[href$=mkv],a[href$=qt],a[href$=rm],a[href$=swf],a[href$=vob],a[href$=flv],a[href$=wmv],a[href$=mpg],a[href$=mpeg],a[href$=mp4],a[href$=avi],a[href$=mov],a[href$=pdf],a[href$=zip],a[href$=csv],a[href$=doc],a[href$=xls],a[href$=ppt],a[href$=docx],a[href$=xlsx],a[href$=pptx]', scope).track_file_outbound();
};

// Functions only applied on DOM ready, includes BK.onload.
BK.load_once = function() {
	BK.onload();
	
};

// global OnDOMReady()
$(document).ready(function() {
	BK.load_once();
});

//write javascript.css link
var jsCss = document.createElement('link');
jsCss.rel = 'stylesheet';
jsCss.href = '/css/javascript.css';
jsCss.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(jsCss);