window.defaultStatus = "insel-langeoog.de";

function fResize()
{
	window.location.reload();
}

// Bannerslide ------------------------------------------------------------------------------------
// style="overflow-x:hidden" to the opening BODY tag

img_places = 2;
data = new Array();
data[0] = new Array("images/wbseewohnen.gif",	"http://www.seewohnen.de/",					"_blank", "");
data[1] = new Array("images/wbBlievhier.gif",	"http://www.langeoog.de/buergerhilfe.htm",	"_blank", "");
data[2] = new Array("images/wbLamberti.gif",	"http://www.hotel-lamberti.de",				"_blank", "");
data[3] = new Array("images/wbNumrich.gif",		"/scripts/branchenverzeichnis.asp?kat=100#wbNumrich",	"frm_main", "");
data[4] = new Array("images/wbschmidthd.gif",	"http://www.eeten-un-drinken.de/",			"_blank", "");

// random permutation of indices
var index, store;
indices = new Array(data.length);
for (var i = 0; i < data.length; i++) {
	indices[i] = i;
}
for (var i = data.length; i>0 ; i--) {
	index = Math.floor(i * Math.random());
	store = indices[index];
	indices [index] = indices[i-1];
	indices[i-1] = store;
}
//alert(indices);

speed_play =  1;
speed_fast = 10;

img_width = 234;		// Breite eines Bildes
img_height = 60;		// Höhe eines Bildes
img_spacer = 10;		// Zwischenraum der Bilder

display_top = 15;		// Position oben
display_left = 285;		// Position links

time_fast = 10;			// Laufsteuerung
time_play = 20;
time_pause = 1000;

moveFlag = 0;			// Laufsteuerung
moveFlag_catch = 0;
moveFlag_end = 0;
moveFlag_fastStop = 0;	

display_border = 0;		// Borderdicke
border_type = "solid";
border_colour = "#ffffff";
space_color = "#397CCB";

display_width = (img_places * img_width) + (img_places * img_spacer);
nowdivpos = new Array();
next_right = "";
nextpic = 0;

function BsControl(aSignal)
{
	switch (aSignal)
	{
		case "on":
			document.getElementById('btnStop').style.display		= "block";
			document.getElementById('btnStart').style.display		= "none";
			//document.getElementById('btnInactiv').style.display	= "none";
			start_play();
			break;

		case "off":
			document.getElementById('btnStop').style.display		= "none";
			document.getElementById('btnStart').style.display		= "none";
			//document.getElementById('btnInactiv').style.display	= "block";
			moveFlag_fastStop = 1;
			break;

		case "next":
			document.getElementById('btnStop').style.display		= "none";
			document.getElementById('btnStart').style.display		= "none";
			//document.getElementById('btnInactiv').style.display	= "block";
			stop_move();
			move_right();
			moveFlag_fastStop=1;
			break;

		case "reset":
			document.getElementById('btnStop').style.display		= "none";
			document.getElementById('btnStart').style.display		= "block";
			//document.getElementById('btnInactiv').style.display	= "none";
			break;
	}
}


