function objectWA(object) {
	document.write(object);
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function mousePos(e) {
	var x = (document.all) ? event.clientX + document.documentElement.scrollLeft : e.pageX;
	var y = (document.all) ? event.clientY + document.documentElement.scrollTop  : e.pageY;
	
	if (toolTip != null) {
		toolTip.style.left = (x + 6) + "px";
		toolTip.style.top = (y + 18) + "px";
		if (toolTip.style.display != 'block') toolTip.style.display = 'block';
	}
}
	
function showImage(path, origin) {
  //alert(findPosX(document.getElementById(origin)));
  //alert(findPosY(document.getElementById(origin)));
	//document.documentElement.clientWidth
	var selects = document.getElementsByTagName('select');
	for (i=0;i<selects.length;i++) {
		selects[i].style.visibility = 'hidden';
	}
	var PH = document.getElementById('imagePlaceholder');
	PH.innerHTML = '<img src="'+path+'" onclick="hideImage();" style="display: block; cursor: pointer;" alt="" title="klicken Sie um das Bild zu schließen" /><img src="images/close_icon.gif" width="24" height="24" alt="" style="position: absolute; right: 0px; top: 0px; cursor: pointer;" title="klicken Sie um das Bild zu schließen" onclick="hideImage();" />';
	PH.style.left = '147px';
	PH.style.top = '400px';
	PH.style.border = '1px solid black';
	PH.style.display = 'block';
}

function hideImage() {
	var selects = document.getElementsByTagName('select');
	for (i=0;i<selects.length;i++) {
		selects[i].style.visibility = '';
	}
	var PH = document.getElementById('imagePlaceholder');
 	PH.style.display = 'none';
}

function checkKontaktForm() {
	var missingText = '';
	if (document.getElementById('kName').value == '') missingText += '- Ihr Name\n';
	if (document.getElementById('kEmail').value == '') missingText += '- Ihre e-mail-Adresse\n';
	if (document.getElementById('kAnfrage').value == '') missingText += '- Ihre Anfrage\n';
	if (document.getElementById('captcha').value == '') missingText += '- den Spamschutz\n';
	
	if (missingText != '') {
		missingText = 'Bitte füllen Sie noch folgende Felder aus:\n\n' + missingText;
		alert(missingText);
		return false;
	} else {
		return true;
	}
}

function checkInfopostForm() {
	var missingText = '';
	if (document.getElementById('ipName').value == '') missingText += '- Ihr Name\n';
	if (document.getElementById('ipStrasse').value == '') missingText += '- Ihre Strasse\n';
	if (document.getElementById('ipPLZ').value == '') missingText += '- Ihre PLZ\n';
	if (document.getElementById('ipOrt').value == '') missingText += '- Ihr Ort\n';

	if (missingText != '') {
		missingText = 'Bitte füllen Sie noch folgende Felder aus:\n\n' + missingText;
		alert(missingText);
		return false;
	} else {
		return true;
	}
}

function checkCallbackForm() {
	var missingText = '';
	if (document.getElementById('cbName').value == '') missingText += '- Ihr Name\n';
	if (document.getElementById('cbTel').value == '') missingText += '- Ihre Telefonnummer\n';
	if (document.getElementById('cbDate').value == '') missingText += '- Ihr gewünschtes Rückrufdatum\n';
	if (document.getElementById('cbTime').value == '') missingText += '- Ihre gewünschte Uhrzeit\n';

	if (missingText != '') {
		missingText = 'Bitte füllen Sie noch folgende Felder aus:\n\n' + missingText;
		alert(missingText);
		return false;
	} else {
		return true;
	}
}

function checkBuchungForm() {
	var missingText = '';
	if (document.getElementById('Firma').value == '') missingText += '- Ihre Firma\n';
	if (document.getElementById('Name').value == '') missingText += '- Ihr Name\n';
	if (document.getElementById('Strasse_Hausnummer').value == '') missingText += '- Ihre Strasse und Hausnummer\n';
	if (document.getElementById('Ort').value == '') missingText += '- Ihre Stadt\n';
	if (document.getElementById('Land').value == '') missingText += '- Ihr Land\n';
	if (document.getElementById('email').value == '') missingText += '- Ihre e-mail-Adresse\n';
	if (document.getElementById('captcha').value == '') missingText += '- den Spamschutz\n';
	if (document.getElementById('Hinweis').checked == false) missingText += '- Bitte akzeptieren Sie die Bedingungen\n';

	if (missingText != '') {
		missingText = 'Bitte füllen Sie noch folgende Felder aus:\n\n' + missingText;
		alert(missingText);
		return false;
	} else {
		return true;
	}
}

function new_win(target, width, height, wname) {
  var wc;
  wc = "status=0,scrollbars=1,resizable=1,width=" + width + ",height=" + height;
  var win = window.open(target, wname, wc);
}

function showTOInfo(id) {
 	toolTip = document.getElementById('toolTip');
	var title = '';
	switch (id) {
		case 'ts_arena':
		  title = 'Arena Trier';
		  break;
		case 'ts_messepark':
		  title = 'Messepark Trier';
		  break;
		case 'ts_europahalle':
		  title = 'Europahalle Trier';
		  break;
		case 'ts_uni':
		  title = 'Uni Trier';
		  break;
		case 'ts_fh':
		  title = 'FH Trier';
		  break;
		case 'ts_ihk':
		  title = 'IHK Tagungszentrum';
		  break;
		case 'ts_era':
		  title = 'ERA Conference Centre';
		  break;
		case 'ts_casino':
		  title = 'Bürgersaal im Casino';
		  break;
		case 'ts_sportakademie':
		  title = 'Europ. Sportakademie';
		  break;
		case 'th_robertschuman':
		  title = 'Robert-Schuman-Haus';
		  break;
		case 'th_nh':
		  title = 'NH Hotel';
		  break;
		case 'th_parkplaza':
		  title = 'Park Plaza Trier';
		  break;
		case 'th_mercureporta':
		  title = 'Mercure Porta Nigra';
		  break;
		case 'th_deutscherhof':
		  title = 'Hotel Deutscher Hof';
		  break;
		case 'th_penta':
		  title = 'penta hotel trier-europahalle';
		  break;
		case 'th_goldentulip':
		  title = 'Arcadia Hotel';
		  break;
		case 'th_nellspark':
		  title = 'Nells Park Hotel';
		  break;
		case 'ht_kunstakademie':
		  title = 'Europ. Kunstakademie';
		  break;
		case 'ht_viehmarktthermen':
		  title = 'Viehmarktthermen';
		  break;
		case 'ht_orangerie':
		  title = 'Orangerie im Nells Park';
		  break;
		case 'ht_palais':
		  title = 'Kurfürstliches Palais';
		  break;
		case 'ht_landesmuseum':
		  title = 'Landesmuseum';
		  break;
	}
	toolTip.innerHTML = title;
}

function hideTOInfo() {
	toolTip.innerHTML = '';
	toolTip.style.display = 'none';
	toolTip = null;
}

function highlightMap(areaId) {
	var area, x, y,
			mapMarker = document.getElementById('map_marker'),
			offset = {x: 11, y: 11};
	
	if (mapMarker) {
		if (!areaId) {
			mapMarker.style.display = 'none';
		} else {
			area = document.getElementById(areaId);
			x = area.coords.split(',')[0];
			y = area.coords.split(',')[1];
			
			mapMarker.style.left = (x - offset.x) + 'px';
			mapMarker.style.top = (y - offset.y) + 'px';
			mapMarker.style.display = 'block';
		}
	}
}

function loadVid(vid) {
	if (vid > 24)
		top.VideoFrame.location.href = 'http://www.trier-newsletter.de/video/play.php?vid='+vid+'&lang=de&tagungen=2';
	else
		top.VideoFrame.location.href = 'http://www.trier-newsletter.de/video/play.php?vid='+vid+'&lang=de&tagungen=1';
}

window.addEvent('domready', function(){
	var searchInput, populateSearch;

	searchInput = $('search');
	if (!searchInput) {
		return;
	}

	populateSearch = function(e) {
		if (e instanceof Event) {
			if (searchInput.value == searchInput.title && e.event.type == 'focus') {
				searchInput.value = '';
				searchInput.style.color = '';
			} else if (searchInput.value == '' && e.event.type == 'blur') {
				searchInput.value = searchInput.title;
				searchInput.style.color = '#999';
			}
		} else {
			searchInput.value = searchInput.title;
			searchInput.style.color = '#999';
		}
	};

	searchInput.addEvent('focus', populateSearch);
	searchInput.addEvent('blur', populateSearch);

	populateSearch();
});

toolTip = null;
document.onmousemove = mousePos;
