
var action = true;

function display(name) {
	if ((navigator.appName == 'Netscape') && (document.documentElement)){
		//var layerObj = eval("document.getElementById(" + name + ").style");
		var layerObj = eval("document.getElementById('" + name +"').style");
		var hide = "hidden";
		var show = "visible";
		}
	else if (document.all) {
		var layerObj = eval("document.all." + name + ".style");
		var hide = "hidden";
		var show = "visible";
		}
	else
		{
		var layerObj = eval("document." + name);
		var hide = "hide";
		var show = "show";
		}
	layerObj.visibility = (action ?  show : hide);
	action = !action;
	}
//-----------------------------------------
function HilfeFenster(seitenID){
F1 = window.open("hilfe.jsp?ActualMenue="+seitenID, "KontextHilfe","width=400, height=500, resizable=no, screenX=0, screenY=0, scrollbar=yes, status=no, menubar=no, resizable=no");
}
//-----------------------------------------
function winopen(hotlisttarget, hotlistname){
  HotlistMonitor = window.open(hotlisttarget, HotlistMonitor, "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=200,height=260")
}
//-----------------------------------------
function FensternachOben() {
self.focus();
window.setTimeout("FensternachOben()",10000);
}
//-----------------------------------------
function ZielOeffnerFenster(Anzahl, Ziel, hotlistwindow)
{
 opener.top.application.location.href = Ziel;
 opener.focus();
 i = Anzahl;
 if (i<=1)
 	{window.close();}
 else
	{
	window.location.href = hotlistwindow;
	window.location.reload();
	}
}
//-----------------------------------------
function closeMonitorWindow()
{
HotlistMonitor.document.close();
}
//-----------------------------------------
function appendAnchor(target, formname)
{
	if(!document.forms[formname])
		return true;
	aktForm = document.forms[formname];
	if(aktForm)
		aktForm.action = aktForm.action + "#" + target;
	return true;
}

//-----------------------------------------
function plz_ort_popup(feld, plz, ort, land)
{
document.forms['findPlz'].land.value = land;
document.forms['findPlz'].plz.value = plz;
document.forms['findPlz'].ort.value = ort;
document.forms['findPlz'].feld.value = feld;
window.open("", "plzWindow", "resizable=yes,width=380,height=490,scrollbars=no,status=yes, top=100,left=100");
document.forms['findPlz'].submit();

// old functions:
// window.open("fenster2.html", "Zweitfenster", "width=300,height=250,scrollbars");
//window.open("../jsp/plz_ort.jsp?feld="+feld+"&plz="+plz+"&ort="+ort+"&land="+land, "PLZ_Ort", "resizable=yes,width=380,height=490,scrollbars=no,status=yes, top=100,left=100");
}
//-----------------------------------------
function showHelp(pid)
{
window.open("../jsp/help.jsp?pid="+pid, "Hilfe", "resizable=yes,width=400,height=490,scrollbars=yes,status=yes, top=100,left=100");
}
//-----------------------------------------
function kalender_popup(feld)
{
s = "top="+screen.availHeight/2+",left="+screen.availWidth/2;
window.open("../jsp/kalender.jsp?chf="+feld, "kalender", "resizable=no,width=150,height=200,scrollbars=no,status=no,"+s);
}

