/**                     Sirocco -- Administation Office
 *                             -- lib_base.js --
 *
 * Various functions for common usage
 * Require EnvInspector loaded and EventObject available.
 *
 * Javascript version : 1.5
 *
 * @category	library
 * @author	Luc Thibault <luc@suhali.net>
 * @copyright	2001-2009 - Luc Thibault - SUHALI WEB DESIGN
 * @license	GNU General Public License
 * @version	2.1
 *
 * GNU General Public License 
 * 	This program 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 2 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.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with this program ; if not, write to the
 *	Free Software Foundation, Inc.,
 *	51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA ;
 *	or visit http://www.gnu.org/copy_nLeft/gpl.html
 */

 
/*********** PAGE FUNCTIONS **************/

//function OffsetX(){
//	if (EnvInspector.browser == 'ie')
//		return document.documentElement.scrollLeft;
//	else	return parseInt(window.pageXOffset);
//}
//function pageW(){
//	if (EnvInspector.browser == 'ie')
//		return document.documentElement.offsetWidth;
//	else	return parseInt(window.innerWidth);
//}
//function getInnerWidth(){
//	var w = 0;
//	if (EnvInspector.browser == 'ie') {
//		w = document.documentElement.clientWidth;
//	} else { 
//		w = window.innerWidth;
//		if (document.height > window.innerHeight) w -= 16; // vert scrollbar
//	}
//	return w;
//}
//
//function OffsetY(){
//	if (EnvInspector.browser == 'ie')
//		return document.documentElement.scrollTop;
//	else	return parseInt(window.pageYOffset);
//}
//function pageH(){
//	if (EnvInspector.browser == 'ie')
//		return document.documentElement.offsetHeight;
//	else	return parseInt(window.innerHeight);
//}
//function getInnerHeight(){
//	var h = 0;
//	if (EnvInspector.browser == 'ie') {
//		h = document.documentElement.clientHeight
//	} else {
//		h = window.innerHeight
//		if (document.width > window.innerWidth) h -= 16	// horz scrollbar
//	}
//		return h;
//}


/************* IMAGE REPLACE *************/

function imageReplace (_id, _url) {
	$('#'+_id).attr('src', _url);
}

/*********** ELEMENT POSITION ************/

//function elementPosition (elem) {
//	positions = new Array()
//	elem = document.getElementById(elem);
//	if (elem){
//		if (EnvInspector.DOM) {
//			positions[0] = elem.offsetLeft;
//			positions[1] = elem.offsetTop;
//			while (elem.offsetParent != null && elem.offsetParent.tagName != 'BODY') {
//				elem = elem.offsetParent;
//				if (elem.tagName == 'BODY')
//					break;
//				positions[0] += elem.offsetLeft;
//				positions[1] += elem.offsetTop;
//			}
//		} else {
//			positions[0] = elem.x;
//			positions[1] = elem.y;
//		}
//		return positions;
//	} else	return null;
//}

/************** OPEN WINDOW **************/

//var variation
//var zoom
//
//variation = $.browser.msie ? (EnvInspector.platform == 'mac') ? -25 : 0 : 5;
//
//function openWindow (url,nom,dimx,dimy,type) {
//	dimy = dimy - variation;
//	featur0 = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+ dimx + ",height=" + dimy;
//        featur1 = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+ dimx + ",height=" + dimy;
//	props = eval('featur'+type);
//	win = window.open(url,nom,props)
//	win.focus();
//	return win;
//}

function populateField (table, index, field) {
	while (field.options.length > selectData[table][index].length)
		field.options[(field.options.length - 1)] = null;
	for (var i=0; selectData[table][index].length > i; i++)
		eval('field.options[i] = new Option("'+selectData[table][index][i][1]+'","'+selectData[table][index][i][0]+'")');
}

/************** BOOKMARK PAGE **************/

function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}

