/* ############################################################################################################
###	VRN GmbH - EFA9 Interface - Markus Müller																###
###	Kunde: VRT GmbH   																						###
###	template: dynamic functions für das VRT-Layout															###
############################################################################################################ */

/* ### // Initialisierung // ######################################## */
var dFocus = false;
var hFocus = false;
var mFocus = false;


function findPosition(obj)
{
	imgOffsetTop=0;imgOffsetLeft=0;

	do 
	{
		imgOffsetTop+=obj.offsetTop;
		imgOffsetLeft+=obj.offsetLeft;
		obj=obj.offsetParent;
	} while (obj.tagName != "BODY" && obj);
}

function hidePanel(pos)
			{
			
			var pos= pos;
			
				var panel = document.getElementById('zonePanel' + pos);
				var imgpanel = document.getElementById('zonePanelimg' + pos);
			
				if (panel)
				{
					panel.style.display = "none";
				}
			if (imgpanel)
			{
				imgpanel.style.display = "none";
			}
			}

function showID(obj) /*Anzeigen des Zonenfensters mit Fahrpreise*/
			{

				var test= obj.id;
				var position = test.substring(9, 11);

				var img = document.getElementById(obj.id);
				var panel = document.getElementById('zonePanel' + position);
				var imgpanel = document.getElementById('zonePanelimg' + position);

				findPosition(img);
				var objLeft = imgOffsetLeft -228;
			//	alert(objLeft);
				var objTop  = imgOffsetTop  + 20;
			//	alert(objTop);
			
			if (panel)  {
					panel.style.left = objLeft + "px";
					panel.style.top  = objTop + "px";
					panel.style.display = "inline";
					panel.style.color = "white";
					panel.style.padding = "5px";
					panel.style.background = "#96BE32";
					panel.style.border = "solid 1px";
					Drag.init(panel);
					}

				var objLeft2 = imgOffsetLeft + 118;
			//	alert(objLeft);
				var objTop2  = imgOffsetTop  + 30;
			//	alert(objTop);

			if (imgpanel)
			{
				imgpanel.style.left = objLeft2 + "px";
				imgpanel.style.top  = objTop2 + "px";
				imgpanel.style.display = "inline";
			}
			
			}



function set_date()
{
	var day, month, year;
	
	if (document.eingabe.action != 'XSLT_PS_REQUEST2')
	{
		day = document.eingabe.itdDateDay.value;
		month = document.eingabe.itdDateMonth.value;
		year = document.eingabe.itdDateYear.value;

		timeString = day + "." + month + "." + year;
		document.eingabe.date.value = timeString;
	}
}

/* ### // set the psparamdate in the ps request // ######################################## */
function set_date_ps() {
	var day, month, year, hours, minutes, seconds, ap;
	var intHours, intMinutes, intSeconds, intDay, intMonth, intYear;
	var today;

	today = new Date();
	intHours = today.getHours();
	intMinutes = today.getMinutes();
	intSeconds = today.getSeconds();
	intDay = today.getDate();
	intYear = today.getFullYear();
	intMonth = today.getMonth() + 1;

	if (intDay < 10) {
		day = "0"+intDay;
	} else {
		day = intDay;
	} 

	if (intMonth < 10) {
		month = "0"+intMonth;
	} else {
		month = intMonth;
	} 

	document.eingabe.psParamSampleDay.value = day;
	document.eingabe.psParamSampleMonth.value = month;
	document.eingabe.psParamSampleYear.value = intYear;
}


