//IIDj BERLIN-A-Z 2006, 04 ----------------------------------------------------
// basic settings

var visible,hidden,theUnitTag,WindowHeight,WindowWidth,vScroll,ScrollMenu,CursorX,CursorY,theMouse,ScrollMenu,slideShow;

window.onerror=null;
if (!document.getElementById) {
if (document.all) {
document.getElementById = IEgetElementByID;
}
else {
if (navigator.userAgent.indexOf('Mac',1)>0) {
self.location="noAccess_M.html";
}
else if (navigator.userAgent.indexOf('Win',1)>0) {
self.location="noAccess_W.html";
}
else {
self.location="noAccess.html";
}
}
}

visible = 'visible';
hidden = 'hidden';
theUnitTag = "px";
if (self.innerHeight) {
WindowHeight="self.innerHeight";
WindowWidth="self.innerWidth";
}

else if (document.documentElement && document.documentElement.clientHeight) {
WindowHeight="document.documentElement.clientHeight";
WindowWidth="document.documentElement.clientWidth";
}

else {
WindowHeight="document.body.clientHeight";
WindowWidth="document.body.clientWidth";
}

if (self.pageYOffset > -1) {
vScroll="self.pageYOffset";
}

else if (document.documentElement && document.documentElement.scrollTop > -1) {
vScroll="document.documentElement.scrollTop + document.body.scrollTop";
}

else {
vScroll="document.body.scrollTop";
}


function IEgetElementByID(ID) {
return document.all[ID];
}

