var pageTitle = "Angels & Demons";

window.onload = initialize;
function initialize() {
  dhtmlHistory.initialize();
  dhtmlHistory.addListener(handleHistoryChange);
}


function updateBrowser(newLocation, historyData) {
  var historyMessage;
  if (historyData != null){
		document.title = pageTitle + " - " + historyData.message;
	} else {
		document.title = pageTitle;
	}
}


function handleHistoryChange(location, historyData) {
  	updateBrowser(location, historyData);

	//if(flashobj.loadStartup){
		//alert("calling loadStartup: " + dhtmlHistory.getCurrentLocation());
	getMovie("mainswf").changePage(dhtmlHistory.getCurrentLocation());
	
	//}
}


function getMovie(name) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[name]
    }
    else {
        return document[name]
    }
}


function setPage(id, title) {
	var historyData = {message:title};

    updateBrowser(id, historyData);
	
	dhtmlHistory.add(id, historyData);
	
	//if tracking - call tracking code here
}
function getPage() {
	return dhtmlHistory.getCurrentLocation();
}


function getPageTitle() {
	return document.title;
}

function setPageTitle(t) {
	document.title = t;
}



function popup(url, w, h) {
	var wid = 600;
	var hi = 476;
	
	if (w != null) wid = w; 
	if (h != null) hi  = h;
	
	var scroll = true;
	
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	
	new_spec = wid + "_" + hi + scroll;
	scrolling = scroll? "yes": "no";
	if (scroll && document.all && (navigator.userAgent.indexOf("Mac") > -1)) wid = wid+17;
	newwin=window.open(url,new_spec,"WIDTH=" + wid + ",HEIGHT=" + hi + ",scrollBars=" + scrolling + ",resizable=yes,screenX="+winl+",screenY="+wint+",left="+winl+",top="+wint);
	newwin.focus();
}

function popupNoScroll(url, w, h) {
	var wid = 600;
	var hi = 476;
	
	if (w != null) wid = w; 
	if (h != null) hi  = h;
	
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	
	new_spec = wid + "_" + hi;
	newwin=window.open(url,new_spec,"WIDTH=" + wid + ",HEIGHT=" + hi + ",scrollBars=no,resizable=no,screenX="+winl+",screenY="+wint+",left="+winl+",top="+wint);
	newwin.focus();
}

function popupFullWindow(url, w, h) {
	var wid = 600;
	var hi = 476;
	
	if (w != null) wid = w; 
	if (h != null) hi  = h;
	
	var scroll = true;
	
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	
	new_spec = wid + "_" + hi + scroll;
	scrolling = scroll? "yes": "no";
	if (scroll && document.all && (navigator.userAgent.indexOf("Mac") > -1)) wid = wid+17;
	newwin=window.open(url,new_spec,"WIDTH=" + wid + ",HEIGHT=" + hi + ",scrollBars=" + scrolling + ",menubar=yes,toolbar=yes,location=yes,resizable=yes,screenX="+winl+",screenY="+wint+",left="+winl+",top="+wint);
	newwin.focus();
}
	

function allSwfsMustDIE(){
	/*var objects = document.getElementsByTagName("OBJECT");
	
	//alert('destroy all ' + (objects.length) + ' swfs');
  for (var i=0; i < objects.length; i++) {
    for (var x in objects[i]) {
      if (typeof objects[i][x] == 'function') {
				//alert('destroying ' + objects[i][x]);
        objects[i][x] = null;
      }
    }
  }
	
	
	var divHolder = document.getElementById("v5wrapper");
	var divToKILL = document.getElementById("flashcontent");
	divHolder.removeChild(divToKILL);
	
	//alert('everything is gone');
	
	
	
	var elem = document.getElementById("v5wrapper");
	alert('target to destroy elem - ' + elem);
	elem.parentNode.removeChild(elem);
	alert(elem);
	*/
	
	//alert('destroying flashcontent');
	//alert(divToKILL);
	
}

if (typeof window.onunload == 'function') {
  //var oldunload = window.onunload;
  window.onunload = function() {
    //allSwfsMustDIE();
    //oldunload();
  }
} else {
  //window.onunload = allSwfsMustDIE;
}

