function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function HighLightField(oField) {
	oField.style.borderColor = "#A4ADB0";
	oField.style.color = "#666666";
	oField.style.backgroundColor = "#FFFFFF";
	oField.value = "";
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function UnHighLightField(oField) {
	oField.style.borderColor = "#A4ADB0";
	oField.style.color = "#666666";
	oField.style.backgroundColor = "#FFFFFF";
	//alert(oField.value);
	//if (oField.value = "") oField.value = "  Unternehmen suchen";
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function HighLightFieldError(oField) {
	oField.style.borderColor = "#9C0000";
	oField.style.color = "#FFFFFF";
	oField.style.backgroundColor = "#A4ADB0";
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function SubmitForm(oForm,a_RequiredFields) { 
	oForm.elements['btnsubmit'].disabled = true;
	var bOK = new Boolean(true);
	for (i = 0 ; i < a_RequiredFields.length ; i++) {
		if (oForm.elements[a_RequiredFields[i]]) {
			oForm.elements[a_RequiredFields[i]].value = trim(oForm.elements[a_RequiredFields[i]].value)
			if (oForm.elements[a_RequiredFields[i]].value == "") {
				HighLightFieldError(oForm.elements[a_RequiredFields[i]]);
				bOK = false;
			};
		}
	}
	if (!bOK) {
		oForm.elements['btnsubmit'].disabled = false;
	}
	return bOK;
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function ResetForm(oForm,a_RequiredFields) {
	for (i = 0 ; i < a_RequiredFields.length ; i++) {
		if (oForm.elements[a_RequiredFields[i]]) {
			UnHighLightField(oForm.elements[a_RequiredFields[i]]);
		}
	}
}


/* --------------------------------------------------------------------------------------------------------------------------------------- */

function Fensterweite () {
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}	

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function Fensterhoehe () {
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

//window.onload = setPos;
//window.onresize = setPos;

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function pagefunctions() {
	setPos();
	setContentHeight('content_td');
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function setPos() {
	var oDiv  = document.getElementById("ext_links");
	var x = Fensterweite();
	var y = 90;
	
	//document.getElementById("ext_links").style.top = y;
	if (x < 1005) {
		document.getElementById("ext_links").style.top = 115;
		document.getElementById("ext_links").style.left = 10;
	}
	else {
		document.getElementById("ext_links").style.top = 90;
		document.getElementById("ext_links").style.left = 815;
	}
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function setContentHeight(sId) {
	var top_offset = 83;
	var fh = Fensterhoehe();
	var h = document.getElementById("content").offsetHeight;
	
	if (h + top_offset < Fensterhoehe()) h = Fensterhoehe() - (top_offset * 2)-2;
	document.getElementById(sId).height = h + top_offset;
}

/* --------------------------------------------------------------------------------------------------------------------------------------- */

function showHand(id) {
	var oObj = document.getElementById(id);

	oObj.style.cursor="pointer";
}

function changePic(sURL,id) {
	document.getElementById(id).src = sURL;
}
