// JavaScript Document
function preViewCadPictureOver(obj, e, picsrc, picwidth, picheight, notExist) {
	var maxheight = 300;
	
	if(notExist) {
		picwidth = 200;
		picheight = 50;
	}
	
	if(!e) e = window.event;
	var top = 0;
	var left = obj.offsetLeft;
	var objp = obj.offsetParent;	
	while (objp != null) {
		left += objp.offsetLeft;
		objp = objp.offsetParent;
	}
	
	var tops = (e.clientY + 0);

	if(picheight>maxheight) {
		picwidth = Math.round((maxheight / picheight * 1000) * picwidth / 1000);
		picheight = maxheight;
	}
	
	boxdiv = document.getElementById('frameApplication');
	if(notExist) {
		boxdiv.innerHTML = '<div style="width:' + picwidth + 'px; height:' + picheight + 'px; text-align:center; vertical-align:middle; display:table-cell;">' + preViewCadPictureOver_text2 + '</div>';
	} else {
		boxdiv.innerHTML = '<div id="pdbCadPrePictureLoading">' + preViewCadPictureOver_text1 + '</div><img onload="javascript:preViewCadPictureLoaded()" src="' + picsrc + '" width="' + picwidth + '" height="' + picheight + '" />';
	}

	left-=picwidth;
	top = tops-picheight;
	if(top<75) top = 75;
	top+=1;
	left-=15;

	boxdiv.className = 'pdbCadPrePicture';
	boxdiv.style.top = top + 'px';
	boxdiv.style.left = left + 'px';
	boxdiv.style.display = 'block';
}
function preViewCadPictureOut() {
				boxdiv = document.getElementById('frameApplication');
				boxdiv.style.display = 'none';
			}