/* ### // set the psparamdate in the ps request as hidden parameter // ######################################## */
function setsampledate() {

	var date;
	var intDay, intMonth, day, month;
	var todaydate = new Date();
	
	intDay = document.eingabe.psParamSampleDay.value;
	intMonth = document.eingabe.psParamSampleMonth.value;

	if (intDay.length == '1') {
		day = "0"+intDay;
	} else {
		day = intDay;
	} 

	if (intMonth.length == '1') {
		month = "0"+intMonth;
	} else {
		month = intMonth;
	} 

	date = document.eingabe.psParamSampleYear.value + month + day;
	
	
	today_year = todaydate.getFullYear();

	today_month = todaydate.getMonth() + 1;
	today_month = ((today_month < 10) ? "0" : "") + today_month;

	today_day = todaydate.getDate();
	today_day =((today_day < 10) ? "0" : "") + today_day;

	today ='' + today_year + today_month + today_day;
	check_date = ((today <= date) ? "ok" : "nicht ok");

//	if (check_date == 'ok') {
		document.eingabe.psParamSampleDate.value = date;
//	} else {
//		alert ('Bitte geben Sie ein Datum ein das in der Zukunft liegt');
//		document.eingabe.psParamSampleDate.value = today;
//	} 

	
}


/* ### // change the class of an obj // ######################################## */
function change_class(id, obj_class) {
	document.getElementById(id).className = obj_class;
}


/* ### // clear the input field of the odv // ######################################## */
function clear_value(obj)
{
	if (obj.value == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)' || obj.value == 'Enter: Place, Stop, Address or Point of Interest (POI)')
	{
		obj.value = '';
	} else if (obj.value == 'hier eintragen: Ort, Haltestelle oder Straße' || obj.value == 'Enter: Place, Stop')
	{
		obj.value = '';
	}
	
	if (obj.value == 'gewählter Start aus Karte' || obj.value == 'gewähltes Ziel aus Karte')
	{
		obj.value = '';
	} else if (obj.value == 'gewählter Punkt aus Karte' || obj.value == 'gewählter Punkt aus Karte')
	{
		obj.value = '';
	}
	
	
}


/* ### // hide the map in the form // ######################################## */
function nomap()
{		
	divstate = document.getElementById('vrnMap');
	divstate.style.display = "none";
}


/* ### // hide an obj in the form // ######################################## */
function hide_id(obj)
{
	document.getElementById(obj).style.display ="none";
}


/* ### // set the focus to the input field // ######################################## */
function setFocus(obj)
{
	var panel = document.getElementById(obj);
	if (panel)
		panel.focus();
	else {
		return true;
	}
}



/* ### // show the route details in the form // ######################################## */
function show_routePanel(pos)
{
	var pos= pos;
	var panel = document.getElementById('route_panel_' + pos);

	if (panel)
	{
		panel.style.display = "inline";
		document.getElementById('show_rp_' + pos).style.display ="none";
		document.getElementById('hide_rp_' + pos).style.display ="inline";
		document.getElementById('route_ani_' + pos).style.display ="inline";
	}
}


/* ### // hide the routePanel in the form // ######################################## */
function hide_routePanel(pos)
{
	var pos= pos;
	var panel = document.getElementById('route_panel_' + pos);

	if (panel)
	{
		panel.style.display = "none";
		document.getElementById('show_rp_' + pos).style.display ="inline";
		document.getElementById('hide_rp_' + pos).style.display ="none";
		document.getElementById('route_ani_' + pos).style.display ="none";
	}
}


/* ### // find the position of the obj // ######################################## */
function find_position(obj)
{
	imgOffsetTop=0;imgOffsetLeft=0;

	do 
	{
		imgOffsetTop+=obj.offsetTop;
		imgOffsetLeft+=obj.offsetLeft;
		obj=obj.offsetParent;
	} while (obj.tagName != "BODY" && obj);
}


