/* A function to display a menu item
*
* @param key int
* @param size int
*/
function displayMenuItem(key, size){
	//Hide the other menu items
	for (var i = 0; i < size; i++){
		if (i != key && $('parent_' +i).className == "menuParentSelected"){
			$('parent_' +i).className = "menuParent";
			if ($('parent_' +i).parentNode.getElementsByTagName("div").length > 3){
				if ($('parent_arrow_' +i)){
					$('parent_arrow_' +i).src = $('parent_arrow_' +i).src.replace(/menuitemselected.gif/, "menuitem.gif");
				}
				new Effect.SlideUp('menuChildren_' +i, { duration: 0.4, queue: 'end'});
			}
			
		}
	}
	
	//Display the menu item
	if ($('menuChildren_' +key).style.display == "none"){
		$('parent_arrow_' +key).src = $('parent_arrow_' +key).src.replace(/menuitem.gif/, "menuitemselected.gif");
		$('parent_' +key).className = "menuParentSelected";
		new Effect.SlideDown('menuChildren_' +key, { duration: 0.6, queue: 'end'});
	}
}


/* A function when hovering over a menu item 
*
* @param element object
*/
function hoverMenuItem(element){
	if (element.className == 'menuParent'){
		element.className = 'menuParentHover'
	}
	else if (element.className == 'menuParentHover'){
		element.className = 'menuParent'
	}		
	else if (element.className == 'menuChild'){
		element.className = 'menuChildHover'
	}		
	else if (element.className == 'menuChildHover'){
		element.className = 'menuChild'
	}		
	else if (element.className == 'lastMenuChild'){
		element.className = 'lastMenuChildHover'
	}		
	else if (element.className == 'lastMenuChildHover'){
		element.className = 'lastMenuChild'
	}		
}


/* Check if an e-mail address is valid or not 
*
* @param email string
*/
function checkEmail(email){
	return /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(email);
}


/**
 * Convert all of the textareas with the wysiwyg class to fckeditor textarea
 *
 * @param path string
 */
function convertTextareasToFckEditor(path){
	//Get all of the textareas
	$$('textarea.wysiwyg').each(function(textarea){
		
		//Create the FCK editor object and replace the textarea
		var oFCKeditor = new FCKeditor(textarea.name);
		oFCKeditor.BasePath	= path +"scripts/fckeditor/";
		oFCKeditor.ReplaceTextarea(); 
		
	});
}
