//= 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 and outbound links
$.fn.track_file_outbound = function() {
	return this.each(function() {
	$(this).click(function() {
			try{
			    //dcsMultiTrack('DCS.dcsuri', $(this).attr("href"));
			    pageTracker._trackEvent(CulturePrefix + 'file_link', 'download', 'download/' + $(this).attr("href"));
			}
            catch(e){}
			return true;
		});
	});
};
// WebTrends tracking for video start
function track_video_start(urlPath) {
    try{
        //dcsMultiTrack('DCS.dcsuri', urlPath + '/start');
        pageTracker._trackEvent(CulturePrefix + 'video/' + document.title, 'start', urlPath);
    }
    catch(e){}
}
// WebTrends tracking for video complete
function track_video_complete(urlPath) {
    try{
        //dcsMultiTrack('DCS.dcsuri', urlPath + '/complete');
        pageTracker._trackEvent(CulturePrefix + 'video/' + document.title, 'complete', urlPath);
    }
    catch(e){}
}

// 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);

//write javascript.css link
//var jsCss = document.createElement('link');
//jsCss.rel = 'stylesheet';
//jsCss.href = '/page_templates/cultures' + CulturePrefix + 'css/javascript.css';
//jsCss.type = 'text/css';
//document.getElementsByTagName('head')[0].appendChild(jsCss);

if (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent) &&
	document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule) {
	DD_belatedPNG.fix('img, h1, h2, h3, h4, h5, h6, ul, li, a, p, div, span, input, td, th, fieldset');
}

$('<img src="/images/nav/bkg.menubar.png" />');
$('<img src="/cms/en/us/cms_out/digital_assets/graphics/pages/bkg.btn-navtab.png" />');

var culture = CulturePrefix.split('/');
BK.local = BK[culture[1]][culture[2]];

