
var popupWindow = null;
var confirmationPopupWindow = null;

function _openPopUp(url, windowVar, windowName, width, height)
{
	window.name = 'TsMainWindow';
	
	if ( windowVar )
	{
		windowVar.close();
	}
	
	windowVar = window.open(url, windowName, 'width=' + width + ', height=' + height + ', scrollbars=yes');
	
	if ( !windowVar )
	{
		//alert('Das Fenster konnte nicht ge&ouml;ffnet werden. Bitte deaktivieren Sie Ihren Popup-Blocker');
		return false;
	}
	
	windowVar.focus();
	
	return true;
}

function openPopUp(url)
{
	return _openPopUp(url, popupWindow, 'TsPopup', 1024, 900);
}

function openInternatePopUp(url)
{
	return _openPopUp(url, popupWindow, 'TsPopup', 460, 625);
}

function openKontaktPopUp(url)
{
	return _openPopUp(url, popupWindow, 'TsPopupKontakt', 1024, 900);
}

function openConfirmationPopUp(url)
{
	if ( confirmationPopupWindow )
	{
		confirmationPopupWindow.close();
	}
	
	confirmationPopupWindow = window.open(url, 'TsConfirmationPopup', 'width=' + 500 + ', height=' + 325 + ', scrollbars=yes');
	
	if ( !confirmationPopupWindow )
	{
		//alert('Das Fenster konnte nicht ge&ouml;ffnet werden. Bitte deaktivieren Sie Ihren Popup-Blocker');
		return false;
	}
	
	confirmationPopupWindow.focus();
	
	return true;
}

function openInParent(url)
{
	if ( opener )
	{
		opener.location.href = url;
	}
	else
	{
		var win = window.open(url);
		if ( !win )
		{
			//alert('Das Fenster konnte nicht ge&ouml;ffnet werden. Bitte deaktivieren Sie Ihren Popup-Blocker');
		}
	}
	
	self.focus();	
}

function switchDropdownToTextField(currentEl)
{
	var inputNode = document.createElement("input");
	
	ie = /msie/i;
	var IE = ie.test(window.navigator.appVersion);
	
	inputNode.setAttribute('id', currentEl.getAttribute('id'));
	inputNode.setAttribute('name', currentEl.getAttribute('name'));
	
	if (IE)
	{
		inputNode.setAttribute('className', currentEl.getAttribute('className').replace(/dropdown/g, "text"));
	}
	else
	{
		inputNode.setAttribute('class', currentEl.getAttribute('class').replace(/dropdown/g, "text"));
	}
	
  	currentEl.parentNode.replaceChild(inputNode, currentEl);
  	inputNode.focus();
}


function submitFormTelCheck(formEl, elId, popUpUrl)
{
	if ( document.getElementById(elId).value == '' )
	{
		//openConfirmationPopUp(popUpUrl + '&elId=' + elId);
		location.href= popUpUrl + '&elId=' + elId;
		return false;
	}
	else
	{
		formEl.submit();
		return true;
	}
}

