// START: Save/Share A/B Testing
function init_save_share() {
	var ss_recipes = new Array("default","sidebar","inline_small","inline_big","bottom","strip");
	var ss_ids = new Array("saveArticle","saveshare-sidebar","saveshare-inline_small-wrapper","saveshare-inline_big-wrapper","saveshare-bottom-wrapper","saveshare-strip-wrapper");

	if ( typeof saveshare_recipe == "undefined" ) {
		saveshare_recipe = 'default';
	}

	var ss_css_output = '<style>\n';
	for (var i=0;i<ss_recipes.length;i++) {
		var recipe = ss_recipes[i];
		var id = ss_ids[i];
		if (recipe == saveshare_recipe)
			ss_css_output += '#'+id+' {display:block;}\n';
		else
			ss_css_output += '#'+id+' {display:none;}\n';
	}
	ss_css_output += '</style>\n';

	document.write(ss_css_output);
}
function finish_save_share() {
	// document.observe('dom:loaded',function() {
	var ss_recipes = new Array("default","sidebar","inline_small","inline_big","bottom","strip");
	var ss_ids = new Array("saveArticle","saveshare-sidebar","saveshare-inline_small-wrapper","saveshare-inline_big-wrapper","saveshare-bottom-wrapper","saveshare-strip-wrapper");

		var p=null; var c=null; var s=null;

		if ( typeof saveshare_recipe == "undefined" ) {
			saveshare_recipe = 'default';
		}

		// Note, this must be called before the inline ad is placed at the bottom of the page
		inlineAdClearance = getInlineAdClearance(saveshare_recipe);

		// for large icons
		if ( saveshare_recipe.match(/^(inline|bottom)/) ) {
			hideContent('digg');
			hideContent('facebook');

			p = document.getElementById('wp-diggthis-'+saveshare_recipe) ;
			c = document.getElementById('wp-diggthis') ;
			//c.style.display = 'block';
			s = document.getElementById('wp-diggthis-'+saveshare_recipe+'-placeholder') ;
			insertContentAfterSibling(p,c,s);

			p = document.getElementById('wp-facebook-'+saveshare_recipe) ;
			c = document.getElementById('wp-facebook') ;
			//c.style.display = 'block';
			s = document.getElementById('wp-facebook-'+saveshare_recipe+'-placeholder') ;
			insertContentAfterSibling(p,c,s);
		}

		// for inline ad
		if ( saveshare_recipe.match(/^inline/) ) {
			var saveshare_clearance = getSaveShareClearance(saveshare_recipe);
			var inlineSaveShareParent = document.getElementById('body_after_content_column') ;
			var inlineSaveShareSibling = getAvailableTagInContainer('p','body_after_content_column','content_column_table',saveshare_clearance);
			if ( inlineSaveShareSibling ) {
				if ( saveshare_recipe.match(/^inline_small/) ) {
					var inlineSaveShareSmall = document.getElementById('saveshare-inline_small-wrapper') ;
					insertContentAfterSibling(document.getElementById('body_after_content_column'),inlineSaveShareSmall,inlineSaveShareSibling );
				} else if ( saveshare_recipe.match(/^inline_big/) ) {
					var inlineSaveShareBig = document.getElementById('saveshare-inline_big-wrapper')
					insertContentAfterSibling(document.getElementById('body_after_content_column'),inlineSaveShareBig,inlineSaveShareSibling );
				}
				if (typeof otto!='undefined'){
					mboxFactoryDefault.addOnLoad(function(){
						otto.mboxUpdate('wp_saveshare_update','inline_ss=yes')
					});
				}
			} else {
				document.getElementById('saveshare-'+saveshare_recipe+'-wrapper').style.display = 'none';
				if (typeof otto!='undefined'){
				mboxFactoryDefault.addOnLoad(function(){
						otto.mboxUpdate('wp_saveshare_update','inline_ss=no')
					});
				}
			}
		}

		// for resetting text
		if ( saveshare_recipe.match(/^(strip)/) ) {
			var services = new Array('digg','facebook','reddit','newsvine','myspace','delicious','newstrust','stumble','furl','google','rojo','yahoo');
			var service_icons = new Array('digg.gif','facebook.gif','reddit.gif','icon_newsvine.gif','myspace.gif','delicious.gif','icon_newstrust.gif','icon_stumble_upon.gif','furl.gif','google.gif','rojo.gif','yahoo.gif');
			for (var i=0; i<services.length; i++) {
				resetLinkTextWithImage(services[i],service_icons[i]);
			}
		}

		// for moving bank of icons
		if ( saveshare_recipe.match(/^(sidebar|inline_big|bottom|strip)/) ) {
			p = document.getElementById('bookmark-'+saveshare_recipe) ;
			c = document.getElementById('bookmark-content') ;
			s = document.getElementById('bookmark-'+saveshare_recipe+'-placeholder') ;
			insertContentAfterSibling(p,c,s);
		}
	// });
}
function getSaveShareClearance(recipe){
	var clearance = 0 ;

	if ( recipe.match(/^inline/) ) {
		if ( typeof COMMENTS_ACTIVE == 'boolean' && COMMENTS_ACTIVE )
			clearance += 75 ;
		else
			clearance += 50 ;
	}

	return clearance;
}
function getInlineAdClearance(recipe){
	var clearance = 200 ;
	clearance += getSaveShareClearance(recipe);

	if ( recipe.match(/^inline/) ) {
		clearance += 30 + document.getElementById('saveshare-'+recipe+'-wrapper').offsetHeight ;
	}

	return clearance;
}
function changebg2(id){
	if ( typeof saveshare_recipe != 'undefined' && saveshare_recipe.match(/^(sidebar|inline_big|bottom|strip)/) ) {
		document.getElementById(id).style.background = '#FFF';
	} else {
		document.getElementById(id).style.background = '#EEE';
	}
}
function resetbg2(id){
	if ( typeof saveshare_recipe != 'undefined' && saveshare_recipe.match(/^(sidebar|inline_big|bottom|strip)/) ) {
		document.getElementById(id).style.background = '#FFF';
	} else {
		document.getElementById(id).style.background = '#EEE';
	}
}
function resetLinkTextWithImage(id,icon) {
	if ( document.getElementById(id+'-link') ) {
		icon = '<img src="http://media3.washingtonpost.com/wp-srv/bookmarking/'+icon+'" border="0">';
		document.getElementById(id+'-link').innerHTML = icon;
	}
}
function saveExpando3(type) {
	var saveArticle = document.getElementById("saveArticle");
	var shareExpando = document.getElementById("shareExpandBox");
	var saveSign = document.getElementById("saveSign");

	if (type == "show") {
		saveArticle.className = "saveDevelopBorder";
		document.saveIcon.src = "http://www.washingtonpost.com/wp-srv/article/images/icon_save_grey.gif";
		saveSign.innerHTML = String.fromCharCode(187);
	} else {
		saveArticle.className = "saveDevelop";
		document.saveIcon.src = "http://www.washingtonpost.com/wp-srv/article/images/icon_save.gif";
		saveSign.innerHTML = "+";
	}
}
// END: Save/Share A/B Testing