//----------------------------------------------------------------------
// functions for scrolling objects
function makeScrollObject(theScrollObjectList) {
var theScrollObject;
this.Speed=15;
this.Snap=8;
this.vScrollPos=eval(vScroll);
this.ScrollFlag=false;
this.Length=theScrollObjectList.length;
this.ScrollObjectList=new Array ();
this.checkScroll=checkScroll;
this.setScroll=setScroll;
this.scrollObjects=scrollObjects;
for (var i in theScrollObjectList) {
theScrollObject=document.getElementById(theScrollObjectList[i][0]);
theScrollObject.origY=parseInt(theScrollObject.style.top);
theScrollObject.height = theScrollObjectList[i][2];
theScrollObject.flow=theScrollObjectList[i][1];
theScrollObject.CurrentScroll=theScrollObject.origY;
theScrollObject.targetY=theScrollObject.CurrentScroll;
theScrollObject.deltaY=0;
//this.ScrollObjectList.push(theScrollObject);
// to include IE prior 5.5
this.ScrollObjectList[this.ScrollObjectList.length]=theScrollObject;
}
this.checkScroll();
return this;
}
function checkScroll() {
if (eval(vScroll) != this.vScrollPos) {
this.vScrollPos=eval(vScroll);
this.ScrollFlag=true;
}
else if (this.ScrollFlag) {
this.setScroll();
}
setTimeout("this.checkScroll();",100);
}
function setScroll() {
var theScrollObject;
//flag menu to disable selection
this.ScrollFlag=false;
//get TARGET scroll, scroll DELTA
for (theScrollObject in this.ScrollObjectList) {
theScrollObject = this.ScrollObjectList[theScrollObject];
if (theScrollObject.height > (eval(WindowHeight)-theScrollObject.origY)) {
theScrollObject.targetY=theScrollObject.origY;
}
else {
theScrollObject.CurrentScroll=parseInt(theScrollObject.style.top);
theScrollObject.targetY=(theScrollObject.origY+this.vScrollPos);
theScrollObject.deltaY=(theScrollObject.targetY - theScrollObject.CurrentScroll)/this.Speed;
}
if (!theScrollObject.flow) {
theScrollObject.style.top=theScrollObject.targetY + theUnitTag;
}
}
this.scrollObjects();
}
function scrollObjects() {
var theNewDeltaY,finishedScroll,theScrollObject;
finishedScroll=false;
for (theScrollObject in this.ScrollObjectList) {
theScrollObject = this.ScrollObjectList[theScrollObject];
if (theScrollObject.flow) {
if (Math.abs(theScrollObject.targetY - theScrollObject.CurrentScroll) > this.Snap) {
theScrollObject.CurrentScroll=theScrollObject.CurrentScroll + theScrollObject.deltaY;
theScrollObject.style.top=theScrollObject.CurrentScroll + theUnitTag;
theNewDeltaY=Math.round((theScrollObject.targetY - theScrollObject.CurrentScroll)/this.Speed);
if (Math.abs(theNewDeltaY) >= 1) {
theScrollObject.deltaY=theNewDeltaY;
}
else {
theScrollObject.style.top=theScrollObject.targetY + theUnitTag;
finishedScroll=true;
}
}
}
}
if (finishedScroll) {
return true;
}
setTimeout("this.scrollObjects();",10);
return false;
}
//----------------------------------------------------------------------
// rollover image menu
// make sure that the roll over image filename is in the following form: RO_theImageFilename, where theImageFilename is the name of the original/default imagefile
function makeImageMenu (theMenuName,theMenuLeft,theMenuTop,theZindex,theMenuImageParentUrl,theMenuImageFileNameList,theLinkList) {
var theMenuItemCounter,theMenuImage;
this.MenuName = theMenuName;
this.MenuLength = theMenuImageFileNameList.length;
this.MenuImageFileNameList = theMenuImageFileNameList;
this.LinkList = theLinkList;
this.MenuImageList = new Array(this.MenuLength);
this.MenuImageParentUrl = theMenuImageParentUrl;
this.switchMenuImage = switchMenuImage;
this.enabled = true;

this.MenuText = "<DIV ID=\"DIV" +this.MenuName + "\" STYLE=\"position:absolute;left:" + theMenuLeft + "px;top:" + theMenuTop + "px;z-index:" + theZindex + ";visibility:hidden;\">"

for (theMenuItemCounter = 0;theMenuItemCounter < this.MenuLength;theMenuItemCounter++) {

 if (this.LinkList[theMenuItemCounter] != "") {
 this.MenuText = this.MenuText + "<A HREF=\"" + this.LinkList[theMenuItemCounter] + "\" onMouseOver=\"javascript:" +this.MenuName +".switchMenuImage(" + theMenuItemCounter + ",false);\" onMouseOut=\"javascript:" +this.MenuName +".switchMenuImage(" + theMenuItemCounter + ",true);\"><IMAGE NAME=\"MenuItem" + theMenuItemCounter + "\" SRC=\"" + this.MenuImageParentUrl + this.MenuImageFileNameList[theMenuItemCounter] + "\" BORDER=0>"
 this.MenuText = this.MenuText + "</A>"
}
 else {
 this.MenuText = this.MenuText + "<IMAGE NAME=\"MenuItem" + theMenuItemCounter + "\" SRC=\"" + this.MenuImageParentUrl + this.MenuImageFileNameList[theMenuItemCounter] + "\">"
}
 this.MenuText = this.MenuText + "<BR>";
}

this.MenuText = this.MenuText + "</DIV>"
// write menu text
document.open();
document.write(this.MenuText);
document.close();

for (theMenuItemCounter = 0;theMenuItemCounter < this.MenuLength;theMenuItemCounter++) {
 theMenuImage=document["MenuItem" + theMenuItemCounter];
 this.MenuImageList[theMenuItemCounter] = new RolloverImage(theMenuImage,this.MenuImageParentUrl,this.MenuImageFileNameList[theMenuItemCounter]);
}

// show Menu
this.Layer = document.getElementById("DIV" + this.MenuName);
this.LayerStyle = this.Layer.style;

return this;
}

//----------------------------------------------------------------------
// functions for rollovers

