// adON - erico brehmer - 23.07.08

//To be used in all Ajax Calls that return JSon.
function doJSON(stringData) {
	try {
		var jsonData = Ext.util.JSON.decode(stringData);
		return jsonData;
		//Ext.MessageBox.alert('Success', 'Decode of stringData OK');
	}
	catch (err) {
		// @TODO: map this to global LTO Messages 
		//Ext.MessageBox.alert('ERROR', 'Could not decode ' + stringData);
		
		// or 
		
		//return some data for the error message b
	}
}


function flyAndFadeIn(elemName) {
	var actualElement = Ext.get(elemName);
	Ext.fly(actualElement).fadeIn({
							easing:'easeIn',
							duration: .4,
							useDisplay: true,
							block:true
					});
}

// easing:'easeIn', duration: .4, useDisplay: true;


function flyAndFadeOut(elemName) {
	var actualElement = Ext.get(elemName);
	Ext.fly(actualElement).fadeOut({
							easing:'easeIn',
							duration: .4,
							useDisplay: true,
							block: true
					});
}

function showRow(elemName, spanName) {
	var actualElement = Ext.get(elemName);
	Ext.fly(actualElement).highlight("F2F1EC", {
							attr: "background-color",
							easing: 'easeOut',
							duration: .9
					});
	document.getElementById(spanName).style.color = '#a21a08';
}


function showRow2(elemName, spanName) {
	var actualElement = Ext.get(spanName);
	Ext.fly(actualElement).highlight("FF3300", {
							attr: "background-color",
							easing: 'easeOut',
							duration: .9
					});
}




function showRowHref(elemName, spanName, hrefName) {
	var actualElement = Ext.get(elemName);
	Ext.fly(actualElement).highlight("F2F1EC", {
							attr: "background-color",
							easing: 'easeOut',
							duration: .9
					});
	document.getElementById(spanName).style.color = '#a21a08';
	document.getElementById(hrefName).className = 'active';
}

function normalizeRowHref(spanName, hrefName) {
	document.getElementById(spanName).style.color = '#222';
	document.getElementById(hrefName).className = '';
}

function normalizeRow(spanName) {
	document.getElementById(spanName).style.color = '#222';
} 



function checkCodeVR(code) {
	
	if (code != 'WH37R9') {
	
		var errMess = '<div style="padding:1px; border:1px solid #fff8db;text-align:center;height:30px;line-height:30px;background:#ff3300;"><div style="display:block;height:30px;line-height:30px;"><span id="errSpan" style="background-color:#f1efe7;display:block;height:30px;line-height:30px;">';
		
		errMess += 'Der eingegebene Code ist nicht korrekt.';
		
		errMess += '</span></div></div>';
		
		document.getElementById('errMess').innerHTML = errMess;
		if (document.getElementById('errMess').style.display != 'none') {
			showRow2('errMess', 'errSpan');
		} else {
			flyAndFadeIn('errMess');
			showRow2('errMess', 'errSpan');
		}

	} else {
		
		var linkInh = '';
		
		flyAndFadeOut('errMess');
		
		window.location = "http://datenbank.formular-fa-verkehrsr.de/FB-FA-Verkehrsrecht/lpext.dll?f=templates&fn=main-5.htm";
		
		
		linkInh += 'Der Code ist korrekt. Falls Sie nicht automatisch zur Datenbank weitergeleitet wurden, klicken Sie bitte <a href="http://datenbank.formular-fa-verkehrsr.de/FB-FA-Verkehrsrecht/lpext.dll?f=templates&fn=main-5.htm" title="">hier</a>';
		flyAndFadeOut('codeContainer');
		document.getElementById('linkInh').innerHTML = linkInh;
		
		
		setTimeout("flyAndFadeIn('linkInh');", 1000);
	}	
}

			


/**************************************************
*
*
*
* UMZUG EXTRAWEB START
*
*
***************************************************/

// VOB