/* ### // check the values of the input fields // ######################################## */
function check_value()
{
	var mapusage = document.eingabe.itdLPxx_mapusage.value;
	if(! (mapusage == 'stt' || mapusage == 'ttb' || mapusage == 'rop' || mapusage == 'dm' || mapusage == 'ss')){
		if (document.eingabe.nameState_origin.value == 'empty')
		{
			var nameorigin = document.eingabe.name_origin.value;
		}
		if (document.eingabe.nameState_destination.value  == 'empty')
		{
			var namedestination = document.eingabe.name_destination.value;document.eingabe.name_via.value = '';
		}
		if (document.eingabe.nameState_via.value  == 'empty')
		{
			var namevia = document.eingabe.name_via.value;
		}
		if (document.eingabe.name_origin.value == 'gewählter Start aus Karte' || document.eingabe.name_origin.value == 'gewähltes Ziel aus Karte')
		{
			document.eingabe.name_origin.value = '';document.eingabe.name_destination.value = '';document.eingabe.name_via.value = '';
		}
		if (document.eingabe.name_destination.value == 'gewähltes Ziel aus Karte'|| document.eingabe.name_destination.value == 'gewählter Start aus Karte' )
		{
			document.eingabe.name_origin.value = '';document.eingabe.name_destination.value = '';document.eingabe.name_via.value = '';
		}
		if (document.eingabe.name_via.value == 'gewählter Punkt aus Karte')
		{
			document.eingabe.name_via.value = '';document.eingabe.name_origin.value = '';document.eingabe.name_destination.value = ''
		}
		if (nameorigin == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)' || nameorigin == 'Enter: Place, Stop, Address or Point of Interest (POI)')
		{
			document.eingabe.name_origin.value = '';
		}
		if (namedestination == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)' || namedestination == 'Enter: Place, Stop, Address or Point of Interest (POI)')
		{
			document.eingabe.name_destination.value = '';
		}
		if (namevia == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)' || namevia == 'Enter: Place, Stop, Address or Point of Interest (POI)')
		{
			document.eingabe.name_via.value = '';
		}
	} else if (document.eingabe.itdLPxx_mapusage.value == 'stt'){
		if (document.eingabe.nameState_stt.value == 'empty')
		{
			var namestt = document.eingabe.name_stt.value;
		}
		if (namestt == 'hier eintragen: Ort, Haltestelle oder Straße' || namestt == 'Enter: Place, Stop')
		{
			document.eingabe.name_stt.value = '';
		}
	} else if (document.eingabe.itdLPxx_mapusage.value == 'ttb'){
		if (document.eingabe.nameState_ttb.value == 'empty')
		{
			var namettb = document.eingabe.name_ttb.value;
		}
		if (namettb == 'hier eintragen: Ort, Haltestelle oder Straße')
		{
			document.eingabe.name_ttb.value = '';
		}
	} else if (document.eingabe.itdLPxx_mapusage.value == 'rop'){
		if (document.eingabe.nameState_rop.value == 'empty')
		{
			var namerop = document.eingabe.name_rop.value;
		}
		if (namerop == 'hier eintragen: Ort, Haltestelle oder Straße')
		{
			document.eingabe.name_rop.value = '';
		}
	} else if (document.eingabe.itdLPxx_mapusage.value == 'dm'){
		if (document.eingabe.nameState_dm.value == 'empty')
		{
			var namedm = document.eingabe.name_dm.value;
		}
		if (namedm == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)')
		{
			document.eingabe.name_dm.value = '';
		}
	} else if (document.eingabe.itdLPxx_mapusage.value == 'ss'){
		if (document.eingabe.nameState_ss.value == 'empty')
		{
			var namess = document.eingabe.name_ss.value;
		}
		if (namess == 'hier eintragen: Ort, Haltestelle oder Straße')
		{
			document.eingabe.name_ss.value = '';
		}
	}
}


/* ### // check the values of the input fields for the ps request // ######################################## */
function check_value_2()
{
	var mapusage = document.eingabe.itdLPxx_mapusage.value;

	if (document.eingabe.nameState_origin.value == 'empty')
	{
		var nameorigin = document.eingabe.name_origin.value;
	}
	if (document.eingabe.nameState_destination.value  == 'empty')
	{
		var namedestination = document.eingabe.name_destination.value;
	}
		
	if (nameorigin == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)')
	{
		document.eingabe.name_origin.value = '';
	}
	
	if (namedestination == 'hier eintragen: Ort, Haltestelle oder Straße oder interessanter Punkt (POI)')
	{
		document.eingabe.name_destination.value = '';
	}
}


