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");
	top.naviSelection=naviframe.document.getElementById("Unternehmen");
	top.leftSelection=null;
}

function selectNavi(item) {
	if (top.naviSelection != null) {
		top.naviSelection.className = "blue";
	}
	
	top.naviSelection = item;
	item.className="blueSelected";
	
	//das Left-Item sollte damit weg sein!
	top.leftSelection=null;
}

function selectLeft(item) {
	if (top.leftSelection != null) {
		if (top.leftSelection.className != null) {
			top.leftSelection.className = "dark";
		}
	}
	
	top.leftSelection = item;
	item.className="yellowSelected";
}

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;
	
	//neues Fenster, kein Aktuelles :)
	top.leftSelection=null;
}

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

function check_Rueckrufformular_DE() {
	if (document.Rueckrufformular.out_005LFirma.value == "" || 
		document.Rueckrufformular.out_022LName.value == "" || 
		document.Rueckrufformular.out_024LTelNr.value == "" || 
		document.Rueckrufformular.out_026LTermin.value == "") {
		alert("Es sind nicht alle Pflichfelder ausgefüllt!\nStellen Sie bitte sicher, dass Sie Firma, Name, Telefonnummer und Rückruftermin ausgefüllt haben!");
		return false;
	}
	return bestaetigen();
}

function check_Rueckrufformular_EN() {
	if (document.Rueckrufformular.out_005LFirma.value == "" || 
		document.Rueckrufformular.out_022LName.value == "" || 
		document.Rueckrufformular.out_024LTelNr.value == "" || 
		document.Rueckrufformular.out_026LTermin.value == "") {
		alert("Missing data in mandatory field!\nPlease make sure that the mandatory fields Company, Surname, Phone no and Appointment to call back are filled in!");
		return false;
	}
	return bestaetigen_en();
}
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;
	}
}

function showDetail(url, target) {
	if (target == "") {
		target = "Detail";
	}
	window.open(url, target);
}

// ---------------- 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 )
	{ 
	  //alert("kein CreateElement() vorhanden")
		return false;
	}


	if( ! detail ) {
		// nur beim ersten Mal
		//var _body = document.getElementsByTagName( 'body' )[0];
		var _body = self.parent.midframe.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 (! self.parent.midframe.document.getElementById( 'Detail' ) ) {
			return false;
		}
		
		detail = self.parent.midframe.document.getElementById( 'Detail' );
	}
	
	//alert(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() {
  if (! detail ) {
		detail = self.parent.midframe.document.getElementById('Detail');
	}
	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="details" 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" style="cursor:pointer"><a class="detals" onClick="closeDetails()">Fenster schlie&szlig;en</a></div>'+
			'</div>';
	
	openDetails(str, x, y, w, h)
}

function openFenster_en(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="details" 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" style="cursor:pointer"><a class="detals" onClick="closeDetails()">Close window</a></div>'+
			'</div>';
	
	openDetails(str, x, y, w, h)
}

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 openBild_en(title, url, x, y, w, h) {
	str = '<span><img src="' + url + '" alt="' + title + '" border="1"><span>';
	openFenster_en(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;
}

