ie = (navigator.userAgent.indexOf("MSIE") != -1)
//var lastURL="";  // ist jetzt global in index.html angelegt
var detail = null;

function setup_top_pic() {
	top.top_pic = document.getElementById('top_pic');
	//alert("setup_top_pic feddich");
}

function setup() {
	//alert("setup");
	//top.top_pic = document.getElementById('top_pic'); <- passiert in top.html
	setLeftFrame("Uleft.html");
}

function set_top_pic(url) {
	if (url != "" && top.top_pic.src != url) {
		top.top_pic.src = url;
	}
}

function setAll(picUrl, leftUrl, midUrl) {
	set_top_pic(picUrl);
	setFrames(leftUrl, midUrl);
}

function applyOther(picUrl, midUrl) {
	set_top_pic(picUrl);
	if (midUrl != "" && top.midframe.location != midUrl) 
		top.midframe.location.replace(midUrl);
}

function setFrames(leftUrl, midUrl) {
	setLeftFrame(leftUrl);
	setMidFrame(midUrl);
}

function setLeftFrame(leftUrl) {
	if (leftUrl != "" && top.leftframe.location != leftUrl)
		top.leftframe.location = leftUrl;
}

function setMidFrame(midUrl) {
	if (midUrl != "" && top.midframe.location != midUrl)
		top.midframe.location = midUrl;
}

function bestaetigen() {
	if (confirm("Daten jetzt senden?") == true) {
		return true;
	}
	else {
		return false;
	}
}

function bestaetigen_en() {
	if (confirm("Send data now?") == true) {
		return true;
	}
	else {
		return false;
	}
}

// ---------------- old but good stuff :-)  --------------------- //


function changeFrames(url) {
	if (top.lastURL != url) {
		loadTop(url);
		top.lastURL = url;
	}
}

function loadTop(url) {
	if (top.topframe != null) {
		top.topframe.location = url;
	}
}


function loadBottom(url) {
	if (top.bottomframe != null) {	
		top.bottomframe.location.replace(url);
	}
}

function openDetails(string, x, y, w, h) {
	if ( !document.createElement )
	{
		return false;
	}

	if( ! detail ) {
		// nur beim ersten Mal
		var _body = document.getElementsByTagName( 'body' )[0];
		
		
		var _span = document.createElement( 'span' );
		_span.innerHTML = '<div id="Detail" style="position:absolute;top:0px:left:0px;visibility:hidden;z-index:255;">&nbsp;</div>';
		_body.appendChild( _span );
		
		
		if (! document.getElementById( 'Detail' ) ) {
			return false;
		}
		
		detail = document.getElementById( 'Detail' )
	}
	
	// html body
	var html ='<div style="width:' + w + ';border:solid 1px #231f20;background-color:#ffffff;padding:2px;">' + string;
	
	// set the content
	detail.style.left = x;
	detail.style.top = y;
	
	
	detail.innerHTML = html;
	detail.style.visibility = 'visible';
}

function hideDetails() {
	detail.style.visibility = 'hidden';
}

function closeDetails() {
	hideDetails();
}

function openFenster(headline, string, x, y, w, h) {
	// simuliert ein Fenster mit Titelzeile und Close-Button
	str = '<table cellpadding="5" cellspacing="0" border="0" width=' + w + '>' +
			'<tr>'+
			'<td class="black" width="100%"><b>' + headline + '</b></td>'+
			'<td><img src="../pics/cross.gif" width="15" height="15" onclick="closeDetails();" style="cursor:pointer;"></td></tr></table>'+
			string +
			'<div align="center"><a class="rouge" onClick="closeDetails()">Fenster schlie&szlig;en</a></div>'+
			'</div>';
	
	openDetails(str, x, y, w, h)
}

function openFlasche(headline, string, img, x, y, w, h) {
	mx = x; if (typeof(mx) == "undefined") mx = 250;
	my = y; if (typeof(my) == "undefined") my = 60;
	mw = w; if (typeof(mw) == "undefined") mw = 460;
	mh = h; if (typeof(mh) == "undefined") mh = 300;

	//alert("head: " + headline + ", x,y,w,h: " + x + " ," + y + " ," + w + " ," + h + " ," );
	// legt in ein Fenster eine Grafik nach links und den übergebenen Text rechts (mit align nach unten) an
	str = '<table width="' + mw + '" border="0" cellspacing="0" cellpadding="0" height="' + mh + '">'
		+ '<tr>'
		+ '<td valign="middle"><img src="../pics/' + img  + '" alt="" height="298" width="85" border="0"></td>' 
		+ '<td valign="middle" width="10">&nbsp;</td>'
		+ '<td valign="bottom" width="' + (mw-95) + '"><div class="black">' + string + '<br><br></div></td>'
		+ '</tr></table>';
	//alert(str);
	
	openFenster(headline, str, mx, my, mw, mh);
}

function openBild(title, url, x, y, w, h) {
	str = '<span><img src="' + url + '" alt="' + title + '" border="1"><span>';
	openFenster(title, str, x, y, w, h);
}

function switchURL() {
   var arg = new Array();
   var location = window.location.search;
   var url = "";
 
   if (location.length > 0) {
   	location = location.substr(1, location.length - 1);  // vorderes '?' abhacken
   	arg = location.split("&");  // Parameter trennen
   	switch(arg[0].toLowerCase()) {
   		case 'einhorn':		url = 'einhorn/einhorn_top.html'; break;
   		case 'weine':		url = 'weine/weine_top.html'; break;
   		case 'chateau':
   		case 'einzelhandel':url = 'einzelhandel/einzelhandel_top.html'; break;
   		case 'probe':		url = 'probe/probe_top.html'; break;
		case 'praesente':	url = 'praesente/praesente_top.html'; break;
		case 'armagnac':	url = 'armagnac/armagnac_top.html'; break;
		case 'couteau':	url = 'couteau/couteau_top.html'; break;
		case 'events':		url = 'events/events_top.html'; break;
		case 'wissen':		url = 'wissen/wissen_top.html'; break;
   		case 'katalog':		url = 'katalog/katalog_top.html'; break;
		case 'kontakt':		url = 'kontakt/kontakt_top.html'; break;
		case 'agb':		url = 'agb/agb_top.html'; break;
		case 'impressum':	url = 'agb/impressum_top.html'; break;
   		case 'undefinded':
   		default:				url = 'entree/entree_top.html';
   	}
   }
   else {  //Standard-Start-Seite
   	url = 'entree/entree_top.html';
   }
   return url;
}