/*utility methods */
var _isIE_ 		= (navigator.userAgent.indexOf("MSIE") > 0);
var _isMozilla_ = (navigator.userAgent.indexOf("Gecko") > 0);
var _isSafari_	= (navigator.userAgent.indexOf("Safari") > 0);
var _isOpera_	= (navigator.userAgent.indexOf("Opera") > 0);

el = function (obj) { return document.getElementById(obj); };
trim = function(s) { if (s == '') return s; while (s.substring(0,1) == ' ') { s = s.substring(1,s.length); } while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1); } return s; };
checkEmail = function (val) {
   var format = /^[0-9a-z]([-+_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,3}$/i;
   return (val.match(format));
};

getConnection = function() { 
	try { 
		return new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {} 
	
	try { 
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	} catch (e) {} 
	
	try { 
		return new XMLHttpRequest(); 
	} catch(e) {}
	
	//return null; 
};

_Ajax = function() { 
	this.in_request = false; 
	return this; 
};

_Ajax.prototype.send = function(url, method, callback, vars, params) { 
	if (this.in_request) return false; 
	this.request = getConnection(); 
	if (this.request) { 
		if (params != undefined && params != null)
			this.params = params; 
		this.request.open("POST", url, true); 
		this.request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.request.onreadystatechange = eval(callback); 
		this.request.send(vars+"&x="+Math.random()); 
		this.in_request = true; 
	}
	else
		return false; 
};
_Ajax.prototype.abort = function() { if (this.in_request) { this.request.abort(); } };
_Ajax.prototype.inRequest = function() {	return this.in_request; };
_Ajax.prototype.removeCallBack = function() { 
	if (typeof this.request == 'XMLHttpRequest') { 
		this.request.onreadystatechange = null;
	} 
};

toggleShare = function() {
	el('share_box').style.display = (el('share_box').style.display == 'none') ? 'block' : 'none';
}


scrub = function(input_string) {		
	if (input_string == '') return '';
	
	var arr_find = [
		String.fromCharCode(8220), //“
		String.fromCharCode(8221), //”
		String.fromCharCode(8216), //‘
		String.fromCharCode(8217), //‘
		String.fromCharCode(8211), //–
		String.fromCharCode(8212), //—
		String.fromCharCode(189), //½
		String.fromCharCode(188), //¼
		String.fromCharCode(190), //¾
		String.fromCharCode(169), //©
		String.fromCharCode(174), //®
		String.fromCharCode(8230) //…
	];


	var arr_replace = [
		'"',
		'"',
		"'",
		"'",
		"-",
		"--",
		"1/2",
		"1/4",
		"3/4",
		"(C)",
		"(R)",
		"..."
	];
	
	for ( var i=0; i<arr_find.length; i++ ) {
		var regex = new RegExp(arr_find[i], "gi");
		input_string = input_string.replace(regex, arr_replace[i]);
		
	}
	
	return input_string;	
}