function RolloverImage(theRolloverImage,theRolloverImageParentUrl,theRolloverImageFileName) {
this.Image = theRolloverImage;
this.RoImage=new Image();
this.RoImage.src = theRolloverImageParentUrl + "RO" + theRolloverImageFileName.substring(2,theRolloverImageFileName.length);
this.OffImage=new Image();
this.OffImage.src = theRolloverImageParentUrl + theRolloverImageFileName;
this.ONstatus = false;
this.switchRolloverImage = switchRolloverImage;
}

function switchMenuImage(theMenuImageId,theOnFlag) {
if (this.enabled){
this.MenuImageList[theMenuImageId].switchRolloverImage(theOnFlag);
}
}

function switchRolloverImage(theOnFlag) {
if (theOnFlag) {
this.Image.src = this.OffImage.src;
}
else {
this.Image.src = this.RoImage.src;
}
}

//----------------------------------------------------------------------
// functions for layers

function writeLayer(theLayer,theLayerText) {
//if (!theLayer.innerHTML) {
//theLayer.document.open();
// theLayer.document.write(theLayerText);
// theLayer.document.close();
//}
//else {
 theLayer.innerHTML=theLayerText;
//}
}

function showLayers(theLayerList) {
var theLayerCounter;
var theLayerCount = theLayerList.length;
for (theLayerCounter = 0; theLayerCounter < theLayerCount; theLayerCounter++) {
theLayerList[theLayerCounter].style.visibility = visible;
}
}

function showImages(theImageList) {
var theImageCount = theImageList.length;
for (var theImageCounter = 0; theImageCounter < theImageCount; theImageCounter++) {
 theImageList[theImageCounter].style.visibility = visible;
}
}

//----------------------------------------------------------------------
// functions for external windows

function displayEXTERNAL(theURL,theWindowName,theWindowProperties) {
externalWINDOW=window.open(theURL,theWindowName,theWindowProperties);
externalWINDOW.focus();
}


//----------------------------------------------------------------------
// cookies



//----------------------------------------------------------------------
// auxiliaries

function putSlideShow(slideDivId,delay,sourceDir) {
slideShow = makeSlideShow(document.getElementById(slideDivId),delay,sourceDir);
var slideShowHtml = '<a href="javascript:slideShow.togglePlayStatus();"><img id="' + slideShow.imageId + '" src="" alt="" width="385" height="299" border="0" align="top" title="止" /></a><br /><div id="' + slideShow.captionId + '" class="CAPTION">mmm</div>';
writeLayer(slideShow.layer,slideShowHtml);
slideShow.image = document.getElementById(slideShow.imageId);
slideShow.caption = document.getElementById(slideShow.captionId);
var initImageIndex = this.location.search.replace(/\?/,'');
if (initImageIndex) {
slideShow.index = initImageIndex;
slideShow.preloadImage.src = slideShow.sourceDir + slideShow.imageList[slideShow.index];
slideShow.togglePlayStatus();
}
else {
slideShow.preloadImage.src = slideShow.sourceDir + slideShow.imageList[0];
}
slideShow.play();
}

function makeSlideShow(slideDiv,delay,sourceDir) {
this.layer = slideDiv;
this.imageList = imageList;
this.captionList = captionList;
this.playStatus = true;
this.index = 0;
this.slideCount = this.imageList.length;
this.sourceDir = sourceDir;
this.image = new Image();
this.preloadImage = new Image();
this.imageId = 'slideImage';
this.captionId = 'slideCaption';
this.delay = delay;
this.play = playSlideShow;
this.togglePlayStatus = togglePlayStatus;
return this;
}

function playSlideShow() {
this.image.src = this.preloadImage.src;
this.caption.innerHTML = this.captionList[this.index];
if (this.playStatus) {
this.index ++;
if (this.index == this.slideCount) {
this.index = 0;
}
this.preloadImage.src = this.sourceDir + this.imageList[this.index];
this.timer = setTimeout("playSlideShow();",this.delay);
}
}

function togglePlayStatus() {
if (this.playStatus) {
this.playStatus = false;
this.image.title = '次';
clearTimeout(this.timer);
}
else {
this.playStatus = true;
this.image.title = '止';
this.playSlideShow();
}
}
