function addMetaTracker(){
	$('body').prepend('<div id="meta"></div>');	
	$('#meta').append('<p><strong>Title:</strong>'+$('title').text()+'</p>');
	$('#meta').append('<p><strong>Description:</strong>'+$('meta[name="description"]').attr('content')+'</p>');
	$('#meta').append('<p><strong>Keywords:</strong>'+$('meta[name="keywords"]').attr('content')+'</p>');
}

function addFlash(){
	
	var flash = {
		"mixing":{swf:"/swf/mixing.swf",w:464,h:394,err:function(e){return false;}},
		"less-infusion-time":{swf:"/swf/less-infusion-time.swf",w:464,h:394,err:function(e){return false;}},
		"single-vial-dosing":{swf:"/swf/single-vial-dosing.swf",w:464,h:394,err:function(e){return false;}},
		"david-video":{swf:"/swf/david-video.swf",w:360,h:240,err:function(e){return false;}}
	}
	
	for(m in flash){
		if(document.getElementById(m)){
			swfobject.embedSWF(flash[m].swf,m,flash[m].w,flash[m].h,"9.0.0","/swf/expressInstall.swf",null,{wmode:"transparent"},{id:m+"-swf"},(function(f){return function(error){f.err(error);return false;}})(flash[m]));
		}
	}
}

function tracking(){
	
	$('.pdf').live('click',
		function(){	
			if('dcsMultiTrack' in window){//PDF download
				_tag.dcsVar();
				dcsMultiTrack('DCS.dcsuri',$(this).attr('href'),'WT.dl','20','WT.ti',"download: "+$(this).text(),'WT.z_pdfdownload',this.pathname,'WT.z_pdfdownloadcount','1');				
			}
			window.open(this.href);
			return false;
		}
	);
	
	$('.register').live('click',
		function(){	
			if('dcsMultiTrack' in window){//email registration
				_tag.dcsVar();
				dcsMultiTrack('WT.dl','24','WT.z_emailregistration','1');
			}
			window.open(this.href);
			return false;
		}
	);
}

/*

	search field focus/blur

*/

$("#header #header-search #search-field").live("click",function() {
	if($(this).val() == "Search") { // or we can just have a switch so if the User retypes Search it doesnt occur again.
		$(this).val("");	
	}
});

/*

if window is pretty wide, we need to have the bg image to the left in place...

slide the nav arrow around the purple subnav. if JS is init, swap the class name to 'active' or something. yo.

slide #main up on content load, fade in #text-area, fade in border-top?
*/



function slidey(){
	
	$('#bg ul').animate({'left':-1200},{duration:10000,easing:"easeInOutElastic",complete:
		function(){$('#bg ul').animate({'left':0},{duration:10000,easing:"easeInOutElastic",complete:
			function(){slidey();}
		});}
	});
}


function init(){
	if(arguments.callee.doOnce){return;}
	arguments.callee.doOnce=true;
	var ref = new ReferencePopUp();
	if('swfobject' in window){addFlash();}
	if('VideoPopUp' in window){var vpu = new VideoPopUp();}
	tracking();
	//addMetaTracker()
	//slidey();
}



if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,null);}
window.onload=init;
if('$' in window){
	$(document).ready(init);
}

