/* Kontaktformular */
if(document.layers) {
height00 = 730;
}
else {
height00 = 700;
}
function openContact2007(url) {
	satellit =eval('window.open(url,"Form","location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=500,height='+height00+'")');
	satellit.window.focus();
}
function openVehicleContact2007(url) {
	satellit =eval('window.open(url,"ProduktForm","location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=500,height='+height00+'")');
	satellit.window.focus();
}

function openBranches2007(url) {
	satellit =eval('window.open(url,"BranchesForm","location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=888,height=750")');
	satellit.window.focus();
}

/* TopUsed */
function openTopUsed2009(url) {
	satellit =eval('window.open(url,"TopUsed","location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=800,height=600")');
	satellit.window.focus();
}

/* Solutionguide */
//Radformel Grafik auf mouseover einblenden
function radformel(url, formel, tabId)
{
//	document.getElementById("radformel").innerHTML = '<div class="radformel_head"><strong>'+formel+'</strong></div><div class="radformel_img"><img src="'+url+'" alt="" border="0" /></div>';

	document.getElementById("radformel_help_" + tabId).style.display = "none";
	document.getElementById("radformel_" + tabId).style.display = "block";

	document.getElementById("radformel_img_" + tabId).src = url;
	document.getElementById("radformel_text_" + tabId).innerHTML = formel;
}

//Radformel Grafik auf mouseout ausblenden
function radformelHelp(tabId)
{
	return;

	document.getElementById("radformel_help_" + tabId).style.display = "block";
	document.getElementById("radformel_" + tabId).style.display = "none";
}

//Radformel Grafik auf mouseout ausblenden
function radformelHelpOLD(txt,touch,show,klick,pick )
{
	var img_radformel_help = /*VIPURL*/ "/mn-prod-neu/man2/global/datapool/images/radformel_help.gif";
	var radformelHTML = '<div class="radformel_titel"><strong>'+txt+'</strong></div><div><img src="' + img_radformel_help + '" alt="" width="223" height="84" border="0" /></div><div class="radformel_txt"><table border="0" cellpadding="0" cellspacing="0"><tr><td class="radformel_legende_r"><strong>'+touch+'</strong></td><td class="radformel_legende">'+show+'</td></tr><tr><td class="radformel_legende_r"><strong>'+klick+'</strong></td><td class="radformel_legende">'+pick+'</td></tr></table></div>';
	document.getElementById("radformel").innerHTML = radformelHTML;
}

//remove label text in input fields
function clearInitValue(el, initString)
{
	// clear text input value when input field is gaining focus for the first time
	if (el && initString && el.value == initString)
		el.value = "";
}

// Google Maps

function initStaticGoogleMap(lat,lng,information)
{
	if (GBrowserIsCompatible())
	{
		toAddressGPoint = new GLatLng( lat, lng );
		gIcon = new GIcon(G_DEFAULT_ICON);
		gIcon.image = /*VIPURL*/ "/mn-prod-neu/man2/resources/templates/2007/_resources/img/marker_green.png";
		gMarker = new GMarker( toAddressGPoint , gIcon );
		gMap = new GMap2(document.getElementById('map_canvas'));
		gMap.disableDragging();
		gMap.disableDoubleClickZoom();
		gMap.setCenter( toAddressGPoint , 13);
		gMap.addOverlay(gMarker);
		gMarker.openInfoWindowHtml( information );
		gMarker.bindInfoWindowHtml( information );
	}
}


function initGoogleMap()
{
	gIcon = new GIcon(G_DEFAULT_ICON);
	gIcon.image = /*VIPURL*/ "/mn-prod-neu/man2/resources/templates/2007/_resources/img/marker_green.png";
	gMarker = new GMarker( toAddressGPoint , gIcon );
	gMap = new GMap2(document.getElementById('map_canvas'));
	gMap.addControl(new GScaleControl());
	gMap.addControl(new GLargeMapControl());
	gMap.addControl(new GMapTypeControl());
	gMap.setCenter( toAddressGPoint , 13);
	gMap.addOverlay(gMarker);
	if ( fromAddressString )
	{
		gDirections = new GDirections( gMap );
		GEvent.addListener( gDirections, "load", handleLoad );
		GEvent.addListener( gDirections, "error", handleErrors );
	}
}

function computeRoute()
{
	fromAddressString = document.getElementById("fromAddress").value;
	initGoogleMap();
	gDirections.load( 'from: ' + toAddressString + ' to: ' + fromAddressString );
}

function handleErrors()
{
	if (gDirections.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gDirections.getStatus().code);
	else if (gDirections.getStatus().code == G_GEO_SERVER_ERROR)
		alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gDirections.getStatus().code);
	else if (gDirections.getStatus().code == G_GEO_MISSING_QUERY)
		alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gDirections.getStatus().code);

	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);

	else if (gDirections.getStatus().code == G_GEO_BAD_KEY)
		alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gDirections.getStatus().code);
	else if (gDirections.getStatus().code == G_GEO_BAD_REQUEST)
		alert("A directions request could not be successfully parsed.\n Error code: " + gDirections.getStatus().code);
	else alert("An unknown error occurred.");

}


function handleLoad()
{
	gRoute = gDirections.getRoute(0);
					/*document.getElementById("tsRouteDesc").innerHTML = "";
					document.getElementById("tsRouteDesc").innerHTML = groute.getSummaryHtml();
					document.getElementById("tsRouteFrom").innerHTML = "";
					document.getElementById("tsRouteFrom").innerHTML = gfrom;
					document.getElementById("tsRouteTo").innerHTML = "";
					document.getElementById("tsRouteTo").innerHTML = title;//gto;
					var dDirList = document.getElementById("tsDir");
					while (dDirList.hasChildNodes()) {
						dDirList.removeChild(dDirList.firstChild);
					}
					*/

					/*for (var i = 1; i <= gRoute.getNumSteps(); i++) {
						var dStep = gRoute.getStep(i-1);
						var dStepDiv = document.createElement("div");
						dStepDiv.innerHTML = '<div class="tsRouteStepIndex"><span>' + i + '</span></div><span class="tsRouteStepDesc">' + dStep.getDescriptionHtml() + '</span><span class="tsRouteStepDistance">' + dStep.getDistance().html + '</span><div/>';
						//dStepDiv.className
						var dDirList = document.getElementById("route");
						dDirList.appendChild(dStepDiv);
					}*/
				}

function openGoogleMapsWithBrowserSwitch(url)
{
	var userAgent = navigator.userAgent;

	var Ergebnis = userAgent.match(/.*MSIE.*/);
	if ( Ergebnis != null )
	{
		alert("MSIE");
		satellit =eval('window.open(url,"GoogleMap","width=806,height=650,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")');
		satellit.window.focus();
		return;
	}

	Ergebnis = userAgent.match(/.*Firefox.*/);
	if ( Ergebnis != null )
	{
		satellit =eval('window.open(url,"GoogleMap","width=806,height=650,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")');
		satellit.window.focus();
		return;
	}

	Ergebnis = userAgent.match(/.*Safari.*/);
	if ( Ergebnis != null )
	{
		satellit =eval('window.open(url,"GoogleMap","width=822,height=651,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")');
		satellit.window.focus();
		return;
	}

	satellit =eval('window.open(url,"GoogleMap","width=806,height=650,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")');
	satellit.window.focus();

}

function openGoogleMaps(url)
{
	satellit =eval('window.open(url,"GoogleMap","width=806,height=650,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no")');
	satellit.window.focus();
}