//-----------------------------------------
function plz_ort_insert(feld,selbox,message,userId)
{

  vapplication = "application"+userId;

if(selbox.selectedIndex == -1 || selbox.options[selbox.selectedIndex].value == "")
{
alert(message);
return false;
}else{
var value = selbox.options[selbox.selectedIndex].value;
val_array = value.split("#");
var land = val_array[0];if(land == "null")land="";
var plz = val_array[1];if(plz == "null") plz="";
var ort = val_array[2];if(ort == "null") ort="";
var ort_feld = "ort_"+feld;




if(feld == "CAvon")
{
  opener.top.frames[vapplication].document.getElementById("zipCode_default_from").value = plz;
  opener.top.frames[vapplication].getElementById("city_default_from").value = ort;
  list = opener.top.frames[vapplication].document.getElementById("Country_default_from");
}
if(feld == "CAnach")
{
  opener.top.frames[vapplication].document.getElementById("zipCode_default_to").value = plz;
  opener.top.frames[vapplication].document.getElementById("city_default_to").value = ort;
  list = opener.top.frames[vapplication].document.getElementById("Country_default_to");
}
if(feld == "CAAvon")
{
  opener.top.frames[vapplication].document.getElementById("zipCode_additional_from").value = plz;
  opener.top.frames[vapplication].document.getElementById("city_additional_from").value = ort;
  list = opener.top.frames[vapplication].document.getElementById("Country_additional_from");
}
if(feld == "CAAnach")
{
  opener.top.frames[vapplication].document.getElementById("zipCode_additional_to").value = plz;
  opener.top.frames[vapplication].document.getElementById("city_additional_to").value = ort;
  list = opener.top.frames[vapplication].document.getElementById("Country_additional_to");
}





if(feld == "von")
{  
  opener.top.frames[vapplication].document.auftragserfassung.plz_von.value = plz;
  opener.top.frames[vapplication].document.auftragserfassung.ort_von.value = ort;
  list = opener.top.frames[vapplication].document.auftragserfassung.land_von;
}
if(feld == "nach")
{
  opener.top.frames[vapplication].document.auftragserfassung.plz_nach.value = plz;
  opener.top.frames[vapplication].document.auftragserfassung.ort_nach.value = ort;
  list = opener.top.frames[vapplication].document.auftragserfassung.land_nach;
}
if(feld == "furthervon")
{
  opener.top.frames[vapplication].document.auftragserfassung.plz_furthervon.value = plz;
  opener.top.frames[vapplication].document.auftragserfassung.ort_furthervon.value = ort;
  list = opener.top.frames[vapplication].document.auftragserfassung.land_furthervon;
}
if(feld == "furthernach")
{
  opener.top.frames[vapplication].document.auftragserfassung.plz_furthernach.value = plz;
  opener.top.frames[vapplication].document.auftragserfassung.ort_furthernach.value = ort;
  list = opener.top.frames[vapplication].document.auftragserfassung.land_furthernach;
}

  		for (var i = 0; i < list.options.length; i++)
  			if (list.options[i].value == land)
  			{
  				list.options[i].selected = true;


			}else{
				list.options[i].selected = false;
			}
 this.window.close();
}
}
  // check if entry is empty shorter than 3 characters
function chkOrt(eing,text)
{
  // Leerteichen vor und hinter dem Suchstring entfernen
var str = eing.value;
  while (str.charAt(0) == ' ')
    str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
    str = str.substring(0, str.length - 1);
 if((str != "") && (str.length < 3))  {
   alert(text);
   return false;
  }
 }




        var ns = (navigator.appName.indexOf("Netscape") != -1);
        var ie = (navigator.appName.indexOf("Microsoft") != 1);
		var show = 0;

function changeStatus(objectId) {		
	var str = "tabelle_"+objectId;
	var tab = document.getElementById(str);
	if(tab.style.display=="block" || tab.style.display=="") {
		tab.style.display = "none";
	}	else {
			tab.style.display = "block";	
	}
}


function usernameFocus() {
//if(document.anmeldung_guest.benutzer_user_id != null)
//document.anmeldung_guest.benutzer_user_id.focus();
}

// change the number of order to be shown
function goToPage(page) {
	var till = page*20;
	document.getElementById("to").value = till;
	document.getElementById("from").value = till - 19;
	document.getElementById("list").submit();
}

function calculateTonnage() {
	var sum = 0;
	var i=0; 
	var j=0;		
	while(document.getElementsByName("load["+i+"].transportLoad["+j+"].numberOf")[0]) {
		while(document.getElementsByName("load["+i+"].transportLoad["+j+"].numberOf")[0]) {			
			var str = "load["+i+"].transportLoad["+j+"]";
			var numberOf = Number(document.getElementsByName(str+".numberOf")[0].value);
			var weight = Number(document.getElementsByName(str+".weight")[0].value);
			sum += Number(numberOf*weight); 
			j++;
		}
		j=0;
		i++;
	}	
	document.getElementsByName("tonnage")[0].value=sum;
}

