// Sniffer based on http://www.mozilla.org/docs/web-developer/sniffer/browser_type.htmlvar uagent    = navigator.userAgent.toLowerCase();var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );var is_opera  = (uagent.indexOf('opera') != -1);var is_webtv  = (uagent.indexOf('webtv') != -1);var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );var is_moz    = ( (navigator.product == 'Gecko')  && (!is_opera) && (!is_webtv) && (!is_safari) );var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );var is_kon    = (uagent.indexOf('konqueror') != -1);var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );function $( id ) {	return document.getElementById( id );}function showHide( id ) {	if ($( id ).style.display == 'none') {		$( id ).style.display = '';	} else {		$( id ).style.display = 'none';	}}function hideShow( id ) {	if ($( id ).style.display == '') {		$( id ).style.display = 'none';	} else {		$( id ).style.display = '';	}}function show( id ) {	$( id ).style.display = '';}function hide( id ) {	$( id ).style.display = 'none';}function _noBubbling( e ) {	e = _fixE( e );	if (typeof(e) != 'undefined') {		if (!e.cancelBubble) e.cancelBubble = true;		if (e.stopPropagation) e.stopPropagation();	}    return false;}function _fixE( e ) {	//if (is_ie) e = event;	if (!e) var e = window.event;	return e;}function showFloatWindow( id, e, noBubbling ) {	if (noBubbling != '1') {		_noBubbling( e );	}	$('float-layer-content').innerHTML = $( id ).innerHTML;	$('float-layer-content').onclick = _noBubbling;	show('float-layer-wrapper');	document.onclick = function() { hide('float-layer-wrapper'); }}/** * Gets the value of the specified cookie. * * name  Name of the desired cookie. * * Returns a string containing value of specified cookie, *   or null if cookie does not exist. */function getCookie( name ) {	if (!name) return;	else name = 'alyth-'+name;    var dc = document.cookie;    var prefix = name + "=";    var begin = dc.indexOf("; " + prefix);    if (begin == -1) {        begin = dc.indexOf(prefix);        if (begin != 0) return null;    } else {        begin += 2;    }    var end = document.cookie.indexOf(";", begin);    if (end == -1) {        end = dc.length;    }    return unescape(dc.substring(begin + prefix.length, end));}/** * Sets a Cookie with the given name and value. * * name       Name of the cookie * value      Value of the cookie * [expires]  Expiration date of the cookie (default: end of current session) (days)!!! * [path]     Path where the cookie is valid (default: path of calling document) * [domain]   Domain where the cookie is valid *              (default: domain of calling document) * [secure]   Boolean value indicating if the cookie transmission requires a *              secure transmission */function setCookie( name, value, expires, path, domain, secure ) {	if (!name) return;	else name = 'alyth-'+name;	var today = new Date();	today.setTime(today.getTime());	if (expires) {		expires = expires * 1000 * 60 * 60 * 24;	}	var expires_date = new Date( today.getTime() + (expires) );	document.cookie = name+'='+escape(value) +		((expires) ? ';expires='+expires_date.toGMTString() : '') +		((path) ? ';path=' + path : '') +		((domain) ? ';domain=' + domain : '') +		((secure) ? ';secure' : '');}function closeSticker( id ) {	var hidden = getCookie( 'top-sticker' );	if (hidden == null) { hidden = ''; }	setCookie( 'top-sticker', hidden + ':' + id, 365 );	hide('top-sticker');}var editorID = 'comment-editor';window.onerror = null;editor = {	ok: 'ok',	insert: function (ibTag, ibClsTag, isSingle) {		var isClose = false;		var obj_ta = $( editorID );		//----------------------------------------		// It's IE!		//----------------------------------------		if ( is_ie && is_win)	{			if (obj_ta.isTextEdit) {				obj_ta.focus();				var sel = document.selection;				var rng = sel.createRange();				rng.colapse;				if((sel.type == "Text" || sel.type == "None") && rng != null) {					if(ibClsTag != "" && rng.text.length > 0)						ibTag += rng.text + ibClsTag;					else if(isSingle)						isClose = true;					rng.text = ibTag;				}			} else {				if(isSingle) {					isClose = true;				}				obj_ta.value += ibTag;			}		}		//----------------------------------------		// It's MOZZY!		//----------------------------------------		else if ( obj_ta.selectionEnd ) {			var ss = obj_ta.selectionStart;			var st = obj_ta.scrollTop;			var es = obj_ta.selectionEnd;			if (es <= 2) {				es = obj_ta.textLength;			}			var start  = (obj_ta.value).substring(0, ss);			var middle = (obj_ta.value).substring(ss, es);			var end    = (obj_ta.value).substring(es, obj_ta.textLength);			//-----------------------------------			// text range?			//-----------------------------------			if (obj_ta.selectionEnd - obj_ta.selectionStart > 0) {				middle = ibTag + middle + ibClsTag;			} else {				middle = ibTag + middle;				if (isSingle) {					isClose = true;				}			}			obj_ta.value = start + middle + end;			var cpos = ss + (middle.length);			obj_ta.selectionStart = cpos;			obj_ta.selectionEnd   = cpos;			obj_ta.scrollTop      = st;		}		//----------------------------------------		// It's CRAPPY!		//----------------------------------------		else {			if (isSingle) {				isClose = true;			}			obj_ta.value += ibTag;		}		obj_ta.focus();		return isClose;	}}function doInsert( tag ) {	editor.insert( tag, '', true);}function simpleQuote(author, cid) {	if (!author || !cid) return;	var comment = $( 'comment-'+cid ).innerHTML ? $( 'comment-'+cid ).innerHTML : null;	if (!comment) return;	comment = comment.replace(/\n/g, "");	comment = comment.replace(/\t/g, "");	comment = comment.replace(/\r/g, "");	comment = comment.replace(/<div class="text-quote"(.*)<\/div>/g, "");	comment = comment.replace(/<(\/?)strike>/g, "[$1s]");	comment = comment.replace(/<(\/?)strong>/g, "[$1b]");	comment = comment.replace(/<(\/?)i>/g, "[$1i]");	comment = comment.replace(/<(\/?)u>/g, "[$1u]");	comment = comment.replace(/<br?\/?>/g, "\n");	comment = comment.replace(/^\n*/, "");	comment = comment.replace(/\n*$/, "");	comment = "[quote="+author+"]"+comment+"[/quote]\n";	doInsert( comment );}var floatSelection = "";var selection_id = 0;function floatSelect( e, author ) {	var str = "";	if (window.getSelection) {		str = window.getSelection();	} else if (document.getSelection) {		str = document.getSelection();	} else if (document.selection && document.selection.createRange) {		var range = document.selection.createRange();		str = range.text;	} else {		str = "Sorry, this is not possible with your browser.";	}	var quoteButton = $("quote-button");	if (str != "") {		var coords = getMouseCoords( e );        floatSelection = "[quote="+author+"]"+str+"[/quote]\n";		coords[0]+=5; coords[1]+=5;		quoteButton.style.left = coords[0]+"px";		quoteButton.style.top = coords[1]+"px";		quoteButton.style.display = "block";	} else {		quoteButton.style.display = 'none';	}	_noBubbling( e );}function floatQuote() {	doInsert( floatSelection );	hide('quote-button');}function getMouseCoords(evt) {	posx = 0;	posy = 0;	if (evt.pageX) return [ evt.pageX, evt.pageY ];	else if (evt.clientX) {   	     posx = evt.clientX + (document.documentElement.scrollLeft ?   	     	  document.documentElement.scrollLeft :   	     	  document.body.scrollLeft);   	     posy = evt.clientY + (document.documentElement.scrollTop ?   	     	  document.documentElement.scrollTop :   	     	  document.body.scrollTop);   	     return [posx, posy ];	} 	else return null;}
