
var hobNob = document.cookie; 

function getCookie(name) { 
var index = hobNob.indexOf(name + "="); 
if (index == -1) return null; 
index = hobNob.indexOf("=", index) + 1; // first character
var endstr = hobNob.indexOf(";", index); 
if (endstr == -1) endstr = hobNob.length;  // last character 
return unescape(hobNob.substring(index, endstr));
}

function initializeDirectory() {
      var info = getCookie("mybruneisettings");
	if (info != null) {
		var splitInfo = info.split("xxx");
		var initialzoom = parseInt(splitInfo[0]);
		var pageadvance = parseInt(splitInfo[1]);
	}
	else {
		var initialzoom = "1";
		var pageadvance = "10";
		setMyPreferences(initialzoom, pageadvance);
	}
}

function getPageAdvance() {
     	var info = getCookie("mybruneisettings");
	if (info != null) {
		var splitInfo = info.split("xxx");
		return parseInt(splitInfo[1]);
	}
	else
		return 10;
}

function getZoomLevel() {
     	var info = getCookie("mybruneisettings");
	if (info != null) {
		var splitInfo = info.split("xxx");
		return parseInt(splitInfo[0]);
	}
	else
	 return 1;

}

function reloadCurrentPage() { 
     if (top.select.menu.section != 'cover' && top.select.menu.section != 'featured') { 
          var page = top.select.menu.getPage(); 
          var section = top.select.menu.getSection(); 
          top.select.menu.openSection(section,page); 
     } 
}

function setMyRadioButtons() {
var zoom = getZoomLevel();
var advance = getPageAdvance();
setZoomButton(zoom);
setAdvanceButton(advance);
}

function setZoomButton(zooming) {
	for (i=0; i < document.radioform1.RadioButton.length; i++) {
		if (document.radioform1.RadioButton[i].value == zooming) {
			document.radioform1.RadioButton[i].checked  = 'true';
		}
	}
}
function setAdvanceButton(pgAdvance) {
	for (i=0; i < document.radioform2.RadioButton.length; i++) {
		if (document.radioform2.RadioButton[i].value == pgAdvance) {
			document.radioform2.RadioButton[i].checked  = 'true';
		}
	}
}

function setMyPreferences(zoom, advance) {
	var cookie_info = zoom + "xxx" + advance;
	document.cookie = 'mybruneisettings='+cookie_info+'; expires=Fri, 31 Dec 2099 11:59:59 UTC; path=/';
}

function openHelp()
{
	var helpWindow=window.open(href='flash/flash.htm', 'Help','width=688,height=500,toolbar=auto,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no')
	if(navigator.appName!="Netscape" && navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.charAt(navigator.appVersion.indexOf("MSIE")+5)== '4')
		top.window.blur();
	else
		helpWindow.focus();
}


var prefWindow="";
function openPreferences()
{
	prefWindow=window.open(href='preferences.htm', 'Prefs','width=150,height=220,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no')
	return prefWindow;
}

//function isClosed() { //alert(prefWindow);
//	if (prefWindow!=null) {
//		//alert("not null now");
//		if (prefWindow && !prefWindow.closed) { alert("closed"); }
//	}
//	else { setTimeout('isClosed()', 1000) }
//}


function decline() {
	top.window.close();
}


function activateBack(){ 
        var backoff = document.getElementById('backoff'); 
        var backon = document.getElementById('backon'); 
          backoff.style.visibility = "hidden" 
          backon.style.visibility = "visible" 
} 
function deactivateBack(){ 
     var backoff = document.getElementById('backoff'); 
    var backon = document.getElementById('backon'); 
     backoff.style.visibility = "visible" 
     backon.style.visibility = "hidden" 
} 
function activateForward(){ 
     var forwoff = document.getElementById('forwoff'); 
     var forwon = document.getElementById('forwon'); 
    forwoff.style.visibility = "hidden" 
     forwon.style.visibility = "visible" 
} 
function deactivateForward(){ 
     var forwoff = document.getElementById('forwoff'); 
    var forwon = document.getElementById('forwon'); 
     forwoff.style.visibility = "visible" 
     forwon.style.visibility = "hidden" 
} 

function doSwitch() { 
    var other = document.getElementById('otherbrowsers'); 
    var backoff = document.getElementById('backoff'); 
    var forwoff = document.getElementById('forwoff'); 
     otherbrowsers.style.visibility = "hidden"; 
     backoff.style.visibility = "visible"; 
     forwoff.style.visibility = "visible"; 
}


var wn = null;
var addrName = null;
var addrNumber = null;
function openAddress() {
   wn = window.open('addrBook.htm','AddressBook','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=400,height=270');
}
function openAddressWithInfo(name,phoneNumber) {

	addrName = name;
	addrNumber = phoneNumber;
	if(wn != null)
		wn.close();
     wn = window.open('addrBook.htm','AddressBook','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=400,height=270');
	wn.focus();
}