/* ### // convert the date in the form for the efa interface // ######################################## */
function submit_date()
{
	var mydate = document.eingabe.date.value;

	if (mydate.length != '10')
	{
		var todaydate = new Date();
		today_year = todaydate.getFullYear();
		today_month = todaydate.getMonth() + 1;
		today_month = ((today_month < 10) ? "0" : "") + today_month;
		today_day = todaydate.getDate();
		today_day =((today_day < 10) ? "0" : "") + today_day;
		mydate = '';
		mydate ='' + today_day + '.' + today_month + '.' + today_year;
		alert ("Bitte ein gültiges Datum eingeben");
	}

	splitString = mydate.split(".");

	document.eingabe.itdDateDay.value=splitString[0];
	document.eingabe.itdDateMonth.value=splitString[1];
	document.eingabe.itdDateYear.value=splitString[2];
}


/* ### // set the date one day in future or past // ######################################## */
function dateUpDown(upOrDown) { 
	var tag;
	var monat;
	var jahr;

	date = document.eingabe.date.value;
	splitString = date.split(".");
	tag = splitString[0];
	monat = splitString[1];
	jahr = splitString[2];

	var jahrIntWert = parseInt(jahr);

	if (jahrIntWert >= 0 && jahrIntWert <= 75)
	{
		jahrIntWert = 2000 + jahrIntWert; 
	} else {
		if (jahrIntWert > 75 && jahrIntWert <= 99)
		{ 
			jahrIntWert = 1900 + jahrIntWert; 
		}
	}
	monat = monat - 1;  
	heute = new Date(jahrIntWert, monat, tag);
	
	var millisecunden = heute.getTime();

	if (upOrDown == 'up')
	{ 
		millisecunden = millisecunden + (24*60*60*1000); 
	}
	if (upOrDown == 'down')
	{ 
		millisecunden = millisecunden - (24*60*60*1000); 
	}
	heute.setTime(millisecunden);
	tag = heute.getDate();
	if (tag > 0 && tag < 10)
	{ 
		tag = "0"+tag; 
	}
	monat = heute.getMonth() + 1;
	if (monat > 0 && monat < 10)
	{ 
		monat = "0"+monat; 
	}
	jahr = "" + heute.getFullYear();
	document.eingabe.date.value = tag + "." + monat + "." + jahr;
}


/* ### // set the hour_minute // ######################################## */
function hour_minute(upOrDown)
 { 
	var hour;
	var minute;
	var tag;
	var monat;
	var jahr;

	date = document.eingabe.date.value;
	hour = document.eingabe.itdTimeHour.value;
	minute = document.eingabe.itdTimeMinute.value;
	splitString = date.split(".");
	tag = splitString[0];
	monat = splitString[1];
	jahr = splitString[2];

	var jahrIntWert = parseInt(jahr);

	if (jahrIntWert >= 0 && jahrIntWert <= 75)
	{ 
		jahrIntWert = 2000 + jahrIntWert; 
	} else {
		if (jahrIntWert > 75 && jahrIntWert <= 99)	    
		{ 
			jahrIntWert = 1900 + jahrIntWert;
		}
	}
	monat = monat - 1;  
	heute = new Date(jahrIntWert, monat, tag, hour, minute);

	var millisecunden = heute.getTime();

	if (upOrDown == 'up_hour')
	{ 
		millisecunden = millisecunden + (60*60*1000); 
	}
	if (upOrDown == 'down_hour' )
	{ 
		millisecunden = millisecunden - (60*60*1000); 
	}
	if (upOrDown == 'up_minute')
	{ 
		millisecunden = millisecunden + (60*1000); 
	}
	if (upOrDown == 'down_minute' )
	{ 
		millisecunden = millisecunden - (60*1000); 
	}
	heute.setTime(millisecunden);
	hour = heute.getHours();
	if (hour >= 0 && hour < 10)
	{ 
		hour = "0"+hour; 
	}
	minute = heute.getMinutes();
	if (minute >= 0 && minute < 10)
	{ 
		minute = "0"+minute; 
	}
	document.eingabe.itdTimeHour.value = hour;
	document.eingabe.itdTimeMinute.value = minute;
}


