
function removeDefault(el) {
	if((!el.rel || el.value == el.rel) && (el.type == "text" || el.type == "")) {     el.rel = el.value;
		el.value = '';
		var elName = el.id;
		el.onblur = function () { if(!el.value) {addDefault(elName);}}
		return true;
	}
}
function addDefault(elName) {
	var el = document.getElementById(elName);
	el.value = el.rel;
}


var gothamblack = {
  src: '/wp-content/themes/wmf/gotham-black.swf'
  ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
};

var gothambook = {
  src: 'http://localhost.localdomain/wp-content/themes/wmf/gotham-book.swf'
  ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
};

var gothambold = {
  src: '/wp-content/themes/wmf/gotham-bold.swf'
  ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
};

var gothammedium = {
  src: '/wp-content/themes/wmf/gotham-medium.swf'
  ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
};

// You probably want to switch this on, but read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad> first.
// sIFR.useStyleCheck = true;

sIFR.activate(gothamblack, gothambook, gothambold, gothammedium);
jQuery(window).load(function() {	
	document.getElementById('s').onclick = function () { removeDefault(this); }

	try {
	  document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
	
	// for suckerfish menu
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("sfhover\\b"), "");
		}
	}

	// sIFR.replace(gothambook, {
	//   selector: '#country_info'
	//   ,css: [
	//     '.sIFR-root { color:#FFFFFF; background-color:#89CCE2; font-weight:bold; }',
	// 	'strong { font-weight:normal; }',
	//     ,'a {  }'
	//     ,'a:link { color: #FFFFFF; }'
	//     ,'a:hover { color: #FFFFFF; }'
	//   ]
	// });

	// sIFR.replace(gothammedium, {
	//   selector: '#the_cry_links'
	//   ,css: [
	//     '.sIFR-root { color:#000000; }'
	//     ,'a { font-size:11px; text-decoration:none;  }'
	//     ,'a:link { color: #000000; }'
	//     ,'a:hover { color: #000000; text-decoration:underline; }'
	//   ]
	// });
	
	//alert(jQuery('.most_recent').css('color'));
	
	var recent_article_color = jQuery('.most_recent').css('color');
	var recent_article_hexcolor = '000000';
	if (recent_article_color) {
		if (recent_article_color.match(/^#/))
			recent_article_hexcolor = recent_article_color;
		else
			recent_article_hexcolor = getHexFromRGB(recent_article_color);
			
		sIFR.replace(gothambook, {
			selector: '.most_recent h3'
			,css: [
			'.sIFR-root { text-transform:uppercase; }'
			,'a { font-size:21px; text-decoration:none; color:' + recent_article_hexcolor + '; }'
			,'a:link { text-decoration:none; }'
			,'a:hover { text-decoration:none; color:' + recent_article_hexcolor + '; }'
			]
		});
	}
	
	var hidden_secret_color = jQuery('#hidden_secret_color').css('color');
	var hidden_secret_hexcolor = '000000';
	if (hidden_secret_color) {
		if (hidden_secret_color.match(/^#/))
			hidden_secret_hexcolor = hidden_secret_color;
		else
			hidden_secret_hexcolor = getHexFromRGB(hidden_secret_color);
	
		sIFR.replace(gothammedium, {
		  selector: '#footer_content div.replace_black'
		  ,css: [
		    '.sIFR-root { color:#000000; font-size:12px; }'
		    ,'a { text-decoration:none; }'
		    ,'a:link { color: #000000; }'
		    ,'a:hover { color: ' + hidden_secret_hexcolor + '; text-decoration:none; }'
		  ]
		});
	}


	sIFR.replace(gothammedium, {
	  selector: '#footer_content div.oxide'
	  ,css: [
	    '.sIFR-root { font-size:12px; }'
		,'.oxide a { color: #939598; text-decoration:none; }'
	    ,'.oxide a:hover { color: #939598; }'
	  ]
	});	
});

// gets the hex value from an RGB color value... silly IE and FF don't work the same with jQuery.css('color')
function getHexFromRGB(color) { 
	var hexString = '';
	var parts = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	delete (parts[0]);
	for (var i = 1; i <= 3; ++i) {
		parts[i] = parseInt(parts[i]).toString(16);
		if (parts[i].length == 1) parts[i] = '0' + parts[i];
		hexString = '#' + parts.join('');
	}
	return hexString;
}