// JavaScript Document
//Startup vars:
var eBookWin = false;
var swfId = "flashContent";
//Functions:
//
//Standard popup, callable from html
//
function popup(url,name,fullscreen,win_width,win_height) {
	if(fullscreen){
		win_height = screen.height-65;
		win_width = screen.width-10;
		pos_horizon = 0;
		pos_vertical = 0;
	}else{
		pos_horizon = (((screen.width-10)/2)-(win_width/2));
		pos_vertical = (((screen.height-65)/2)-(win_height/2));
	}
	window.open(url,name,"width="+win_width+",height="+win_height+",top="+pos_vertical+",left="+pos_horizon);
}
//
//Returns the title of the current window
//
function get_Title(){
	return(window.document.title);
}
//
//Returns the location (URL) of the current window
//
function get_Location(){
	return(window.location.href);
}
//
//Returns the window DOM object
//
function get_window_object_by_name(nameStr){
	var result = window.open('goback.htm', nameStr);
	return result;
}
//
//Start a popup from flash
//
function popupWindow(win){
	//Get the properties of the window to be opened from the flash paramaters
	var winprops = new String('width='+win[2]+',outerWidth='+win[2]+',height='+win[3]+',outerHeight='+win[3]+',top='+win[6]+',left='+win[5]+',toolbar='+win[7]+',location='+win[9]+',scrollbars='+win[10]+',status='+win[8]+',resizable='+win[11]);
	//Only open the window if it does not exist
	if (!eBookWin) {
		eBookWin=window.open(win[0],win[1],winprops);
		//Safari workaround: Popups are blocked when coming from flash, call back flash and ask for a normal window
		if(!eBookWin) {
            getSwf(swfId).openWindowFromSwf(win[0]);
        }
	//If the window already exist:
	} else {
		//If the window has been closed, reopen it:
		if(eBookWin.closed){
			eBookWin=window.open(win[0],win[1],winprops);
		}
	}
	//Focus the new window:
	eBookWin.focus();
}
//
//Get the flash document id
//
function getSwf(id) {
	return document.getElementById(id);
}    
//
//Add a url to the favourites
//
function addFavorite(page){
	var url = new String(page[0]);
	var title = new String(page[1]);
	var warn = new String(page[2]);
	//alert(url+' - '+title+' - '+warn);
	if (window.sidebar) {
		//alert('FIREFOX');
		window.sidebar.addPanel(title, url, "");
		return;
	} else if(document.all){
		if(window.opera && window.print){
			//alert('OPERA');
		}else{
			//alert('IE');
			window.external.AddFavorite(url, page[1]);
			return;
		}
	}
	alert(warn);
}