function checkUserRightsVOB(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000038' || rightsArray[i] == 'WKBR000011' || rightsArray[i] == 'WKBR001000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					document.getElementById('hasRights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsVOB(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsVOB(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeEingabe").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}




// Schulrecht Brandenburg

function checkUserRightsSchulBra(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000069') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					document.getElementById('hasRights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsSchulBra(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsSchulBra(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeEingabe").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


// FK-INSO

function checkUserRightsFkinso(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKFI001000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					document.getElementById('hasRights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsFkinso(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsFkinso(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value + 'M', portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeEingabe").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}




// Fingerhut

function checkUserRightsFingerhut(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKFI001000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					//document.getElementById('hasRights').style.display = 'block';
					document.getElementById('finger').style.display = 'none';
					document.getElementById('fingerLogged').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsFingerhut(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsFingerhut(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					//document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeEingabe").style.display = "none";
					
					document.getElementById('finger').style.display = 'none';
					document.getElementById('fingerLogged').style.display = 'block';
					
					
				} else {
					//document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeerror2").style.display = "block";
					document.getElementById("codeEingabe").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}



// Mietrecht

function checkUserRightsMietrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKFM001000' || rightsArray[i] == 'WKFM002000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					document.getElementById('hasRights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsMietrecht(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsMietrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeEingabe").style.display = "none";
					
					
				} else {
					document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeEingabe").style.display = "block";
					document.getElementById("codeEingabe").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


// Architektenrecht

function checkUserRightsArchitektenrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKFBBA1000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('codeEingabe').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					
					document.getElementById('hasRights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsArchitektenrecht(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("codeEingabe").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsArchitektenrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("hasRights").style.display = "block";
					document.getElementById("codeEingabe").style.display = "none";
					document.getElementById("codeEingabe").style.display = "none";
					
					
				} else {
					document.getElementById("hasRights").style.display = "none";
					document.getElementById("codeEingabe").style.display = "block";
					document.getElementById("codeEingabe").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


// EZA

function checkUserRightsEza(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKEZ001000') {		
				
					//document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					
					//document.getElementById('notlogged_1').style.display = 'none';
					document.getElementById('fakommcode').style.display = 'none';
					
					//document.getElementById('logged_1').style.display = 'block';
					
					document.getElementById('fakomm').style.display = 'none';
					document.getElementById('fakommrights').style.display = 'block';
					
				
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsEza(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsEza(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("fakommrights").style.display = "block";
					document.getElementById('fakomm').style.display = 'none';
					document.getElementById("fakommcode").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}



// Beamtenrecht

function checkUserRightsBeamtenrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000050') {				 
					document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-BEA';
					flyAndFadeIn('fakommrights');
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsBeamtenrecht(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsBeamtenrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("fakommrights").style.display = "block";
					document.getElementById("fakommcode").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}






// Ausländerrecht

function checkUserRightsAuslaenderrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000054') {				 
					document.getElementById('DBref').href = 'http://ola-cams.level7.ro/OLA-AUS-ASYLVFG';
					flyAndFadeIn('fakommrights');
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsAuslaenderrecht(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsAuslaenderrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("fakommrights").style.display = "block";
					document.getElementById("fakommcode").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}





/******************************************************
*
*
* UMZUG EXTRAWEB ENDE
*
*
****************************************************/



/****************************************************
*
* FORMULARBUCH SCHULLEITUNG / ONE PORTAL ID
* ONE MULTI CODE - ONE PROD
* CODE AFTER LOGIN
*
*****************************************************/

function checkUserRightsSchulleitung(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			//alert(responseObject.responseText);
			
			//Abo-ID (FAKOMM): FAKM001000 
			
			var showCodeBox = 0;
			
			var rightsArray = doJSON( responseObject.responseText );
			

				
				
				if (rightsArray.abo1) {				
					document.getElementById("abo1").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo2) {				
					document.getElementById("abo2").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo3) {				
					document.getElementById("abo3").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo4) {				
					document.getElementById("abo4").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo5) {				
					document.getElementById("abo5").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo6) {				
					document.getElementById("abo6").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo7) {				
					document.getElementById("abo7").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo8) {				
					document.getElementById("abo8").style.display = "block";
					showCodeBox++;
				}
				if (rightsArray.abo9) {				
					document.getElementById("abo9").style.display = "block";
					showCodeBox++;
				}

				
				
			/*
				
			if(code_value != '') {
				checkCodeCamsFakomm(code_url, code_value, portalid);
			}
			
			
			*/
			
			if (showCodeBox > 0) {
				flyAndFadeIn("aboDiv");
			}
			
			if (showCodeBox == 9) {
				flyAndFadeOut("codeBoxDiv");
			}
			
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsSchulleitung(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
									
				
					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
				
					
					
				} else {
					flyAndFadeIn("errorCode");
					setTimeout("showRow2('errorCode','errorCode')", 500);
					document.getElementById("errorCode").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


/****************************************************
*
* FORMULARBUCH ARBEITSRECHT / ONE PORTAL ID
* ONE MULTI CODE - ONE PROD
* CODE AFTER LOGIN
*
*****************************************************/

function checkUserRightsFormArbeitsrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			//alert(responseObject.responseText);
			
			//Abo-ID (FAKOMM): FAKM001000 
			
			var showCodeBox = true;
			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000087') {
				
				
					window.location = "http://Datenbank.formularbuch-arbeitsrecht.de/RightsService-fb-fa-arbr/CheckRights.aspx";
				
				
					document.getElementById("fakommrights").style.display = "block";
					showCodeBox = false;
				} 
			}
					
			if(code_value != '') {
				checkCodeCamsFakomm(code_url, code_value, portalid);
			}
			
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
			
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsFormArbeitsrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
				
					window.location = "http://Datenbank.formularbuch-arbeitsrecht.de/RightsService-fb-fa-arbr/CheckRights.aspx";
					
					/*
					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
					*/
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

/****************************************************
*
* FAKOMM / ONE PORTAL ID
* ONE MULTI CODE - ONE PROD
* CODE AFTER LOGIN
*
*****************************************************/

function checkUserRightsFakomm(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			//alert(responseObject.responseText);
			
			//Abo-ID (FAKOMM): FAKM001000 
			
			var showCodeBox = true;
			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == 'FAKM001000') {
					document.getElementById("fakommrights").style.display = "block";
					showCodeBox = false;
				} 
			}
					
			if(code_value != '') {
				checkCodeCamsFakomm(code_url, code_value, portalid);
			}
			
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
			
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsFakomm(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

/****************************************************
*
* RECHT GMBH / ONE PORTAL ID
* ONE MULTI CODE - ONE PROD
* CODE AFTER LOGIN
*
*****************************************************/

function checkUserRightsRechtGmbh(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			var showCodeBox = true;			
			var rightsArray = doJSON( responseObject.responseText );
			for (i in rightsArray) {
				if (rightsArray[i] == '1') {				 
					document.getElementById('rechtgmbhDBref').href = 'http://datenbank.formular-meyer-landrut.de/RightsService-formular-meyer-landrut/CheckRights.aspx';
					flyAndFadeIn('fakommrights');
					showCodeBox = false;
				} 
			}
			if(code_value != '') {
				checkCodeCamsFakomm(code_url, code_value, portalid);
			}
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
		},
		failure: function() { 
		}
	});
}

// code check logged in 

function checkCodeCamsRechtGmbh(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					
					//alert('recht wurde geschrieben - db url fehlt noch.');
					document.getElementById("fakommrights").style.display = "block";
					document.getElementById("fakommcode").style.display = "none";
					document.getElementById("codeerror2").style.display = "none";
					
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


/****************************************************
*
* TARIFRECHT / ONE PORTAL ID
* SEVERAL CODES - EACH CODE UNLOCKS ONE PROD
* 2 PROD AVAILABLE - THIRD WILL BE UNLOCKED END 2010
*
*****************************************************/

// LOGGED IN CHECK UserRights FUNC RIGHT AT LOGIN

function checkUserRightsTarifrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			
			var abo1 = false;
			var abo2 = false;
			var abo3 = false;
			
			//alert(responseObject.responseText);
			
			//Abo-ID (Tarifrecht Abo 3): 0000000081 
			//Abo-ID (Tarifrecht Abo 2): 0000000079 
			//Abo-ID (Tarifrecht Abo 1): 0000000045 (only one diff in testportid) 
			//Abo-ID (Tarifrecht Abo 1): 0000000052 (real prodid)
			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000052') {
					document.getElementById("displayAbo1").style.display = "block";
					abo1 = true;
				} 
				if (rightsArray[i] == '0000000079') {
					document.getElementById("displayAbo2").style.display = "block";
					abo2 = true;
				} 
				if (rightsArray[i] == '0000000081') {
					document.getElementById("displayAbo3").style.display = "block";
					abo3 = true;
				} 
			}
			
			// abo3 noch nicht aktiv
			
			if (!abo1 || !abo2) {
			
				document.getElementById("ecom_content").style.display = "block";
			}
			
			
			if(code_value != '') {
				checkCodeCamsTarifrecht(code_url, code_value, portalid, '/de/html/wkd/product/nouser/eztoed');
			}
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsTarifrecht(code_url, code_value, portalid, nocamsCode_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	
	var updateECom = false;
	
	conn.request({
		url: nocamsCode_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
			/*
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000081' || rightsArray[i] == '0000000079' || rightsArray[i] == '0000000052') {
					
					updateECom = true;
					alert('to update 1');
					
				}
				
			}
			*/
			if (rightsArray == '0000000081' || rightsArray == '0000000079' || rightsArray == '0000000052') {
			
				//updateECom = true;
				//alert('to update 2');
				
				writeCode(code_url, code_value, portalid);
				
			
			} else {
			
				document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
			
			
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});

}

function writeCode(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();


	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
					
					//alert('code checken - ready to write into db');
					
					
					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
				} else {
					document.getElementById("code_correct_cams").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				}
			},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check guest

function checkCodeNoCamsTarifrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000081' || rightsArray[i] == '0000000079' || rightsArray[i] == '0000000052') {
					document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/personalamtonline/frmRegistrierung.aspx?code="+code_value+"&portal=TARIFRDI&bank=false&url="+window.location;
					document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
			
				
					document.getElementById("code_correct").style.display = "block";
					document.getElementById("ecom_content").style.display = "none";
					document.getElementById("error_code").style.display = "none";
				} else {
				
					document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				
				}
				
			}
			
			if (rightsArray == '0000000081' || rightsArray == '0000000079' || rightsArray == '0000000052') {
			
				document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/personalamtonline/frmRegistrierung.aspx?code="+code_value+"&portal=TARIFRDI&bank=false&url="+window.location;
				document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
			
				
				document.getElementById("code_correct").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
				document.getElementById("error_code").style.display = "none";
			
			} else {
			
			
			
				document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
			
			
			
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

/****************************************************
*
* EZTöD / ONE PORTAL ID
*
*****************************************************/


// LOGGED IN CHECK UserRights FUNC RIGHT AT LOGIN

function checkUserRightsEZToeD(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			
			var abo = false;
			
			//alert(responseObject.responseText);
			
			//Abo-ID (Tarifrecht Abo EZToeD): 0000000083
			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000083') {
					document.getElementById("camsGotRights").style.display = "block";
					abo = true;
				} 
			}
			
			if (!abo) {
				document.getElementById("ecom_content").style.display = "block";
			}
			
			if(code_value != '') {
				checkCodeCamsEZToeD(code_url, code_value, portalid, '/de/html/wkd/product/nouser/eztoed');
				//checkCodeCamsTarifrecht(code_url, code_value, portalid, '/de/html/wkd/product/nouser/eztoed');
			}
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsEZToeD(code_url, code_value, portalid, nocamsCode_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	
	// PreCheck: is this Code for this Page (This portalid has several pages, which show diff. prods.)
	
	// EZToeD == 0000000083
	
	
	var updateEcom = false;
	
	
	conn.request({
		url: nocamsCode_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
					
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000083') {
					
					updateEcom = true;
				
				}
				
			}
			
			if (rightsArray == '0000000083') {
			
				writeCode(code_url, code_value, portalid);
				
			
			} else {
			
					document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
			
			
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
	
}


// code check guest

function checkCodeNoCamsEZToeD(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}

	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
					
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000083') {
					document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/personalamtonline/frmRegistrierung.aspx?code="+code_value+"&portal=TARIFRDI&bank=false&url="+window.location;
					document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
			
				
					document.getElementById("code_correct").style.display = "block";
					document.getElementById("ecom_content").style.display = "none";
					document.getElementById("error_code").style.display = "none";
				} else {
				
					document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				
				}
				
			}
			
			if (rightsArray == '0000000083') {
			
				document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/personalamtonline/frmRegistrierung.aspx?code="+code_value+"&portal=TARIFRDI&bank=false&url="+window.location;
				document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
			
				
				document.getElementById("code_correct").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
				document.getElementById("error_code").style.display = "none";
			
			} else {
			document.getElementById("code_correct").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				
			
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}



/****************************************************
*
* SGBV / 1 PORTAL ID 
* MULTICODE
*
*****************************************************/
/*

function checkUserRightsSgbv(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			//alert(responseObject.responseText);
			
			//Abo-ID (FAKOMM): FAKM001000 
			
			var showCodeBox = true;
			
			var rightsArray = doJSON( responseObject.responseText );
			
			
			
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKSGBV0000') {
					document.getElementById("fakommrights").style.display = "block";
					showCodeBox = false;
				} 
			}
					
			if(code_value != '') {
				checkCodeCamsSgbv(code_url, code_value, portalid);
			}
			
			if (showCodeBox) {
				document.getElementById("fakommcode").style.display = "block";
			}
			
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsSgbv(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					

					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
				} else {
					document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

*/











// LOGGED IN CHECK UserRights FUNC RIGHT AT LOGIN

function checkUserRightsSgbv(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			
			var abo1 = false;
			var abo2 = false;
			var abo3 = false;
			
			//alert(responseObject.responseText);
			
			//Abo-ID (Tarifrecht Abo 3): 0000000081 
			//Abo-ID (Tarifrecht Abo 2): 0000000079 
			//Abo-ID (Tarifrecht Abo 1): 0000000045 (only one diff in testportid) 
			//Abo-ID (Tarifrecht Abo 1): 0000000052 (real prodid)
			
			var rightsArray = doJSON( responseObject.responseText );
			
			
			if (rightsArray == 'WKSGBV0000') {
				document.getElementById("camsGotRights").style.display = "block";
			} else {
				document.getElementById("ecom_content").style.display = "block";
				
			
			}
			
			
			if(code_value != '') {
				checkCodeCamsSgbv(code_url, code_value, portalid);
			}
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


// code check logged in 

function checkCodeCamsSgbv(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
				} else {
					document.getElementById("code_correct_cams").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				}
			},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check guest

function checkCodeNoCamsSgbv(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
		
			var rightsArray = doJSON( responseObject.responseText );
				
			if (rightsArray.success) {
				document.getElementById("regLink").href="http://registrierung.wolterskluwer.de/Reg.aspx?bank=false&url="+window.location+"&portal=SGBV&code="+code_value;
				document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
				
				
				document.getElementById("code_correct").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
				document.getElementById("error_code").style.display = "none";
			} else {
				document.getElementById("code_correct").style.display = "none";
				document.getElementById("ecom_content").style.display = "block";
				document.getElementById("error_code").style.display = "block";
			}
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

/****************************************************
*v
* ERBRECHT / 1 PORTAL IDS 
* NEW LOGIC / ALL NEW LAYOUT
*
* Portal-ID: FBFAERBR 
* Abo-ID: WKFB001000 
*
*****************************************************/


function checkUserRightsErbrecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			
			var abo1 = false;
			
			//alert(responseObject.responseText);
			
			//abo1 = Erbecht: WKFB001000 

			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == 'WKFB001000') {
						
					Ext.get('codeActivate').fadeIn({duration:0.9});
					
					document.getElementById("codeHeader").innerHTML = 'Ihr Zugang zur Datenbank ist aktiv';
					document.getElementById("code").style.display = 'none';
					document.getElementById("codeButton").style.display = 'none';
					document.getElementById("codeInfo").style.display = 'none';
					
					Ext.get('successDiv').slideIn('t', {easing:'easeIn',duration:0.6});
					
					abo1 = true;
					
				} 
				
				if (!abo1) {
				
					Ext.get('codeActivateInfo').fadeIn({duration:0.9});
				
				}

			}

			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsErbrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
		
		
			if (rightsArray.success) {
				
				if (document.getElementById('errorDiv').style.display != 'none') {
					Ext.get('errorDiv').fadeOut({duration:0.6});
				}
				
				document.getElementById("codeHeader").innerHTML = 'Der Zugangscode ist korrekt';
				document.getElementById("code").style.background = 'transparent';
				document.getElementById("code").style.border = '0px';
				document.getElementById("codeButton").style.visibility = 'hidden';
				
				
				Ext.get('codeInfo').fadeOut({duration:0.6});
				Ext.get('successDiv').slideIn('t', {easing:'easeIn',duration:0.6});
				
			} else {
				
				Ext.get('errorDiv').slideIn('t',{easing:'easeIn',duration:0.6});
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check guest

function checkCodeNoCamsErbrecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
		
		
			if (rightsArray.success) {
				
				if (document.getElementById('errorDiv').style.display != 'none') {
					Ext.get('errorDiv').fadeOut({duration:0.6});
				}
				
				document.getElementById("codeHeader").innerHTML = 'Der Zugangscode ist korrekt';
				document.getElementById("code").style.background = 'transparent';
				document.getElementById("code").style.border = '0px';
				document.getElementById("code").style.color = '#2e722f';
				document.getElementById("codeButton").style.visibility = 'hidden';
				 
				 document.getElementById("reglink").href = "http://registrierung.formularbuch-erbrecht.de/Reg.aspx?bank=false&url=http://www.formularbuch-erbrecht.de/&portal=FBFAERBR&code="+code_value
				 
				
				Ext.get('codeInfo').fadeOut({duration:0.6});
				Ext.get('successDiv').slideIn('t', {easing:'easeIn',duration:0.6});
				
			} else {
				
				Ext.get('errorDiv').slideIn('t',{easing:'easeIn',duration:0.6});
			}
			
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}



/****************************************************
*v
* PFLEGERECHT / 3 PORTAL IDS 
* FOR EACH PortalId ONE CODE
*
*****************************************************/

/*

function checkUserRightsPflegerecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			//alert(responseObject.responseText);
			
			//Abo-ID (FAKOMM): FAKM001000 
			
			
			var rightsArray = doJSON( responseObject.responseText );
			
			var abo1 = false;
			var abo2 = false;
			var abo3 = false;
			
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000027') {
					document.getElementById("displayAbo1").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo1 = true;
				} 
				if (rightsArray[i] == '0000000029') {
					document.getElementById("displayAbo2").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo2 = true;
				} 
				if (rightsArray[i] == '0000000031') {
					document.getElementById("displayAbo3").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo3 = true;
				} 
			}
					
			if(code_value != '') {
				checkCodeCamsFakomm(code_url, code_value, portalid);
			}
			
			if (!abo1|| !abo2 || !abo3) {
				document.getElementById("fakommcode").style.display = "block";
			}
			
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsPflegerecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					//window.location = "http://datenbank.fakomm-famr.de/RightsService-fakomm-famr/CheckRights.aspx";
					

					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
				} else {
					//document.getElementById("fakommrights").style.display = "none";
					document.getElementById("fakommcode").style.display = "block";
					document.getElementById("codeerror2").style.display = "block";
				}
			},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


*/





function checkUserRightsPflegerecht(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			
			
			var abo1 = false;
			var abo2 = false;
			var abo3 = false;
			
			//alert(responseObject.responseText);
			
			//abo1 = Heimrecht: 0000000027 
			//abo2 = Betreuung: 0000000029 
			//abo3 = SGB XI: 0000000031 
			
			var rightsArray = doJSON( responseObject.responseText );
			
			for (i in rightsArray) {
				if (rightsArray[i] == '0000000027') {
					document.getElementById("displayAbo1").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo1 = true;
				} 
				if (rightsArray[i] == '0000000029') {
					document.getElementById("displayAbo2").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo2 = true;
				} 
				if (rightsArray[i] == '0000000031') {
					document.getElementById("displayAbo3").style.display = "block";
					document.getElementById("displayAboHeader").style.display = "block";
					abo3 = true;
				} 
			}
			
			// abo3 noch nicht aktiv
			
			if (!abo1 || !abo2 || !abo3) {
			
				document.getElementById("ecom_content").style.display = "block";
			}
			
			
			if(code_value != '') {
				document.getElementById("code_correct_wait").style.display = "block";
				checkCodeCamsPflegerecht(code_url, code_value, portalid);
			}
			
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check logged in 

function checkCodeCamsPflegerecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
			
			
				var rightsArray = doJSON( responseObject.responseText );
				
				if (rightsArray.success) {
				
					
					var url = window.location.toString();
					var param_index = url.indexOf('?');
					if (param_index != -1) {
						url = url.substring(0, param_index);
					} else {
						url = window.location;
					}
					
					window.location = url;
					
					
				} else {
					document.getElementById("code_correct_cams").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				}
			},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// code check guest

function checkCodeNoCamsPflegerecht(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
		
			var rightsArray = doJSON( responseObject.responseText );
		
		
			if (rightsArray.success) {

				document.getElementById("regLink").href="http://registrierung.wolterskluwer.de/Reg.aspx?bank=false&url="+window.location+"&portal=PFLEGE&code="+code_value;
				
				
				document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
			
				
				document.getElementById("code_correct").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
				document.getElementById("error_code").style.display = "none";
			} else {
				document.getElementById("code_correct").style.display = "none";
				document.getElementById("ecom_content").style.display = "block";
				document.getElementById("error_code").style.display = "block";
			}
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}




/****************************************************
*
*
*
*		PRE - GENERIC CHECKS and LOGIK HERE IN JS
*
*
*
*
* GENERIC CODE CHECK / ONE PortalID
* USER NOT LOGGED IN - JUST CHECKS IF CODE IS OK
*
*****************************************************/

// NOT LOGGED IN CHECK CODE FUNC 

function checkCodeNoCams(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
		success: function(responseObject) {
			if (responseObject.responseText.indexOf("success") > -1) {
				
				// check this when going live: regLink param == testserver
					if (portalid == 'KITA') { 
						document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/KITA/frmRegistrierung.aspx?code="+code_value+"&portal=KITA&bank=false&url=http://landingpages.wolterskluwer.de/de/html/content/799/Startseite/";
						document.getElementById("cams_original_url").value = "http://landingpages.wolterskluwer.de/de/html/content/799/Startseite/?code="+code_value;
				
				
					} else if (portalid == 'TARIFRDI') {
						
						document.getElementById("regLink").href="http://bestellung.wolterskluwer.de/personalamtonline/frmRegistrierung.aspx?code="+code_value+"&portal=TARIFRDI&bank=false&url="+window.location;
						document.getElementById("cams_original_url").value = window.location+'?code='+code_value;
					
					}
				
				document.getElementById("code_correct").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
				document.getElementById("error_code").style.display = "none";
			} else {
				document.getElementById("code_correct").style.display = "none";
				document.getElementById("ecom_content").style.display = "block";
				document.getElementById("error_code").style.display = "block";
			}
		},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}



// LOGGED IN CHECK CODE FUNC 

function checkCodeCAMS(code_url, code_value, portalid) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid},
			success: function(responseObject) {
				if (responseObject.responseText.indexOf("success") > -1) {
				
					if (portalid == 'TARIFRDI') {
						window.location = "http://landingpages.wolterskluwer.de/de/html/content/799/Startseite/";
					}
					
					/*
					document.getElementById("code_correct_cams").style.display = "block";
					document.getElementById("ecom_content").style.display = "none";
					document.getElementById("error_code").style.display = "none";
					*/
				} else {
					document.getElementById("code_correct_cams").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				}
			},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// LOGGED IN CHECK UserRights FUNC RIGHT AT LOGIN

function checkUserRightsEcom(route, cams_id, portalid, code_value, code_url) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	hasSubRight = false;
	if (portalid == 'BAURECHT' && code_url.indexOf('content/932') > -1) {
		// leinemann (do this later with productId)
		hasSubRight = true;
	}
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid, subRight: hasSubRight},
		success: function(responseObject) {
			//alert(responseObject.responseText);
			if (responseObject.responseText.indexOf("success") > -1) {
				document.getElementById("camsGotRights").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
			} else if(responseObject.responseText.indexOf("kitaMap") > -1) {
				if (responseObject.responseText == 'kitaMap_1_1_1') {
					document.getElementById("camsGotRights").style.display = "block";
					document.getElementById("ecom_content").style.display = "none";
				} else {
					document.getElementById("camsGotRights").style.display = "block";
					document.getElementById("ecom_content").style.display = "block";
				}
			
			} else {
				if(code_value != '') {
					checkCodeCAMS(code_url, code_value, portalid);
				} else {
					document.getElementById("camsGotRights").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
				}
			}
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}


/****************************************************
*
* KITA SEVERAL CODES / ONE PortalID
* ALL CODES SHOW ONLY ONE PROD
* CODE BOX DISAPPEARS WHEN ALL 3 CODES IN USER RIGHTS 
*
*****************************************************/


// LOGGED IN CHECK CODE FUNC // ONE PortalID AND SEVERAL Codes (KITA)

function checkPluralCodeCAMS(code_url, code_value, portalid, reloadurl) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	if (code_value == '') {
		code_value = 'xxx';
	}
	conn.request({
		url: code_url,
		method: 'POST',
		headers: '',
		params: { productid : code_value, portid: portalid, reload: reloadurl},
			success: function(responseObject) {
				if (responseObject.responseText.indexOf("success") > -1) {
					
					
					//document.getElementById("code_correct_cams").style.display = "block";
					window.location = "http://landingpages.wolterskluwer.de/de/html/content/799/Startseite/";
					/*
					if (document.getElementById("camsGotRights").style.display != "block") {
						document.getElementById("code_correct_cams").style.display = "block";
						document.getElementById("ecom_content").style.display = "none";
						document.getElementById("error_code").style.display = "none";
					} else {
						document.getElementById("ecom_content").style.display = "none";
						document.getElementById("error_code").style.display = "none";
					}
					*/
					
				} else {
					document.getElementById("code_correct_cams").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
					document.getElementById("error_code").style.display = "block";
				}
			},
		failure: function() { 
			document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

// LOGGED IN CHECK CODE FUNC RIGHT AT LOGIN // ONE PortalID AND SEVERAL Codes (KITA)

function checkUserRightsPluralEcom(route, cams_id, portalid, code_value, code_url, reloadurl) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();
	//alert('caslled: ' + code_value + ' / asdfas:' + code_url);
	conn.request({
		url: route,
		method: 'POST',
		headers: '',
		params: { camsid : cams_id, ppoid: portalid},
		success: function(responseObject) {
			//alert(responseObject.responseText);
			if (responseObject.responseText.indexOf("success") > -1) {q
				document.getElementById("camsGotRights").style.display = "block";
				document.getElementById("ecom_content").style.display = "none";
			} else if(responseObject.responseText.indexOf("kitaMap") > -1) {
				if (responseObject.responseText == 'kitaMap_1_1_1') {
					document.getElementById("camsGotRights").style.display = "block";
					document.getElementById("ecom_content").style.display = "none";
				} else if (responseObject.responseText == 'kitaMap_0_0_0') {
						if(code_value != '') {
							checkPluralCodeCAMS(code_url, code_value, portalid, reloadurl);
						} else {
							document.getElementById("camsGotRights").style.display = "none";
							document.getElementById("ecom_content").style.display = "block";
						}
				} else {
						if(code_value != '') {
							checkPluralCodeCAMS(code_url, code_value, portalid, reloadurl);
						} else {
							document.getElementById("camsGotRights").style.display = "block";
							document.getElementById("ecom_content").style.display = "block";
						}
					//document.getElementById("camsGotRights").style.display = "block";
					//document.getElementById("ecom_content").style.display = "block";
				}
			
			} else {
				if(code_value != '') {
					checkPluralCodeCAMS(code_url, code_value, portalid, reloadurl);
				} else {
					document.getElementById("camsGotRights").style.display = "none";
					document.getElementById("ecom_content").style.display = "block";
				}
			}
		},
		failure: function() { 
			//document.getElementById("code_container").innerHTML = unescape(responseObject.responseText);
		}
	});
}

/******* CODE STUFF END *********************************************/







// OLDER

function checkCodeNoECom(codeurl, codevalue, baseHref) { 
	

	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
	var conn = new Ext.data.Connection();

	if (codevalue == '') {
		codevalue = 'xxx';
	}
	conn.request({
		url: codeurl,
		method: 'POST',
		params: { code : codevalue},
		success: function(responseObject) {
			if (responseObject.responseText == 'false') { 
				document.getElementById('codeerror2').style.display = 'block';
				document.getElementById('codeerror2_inner').innerHTML = 'Der Code ist falsch.<br />Bite versuchen Sie es erneut.';
			} else {
				
				window.location = baseHref+responseObject.responseText;
			
			}
		},
		failure: function() {
			alert('Fehler - Bitte versuchen Sie es erneut.')
		}
		
	});
}





//JURION HOTPIPES (for other than jurion.de -> this is in jurion.js)

function showJurionHotpipeList(route, juriondiv, lawsector, lenght, slot_title) {
	Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: application/json; charset=utf-8;');
	document.getElementById(juriondiv).innerHTML = '<div style="color:#777;padding:30px;line-height:26px;font-weight:bold">"'+lawsector+'" wird geladen ...</div>';
	
	Ext.Ajax.request({
		url: route,
		method: 'POST',
		headers: '',
		params: {rechtsgebiet : lawsector, lenght : lenght, slot_title : slot_title},
		success: function(responseObject) {
			var hotpipeArray = doJSON( responseObject.responseText );
			
			renderedResponse = '<table cellspacing="0" cellpadding="10" border="0" width="100%">';
			count = 1;
			for (var i = 0; i  < hotpipeArray.length; i++) {
				renderedResponse += '<tr>';
				renderedResponse += '<td>';
				renderedResponse += hotpipeArray[i]['fulltitle']+':<br />';
				renderedResponse += '<a href="'+hotpipeArray[i]['route']+'" title="Details f&uuml;r '+hotpipeArray[i]['title']+' anzeigen" onclick="window.open(this.href, \'\', \'\'); return false;"><strong>'+hotpipeArray[i]['sub_title']+'</strong></a>';
				renderedResponse += '</td></tr>';
				count++;
				if (count < i) {
					renderedResponse += '<tr><td><div class="underline-m0-dotted"></div>';
				}
				renderedResponse += '</td>';
				renderedResponse += '</tr>';
			}
		renderedResponse += '</table>';
		renderedResponse += '<div class="trenner-m10"></div>';
		document.getElementById(juriondiv).innerHTML = renderedResponse;
		},
		failure: function() { 
			document.getElementById(juriondiv).innerHTML = '<div style="color:#777;padding:30px;line-height:26px;font-weight:bold">Die Jurion-Rechtsprechungen konnten nicht angezeigt werden.</div>';
		}
	});
}












// adON - erico brehmer - 23.07.08

// GET PARAMETERS DUMMY -->
//
// Um das erfolgreiche Speichern von DAten in den Tamplates zu simulieren, hebn wir diese kleine
// Funktion, die Get-Parameter ausliest und wir so die Meldung nach dem Speichern anzeigen koennen:
//
// wird hier weiter unten mittels "window.onload" aufgerufen
//
// das Anzeigen der Success meldung muesste fuer jede Logik leicht anzupassen sein.
//
function getUrlParams() {

	var query = window.location.search.substring(1);
	var parms = query.split('&');
	
	if (parms.length > 0) {
	
	for (var i=0; i<parms.length; i++) {
	
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
	
			if 	(key == 'edited' && val == '1') {
			
				document.getElementById('formSuccessInner').innerHTML = "Die Daten wurden erfolgreich gespeichert&nbsp;&nbsp;&nbsp;<img src='images/accept.gif' border='0' />";
				new Effect.SlideDown(document.getElementById('formSuccess'), {duration:0.5});
			
			}	
			
		}
		
	}
	
	}

}

function cleanUpPrintWindow(){
	var heute = new Date();
	var jahr = heute.getFullYear();
	var monat = heute.getMonth()+1;
	var tag = heute.getDate();
	//text = String(jahr);
	//text = text.substr(2,2);
	monat  = ((monat < 10) ? "0" + monat : monat);
	tag  = ((tag < 10) ? "0" + tag : tag);
	if (document.getElementById('toolbar-news')) {
		document.getElementById('toolbar-news').innerHTML = '<div class="printwindow">&copy; Schulleitung.de, Wolters Kluwer Deutschland GmbH, '+tag+'.'+monat+'.'+jahr+'</div>';
	}
	
	if (document.getElementById('print_logo')) {
		document.getElementById('print_logo').innerHTML = '<h1>Schulleitung</h1><div class="adon-divider-solid"></div>';
	}
	if (document.getElementById('slot_right_box')) {
		document.getElementById('slot_right_box').style.display = "none";
	}
	window.print();
}

function makeGbImg() {

	/*
	var inputElements = document.getElementsByTagName('input');
	
	for (var i = 0; i < inputElements.length; i++) {
		if (inputElements[i].className) {
			if (inputElements[i].className.indexOf('error') > -1) {
				document.getElementById('adonformFeedback').style.display = "block";
				new Effect.Highlight(document.getElementById('adonformFeedback'), {duration:1.9, startcolor: "#e6b4b4", endcolor: "#f1f3de",});
			}
		}
	}
*/

}


function clearPage() {
	
	// shop
	// themenportale
	// wolters-kluwer-deutschland
	
	if (document.getElementById('shop')) {
	
		if (document.getElementById('shop').style.display != 'none') {
			document.getElementById('shop').style.display = 'none';
		}
		
	} 
	if (document.getElementById('themenportale')) {
		if (document.getElementById('themenportale').style.display != 'none') {
			document.getElementById('themenportale').style.display = 'none';
		}
	}
	if (document.getElementById('themenportale')) {
		if (document.getElementById('wolters-kluwer-deutschland').style.display != 'none') {
			document.getElementById('wolters-kluwer-deutschland').style.display = 'none';
		}
	}
	
	// form-feedback
	
	if (document.getElementById('formFeedbackOuter')) {
		
		if (document.getElementById('formFeedbackOuter').style.display != 'none') {		
			setTimeout("new Effect.SlideUp(document.getElementById('formFeedbackOuter'), {duration:0.4})", 600);
		}
	}

}

// FORM CHECK DUMMY -->
//
// Nur ein Beispiel:
// Die Idee dahinter ist immer das selbe Div Elelemt (errorElem & errorInnerElem) fuer die Fehleranzeige zu benutzen.
// Auf jedem HTML-Template ist das versteckte ERROR DIV direkt unter der Header-Zeile - der Effekt (new Effect.SlideDown(errorElem))
// scheint die Fehlermeldung aus der Ueberschriftszeile zu "sliden".
//
// Somit wid eine einheiltiche Fehler-Anzeige sowie -Behandlung gewaehrleistet
//
function checkForm(formElem, errorElem, errorInnerElem) {
		
	var errors = false;	
	var errorArray = new Array();
	
	// falls Login Formular
	if (formElem.name == 'loginForm'){

			if (formElem.benutzername.value == '') {
				errorArray.push("Bitte geben Sie Ihre E-Mail Adresse an");
				errors = true;
			}
			
			if (formElem.kennwort.value == '') {
				errorArray.push("Bitte geben Sie Ihren Kennwort an");
				errors = true;
			}
			
	}
	
	// falls Konto Freischalten
	if (formElem.name == 'kontoFreischalten'){

			if (formElem.zugangscode.value == '' || formElem.zugangscode.value == 'Zugangscode') {
				errorArray.push("Bitte geben Sie einen Zugangscode ein");
				errors = true;
			}
						
	}
	
	// falls Konto Daten aendern
	if (formElem.name == 'kontoDaten'){

			if (formElem.benutzername.value == '') {
				errorArray.push("Bitte geben Sie Ihre E-Mail Adresse an");
				errors = true;
			}
						
	}
	
	// falls Zahlungsarrt aendern
	if (formElem.name == 'zahlungsDaten'){

			if (formElem.zahlungsmethode[1].checked == true) {
			
				if (formElem.kontonummer.value == '') {
					errorArray.push("Bitte geben Sie Ihre Kontonummer an");
					errors = true;
				}
				if (formElem.bankleitzahl.value == '') {
					errorArray.push("Bitte geben Sie die Bankleitzahl an");
					errors = true;
				}
				if (formElem.bankinstitut.value == '') {
					errorArray.push("Bitte geben Sie das Bankisntitut an");
					errors = true;
				}
				if (formElem.kontoinhaber.value == '') {
					errorArray.push("Bitte geben Sie den Kontoinhaber an");
					errors = true;
				}
				
			}
						
	}
	
	if (errors) {
	
		errorInnerElem.innerHTML = "<div style='color:#4c4c4c;font-weight:bold'>Der Vorgang konnte nicht ausgef&uuml;hrt werden:</div>";
		
		for (i = 0; i < errorArray.length; i++) {
			errorInnerElem.innerHTML += "<br />- " + errorArray[i];
		}
				
		// falls fehlermeldung schon offen war, nicht wieder oeffnen
		// nur aktualisieren <<
		if (errorElem.style.display == 'none') {
			new Effect.SlideDown(errorElem, {duration:0.5});
			// falls schon gespeichert worden war und SUCCESS meldung noch offen ist
			if (document.getElementById('formSuccess').style.display != 'none') {
				setTimeout("new Effect.SlideUp(document.getElementById('formSuccess'), {duration:0.5})", 600);
			}
		}
	} else {
		
		formElem.submit();
	
	}
	

}




// SHOW LEVEL 1 MENU HIDDEN DIVs -->

var linkelem = '';
var divArray = ['themenportale', 'wolters-kluwer-deutschland', 'shop'];
function showFloatingMenu(linkelem, windivid, elemy, elemx) {
	
	if(windivid == 'themenportale') {
		document.getElementById('wolters-kluwer-deutschland').style.display = "none";
		document.getElementById('shop').style.display = "none";
	}
	
	if(windivid == 'wolters-kluwer-deutschland') {
		document.getElementById('themenportale').style.display = "none";
		document.getElementById('shop').style.display = "none";
	}
	
	if(windivid == 'shop') {
		document.getElementById('themenportale').style.display = "none";
		document.getElementById('wolters-kluwer-deutschland').style.display = "none";
	}
	
	// Bild im LinkElement austauschen
	if (document.getElementById(windivid).style.display == 'none') {
		document.getElementById(windivid).style.display = "block";
	} else {
		document.getElementById(windivid).style.display = "none";
	}
	
	if(self.linkelem != linkelem) {
		document.getElementById(windivid).style.display = "block";
	}
	
	// LinkElement Position ermitteln und anpassen
	document.getElementById(windivid).style.top = (findPosY(linkelem) +elemy)+"px";
	document.getElementById(windivid).style.left = (findPosX(linkelem) - elemx)+"px";
	self.linkelem = linkelem;
	// ShoppingCart Anzeigen/Verstecken
}

function hideFloatingMenu(divid) {
	document.getElementById(divid).style.display = 'none';
}

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 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 changeSource(image) {

	var fullimg = image.src.substring(image.src.lastIndexOf('/') + 1, image.src.length);
	var picext = fullimg.substring(fullimg.indexOf('.'), fullimg.length);
	var picname = fullimg.substring(0, fullimg.indexOf('.'));
	var newpic;
	
	if (picname.indexOf('_on') != -1) {
		newpic = picname.substring(0, picname.indexOf('_on')) + picext;
		}
	else {
		newpic = picname + '_on' + picext;
		}	
	
	image.src = "../html/img/" + newpic;

}


var unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~";
var reserved = "!*'();:@&=+$,/?%#[]";
var allowed = unreserved + reserved;
var hexchars = "0123456789ABCDEFabcdef";

// This function returns a percent sign followed by two hexadecimal digits.
// Input is a decimal value not greater than 255.
function gethex(decimal) {
    return "%" + hexchars.charAt(decimal >> 4) + hexchars.charAt(decimal & 0xF);
}

// This function "does the job": it takes the user input and encodes it in the UTF-8 charset
function encode(decoded/*, productCode*/) {
    // Some variables:
    var encoded = "";
    for (var i = 0; i < decoded.length; i++) {
        var ch = decoded.charAt(i);
        // Check if character is an unreserved character:
        if (unreserved.indexOf(ch) != -1) {
            encoded = encoded + ch;
        } else {
            // The position in the Unicode table tells us how many bytes are needed.
            // Note that if we talk about first, second, etc. in the following, we are
            // counting from left to right:
            //
            //   Position in   |  Bytes needed   | Binary representation
            //  Unicode table  |   for UTF-8     |       of UTF-8
            //     0 -     127 |    1 byte       | 0XXX.XXXX
            //   128 -    2047 |    2 bytes      | 110X.XXXX 10XX.XXXX
            //  2048 -   65535 |    3 bytes      | 1110.XXXX 10XX.XXXX 10XX.XXXX
            // 65536 - 2097151 |    4 bytes      | 1111.0XXX 10XX.XXXX 10XX.XXXX 10XX.XXXX

            var charcode = decoded.charCodeAt(i);

            // Position 0 - 127 is equal to percent-encoding with an ASCII character encoding:
            if (charcode < 128) {
                encoded = encoded + gethex(charcode);
            }

            // Position 128 - 2047: two bytes for UTF-8 character encoding.
            if (charcode > 127 && charcode < 2048) {
                // First UTF byte: Mask the first five bits of charcode with binary 110X.XXXX:
                encoded = encoded + gethex((charcode >> 6) | 0xC0);
                // Second UTF byte: Get last six bits of charcode and mask them with binary 10XX.XXXX:
                encoded = encoded + gethex((charcode & 0x3F) | 0x80);
            }

            // Position 2048 - 65535: three bytes for UTF-8 character encoding.
            if (charcode > 2047 && charcode < 65536) {
                // First UTF byte: Mask the first four bits of charcode with binary 1110.XXXX:
                encoded = encoded + gethex((charcode >> 12) | 0xE0);
                // Second UTF byte: Get the next six bits of charcode and mask them binary 10XX.XXXX:
                encoded = encoded + gethex(((charcode >> 6) & 0x3F) | 0x80);
                // Third UTF byte: Get the last six bits of charcode and mask them binary 10XX.XXXX:
                encoded = encoded + gethex((charcode & 0x3F) | 0x80);
            }

            // Position 65536 - : four bytes for UTF-8 character encoding.
            if (charcode > 65535) {
                // First UTF byte: Mask the first three bits of charcode with binary 1111.0XXX:
                encoded = encoded + gethex((charcode >> 18) | 0xF0);
                // Second UTF byte: Get the next six bits of charcode and mask them binary 10XX.XXXX:
                encoded = encoded + gethex(((charcode >> 12) & 0x3F) | 0x80);
                // Third UTF byte: Get the last six bits of charcode and mask them binary 10XX.XXXX:
                encoded = encoded + gethex(((charcode >> 6) & 0x3F) | 0x80);
                // Fourth UTF byte: Get the last six bits of charcode and mask them binary 10XX.XXXX:
                encoded = encoded + gethex((charcode & 0x3F) | 0x80);
            }
        }
    }
    return encoded;
}

function callWebService(){
    var raw = document.getElementById("searchQuery").value;
    var productCode = document.getElementById("productCode").value;
    var encoded = encode(raw);
    document.location="http://ola.level7.ro/cross-search-client/searchClient?productId=" + productCode + "&query=" + encoded;
}

function callSearchFromURL(){
    var raw = document.getElementById("searchQuery").value;
    var productCode = document.getElementById("productCode").value;
    var encoded = encode(raw);
    var olaaa ="http://ola-cams.level7.ro/OLA-" + productCode + "/allTypesResults.jsf?q=" + encoded;
    window.open(olaaa,'searchForm','');
}

function resetValues(){
    document.getElementById("searchQuery").value = "";
    document.getElementById("productCode").value = "SGBIX";
}


function askUserLogin(linkelement, title) {



	//document.getElementById('globCont').className = "adon-globalDivContainerTrans";
	
	document.getElementById('ToolNor').style.top = (findPosY(linkelement)-200) + "px";
	document.getElementById('ToolNor').style.left = (findPosX(linkelement)-500)+"px";
	
	document.getElementById('ToolNorLink').href = linkelement.href;
	document.getElementById('ToolNorLink').title = "'" + title + "' �ber click & buy kaufen";
	
document.getElementById('ToolNor').style.display='block';

}

function askUserLoginTitle(linkelement, title) {



	//document.getElementById('globCont').className = "adon-globalDivContainerTrans";
	
	document.getElementById('ToolNor').style.top = (findPosY(linkelement)-200) + "px";
	document.getElementById('ToolNor').style.left = (findPosX(linkelement)+190)+"px";
	
	document.getElementById('ToolNorLink').href = linkelement.href;
	document.getElementById('ToolNorLink').title = "'" + title + "' &Uuml;ber click & buy kaufen";
	
document.getElementById('ToolNor').style.display='block';

}

function askUserLoginTitleJB(linkelement, title) {



	//document.getElementById('globCont').className = "adon-globalDivContainerTrans";
	
	document.getElementById('ToolNorJB').style.top = (findPosY(linkelement)-200) + "px";
	document.getElementById('ToolNorJB').style.left = "300px";
	
	new Effect.Appear(document.getElementById('ToolNorJB'));

}

function closeUserLoginJB(linkelement) {
	
	new Effect.Fade(document.getElementById('ToolNorJB'));
	
	//document.getElementById('globCont').className = "adon-globalDivContainer";

}

function closeUserLogin(linkelement) {
	
	new Effect.Fade(document.getElementById('ToolNor'));
	
	//document.getElementById('globCont').className = "adon-globalDivContainer";

}
// Dropdown funktion fuer den slot auf der Startseite von schulleitung.de
function dropdown_slot_homepage(){
	if (document.getElementById('steuern').sls.value == 'no_link'){
		document.getElementById('fehler').style.display = 'block';
	} else {
		window.location = document.getElementById('steuern').sls.value;
	}
}

function checkEzaCode(code) {
	//alert(code);
	if (code == 'WKYT912XM') {
		document.location.href="http://extraweb.wolterskluwer.de/eza/index.php?code="+code;
	}else {
		document.getElementById('codeerror').style.display = "block";
	}
}


function checkBSGCode(code) {
	//alert(code);
	if (code == 'WK8JK35VM') {
		document.location.href="http://extraweb.wolterskluwer.de/sgbv/db.php?code="+code;
	}else {
		document.getElementById('codeerror').style.display = "block";
	}
}

function checkSchulleitungDownload(code) {
	//alert(code);
	if (code == 'slh467') {
		document.location.href="/index.php/de/html/content/862/downloads/";
	}else {
		document.getElementById('code_message').style.display = "block";
	}
}

// PRODUCT CHECK AJAX
function checkCode(action_url, action_camsId, action_productid, action_portid) {
	if (action_productid != '') {
		Ext.apply(Ext.lib.Ajax.defaultHeaders,'Content-Type: text/xml;charset=utf-8');
		var conn = new Ext.data.Connection();
			conn.request({
				url: action_url,
				method: 'POST',
				params: { camsId : action_camsId, portid : action_portid,productid :  action_productid},
				waitMsg:'Bitte warten, der Kommentar wird gespeichert',
				success: function(responseObject) {
					//alert(responseObject.responseText);
					if (responseObject.responseText == 'success') {
						window.location.reload();
					} else {
						document.getElementById('code_empty_div').innerHTML = "Der Code ist nicht korrekt. Bitte geben Sie den Code erneut ein.";
						document.getElementById('code_empty_div').style.display = "block";
					}
				},
				failure: function() {
					document.getElementById('code_empty_div').innerHTML = "Der Code konnte nicht gepr&uuml;ft werden. Bitte versuchen Sie es gleich noch mal.";
					document.getElementById('code_empty_div').style.display = "block";
				}
			});
	} else {
		document.getElementById('code_empty_div').style.display = "block";
	}
}

// BEWARE: window.onload functions are called trough the whole website
function triggerEvents() {
	// Registrierung
	var inputNodes = document.getElementsByTagName("input");
	for (var i = 0; i < inputNodes.length; i++) {
		if (inputNodes[i].className == 'adon-form-input-normal') {
			inputNodes[i].onfocus = function() {
				this.className = 'adon-form-input-normal-focus';
			}
			inputNodes[i].onblur = function() {
				this.className = 'adon-form-input-normal';
			}
		}
		if (inputNodes[i].className == 'adon-form-input-small') {
			inputNodes[i].onfocus = function() {
				this.className = 'adon-form-input-small-focus';
			}
			inputNodes[i].onblur = function() {
				this.className = 'adon-form-input-small';
			}
		}
		if (inputNodes[i].className == 'adon-form-input-medium') {
			inputNodes[i].onfocus = function() {
				this.className = 'adon-form-input-medium-focus';
			}
			inputNodes[i].onblur = function() {
				this.className = 'adon-form-input-medium';
			}
		}
	}
	var selectNodes = document.getElementsByTagName("select");
	for (var i = 0; i < selectNodes.length; i++) {
		if (selectNodes[i].className == 'adon-form-select') {
			selectNodes[i].onfocus = function() {
				this.className = 'adon-form-select-focus';
			}
			selectNodes[i].onblur = function() {
				this.className = 'adon-form-select';
			}
		} else {
			selectNodes[i].className = 'adon-form-select';
			selectNodes[i].onfocus = function() {
				this.className = 'adon-form-select-focus';
			}
			selectNodes[i].onblur = function() {
				this.className = 'adon-form-select';
			}
		}
	}
	if (document.getElementById('terms_agb')) {
		document.getElementById('terms_agb').onmouseover = function() {
			this.className = 'adon-form-terms-hover';
		}
		document.getElementById('terms_agb').onmouseout = function() {
			this.className = 'adon-form-terms';
		}
	}
	if (document.getElementById('terms_kluwer_account')) {
		document.getElementById('terms_kluwer_account').onmouseover = function() {
			this.className = 'adon-form-terms-hover';
		}
		document.getElementById('terms_kluwer_account').onmouseout = function() {
			this.className = 'adon-form-terms';
		}
	}
	if (document.getElementById('terms_info')) {
		document.getElementById('terms_info').onmouseover = function() {
			this.className = 'adon-form-terms-hover';
		}
		document.getElementById('terms_info').onmouseout = function() {
			this.className = 'adon-form-terms';
		}
	}
	// search box
	if (document.getElementById('search_container') && document.getElementById('search_term')) {
	
		var isFocused=false;
	
		document.getElementById('search_term').onfocus =  function() {
			isFocused=true;
			document.getElementById('search_container').className = 'header-search-container-focused';
			this.className = 'adon-input-box-header-search-focused';
			if (this.value == 'Suche') {
				this.value = "";
			}
		}
		document.getElementById('search_term').onblur =  function() {
			isFocused=false;
			document.getElementById('search_container').className = 'header-search-container';
			this.className = 'adon-input-box-header-search';
			if (this.value == '') {
				this.value = "Suche";
			}
		}
		document.getElementById('form_search_hover').onmouseover =  function() {
			document.getElementById('search_container').className = 'header-search-container-hover';
		}
		document.getElementById('form_search_hover').onmouseout =  function() {
			if (isFocused) {
				document.getElementById('search_container').className = 'header-search-container-focused';
			} else {
				document.getElementById('search_container').className = 'header-search-container';
			}
			
		}
	}
	
	
	if (document.getElementById('adon-level4menu-container')) {
		//document.getElementById('adon-level4menu-container').style.display = "block";
		//alert(document.getElementById('adon-level4menu-container').innerHTML)
		var menu2 = document.getElementById('adon-level4menu-container').innerHTML;
		if (menu2.replace(/^\s+|\s+$/g,"") != '') {
			document.getElementById('adon-level4menu-container').style.display = "block";
		} else {
			//if (document.getElementById('adon-level4menu-container-shadow')) {
			//	document.getElementById('adon-level4menu-container-shadow').style.display = "block";
			//}
		}
		
	}
	
	setTimeout('showLevel3()', 1000);
	
}

function showLevel3() {

	if (document.getElementById('adon-level3menu-container')) {
		//document.getElementById('adon-level3menu-container').style.display = "block";
		var menu = document.getElementById('adon-level3menu-container').innerHTML;
		
		///alert(menu);
		
		
		
		if (menu.indexOf('adon-level2menu') > -1) {
			
			document.getElementById('adon-level3menu-container').style.display = "block";
		
		
		} else {
			if (document.getElementById('adon-level3menu-container-shadow')) {
				document.getElementById('adon-level3menu-container-shadow').style.display = "block";
			}
		}

	}


}




function toggleDeliveryAdress() {
	if (document.getElementById('deliveryAddress').style.display == 'none') {
		document.getElementById('deliveryAddress').style.display = "block";
	} else {
		document.getElementById('deliveryAddress').style.display = "none";
	}
}

function checkInfoboxes() {
	if (document.getElementById('infooffer').checked === true) { 
		document.getElementById('infooffer_email').disabled = false;
		document.getElementById('infooffer_phone').disabled = false;
		document.getElementById('infooffer_smsmms').disabled = false;
		document.getElementById('infooffer_mail').disabled = false;
		document.getElementById('infooffer_fax').disabled = false;
		document.getElementById('infooffer_email').checked = true;
		document.getElementById('infooffer_phone').checked = true;
		document.getElementById('infooffer_smsmms').checked = true;
		document.getElementById('infooffer_mail').checked = true;
		document.getElementById('infooffer_fax').checked = true;
	} else {
		document.getElementById('infooffer_email').checked = false;
		document.getElementById('infooffer_phone').checked = false;
		document.getElementById('infooffer_smsmms').checked = false;
		document.getElementById('infooffer_mail').checked = false;
		document.getElementById('infooffer_fax').checked = false;
		document.getElementById('infooffer_email').disabled = true;
		document.getElementById('infooffer_phone').disabled = true;
		document.getElementById('infooffer_smsmms').disabled = true;
		document.getElementById('infooffer_mail').disabled = true;
		document.getElementById('infooffer_fax').disabled = true;
	}
}
window.onload = triggerEvents;
