var currentBook;
function callExternalInterface(targ) {
    thisMovie("flip_book").goHome(targ);
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
var incr=0;
function raiseDiv(){
	incr+=157;
	swif.style.height=incr+'px';
	if(swif.offsetHeight>=785){
		clearInterval(interval);
		callExternalInterface(currentBook);
	}	
}
function closeDiv(){
	incr-=157;
	swif.style.height=incr+'px';
	if(swif.offsetHeight<=0)
		clearInterval(interval);
}

function init(){
	var a =document.getElementsByTagName('a');
	for(i=0;i<a.length;i++){
		if(a[i].className=='flipbook'){
			a[i].onclick=function(){
				swif=document.getElementById('flip_book');
				currentBook=this.id;
				if(swif.offsetHeight<=0)
					interval=setInterval('raiseDiv()',2);
				else
					callExternalInterface(currentBook);
			}
		}
	}
}

function close(){
				swif=document.getElementById('flip_book');
				interval=setInterval('closeDiv()',2);
}
function preload(){
					callExternalInterface('autumn_nights');
}


function addEvent(elm, evType, fn, useCapture){  //cross-browser event handling
	if(elm.addEventListener){//firefox, safari, chrome, opera
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if(elm.attachEvent){//ie
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}else{
		elm['on' + evType] = fn;
	}
}
addEvent(window, 'load', init, false);
