function akilia_logoff() {
	//var msg = 'Are you sure you want to exit?';
	//if (confirm(msg)) {
		document.location='./index.php?logoff=true';
	//}
}

function moneyFormat(number, symbol, locale) {
	if (locale == 'US') {
		dec_separator = '.';
		thousand_separator = ',';
	} else {
		dec_separator = ',';
		thousand_separator = '.';
	}
	currency = '';
	
	switch (symbol) {
		case 'EUR' : currency = 'EUR'; break;
		case 'GBP' : currency = '£'; break;
		case 'USD' : currency = '$'; break;
		default : currency = '?';
	}
	
	number = Math.round(number*100)/100;
	number = number + '';
	number_parts = number.split('.');
	int_part = number_parts[0];
	formatted = '';

	for (i = 0; i < int_part.length; i++) {
	
		if (i != 0 && (int_part.length-i)%3==0) formatted += thousand_separator + int_part[i];
		else formatted += int_part[i];
	
	}	
	if (isNaN(number_parts[1])) {
		dec_part = '00';
	} else {
		dec_part = number_parts[1];
	}
	formatted += dec_separator + dec_part + ' ' + currency;

	return formatted;
} 

function noaccess() {

	alert(noaccess_text);	
	
}

function changeUrl(url, name, value) {


	var getname = name + "=";
	var namelength = name.length;
	
	var pos=url.indexOf(getname);
	
	var ln_pos 	= url.indexOf('#');
	var ln 		= '';
	
	if (ln_pos > 0 ){

		ln	= url.substr(ln_pos, url.length);	
		url = url.substr(0, ln_pos);
		
	}
	
	
	var newurl='';
	
	if (pos>=0) {
	
		var before = url.substr(0, pos);
		var tmp  = url.substr(namelength+pos+1, url.length);
		
		var pos2 = tmp.indexOf('&');
		
		if (pos2 >= 0) {
		
			var after = url.substr(pos2+pos+namelength+1, url.length);
			
		} else {
		
			var after = '';
		}
		
		
		newurl = before + getname + value + after + ln;
		
	} else {

		
		var glue='?';
		if (url.indexOf('?') > 0) glue = '&';

		
		newurl = url + glue + getname + value + ln;
			
	}

	return newurl;

}

function setGetVar(name, value) {

	document.location.href=changeUrl(document.location.href, name, value); 
	
}

function newurl(url) {
	
	document.location.href=url;

}

function newwindow(serverurl, request, title, width, height, posX, posY, location, menubar, toolbar, scrollbar, resize, status) {
/*	receives the following parameters:
	(mandatory) string server, string url 
	(optional)  [, string title, int width, int height, 
				int/string X position, int/string Y position,
				boolean location, boolean menubar, boolean toolbar, boolean scrollbar, 
				boolean resizable, boolean status ]
	(note : X position can be string left, center, right
			and Y position can be string top, middle, bottom)
	
	! beware that IExplorer needs a title without any space and not special chars (.)
*/
	var x,y,w,h;
	if (self.screenX) {// all except Explorer, Safari, Opera
		x = self.screenX;
		y = self.screenY;
	} else if (self.screenLeft) { // all other	
		x = self.screenLeft;
		y = self.screenTop;
	}
	//protection against IExplorer
	if(!x) x = 0; if(!y) y = 0;
	
	if (self.innerHeight){ // all except Explorer
		w = self.innerWidth;
		h = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){
		// Explorer 6 Strict Mode
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else if (document.body){ // other Explorers
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	var thresholdX = (document.all)? 4 : 1; //compensate borders
	var thresholdY = (document.all)? 248 : 100; //compensate menubar and toolbar
	
	if(typeof(posX) == "string") {
		if(posX == "center") posX = (w - ((width)? width : 800)) / 2;
		else if(posX == "left") posX = 0;
		else if(posX == "right") posX = (w - ((width)? width : 800));
		else posX = 800;
	}
	if(typeof(posY) == "string") {
		if(posY == "middle") posY = (h - ((height)? height : 400)) / 2;
		else if(posY == "top") posY = 0;
		else if(posY == "bottom") posY = (h - ((height)? height : 400));
		else posY = 600;
	}
	/*alert('url: ' + serverurl + '\n' +
			'request: ' + request + '\n' + 
			'title: ' + title + '\n' + 
			'width: ' + width + ', height: ' + height + '\n' +
			'left: ' + posX + ', top: ' + posY + '\n' +
			'location: ' + location + '\n' +
			'menubar: ' + menubar + '\n' +
			'toolbar: ' + toolbar + '\n' +
			'scrollbar: ' + scrollbar + '\n' +
			'resizable: ' + resize + '\n' +
			'statusbar: ' + status
		);*/
	var link = serverurl + '?window=new' + ((request != "")? '&' + request: '');
	newWindow = window.open(link, ((title)? title : "detail"),"width=" + ((width)? width : 800) + ",height=" + ((height)? height : 600) + ",left=" + ((posX)? posX + x - thresholdX : 100 + x - thresholdX) + ",top=" + ((posY)? (posY + y - thresholdY) : (100 + y - thresholdY)) + ",location=" + ((location)? location : "no") + ",menubar=" + ((menubar)? menubar : "no") + ",directories=no,toolbar=" + ((toolbar)? toolbar : "no") + ",scrollbars=" + ((scrollbar)? scrollbar : "yes") + ",resizable=" + ((resize)? resize : "yes") + ",status=" + ((status)? status : "no"), true);
	newWindow.focus();

} 


function grid_cell_over(obj) {

	//obj.style.background=color;
	//obj.style.backgroundImage= "url('./images/side_bg.gif')";
	obj.style.cursor = 'pointer';
	obj.className = 'grid-sel';
	//obj.style.borderStyle = "inset"; 
	//obj.style.borderWidth = 1;
	
}

function grid_cell_out(obj) {

	//obj.style.background = color;
	//obj.style.borderStyle = '';
	//obj.style.background = parent.style.background;
	//obj.style.background = color;
	//alert(obj.parentElement.className);
	//obj.parentElement.style.background = '#000000';

	if (obj.parentElement.sectionRowIndex % 2) {
		
		obj.className='grid-odd';
	
	} else {
		
		obj.className='grid-even';
		
	}

}

function line_color(obj, color, type) {
	
	if (type == 'selector') {
		obj.style.cursor = 'hand';	
	} else {
		obj.style.cursor = '';	
	}
	
	obj.style.background = color;	
}


function restore_line(obj) {

	// tbody.rows.length
	if (obj.sectionRowIndex % 2) {
		
		obj.className='grid-line-odd';
	
	} else {
		
		obj.className='grid-line-even';
		
	}
	
}


function line_style(obj, style, type) {

	
	if (type == 'selector') {
		obj.style.cursor = 'hand';	
	} else {
		obj.style.cursor = '';	
	}
	
	obj.className = style;	
	
}

function addBookmark(url){
		
		var parent_url = document.location.search;
	
		parent_url = parent_url.replace("?","");
		parent_url = parent_url.replace("&","|","g");
		
		url += '&parent_url=' + parent_url +''; 
		newwindow('./', url, 'Bookmarks', 380, 180, 'center', 'middle', 0, 0, 0, 0, 0, 0);
}