/* ### // set the keydown event in the form // ######################################## */
document.onkeydown = findTaste;

function findTaste(Ereignis) 
{
	if (!Ereignis)
		Ereignis = window.event;
	if (Ereignis.which) {
		Tastencode = Ereignis.which;
	} else if (Ereignis.keyCode) {
		Tastencode = Ereignis.keyCode;
	}
	findkey(Tastencode);
}

function findkey(Tastencode)
{
	if ((Tastencode == 38) && (dFocus == true))
	{
		dateUpDown('up');
	}
	if ((Tastencode == 40) && (dFocus == true))
	{
		dateUpDown('down');
	}
	if ((Tastencode == 38) && (hFocus == true))
	{
		hour_minute('up_hour');
	}
	if ((Tastencode == 40) && (hFocus == true))
	{
		hour_minute('down_hour');
	}
	if ((Tastencode == 38) && (mFocus == true))
	{
		hour_minute('up_minute');
	}
	if ((Tastencode == 40) && (mFocus == true))
	{
		hour_minute('down_minute');
	}
	if ((Tastencode == 13) && ((document.eingabe.itdLPxx_mapusage.value == "Trip") || (document.eingabe.itdLPxx_mapusage.value == "dm")))
	{
		if (document.forms[0].itdLPxx_options.value == 0)
		{
			check_value_2();
		} else {
			check_value();
		}
		submit_date();
		setTimeout("document.eingabe.submit()",1000);
	}
	if ((Tastencode == 13) && (document.eingabe.itdLPxx_mapusage.value == "ps_Trip"))
	{
		check_value_2();
		setsampledate();
		document.eingabe.submit();
	}
	if ((Tastencode == 13) && (document.eingabe.itdLPxx_mapusage.value == "car_Trip"))
	{
		check_value_2();
		document.eingabe.submit();
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "Trip"))
	{
		location.href="XSLT_TRIP_REQUEST2?language=de";
	}
	if ((Tastencode == 13) && ((document.eingabe.itdLPxx_mapusage.value == "stt") || (document.eingabe.itdLPxx_mapusage.value == "ttb") || (document.eingabe.itdLPxx_mapusage.value == "rop") || (document.eingabe.itdLPxx_mapusage.value == "ss")))
	{
		check_value();
		document.eingabe.submit();
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "stt"))
	{
		location.href="XSLT_STT_REQUEST?language=de";
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "ttb"))
	{
		location.href="XSLT_TTB_REQUEST?language=de";
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "rop"))
	{
		location.href="XSLT_TTB_REQUEST?language=de";
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "dm"))
	{
		location.href="XSLT_DM_REQUEST?language=de";
	}
	if ((Tastencode == 113) && (document.eingabe.itdLPxx_mapusage.value == "ss"))
	{
		location.href="XSLT_SCREEN_SAVER_REQUEST?language=de";
	}
//	alert(event.keyCode+' : '+String.fromCharCode(event.keyCode));
}

if (parseInt(navigator.appVersion)>3) {
 document.onmousedown = mouseDown;}

function mouseDown(e) 
{
	var altPressed=0;
	var button;
	var ServerID = document.eingabe.Server.value;
	var SessionID = document.eingabe.sessionID.value;
	var url_xml;

	
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") 
		{
			shiftPressed=e.shiftKey;
			altPressed  =e.altKey;
			ctrlPressed =e.ctrlKey;
			button= e.button;
		} 
		else 	
		{
			shiftPressed=event.shiftKey;
			altPressed  =event.altKey;
			ctrlPressed =event.ctrlKey;
			button= event.button;
//			self.status=""
//			+  "shiftKey="+event.shiftKey 
//			+", altKey="  +event.altKey 
//			+", ctrlKey=" +event.ctrlKey 
		}
	
}
	return true;
}