function changeThermal(theCheckBox, theFieldName)	{
	var theField = document.getElementsByName(theFieldName)[0];
	
	if (theCheckBox.checked) {
		theField.disabled=false;
		theField.focus();
	} 
	else {
		theField.disabled=true; 
		theField.value='';
	}

	
	var theImage = document.getElementById('img_thermometer');
	if (theImage)	{
		var isThermal = false;
		var loadIndex = 0;
		var checkBox = document.getElementById('load['+loadIndex+'].temperatureCheck');
		while (checkBox)	{
			if (checkBox.checked)	{
				isThermal = true;
				break;
			}
			loadIndex++;
			checkBox = document.getElementById('load['+loadIndex+'].temperatureCheck');
		}
		if (isThermal)	{
			theImage.style.display='';
		}
		else	{
			theImage.style.display='none';
		}
	}
}

	function getPageXOffset()	{
		if (document.all)	{
			if (document.documentElement && document.documentElement.scrollLeft > 0)	{
				return document.documentElement.scrollLeft;
			}
			else	{
				return document.body.scrollLeft;
			}
		}
		return  window.pageXOffset;
	}
	
	function getPageYOffset()	{
		if (document.all)	{
			if (document.documentElement && document.documentElement.scrollTop > 0)	{
				return document.documentElement.scrollTop;
			}
			else	{
				return document.body.scrollTop;
			}
		}
		return  window.pageYOffset;
	}
	
	function showLongHelp(divName, imgName, showTitle, hiddenTitle)	{
		var changeImage = document.getElementsByName(imgName)[0];

		if(document.getElementById(divName).style.display == 'none') {
			document.getElementById(divName).style.display = 'block';
			changeImage.src="www/layout/images/hideExtHelp.gif";
			changeImage.title=hiddenTitle;
		} else {
			document.getElementById(divName).style.display = 'none';	
			changeImage.src="www/layout/images/showExtHelp.gif";		
			changeImage.title=showTitle;
		}
	}
	
		function changeStatus(index, stelle) {
		var checkBox = document.getElementsByName(stelle+"["+index+"].value")[0];	
		var field = document.getElementsByName(stelle+"["+(index+1)+"].value")[0];
		var focus = false;
		if(field.type == "text") {
			while (field && field.type == "text") {
				index++;
				if(checkBox.checked == false) {
					field.value="";
					field.disabled=true;
					focus=false;
				} else {
					field.disabled = false;
					if(focus==false)	{
						field.focus();
						focus=true;
					}
				}
				field = document.getElementsByName(stelle+"["+(index+1)+"].value")[0];				
			}
		}
	}			
	
	function changeVisible(theElementId)	{
		var theElement = document.getElementById(theElementId);
		if (theElement.style.display == '') {
			theElement.style.display = 'none';
		}
		else {
			theElement.style.display = '';
		}
	}
	
function convertToDate(theDate) {
        var datum = theDate.split(" ")[0];
        var time= theDate.split(" ")[1];
        var day = datum.split(".")[0];
        var month = datum.split(".")[1];
        var year = datum.split(".")[2];
        var hours = time.split(":")[0];
        var minutes = time.split(":")[1];
        if (month.indexOf('0') == 0)
          month = month.substring(1, month.length);
        if (day.indexOf('0') == 0)
          day = day.substring(1, day.length);
        if (hours.indexOf('0') == 0)
          hours = hours.substring(1, hours.length);
        if (minutes.indexOf('0') == 0)
          minutes = minutes.substring(1, minutes.length);
        var d = new Date(0);
        d.setHours(parseInt(hours));
        d.setMinutes(parseInt(minutes));
        d.setSeconds(0);
        d.setMilliseconds(0);
        d.setYear(parseInt(year));
        d.setMonth(parseInt(month)-1, parseInt(day));
        return d;
}

function getInnerWidth()	{
		if (document.all) {
			if (document.documentElement)	{
				return (document.documentElement.offsetWidth);
			}
			else	{
				return (document.body.offsetWidth);
			}
		}
		else	{
  			return (window.innerWidth);
		}	
}	