/*
 	The first part is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    A copy of the GNU General Public License can be obtained from http://www.gnu.org/licenses/.
*/

/*
* 	Copyright (c) 2002 Thinking Arts Ltd (contact via http://www.thinkingarts.com/).
*/

//Function tomovehorizonta menu bar
function moveHorizontalMenu(id){
	var menuObj = 	document.getElementById(id);
	if(menuObj){
		menuObj.style.left = 0;
		menuObj.style.position = 'relative';
	}	
}

function showObject(id){
		
	var obj = document.getElementById(id);
	if(obj){
		obj.style.visibility =  'visible';
	}	
}	

function centreMenuObject(id){
	var menuObj = 	document.getElementById(id);
	if(menuObj){
		var width = menuObj.offsetParent.offsetWidth;
		var menuObjRealWidth = 0;
		
		for(var i=0; i < menuObj.childNodes.length; i++){
			if( menuObj.childNodes[i].tagName == 'LI'){
				menuObjRealWidth += menuObj.childNodes[i].offsetWidth;
			}	
		}
		
		menuObj.style.marginLeft = parseInt((width - menuObjRealWidth) /2);
		//alert("width:" + width + " Real Width:" + menuObjRealWidth);
		//window.status = "width:" + width + " Real Width:" + menuObjRealWidth;
	}	

}

function centreFieldsetDiv(id, parentId){
	var obj = 	document.getElementById(id);
	var parentObj = document.getElementById(parentId);
	
	if(obj && parentObj){
		var parentWidth = parentObj.offsetWidth;
		//var thisWidth = obj.offsetWidth;
		var thisWidth = 0;
		if(! thisWidth){
			for(var i=0; i < obj.childNodes.length; i++){
				if(obj.childNodes[i].tagName){
					if( obj.childNodes[i].tagName.toLowerCase() == 'fieldset'){

						thisWidth += obj.childNodes[i].offsetWidth;
						break;
					}	
				}	
				
			}
		}	
		
		obj.style.marginLeft = parseInt((parentWidth - thisWidth) /2);
		//alert("this:" + thisWidth + " parent:" + parentWidth);
		window.status = "Width:" + thisWidth + " Parent Width:" + parentWidth;
	}	

}


function getPositionOfElement(obj) {
	pos = new Object;
	
	if ( obj.offsetParent ) {
		pos.x = obj.offsetLeft;
		pos.y = obj.offsetTop;
		while ( obj = obj.offsetParent ) {
			pos.x += obj.offsetLeft;
			pos.y += obj.offsetTop;
		}
	}
	return pos;
}