/* ### // show the print-layout // ######################################## */
function submit_print_trip()
{
	document.eingabe.target = 'print_trip';
	document.eingabe.itdLPxx_printTrip.value='1';
	document.forms[0].submit();
}


/* ### // set the street layout in the rop request // ######################################## */
function set_mode(obj)
{
	document.eingabe.mode.value = obj;
}


/* ### // set the drag n drop functionin the form // ######################################## */
var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};

function makeBarChart(data, width, height, barcolor) {
    width -= 1;  // subtract 10px padding and 2px border left and right
    height -= 14; // Subtract 10px top padding and 2px top and bottom border

    var chart = document.createElement("DIV");
//debugger;
	chart.style.position = "absolute";          // Set relative positioning
    chart.style.top = "300px";        		// Set relative positioning
    chart.style.left = "185px";        		// Set relative positioning
    chart.style.width = "550px";           // Set the chart width
    chart.style.height = "350px";         // Set the chart height
   
	var header_1 = document.createElement("div"); // Create div for bar
	header_1.innerHTML = "MobilTicket Monat\<img style\=\"width\:35px\;height\:1px\;\" src\=\"images\/transparent.gif\" alt\=\"spacer\"\>MobilTicket Jahr\<img style\=\"width\:33px\;height\:1px\;\" src\=\"images\/transparent.gif\" alt\=\"spacer\"\>KFZ-Betriebskosten";
	header_1.style.position = "relative";          // Set relative positioning
	header_1.style.top = "150px";        		// Set relative positioning
	header_1.style.left = "20px";        		// Set relative positioning
	chart.appendChild(header_1);                  // Add bar to chart

    // Compute the width of each bar
    //var barwidth = Math.floor(width/data.length);
    var barwidth = 130;
	// Find largest number in data[].  Note clever use of Function.apply()
    var maxdata = Math.max.apply(this, data);
    // The scaling factor for the chart: scale*data[i] gives height of a bar
    var scale = height/maxdata;
    
    // Now loop through the data array and create a bar for each datum
    for(var i = 0; i < data.length; i++) {
        var bar = document.createElement("div"); // Create div for bar
        var barheight = data[i] * scale;         // Compute height of bar
        bar.style.position = "absolute";         // Set bar position and size
        bar.style.left = (barwidth*i+1+10)+"px"; // Add bar border & chart pad
        bar.style.top = height-barheight+10+"px";// Add chart padding
        bar.style.width = (barwidth-20) + "px";   // -2 for the bar border
        bar.style.height = (barheight) + "px"; // -1 for the bar top border
        bar.style.border = "solid black 1px";    // Bar border style
        bar.style.backgroundColor = barcolor[i];    // Bar color
        bar.style.fontSize = "1px";              // IE bug workaround
		chart.appendChild(bar);                  // Add bar to chart
   }

    // Now add the chart we've built to the document body
    document.body.appendChild(chart);

    // Finally, return the chart element so the caller can manipulate it
    return chart;
}

function toogle_stops(id)
{
	if (document.getElementById('div' + id).style.display=='inline')
	{
		document.getElementById('div' + id).style.display = "none";
		document.getElementById('pic' + id).style.backgroundImage = "url('images/response/point_p_1.gif')";
	} 

	else if (document.getElementById('div' + id).style.display=='none')
	{
		document.getElementById('div' + id).style.display = "inline";
		document.getElementById('pic' + id).style.backgroundImage = "url('images/response/point_m_1.gif')";
	}
}

function reset_date_ps()
{
	document.eingabe.psParamSampleDay.value="TT";
	document.eingabe.psParamSampleMonth.value="MM";
	document.eingabe.psParamSampleYear.value="JJJJ";
}