function InitBannerslide()
{
	nextpic = 0;
	document.write("<div id=\"btnStop\" style=\"position:absolute; display:block; right:525px; top:61px; height:15px; border:solid 0px #fff; background-color:#4897E8; color:#fff; font-size:10px; font-family:verdana; line-height:13px; padding:0px 1px 1px 1px;\"><a href=\"javascript:BsControl('off');\" onFocus=\"if (this.blur) this.blur();\">&nbsp;stop&nbsp;</a></div>");
	document.write("<div id=\"btnStart\" style=\"position:absolute; display:none; right:525px; top:61px; height:15px; border:solid 0px #fff; background-color:#4897E8; color:#fff; font-size:10px; font-family:verdana; line-height:13px; padding:0px 1px 1px 1px;\"><a href=\"javascript:BsControl('on');\" onFocus=\"if (this.blur) this.blur();\">&nbsp;start&nbsp;</a></div>");
	document.write("<div id=\"btnNext\" style=\"position:absolute; display:block; right:560px; top:61px; height:15px; border:solid 0px #fff; background-color:#4897E8; color:#fff; font-size:10px; font-family:verdana; line-height:13px; padding:0px 1px 1px 1px; font-weight:bold;\"><a href=\"javascript:BsControl('next');\" title=\"Einzelbildschaltung\" onFocus=\"if (this.blur) this.blur();\">&nbsp;&nbsp;<<&nbsp;&nbsp;</a></div>");
	
	document.write("<div id=\"display\" style=\"position:absolute; right:30px; top:"+display_top+"; width:" + (display_width + display_border * 2) + "px; height:"+(img_height+display_border*2)+"px; border:"+display_border+"px "+border_type+" "+border_colour+"; background-color:"+space_color+"\">");
	document.write("<div id=\"center_div\" style=\"position:absolute; left:0; top:0; width:"+display_width+"px; height:"+img_height+"px; clip:rect(0,"+display_width+","+img_height+",0)\" onmouseover=\"if (moveFlag_fastStop==0) stop_move();\" onmouseout=\"if (document.getElementById('btnStop').style.display=='block') start_play();\">");
	for (i=0; i<img_places + 1; i++)
	{
		document.write("<div id=\"div_"+[i]+"\" style=\"position:absolute\">");
		document.write("<a class='Standard' id=\"loc"+[i]+"\" href=\"#\" onclick=\"if (this.target == '_blank') newwin(this.location); else parent.frm_main.location = this.location; return false\"><img src=\"\" id=\"pic_"+[i]+"\" width="+img_width+" height="+img_height+" alt=\"\" border=\"0\"></a></div>");
	}
	document.write("</div>");
	document.write("</div>");

	el_center = document.getElementById("center_div");
	el_pos = -document.getElementById("pic_0").width - img_spacer; 
	for (i=0; i < img_places+1; i++)
	{
		el_pos += document.getElementById("pic_0").width + img_spacer;
		document.getElementById("div_" + [i]).style.left = el_pos;
		document.getElementById("loc" + [i]).location = data[indices[nextpic]][1];
		document.getElementById("loc" + [i]).target = data[indices[nextpic]][2];
		document.getElementById("pic_" + [i]).alt = data[indices[nextpic]][3];
		document.getElementById("pic_" + [i]).src = data[indices[nextpic++]][0];
	}
	speed = speed_play;

	//next_right = setTimeout("move_right()", time_pause);
	BsControl('reset');
}



function move_right()
{
	if (moveFlag_end == 0 || moveFlag_fastStop == 0) 
	{	
		moveFlag = 1;
		moveFlag_end = 0;
		for (i = 0; i < img_places+1; i++)
		{
			nowdivpos[i] = parseInt(document.getElementById("div_" + [i]).style.left);
			nowdivpos[i] -= speed;
			
			var dist_left = nowdivpos[i] + document.getElementById("pic_0").width + img_spacer; 	
			if (dist_left <= 0)
			{
				moveFlag_catch = 0;
				moveFlag_end = 1;
				document.getElementById("div_"+[i]).style.left = parseInt(el_center.style.width);  
				if (nextpic > data.length-1) 
				{
					nextpic = 0;
				}
				document.getElementById("loc" + [i]).location = data[indices[nextpic]][1];
				document.getElementById("loc" + [i]).target = data[indices[nextpic]][2];
				document.getElementById("pic_" + [i]).src = data[indices[nextpic]][0];
				document.getElementById("pic_" + [i]).alt = data[indices[nextpic++]][3];
			}
			else
			{
				if(dist_left < speed_fast) moveFlag_catch = 1;
				document.getElementById("div_"+[i]).style.left = nowdivpos[i];
			}
		}
		moveFlag = moveFlag + moveFlag_catch + 2*moveFlag_end + 3*moveFlag_fastStop;	// key
		//key-values: 1 play, 2 play_catch, 3 pause, 4 fast, 5 fast_catch, 6 stop
		
		switch (moveFlag)
		{
			case 3:
				next_right = setTimeout("move_right()", time_pause);
				break;
			case 4:
				speed = speed_fast;
				next_right = setTimeout("move_right()", time_fast);
				break;
			case 5:
				speed = speed_play;
				next_right = setTimeout("move_right()", time_play);
				break;
			case 6:
				clearTimeout(next_right);
				moveFlag = 0;
				moveFlag_fastStop = 0;
				BsControl("reset")	//reset start-button
				break;
			default:
				next_right = setTimeout("move_right()", time_play);
				break;
		}
	}
	else 
	{
		moveFlag = 0;
		moveFlag_fastStop = 0;
		BsControl("reset");
	}
}

function start_play()
{
	if (moveFlag == 0 && moveFlag_fastStop == 0) 
	{
		clearTimeout(next_right);
		speed = speed_play;
		move_right();
	}
}

function stop_move()
{
	if (moveFlag != 0)
	{
		clearTimeout(next_right);
		moveFlag = 0;
		moveFlag_fastStop = 0;
	}
}

function BsMoveToEnd()
{
	switch (moveFlag)
	{
		case 0:
			break;
		case 3:
			stop_move();
			BsControl("reset");
			break;
		default:
			BsControl("next");
			break;
	}
}

function newwin(loc)
{
	if (loc == "") 
	{
		return;
	}
	window.open(loc);
}
// Bannerslide ------------------------------------------------------------------------------------

