/*
	File: general.js
  Logahead Version: logahead UNU edition by Klaus Schlichter based on Logahead Beta 1.0 by James, UK
	Licence: GPL
  Edit: Added support for the plugins use_nice_urls, full_html_messages, comments_notification and email/website fields as well as Edit Comments by IP
*/

lh_fullhtmlmessages = "";
lh_wysiwygeditor = "";
lh_useniceurls = "";
lh_adminnotify = "";

var message = 'livesearch the blog...'; //Message for search box


/* ************************************************************************************************
	Edit Comments by IP
	Author: glefebvre / garcimore
	$Date: 2006-03-31 $
	$Revision: 01 $
 ************************************************************************************************ */
/* GL : Edit Comment*/
function editComment(id, postid)
{
	load = 'loadComment';
	load = load.concat(id);
	load = document.getElementById(load);
	load.style.display = 'block';
	//alert("Edition du commentaire ["+ id+", postid="+postid+"]");

	request = 'idComment=';
	request = request.concat(id);

	upcomment = 'upcomment';
	upcomment = upcomment.concat(id);

	load = 'loadComment';
	load = load.concat(id);
	
	new Ajax.Updater(upcomment, 'editcomment.php', {method:'post', postBody: request, asynchronous:true, evalScripts:true, onSuccess: function() {
    new Effect.Fade(load, {duration: 0.0});
    new Effect.Appear(upcomment, {duration: 0.5});
    //new Effect.SlideDown(upcomment, {duration: 0.5});
    if (browser == "IE")
    {
    /* Refresh cos gets messed */
    document.getElementById('addcomment').innerHTML = document.getElementById('addcomment').innerHTML;
    }
	}});
}
/*Delete Comment*/
function deleteComment(id, postid)
{
  request = 'commentid=';
  request = request.concat(id);	
  input = confirm('Are you sure you want to delete this comment?');
  if (input==true)
  {
    new Ajax.Request('deletecomment.php', {method:'post', postBody: request, onSuccess: function(t) {
      comment = 'comment';
      comment = comment.concat(id);
      new Effect.Fade(comment, {duration: 0.5, afterFinish: function()
      { 
        request = 'postid=';
        request = request.concat(postid); 
        request = request.concat('&requesturi=');
        request = request.concat(lh_requesturi);  
        new Ajax.Updater('comments', 'getcomments.php', {method:'post', postBody: request, asynchronous:true, evalScripts:true, onSuccess: function() {
        if (browser == "IE")
        {
        /* Refresh cos gets messed */
        document.getElementById('addcomment').innerHTML = document.getElementById('addcomment').innerHTML;
        }
        }});
      }}); 
    }});
  }
}

function hideEditComment(id)
{
	upcomment = 'upcomment';
	upcomment = upcomment.concat(id);

	new Effect.Fade(upcomment, {duration: 0.0, afterFinish: function()
  {
	if (browser == "IE")
	{
		/* Refresh cos gets messed */
		document.getElementById('addcomment').innerHTML = document.getElementById('addcomment').innerHTML;
  }
	}}); 
}