function preViewCadPictureLoaded() {
	div = document.getElementById('pdbCadPrePictureLoading');
	div.style.display = 'none';
}
function ViewHideHelpBox(value) {
	var element = 'pdbCFHelpBoxContainer';
	//document.getElementById(element).style.top=window.event.y;
	if(value==1)
		document.getElementById(element).style.display="block";
	else
		document.getElementById(element).style.display="none";
}
function pdbOnlineAppInit() {
	co = document.cookie;
	if(co.match(/onlineApplicationBox=1/)) {
		pdbOnlineAppView(1);
		document.getElementById('pdbOABlock').innerHTML = pdbOnlineAppInit_text1;
	} else {
		pdbOnlineAppView(0);
		document.getElementById('pdbOABlock').innerHTML = pdbOnlineAppInit_text2;
	}
}
function pdbOnlineAppView(action) {
	if(action==3) {
		if(document.getElementById('pdbOADataBox').style.display=="none")
			action=1;
		else
			action=0;
	}
	else if(action==4) {
			co = document.cookie;
			if(co.match(/onlineApplicationBox=[10]/)) {
				if(co.match(/onlineApplicationBox=1/))
					document.cookie = "onlineApplicationBox=0";
				else
					document.cookie = "onlineApplicationBox=1";
			}	else {
				document.cookie = "onlineApplicationBox=1";
			}
			pdbOnlineAppInit();
	}

	if(action==0) {
		document.getElementById('pdbOADataBox').style.display="none";
	}
	else if(action==1) {
		document.getElementById('pdbOADataBox').style.display="block";
	}
}
function userImgRotate(elementid) {
	eval('iPointer = ImgRotatePointer'+elementid);
	eval('aImgList = ImgRotateArray'+elementid);
	iPointer++;
	if((iPointer+1)>aImgList.length)
		iPointer = 0;
	var newImg = new Image(); newImg.src = aImgList[iPointer];
	eval('ImgRotatePointer'+elementid+'=iPointer');

	if (document.all){
		document.getElementById(elementid).style.filter="blendTrans(duration=2)";
		document.getElementById(elementid).style.filter="blendTrans(duration=crossFadeDuration)";
		document.getElementById(elementid).filters.blendTrans.Apply();
	}
	document.getElementById(elementid).src = newImg.src;
	if (document.all){
		document.getElementById(elementid).filters.blendTrans.Play();
	}
}
function ViewHideBox(element) {
	var imgid = element + "_img";
	if(document.getElementById(element).style.display=="block") {
		document[imgid].src = ViewHideBoxUp.src;
		document[imgid].alt = ViewHideBox_text1;
		document.getElementById(element).style.display="none";
	} else {
		document[imgid].src = ViewHideBoxDown.src;
		document[imgid].alt = ViewHideBox_text2;
		document.getElementById(element).style.display="block";
	}
}
function ChangeInputValue(obj, typ) { //
	if(obj.value.search(/^[0-9.,]*$/) && typ=='n') {
		alert(ChangeInputValue_text1);
		if(obj.value.length>1)
			obj.value = obj.value.substring(0,obj.value.length-1);
		else
			obj.value = '';
	}
}
function CopyInputValue(value1, value2) {
	if(document.getElementById(value1).value!='' && document.getElementById(value2).value=='') {
		document.getElementById(value2).value = document.getElementById(value1).value;
		return;
	}
	if(document.getElementById(value1).value=='' && document.getElementById(value2).value!='') {
		document.getElementById(value1).value = document.getElementById(value2).value;
		return;
	}
}
function ChangeInputValueRange(obj, charactuid) { //
	checkValue = parseFloat(obj.value.replace(/,/g,'.'));
	//alert(checkValue);
	if(checkValue==0 || isNaN(checkValue))
		return;
	try {
		eval('checkValueMin = parseFloat(CheckValue' + charactuid + "min)");
		eval('checkValueMax = parseFloat(CheckValue' + charactuid + "max)");
		if(checkValue<checkValueMin || checkValue>checkValueMax) {
			alert('Zahl ist zu klein oder zu gross!');
			//obj.focus();
			return false;
		} else {
			//obj.value = checkValue;
		}
	} catch(e) {
		//alert(e);
	}
}
function doFormAction(action) {
	document.forms[doFormAction_formname].elements[doFormAction_formelement].value = action;
	if(action=='contactPrint') {
		window.print();
	}
	else if(action=='back') {
		history.back();
	} else {
		document.forms[doFormAction_formname].submit();
	}
}
function ChangeOperator(obj, fvar) {
	objType = document.forms[ChangeOperator_formname][fvar + '[type]'];
	if(obj.value=='BT' && objType.value=='n') {
		objValue2 = document.forms[ChangeOperator_formname][fvar + '[value2]'];
		objValue2.style.visibility = 'visible';
	} else {
		if(objType.value=='n') {
			objValue2 = document.forms[ChangeOperator_formname][fvar + '[value2]'];
			objValue2.style.visibility = 'hidden';
			objValue2.value = '';
		}
	}
}
function activateInputExitButton(obj, fvar) {
	element = fvar + '[ok]';
	objOK = document.getElementById(element);
	objOK.style.visibility = 'visible';
}
function myXajaxloadingFunction() {
		var boxdiv = document.getElementById('ajax-loader');
		if(boxdiv) boxdiv.style.display = 'block';
}
function myXajaxdoneLoadingFunction() {
		var boxdiv = document.getElementById('ajax-loader');
		if(boxdiv) {
				boxdiv.style.display = 'none';
		}
}
function checkKeyEnter() {
	var keyCode= event.keyCode;
	if (keyCode == 13) {
		return true;
	}
}

function checkKeyEnterBB(obj) {
	var keyCode=obj.value.substr(obj.value.length-1,1);
	if (keyCode == chr(13)) {
		return true;
	}
}
function addSelectOptionAtLast(text, value, elementName)
{
  var sOptionsField = document.createElement('option');
  sOptionsField.text = text;
  sOptionsField.value = value;
  var SelectField = document.getElementById(elementName);
  try {
    SelectField.add(sOptionsField, null);
  }
  catch(e) {
    SelectField.add(sOptionsField);
  }
}
function removeSelectOptionALL(elementName)
{
  var SelectField = document.getElementById(elementName);
  var i;
  for (i = SelectField.length - 1; i>=0; i--) {
		SelectField.remove(i);
  }
}
