﻿// JavaScript Document
ie = document.all?1:0
ns4 = document.layers?1:0

blockallactions = false;

// open window
function openwindow(url,name,options) {
newwin=window.open(url,name,options);
newwin.focus();
}

//show tabs
var currenttab='tab1';
var currentlayer='privacynotice';
var printmode = false;

function showtab(layername,tabnr)
{if (!blockallactions) {
	tabs = document.getElementById(currenttab);
	currenttab='tab'+tabnr;
	tabs.id=currenttab;
	obj = document.getElementById(currentlayer);
	obj.style.display ='none';
	obj = document.getElementById(layername);
	obj.style.display ='';
	currentlayer=layername;
	} else alert(oText.pleasewait);
}

//show text field etc.
function showhideblock(ID,showel){
	var obj = document.getElementById(ID);
		
	if(showel) {
		obj.style.display ='';
		infofields=1;
	}
	else {
		obj.style.display ='none';
		infofields=0;	
	}
}

//show additional rows
function showhiderowblock(ID,imgID,url){
	var obj = document.getElementById(ID);
	var img = document.getElementById(imgID);
		
	if(obj.style.display == 'none') {
		obj.style.display ='';
		img.src=url+'shared/img/minus.gif';	
		extraFields=1;
	}
	else {
		obj.style.display ='none';
		img.src=url+'shared/img/plus.gif';
		extraFields=0;	
	}
}

// Check-Funktion für die Aktivierung 
function checkEnable() {
	if (document.co_form.save_confirmed.checked) {
		document.co_form.next1.disabled=false;
	}
	else {
	document.co_form.next1.disabled=true;
	}
}

//jump from tab1
function checkCheckboxActivation() {
	if (document.co_form.next1.disabled) {
		alert(oText.checkbox);
		return false;
	}
	else 
		return true;
}

//write text
function writetext(fieldname, sValueField)
{	

	if (!printmode){
	
		if (sValueField != null) {
			sAusgabe = eval('objForm.'+sValueField+'.getValue()');
		}
		else {
			sAusgabe = eval('objForm.'+fieldname+'.getValue()');
		}
		
	}
	else {

		if (sValueField != null) {
			sAusgabe = eval('opener.objForm.'+sValueField+'.getValue()');
		}
		else {
			sAusgabe = eval('opener.objForm.'+fieldname+'.getValue()');
		}
		
	}
	
	if ((sAusgabe.length>61)&&(sAusgabe.indexOf(" ")<0))
		sAusgabe = sAusgabe.substr(0,20)+".."+sAusgabe.substr(sAusgabe.length-41,41);
	document.getElementById('show'+fieldname).innerHTML = sAusgabe;
	document.getElementById('show'+fieldname).style.textAlign ='left';
	document.getElementById('show'+fieldname).className='cmtxt';
}

//startprocessing

//scroll to top
function scrolltotop() {
 var y=0;
 if (window.pageYOffset) y = window.pageYOffset;
 else if (document.body && document.body.scrollTop) y=document.body.scrollTop;
 window.scrollBy(0,-y);
}

function startprocessing()
{ 
if (!blockallactions) {
	if (confirm(oText.transmit))
	{
	scrolltotop();
	setTimeout("showhideblock('processlayer',true)",500);
	blockallactions = true;
	
	if(extraFields==0) 
	{
		objForm.ansch2.setValue('');
		objForm.ansch2plz.setValue('');
		objForm.ansch2ort.setValue('');
		//objForm.ansch2land.setValue('');
		objForm.telefon2.setValue('');
		objForm.email2.setValue('');
	}
	document.co_form.submit();
	}
  } else alert(oText.pleasewait);
}

//jump to tab4
function checkCheckboxActivationAndComplete() {
	if (!blockallactions) {
	if (checkCheckboxActivation())
		{
		checkform();
		}
	return false;
	
	/*debug:
	//prepare tab4:
	for (i=0; i<aAllFields.length; i++)
	{
		writetext(aAllFields[i]);
		
	}
	if (extraFields)
		showhideblock('taddress_sum',true);
	else
		showhideblock('taddress_sum',false);
	showtab('summary',4); */	
	} else alert(oText.pleasewait);	
}