// prevent background image flicker in IE
try{
  document.execCommand("BackgroundImageCache", false, true);
}
catch(err){};

if(typeof window.console === 'undefined'){var console={log: function(e){/* alert(e) */}}}

BGC.track.init('UA-27434605-1');
BGC.track();

createMask = function(e){
	var d = $(document);
	$('<div class="mask">')
	.width(d.width())
	.height(d.height())
	.bind('click',function(){
		swfobject.embedSWF("flashVid");
		$(this).add(e).remove();
	}).prependTo('body')
	;
}

videoOverlay = function(vid){
	var w = $(window)
	,	vid = vid || 'ScottMultiVideoPlayer.swf'
	,	vars={
		baseUrl:'',
		swfUrl:'/swf/'
	}
	,	attrs = {id:'overlayFlash'}
	,	params = {wmode:'transparent',scale:'exactfit'}
	;
	 
	createMask('#overlayFlash');
	$('#overlayFlash').remove();
	$('<div id="overlayFlash"><div id="flashVid"></div>').css({
			top : function(){return (w.height() - 506)/2}
		,	left :  function(){return (w.width() - 648)/2}
		}).prependTo('body');
	
	$('<a href="#" id="fvclose" />').bind('click',function(){swfobject.embedSWF("flashVid"); $('.mask').add('#overlayFlash').remove();}).appendTo('#overlayFlash');
	
	swfobject.embedSWF("/swf/"+vid, "flashVid", "648", "506", "9.0.45", false, vars, params, attrs,function(e){
	});
}

$(function(){
	//Pre-disable all the <a href="#"> tags.
	$('a[href=#]').live('click',function(e){e.preventDefault();});

	$('#country').hover(function(){
	    $('.drop-menu',this).toggle();
	})
	
	$('.mainlink').parent().hover(function(){
	    $('.drop-menu',this).toggle();
	})
	
	$('#flashwarning').click(function(e){
		document.location = $('a',this)[0].href;
	}).addClass('pointer');
	
	$('#search-link').show().add('#topNavSearchLargeCloseButton').bind('click',function(){
	    $('#search-large').add('#search-link').toggle('fast');
	});
	
	$('.p-desc-img').css('margin-bottom',function(){
		//Preventing float orphans in copy.
		var x = $(this);
		return x.parent().height() - x.height();
	})
});
