/*******************************************************************************
  Function: htmlspecialchars
*******************************************************************************/
function htmlspecialchars(string) { 
	return (string + '').replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
/*******************************************************************************
  Function: preg_quote
*******************************************************************************/
function preg_quote(string) {
	return (string + '').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");
}
/*******************************************************************************
  Function: rel2abs
*******************************************************************************/
function rel2abs(relUrl) {
	var span = document.createElement('span');
	span.innerHTML = '<a href="' + relUrl + '" />';
	return span.firstChild.href;
}
/*******************************************************************************
  Object: imageCache
*******************************************************************************/
var imageCache = new Object();
/*******************************************************************************
  Event: Image Rollover
*******************************************************************************/
$(document).ready(function() {
	$('*[src*="_fr."]').each(function() {
		var srcFront = this.src;
		var srcBack = srcFront.replace('_fr.', '_bk.');
		imageCache[srcFront] = new Image();
		imageCache[srcFront].src = srcBack;
		$(this).hover(
			function() { this.src = srcBack; },
			function() { this.src = srcFront; }
		);
	});
});
/*******************************************************************************
  Event: Open Link in Another Window
*******************************************************************************/
$(document).ready(function() {
	$('a.target_blank').click(function(){
		var anotherWindow = window.open(this.href, 'another', 'toolbar=yes, scrollbars=yes, menubar=yes, location=yes, status=yes, directories=yes, resizable=yes');
		anotherWindow.focus();
		return false;
	});
});
/*******************************************************************************
  Event: Open Link in Sub-window
*******************************************************************************/
$(document).ready(function() {
	$('a.target_sub').click(function(){
		var subWindow = window.open(this.href, 'sub', 'toolbar=yes, scrollbars=yes, menubar=yes, location=yes, status=yes, directories=yes, resizable=yes');
		subWindow.focus();
		return false;
	});
});
/*******************************************************************************
  Event: Open Link in Main Window
*******************************************************************************/
$(document).ready(function() {
	$('a.target_main').click(function(){
		if (window.opener && !window.opener.closed) {
			window.opener.location.href = this.href;
			window.opener.focus();
		} else {
			window.name = 'sub';
			var mainWindow = window.open(this.href, 'main', 'toolbar=yes, scrollbars=yes, menubar=yes, location=yes, status=yes, directories=yes, resizable=yes');
			mainWindow.focus();
		}
		return false;
	});
});