/*Update Comment*/
function updateComment(id)
{
	var upcontentcomment = 'upcontentcomment' + id;
	var comment = document.getElementById(upcontentcomment);

	load = 'loadComment';
	load = load.concat(id);
	load = document.getElementById(load);
	load.style.display = 'block';
	
	request = 'comment=';
	// comment = stripHTML(comment.value);
	comment = comment.value;
  request = request.concat(comment.replace(/'/g,'%27').replace(/\+/g, '%2B').replace(/&/g, '%26').replace(/\(/g, '%28').replace(/\)/g, '%29'));
	// request = request.concat(comment.value.replace(/\</g,'%%lt;').replace(/\>/g,'%%gt;').replace(/"/g,'%%quot;').replace(/'/g,'%27').replace(/\+/g, '%2B').replace(/&/g, '%26').replace(/\(/g, '%28').replace(/\)/g, '%29')); 
	request = request.concat('&id='); 
	request = request.concat(id);
	
	new Ajax.Request('updatecomment.php', {method: 'post', postBody: request, onSuccess: function() 
		{
			
			load = 'loadComment';
			load = load.concat(id);
			new Effect.Fade(load, {duration: 0.0});

			upcomment = 'upcomment';
			upcomment = upcomment.concat(id);
			new Effect.Fade(upcomment, {duration: 0.0});

			contentCommentDiv = 'contentComment';
			contentCommentDiv = contentCommentDiv.concat(id);
			
			request = 'comment=';
      request = request.concat(comment.replace(/'/g,'%27').replace(/\+/g, '%2B').replace(/&/g, '%26').replace(/\(/g, '%28').replace(/\)/g, '%29'));
			// request = request.concat(comment.value.replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&acute;').replace(/\+/g, '%2B').replace(/&/g, '%26').replace(/\(/g, '%28').replace(/\)/g, '%29'));
			//request = request.concat(comment.value);
			//alert("Mise A jour effectuee. request = [" + request + "]");
			new Ajax.Updater(contentCommentDiv, 'getcomment.php', {method:'post', postBody: request, asynchronous:true, evalScripts:true, onSuccess: function() {
        if (browser == "IE")
        {
        /* Refresh cos gets messed */
        document.getElementById('addcomment').innerHTML = document.getElementById('addcomment').innerHTML;
        }
      }});
			
			//document.getElementById(contentCommentDiv).innerHTML = comment.value;
			if (document.getElementById('upcontentcomment')) {document.getElementById('upcontentcomment').value = "";}
		}
	});
}

/*Comment Fade Tab after time*/
function ctabmouseover(id)
{
	var conid = 'commenttab';
	conid = conid.concat(id);
	var tabID = document.getElementById(conid);
	if (tabID.style.display == 'none')
	{
		new Effect.Appear(conid, {duration: 0.5});
		chideaftertime(id);
	}
}

function chideaftertime(id)
{
	var func = "chidetab(";
	func = func.concat(id);
	func = func.concat(")");
	setTimeout(func,2500);
}
function chidetab(id)
{
	var tab = "commenttab".concat(id);
	if (document.getElementById(tab))
	{
		new Effect.Fade(tab, {duration: 0.5});
	}
}

/*Fade Tab after time*/
function tabmouseover(id)
{
	var conid = 'tab';
	conid = conid.concat(id);
	var tabID = document.getElementById(conid);
	if (tabID.style.display == 'none')
	{
		new Effect.Appear(conid, {duration: 0.5});
		hideaftertime(id);
	}
}
function hideaftertime(id)
{
	var func = "hidetab(";
	func = func.concat(id);
	func = func.concat(")");
	setTimeout(func,2500);
}
function hidetab(id)
{
	var tab = "tab".concat(id);
	if (document.getElementById(tab))
	{
		new Effect.Fade(tab, {duration: 0.5});
	}
}

// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
  } else {
	window.onload = function() {
	  oldonload();
	  func();
	}
  }
}
/* A few global variables for the livesearch function*/
var liveSearchId = 'livesearch'; //ID of search box
var message = 'livesearch the blog...'; //Message for search box
/*Global Doing something , stop clicking function variable */
var clicking = 0;
var higheffect = 1;
/* Detect Browser and Operating System*/
var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "IE"
else if (checkIt('camino')) browser = "Camino"
else if (!checkIt('compatible'))
{
	browser = "Firefox"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
function stripHTML(oldString) {
   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
		if(oldString.charAt(i) == '<') inTag = true;
		if(oldString.charAt(i) == '>') {
				 inTag = false;
				 i++;
		}
		if(!inTag) newString += oldString.charAt(i);
   }
   return newString;
}
/* Disable slide effects for setups which are not compatible */
// Firefox on Mac is very clunky
if ((OS == 'Mac') && (browser == 'Firefox')) macfox = 1;
/*Event listener functions by www.scottandrew.com*/
function addEvent(obj, evType, fn)
	{
	if (obj.addEventListener)
		{
		obj.addEventListener(evType, fn, false); 
		return true;
		}
	else if (obj.attachEvent)
		{
		var r = obj.attachEvent('on'+evType, fn);
		return r;
		}
	else
		{
		return false;
		}
	}
function addEventToObject(obj, evt, func)
	{
	var oldhandler = obj[evt];
	if (typeof obj[evt] != 'function')
		{
		obj[evt] = func;
		}
	else
		{
		obj[evt] = function()
			{
			oldhandler();
			func();
			}
		}
	}
	
/*Cookie Functions from techpatterns.com/downloads/javascript_cookies.php */
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
	expires = expires * 1000 * 60;
	}
	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" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) 
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/* Email validation */
function isValidEmail(email) {
//	var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  var re = /^(.+@.+\.[a-zA-Z]{2,})/;
	return (re.test(email));
}
/* Link validation */
function isValidLink(sitelink) {
  var re = /^(http[s]?:\/\/.+\.[a-zA-Z]{2,}.?)/;
	return (re.test(sitelink));
}

/* Add Comment */
function addComment(postid, admin)
{
	if (!Get_Cookie( 'comment' ) || (admin == 88)) // Check cookie to stop light spam, very easy to get round...
	{
	if (clicking != 1) //Check to see if already adding a post.
	{
	clicking = 1;
	var name = document.getElementById('commentname');
	var email = document.getElementById('commentemail');
	var linkurl = document.getElementById('commenturl');
	var comment = document.getElementById('commentcontent');
	var commentcont = document.getElementById('comments');
	//Validate
	if (name.value == "") 
	{
		alert('You must enter a name');
		clicking = 0;
		return;
	}
	//REQUIRE EMAIL
	if (email.value == "") 
	{
		alert('To protect against spam, you must enter an email');
		clicking = 0;
		return;
	}
	//END REQUIRE EMAIL
	//validate email
	if (!isValidEmail(email.value))
	{
		alert('Please enter a valid email address');
		clicking = 0;
		return;
	}
	//LINK CHECK
	if (linkurl.value!="" && linkurl.value.toLowerCase()!="http://" && !isValidLink(linkurl.value))
	{
		alert('Please enter a valid website address');
		clicking = 0;
		return;
	}
	if (comment.value == "")
	{
		alert('Enter some text for your comment');
		clicking = 0;
		return;
	}
	Set_Cookie( 'comment', 'posted', 2, '/', '', '' ); //Set cookie for 2 minutes
	if (!Get_Cookie( 'comment' ) ) //Check user has cookie enables so they can't just disable them
	{
		alert('Cookies must be enabled to comment');
		clicking = 0;
		return;
	}
	var loading = "<div class=\"loadingother\"></div><br />";
	document.getElementById('comments').innerHTML = document.getElementById('comments').innerHTML + loading;
	name = stripHTML(name.value);
	// comment = stripHTML(comment.value);
	comment = comment.value;
	request = 'name=';
	request = request.concat(name);
	request = request.concat('&email=');
	request = request.concat(email.value);
	request = request.concat('&linkurl=');
	request = request.concat(linkurl.value.replace(/>/g,'').replace(/</g,''));
	request = request.concat('&comment=');
	request = request.concat(comment.replace(/'/g,'%27').replace(/\+/g, '%2B').replace(/&/g, '%26').replace(/\(/g, '%28').replace(/\)/g, '%29'));
	request = request.concat('&postid=');
	request = request.concat(postid);
	request = request.concat('&unu=');
	request = request.concat(lh_useniceurls);
	request = request.concat('&adminnotify=');
	request = request.concat(lh_adminnotify);    
	updater = 'postid=';
	updater = updater.concat(postid);
	updater = updater.concat('&requesturi=');
	updater = updater.concat(lh_requesturi);  
	new Ajax.Request('addcomment.php', {method: 'post', postBody: request, onSuccess: function() {
  	new Ajax.Updater('comments', 'getcomments.php', {method:'post', postBody: updater, asynchronous:true, evalScripts:true, onSuccess: function() {
    	if (browser == "IE")
    	{
    		/* Refresh cos gets messed */
    		document.getElementById('addcomment').innerHTML = document.getElementById('addcomment').innerHTML;
    	}
    	clicking = 0;
    }});
  }});
  }
	}
	else if (clicking == 1)
	{
		alert('Your comment is being added...');
	}
	else
	{
		alert('You may only make one comment every 2 minutes.');
	}
}
/* The main preperation and listening function*/
function prep()
{
	if (browser == "Opera")
	{
	message = 'search the blog...';
	}
	var podBox = document.getElementById('podcast'); 
	if (podBox)
	{
	if (browser == "Safari" || browser == "Camino")
	{
	podBox.value = 'Podcast'; // Add the message
	}
	}
	var liveSearchBox = document.getElementById(liveSearchId); // Create a search box variable
	var textBox = document.getElementById('content'); // Create a search box variable
	liveSearchBox.value = message; // Add the message
	liveSearchBox.setAttribute('autocomplete', 'off'); // Remove autocomplete
	/*Listeners for keypress and select on search box*/
	addEvent(liveSearchBox, 'focus', clearLiveSearchBox, false); 
	addEvent(liveSearchBox, 'keyup', delay, false);
}

addLoadEvent(prep);
/* Clear the livebox function */
function clearLiveSearchBox()
{
	var liveSearchBox = document.getElementById(liveSearchId);
	if (liveSearchBox.value == message)
		{
		liveSearchBox.value = "";
		}
}

function index()
{
	location.href='index.php';
}

function logout()
{
	location.href='logout.php';
}

function hideOthers(notme)
{
					if (higheffect == 1)
					{
					if (notme != 'pluginoptions')
					{
					var tool = document.getElementById('pluginoptions');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('pluginoptions', {duration: 0.0});
					var tool = document.getElementById('plugin');
					tool.className = "plugin";
					}
					}
					if (notme != 'useroptions')
					{
					var tool = document.getElementById('useroptions');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('useroptions', {duration: 0.0});
					var tool = document.getElementById('users');
					tool.className = "users";
					}
					}
					if (notme != 'styleoptions')
					{
					var tool = document.getElementById('styleoptions');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('styleoptions', {duration: 0.0});
					var tool = document.getElementById('layout');
					tool.className = "layout";
					}
					}
					if (notme != 'timeoptions')
					{
					var tool = document.getElementById('timeoptions');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('timeoptions', {duration: 0.0});
					var tool = document.getElementById('time');
					tool.className = "time";
					}
					}
					if (notme != 'login')
					{
					var tool = document.getElementById('loginform');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('loginform', {duration: 0.0});
					var tool = document.getElementById('login');
					tool.className = "logindown";
					}
					}
					if (notme != 'addpost')
					{
					var tool = document.getElementById('addpost');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('addpost', {duration: 0.5});
					var tool = document.getElementById('newpost');
					tool.className = "newpostdown";
					}
					}
					if (notme != 'goptions')
					{
					var tool = document.getElementById('goptions');
					if (tool.style.display != 'none') 
					{
					new Effect.Fade('goptions', {duration: 0.5});
					var tool = document.getElementById('advanced');
					tool.className = "advanced";
					}
					}
					}
					else
					{
					if (notme != 'login')
					{
					var tool = document.getElementById('loginform');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('login');
					tool.className = "logindown";
					}
					}
					if (notme != 'addpost')
					{
					var tool = document.getElementById('addpost');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('newpost');
					tool.className = "newpostdown";
					}
					}
					if (notme != 'timeoptions')
					{
					var tool = document.getElementById('timeoptions');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('time');
					tool.className = "time";
					}
					}
					if (notme != 'styleoptions')
					{
					var tool = document.getElementById('styleoptions');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('layout');
					tool.className = "layout";
					}
					}
					if (notme != 'goptions')
					{
					var tool = document.getElementById('goptions');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('advanced');
					tool.className = "advanced";
					}
					}
					if (notme != 'useroptions')
					{
					var tool = document.getElementById('useroptions');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('users');
					tool.className = "users";
					}
					}
					if (notme != 'pluginoptions')
					{
					var tool = document.getElementById('pluginoptions');
					if (tool.style.display != 'none') 
					{
					tool.style.display = 'none';
					var tool = document.getElementById('plugin');
					tool.className = "plugin";
					}
					}
					}
					Behaviour.apply();
}
/* Behavior based rules for CSS elements*/
var myrules = {
	'.newpost' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('addpost', {duration: 1.0, afterFinish: function() {
							var tool = document.getElementById('newpost');
						tool.className = "newpostdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
				}
				else
				{
							new Effect.SlideUp('addpost', {duration: 2.0,afterFinish: function() {
							var tool = document.getElementById('newpost');
						tool.className = "newpostdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
				}
			}
			else
			{
			var tool = document.getElementById('addpost');
			tool.style.display = 'none';
			var tool = document.getElementById('newpost');
			tool.className = "newpostdown";
			Behaviour.apply();
			}
		}
	},
		'.newpostdown' : function(el){
		el.onclick = function(){
				 hideOthers('addpost');
			if (higheffect == 1)
			{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('addpost', {duration: 1.0,afterFinish: function() {
							var tool = document.getElementById('newpost');
						tool.className = "newpost";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('addpost', {duration: 2.0,afterFinish: function() {
							var tool = document.getElementById('newpost');
						tool.className = "newpost";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
			{
			var tool = document.getElementById('addpost');
			tool.style.display = 'inline';
			var tool = document.getElementById('newpost');
			tool.className = "newpost";
			Behaviour.apply();
			}
		}
	},
	'.toolup' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
			{
			new Effect.SlideUp('toolbar', {afterFinish: function() {
							var tool = document.getElementById('tab');
						tool.className = "tooldown";
						Behaviour.apply();
						new Ajax.Request('updatetoolbar.php');
						}});
			}
		else
		{
		var tool = document.getElementById('toolbar');
		tool.style.display = 'none';
		var tool = document.getElementById('tab');
		tool.className = "tooldown";
		new Ajax.Request('updatetoolbar.php');
		}
		Behaviour.apply();
		}
	},
	'.tooldown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
			new Effect.SlideDown('toolbar', {afterFinish: function() {
							var tool = document.getElementById('tab');
						tool.className = "toolup";
						Behaviour.apply();
						new Ajax.Request('updatetoolbar.php');
						}});
		}
		else
		{
		var tool = document.getElementById('toolbar');
		tool.style.display = 'block';
		var tool = document.getElementById('tab');
		tool.className = "toolup";
		new Ajax.Request('updatetoolbar.php');
		}
		Behaviour.apply();
		}
	},
	'.login' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('loginform', {afterFinish: function() {
							var tool = document.getElementById('login');
						tool.className = "logindown";
						Behaviour.apply();
						}});
			Behaviour.apply();
				}
				else
				{
							new Effect.SlideUp('loginform', {afterFinish: function() {
							var tool = document.getElementById('login');
						tool.className = "logindown";
						Behaviour.apply();
						}});
				}
			}
					else
		{
		var tool = document.getElementById('loginform');
		tool.style.display = 'none';
		var tool = document.getElementById('login');
		tool.className = "logindown";
		}
		Behaviour.apply(); 
		}
	},
		'.logindown' : function(el){
		el.onclick = function(){
				   	var addPost = document.getElementById('addpost');
					if (addPost)
					{
					hideOthers('login');
					}
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('loginform', {afterFinish: function() {
							var tool = document.getElementById('login');
						tool.className = "login";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('loginform', {afterFinish: function() {
							var tool = document.getElementById('login');
						tool.className = "login";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		 else
		{
		var tool = document.getElementById('loginform');
		tool.style.display = 'inline';
		var tool = document.getElementById('login');
		tool.className = "login";
		}
		Behaviour.apply();
		}
	},
	'.buttonup' : function(el){
		el.onclick = function(){
		if (((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox'))) || (higheffect != 1))
			{
			new Effect.Appear('sideoptions', {afterFinish: function() {
							var tool = document.getElementById('optionbar');
						tool.className = "buttondown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('sideoptions', {afterFinish: function() {
							var tool = document.getElementById('optionbar');
						tool.className = "buttondown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
	},
	'.buttondown' : function(el){
		el.onclick = function(){
			if (((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox'))) || (higheffect != 1))
			{
			new Effect.Fade('sideoptions', {afterFinish: function() {
							var tool = document.getElementById('optionbar');
						tool.className = "buttonup";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('sideoptions', {afterFinish: function() {
							var tool = document.getElementById('optionbar');
						tool.className = "buttonup";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
	},
	'.advanced' : function(el){
		el.onclick = function(){
		hideOthers('goptions');
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('goptions', {afterFinish: function() {
							var tool = document.getElementById('advanced');
						tool.className = "advanceddown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('goptions', {afterFinish: function() {
							var tool = document.getElementById('advanced');
						tool.className = "advanceddown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('goptions');
		tool.style.display = 'inline';
		var tool = document.getElementById('advanced');
		tool.className = "advanceddown";
		}
		Behaviour.apply();
		}
	},
	'.advanceddown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('goptions', {afterFinish: function() {
							var tool = document.getElementById('advanced');
						tool.className = "advanced";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('goptions', {afterFinish: function() {
							var tool = document.getElementById('advanced');
						tool.className = "advanced";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('goptions');
		tool.style.display = 'none';
		var tool = document.getElementById('advanced');
		tool.className = "advanced";
		}
		Behaviour.apply();
		}
	},
	'.time' : function(el){
		el.onclick = function(){
		hideOthers('timeoptions');
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('timeoptions', {afterFinish: function() {
							var tool = document.getElementById('time');
						tool.className = "timedown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('timeoptions', {afterFinish: function() {
							var tool = document.getElementById('time');
						tool.className = "timedown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('timeoptions');
		tool.style.display = 'inline';
		var tool = document.getElementById('time');
		tool.className = "timedown";
		}
		Behaviour.apply();
		}
	},
		'.timedown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('timeoptions', {afterFinish: function() {
							var tool = document.getElementById('time');
						tool.className = "time";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('timeoptions', {afterFinish: function() {
							var tool = document.getElementById('time');
						tool.className = "time";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('timeoptions');
		tool.style.display = 'none';
		var tool = document.getElementById('time');
		tool.className = "time";
		}
		Behaviour.apply();
		}
	},
		'.layout' : function(el){
		el.onclick = function(){
		hideOthers('styleoptions');
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('styleoptions', {afterFinish: function() {
							var tool = document.getElementById('layout');
						tool.className = "layoutdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideDown('styleoptions', {afterFinish: function() {
							var tool = document.getElementById('layout');
						tool.className = "layoutdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('styleoptions');
		tool.style.display = 'inline';
		var tool = document.getElementById('layout');
		tool.className = "layoutdown";
		}
		Behaviour.apply();
		}
	},
		'.layoutdown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
					if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('styleoptions', {afterFinish: function() {
							var tool = document.getElementById('layout');
						tool.className = "layout";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('styleoptions', {afterFinish: function() {
							var tool = document.getElementById('layout');
						tool.className = "layout";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('styleoptions');
		tool.style.display = 'none';
		var tool = document.getElementById('layout');
		tool.className = "layout";
		}
		Behaviour.apply();
		}
	},
  	'.users' : function(el){
		el.onclick = function(){
		hideOthers('useroptions');
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('useroptions', {afterFinish: function() {
							var tool = document.getElementById('users');
						tool.className = "usersdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
						 new Effect.SlideDown('useroptions', {afterFinish: function() {
							 var tool = document.getElementById('users');
						tool.className = "usersdown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('useroptions');
		tool.style.display = 'inline';
		var tool = document.getElementById('users');
		tool.className = "usersdown";
		}
		Behaviour.apply();
		}
	},
	  '.usersdown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('useroptions', {afterFinish: function() {
							var tool = document.getElementById('users');
						tool.className = "users";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('useroptions', {afterFinish: function() {
							var tool = document.getElementById('users');
						tool.className = "users";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('useroptions');
		tool.style.display = 'none';
		var tool = document.getElementById('users');
		tool.className = "users";
		}
		Behaviour.apply();
		}
	},
  	'.plugin' : function(el){
		el.onclick = function(){
		hideOthers('pluginoptions');
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Appear('pluginoptions', {afterFinish: function() {
							var tool = document.getElementById('plugin');
						tool.className = "plugindown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
						 new Effect.SlideDown('pluginoptions', {afterFinish: function() {
							 var tool = document.getElementById('plugin');
						tool.className = "plugindown";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('pluginoptions');
		tool.style.display = 'inline';
		var tool = document.getElementById('plugin');
		tool.className = "plugindown";
		}
		Behaviour.apply();
		}
	},
	  '.plugindown' : function(el){
		el.onclick = function(){
		if (higheffect == 1)
		{
			if ((browser == "IE") || ((OS == 'Mac') && (browser == 'Firefox')))
			{
			new Effect.Fade('pluginoptions', {afterFinish: function() {
							var tool = document.getElementById('plugin');
						tool.className = "plugin";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		else
		{
					new Effect.SlideUp('pluginoptions', {afterFinish: function() {
							var tool = document.getElementById('plugin');
						tool.className = "plugin";
						Behaviour.apply();
						}});
			Behaviour.apply();
		}
		}
		else
		{
		 var tool = document.getElementById('pluginoptions');
		tool.style.display = 'none';
		var tool = document.getElementById('plugin');
		tool.className = "plugin";
		}
		Behaviour.apply();
		}
	}
	};
Behaviour.register(myrules);

