var testalerts = false;
function alertTest(str){
	if (testalerts){
		alert('TESTING: '+ "\n\n"+ str);
	}
}

function space2plus(str){
	while (str.indexOf(' ') > 0){
		str = str.replace(/ /,"+");
	}
	return str;
}

function lowerstr(str){
	str = str.toLowerCase();
	return str;
}

//hbx page track
function hbxExit(exitname){
	exitname = space2plus(exitname);
	alertTest('hbxExit(\''+ exitname +'\')');
	if (exitname != undefined && exitname != null && exitname != ''){
		hitbox.Set_hbLink(exitname);
	}
}

function hbxPageHit(pagename, mlc){
	pagename = space2plus(pagename);
	pagename = lowerstr(pagename);
	mlc = space2plus(mlc);
	alertTest('hbxPageHit(\''+ pagename +'\', \''+ mlc +'\')');
	if (pagename != undefined && pagename != null && pagename != '' && mlc != undefined && mlc != null && mlc != ''){
		hitbox.Set_hbPageView(pagename, mlc);
	}
}

//action tag track
function actionTag(page){
	var actionLoad = 'http://switch.atdmt.com/action/';
	document.action_tag.src = actionLoad + page;
}

//control how each tracks
function trackDVDBonus(){
	hbxPageHit('dvd+features', '/the+lookout/about/dvd+features;about/miramax/the+lookout/dvd+features');
}

function trackBlurayBonus(){
	hbxPageHit('bluray+features', '/the+lookout/about/dvd+features;about/miramax/the+lookout/dvd+features');
}

function trackSynopsis(){
	hbxPageHit('synopsis', '/the+lookout/about/story;about/miramax/the+lookout/story');
}


function trackTrailer(){
	hbxPageHit('trailer', '/the+lookout/multimedia/trailer;multimedia/miramax/the+lookout/trailer');
}

function trackPreview(){
	hbxPageHit('8+min+preview', '/the+lookout/multimedia/ext+preview;multimedia/miramax/the+lookout/ext+preview');
	actionTag('TheLookout_Preview');
}

function trackGallery(){
	hbxPageHit('gallery', '/the+lookout/multimedia/photo+galleries;multimedia/miramax/the+lookout/photo+galleries');
}

function trackCastCrew(){
	hbxPageHit('cast+crew', '/the+lookout/about/cast;about/miramax/the+lookout/cast');
}

function trackBonus(num){
	hbxPageHit('bclip'+num, '/the+lookout/multimedia/bonus+clips;multimedia/miramax/the+lookout/bonus+clips');
}

function trackOrderBluray(){
	actionTag('TheLookOut_BlurayBuynow');
	hbxExit('Exit_the+lookout_ORDER+BLURAY');
}

function trackOrderDVD(){
	actionTag('TheLookOut_BuyNow');
	hbxExit('Exit_the+lookout_ORDER+DVD');
}