			EI = ( document.getElementById && !( document.all ) );
			DA  = ( document.all );
			
function openAffiliate( field ){
	var aff_id = field.options[ field.selectedIndex ].value;
	openAffiliateWithId( aff_id );
}

function openAffiliateWithId( id ){
	if( id != 'noagnr' ){
		document.submitform.open_affiliate_id. value = id;
		document.submitform.action.value = 'openAffiliate';
		sendRequest();
	}
}

function newAffiliate(){
	document.submitform.action.value = 'newAffiliate';
	sendRequest();
}

function changeStatus( id, field ){
	document.submitform.value_field.value = field.options[ field.selectedIndex ].value;
	document.submitform.open_affiliate_id. value = id;
	document.submitform.action.value = 'changeStatus';
	sendRequest();
}

function sendRequest(){
	sendUsingAjax();
}

function closeError(){
	document.getElementById( "error_span" ).style.display = "none";
}

function changePassword(){
	win = window.open( "", "changePassword", "height=300,width=400,scrollbars=no,location=no,menubar=no,status=no,toolbar=no,titlebar=no,resizable=no,resize=no" );
	win.document.location.href = './changePassword.jsp';
}

function forgotPwd(){
	win = window.open( "", "forgotPassword", "height=300,width=400,scrollbars=no,location=no,menubar=no,status=no,toolbar=no,titlebar=no,resizable=no,resize=no" );
	win.document.location.href = './forgotPassword.jsp';
}

function openExamples( agnr ){
	$( "overview_menu" ).style.display = "none";
	
	//var target = document.submitform.target;
	document.submitform.action.value = "showAdvertising";
	sendUsingAjax(  );
	//document.submitform.target = "doc_frame";
	//document.submitform.submit();
	//document.submitform.target = target;
	
//	parent.doc_frame.location.href = './advertising.jsp?partner_id=' + agnr;
}

function openDownloads(){
	document.submitform.action.value = "showDownloads";
	document.submitform.target = "doc_frame";
	sendUsingAjax(  );
	$( "overview_menu" ).style.display = "none";
	//var target = document.submitform.target;
	//document.submitform.submit();
	//document.submitform.target = target;
}

function openAccounting(){
	$( "overview_menu" ).style.display = "none";
	//var target = document.submitform.target;
	document.submitform.action.value = "prepareAccounting";
	sendUsingAjax( );
	//document.submitform.target = "doc_frame";
	//document.submitform.submit();
	//document.submitform.target = target;
}

function openExchange(){
	win = window.open( "", "exchange", "height=700,width=500,scrollbars=auto,location=no,menubar=no,status=no,toolbar=no,titlebar=no,resizable=yes,resize=no" );
	var target = document.submitform.target;
	document.submitform.action.value = "exchange.open";
	document.submitform.target = "exchange";
	document.submitform.submit();
	document.submitform.target = target;
}


function logout(){
	document.submitform.action.value = "logout";
	document.submitform.submit();
}


function sendEditDataRequest(){
	$( "overview_menu" ).style.display = "none";
	document.submitform.action.value = "editData";
	sendUsingAjax();
	//var target = document.submitform.target;
	
	//document.submitform.target = "doc_frame";
	//document.submitform.submit();
	//document.submitform.target = target;
}

function showReport_main(){
	$( "overview_menu" ).style.display = "none";
	//var target = document.submitform.target;
	document.submitform.action.value = "showReport_main";
	sendUsingAjax();
	//document.submitform.target = "doc_frame";
	//document.submitform.submit();
	//document.submitform.target = target;
}

function showOverview(){
	document.submitform.action.value = "overview";
	sendUsingAjax();
	$( "overview_menu" ).style.display = "inline";
	//show( "overview_menu" );
}

function show( id ){
	if( DA ) eval( "document.all." + id + ".style" ).display = "inline";
	else if( EI  ) document.getElementById( id ).style.display = "inline";
}

function hide( id ){
	if( DA ) eval( "document.all." + id + ".style" ).display = "none";
	else if( EI  ) document.getElementById( id ).style.display = "none";
}

function openSpecial(){
	var length = ( document.overviewForm.agency.options.length - 1 );
//	alert( agency_length + " = " + length );
	if( document.overviewForm.agency.selectedIndex != 0 )/*top.doc_frame.*/openOnly( document.overviewForm.agency.selectedIndex - 1 , length );
	else /*top.doc_frame.*/openAll( length );
}

var transfering = false;
function calculate(){
	if( transfering == false ){
		var popup = window.open( "", "calculation_window", "menubar=no,location=no,dependent=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=600px,height=600px" );
		document.calcu.target = "calculation_window";
		document.calcu.action.value = "showReport_main";
		document.calcu.submit();
	}
}

function updateBookings(){
	if( transfering == false ){
		var popup = window.open( "", "update_window", "menubar=no,location=no,dependent=no,status=no,toolbar=no,resizable=yes,width=400px,height=300px" );
		document.calcu.target = "update_window";
		document.calcu.action.value = "updateBookings";
		document.calcu.submit();
	}
}

function openReport(){
	if( transfering == false ){
		if( document.fileform.filename.options[ document.fileform.filename.selectedIndex ].value != "none" ){
			var popup = window.open( "", "calculation_window", "menubar=no,location=no,dependent=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=400px,height=300px" );
			document.fileform.target = "calculation_window";
			document.fileform.submit();
		}
		else document.formular.submit();
	}
}

function cancelBooking(){
	if( transfering == false ){
		document.editBooking.action.value="cancelBooking";
		document.editBooking.submit();
		transfering = true;
	}
}

function updateBooking(){
	if( transfering == false ){
		document.editBooking.action.value="updateBooking";
		document.editBooking.submit();
		transfering = true;
	}
}

function changeDate( service_id ){
	if( transfering == false ){
		document.editBooking.action.value = "changeDate";
		document.editBooking.service_id.value = service_id;
		document.editBooking.submit();
		transfering = true;
	}
}

function setIdOut( id ){
	document.vform.id_out.value = id;
}

function setIdIn( id ){
	document.vform.id_in.value = id;
}

function deletePax( id ){
	if( transfering == false ){
		document.editBooking.action.value = "deletePax";
		document.editBooking.delete_pax_id.value = id;
		document.editBooking.submit();
		transfering = true;
	}
}
function addPax(){
	if( transfering == false ){
//		var popup = window.open( "", "add_pax", "menubar=no,location=no,dependent=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=400px,height=300px" );
//		var target = document.editBooking.target;
		document.editBooking.action.value = "openAddPax";
//		document.editBooking.target = "add_pax";
		document.editBooking.submit();
//		document.editBooking.target = target;
		transfering = true;
	}
}


function sendUsingAjax(  ){
	var fn = function() {
		$('dataTd').style.cursor = "default";
	}
	
	$('dataTd').style.cursor = "wait";
	
	var url = "./cuis";
	var myAjax = new Ajax( url, {
		method: 'post', 
		data: $('submitform').toQueryString(), 
		update: 'dataTd',
		onComplete: fn,
		evalScripts: true
	} );
	myAjax.request();
}
function editBooking( id ){
	
	var fn = function() {
		$('dataTd').style.cursor = "default";
	}
	
	$('dataTd').style.cursor = "wait";
	
	clearAffiliates();
	$( "overview_menu" ).style.display = "none";
	document.ov_form.action.value = "openBooking";
	document.ov_form.booking_id.value = id;
	//document.ov_form.submit();
	var url = "./cuis";
	var myAjax = new Ajax( url, {
		method: 'post', 
		data: $('ov_form').toQueryString(), 
		update: 'dataTd',
		onComplete: fn,
		evalScripts: true
	} );
	myAjax.request();
}

//function normalizeCursor(){
//	$('dataTd').style.cursor = "default";
//}

function updateOverview(){
	
	var fn = function() {
		$('dataTd').style.cursor = "default";
	}
	
	$('dataTd').style.cursor = "wait";
	
	var url = "./cuis";
	var myAjax = new Ajax( url, {
		method: 'post', 
		data: $('overviewForm').toQueryString(), 
		update: 'dataTd',
		onComplete: fn,
		evalScripts: true
	} );
	myAjax.request();
}

function sendAccountingFirst(){
	
	var fn = function() {
		$('dataTd').style.cursor = "default";
	}
	
	$('dataTd').style.cursor = "wait";
	
	var url = "./cuis";
	var myAjax = new Ajax( url, {
		method: 'post', 
		data: $('closeForm').toQueryString(), 
		update: 'dataTd',
		onComplete: fn,
		evalScripts: true
	} );
	myAjax.request();
}

function openNewSubaffiliatePage( url ){
	
	var fn = function() {
		$('dataTd').style.cursor = "default";
	}
	
	$('dataTd').style.cursor = "wait";
	
	$( "overview_menu" ).style.display = "none";
	//var url = "./cuis";
	var myAjax = new Ajax( url, {
		method: 'post', 
		data: $('subaffiliateForm').toQueryString(), 
		update: 'dataTd',
		onComplete: fn,
		evalScripts: true
	} );
	myAjax.request();
}


//Code aus overview.jsp

//Anzahl der elemente in der Auswahlliste "agency" wird ge�ndert durch overview.jsp overview.jsp.clearAffiliates() overview.jsp.addAffiliate()
			var agency_length = 0;
			
			
			function hideHead( id ){
				if( DA ) eval( "document.all.agency" + id + ".style" ).display = "none";
				else if( EI  ) document.getElementById( "agency" + id ).style.display = "none";
			}
			
			function showHead( id ){
		//	alert( "id: " + id );
				if( DA ) eval( "document.all.agency" + id + ".style" ).display = "inline";
				else if( EI  ) document.getElementById( "agency" + id ).style.display = "inline";
			}
			function changeBG( id ){
				if( DA ) eval( "document.all.agency" + id + ".style" ).backgroundColor = "#B3C6E4";
				else if( EI  ) document.getElementById( "agency" + id ).style.backgroundColor = "#B3C6E4";
			}
			function openOnly( id, size ){
				size = agency_length;
				size --;
	//			alert( "inOpenOnly size:" + size );
				
				for( var i = 0; i < size; i++ ){
					hideResults( i );
				}
				showHead( id );
				showResults( id );
				
				var field;
				if( DA ) field = eval( "document.all.agency" + id );
				else if( EI  ) field = document.getElementById( "agency" + id );
//				if( DA ) field = eval( "document.all.headline" + id );
//				else if( EI  ) field = document.getElementById( "headline" + id );
				
				window.scrollTo( 0, findPosY( field ) );
//				alert( findPosY( field ) );
			}
			function openAll( size ){
				size = agency_length;
				size --;
//				alert( "inOpenAll size:" + size );
				
				for( var i = 0; i < size; i++ ){
					showResults( i );
				}
			}
			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 clearAffiliates(){
				for( var i = 0; i < document.overviewForm.agency.length - 1; i++ ){
					document.overviewForm.agency.options[ i ] = null;
					agency_length--;
				}
			}
			function addAffiliate( id, affiliate_number ){
				NewEntry = new Option( affiliate_number, agency_length );
				document.overviewForm.agency.options[ agency_length ] = NewEntry;
//				top.document.formular.agency.options[ top.document.formular.agency.length ] = NewEntry;
				agency_length++;
			}
			function checkCommissionField( field, min, max ){
			
				cleanNumber( field );
				field.value = field.value.replace( ",", "." );
				if( isNaN( parseFloat( field.value ) ) || field.value == '' ) return false;
				if( parseFloat( field.value ) < min || parseFloat( field.value ) > max ) return false;
				//				alert( '' + parseFloat( field.value ) );
				field.value = '' + parseFloat( field.value );
				field.value = field.value.replace( ".", "," );
				return true;
			
			}
			
			function checkPercentField( field, min, max ){
			
				cleanPercent( field );
				if( isNaN( parseInt( field.value ) ) || field.value == '' ) return false;
				if( parseInt( field.value ) < min || parseInt( field.value ) > max ) return false;
				field.value = '' + parseInt( field.value );
				
				return true;
			
			}
			
			function cleanNumber( field ){
				field.value = field.value.replace( ".", "," );
				field.value = field.value.replace( /[^1234567890,]/g, "" );
			}
			
			function cleanPercent( field ){
				field.value = field.value.replace( /[^1234567890]/g, "" );
			}
			function checkEmailField( field ){
				if( field.value.indexOf( "@" ) < 0 || field.value.indexOf( "." ) < 0 || field.value.indexOf( "@" ) != field.value.lastIndexOf( "@" )){
					field.value = "";
				}
			}
			function toBig( field, max ){
				if( parseFloat( field.value ) == "NaN" ) return false;
				return parseFloat( field.value ) > max;
			}
			function toSmall( field, min ){
				if( parseFloat( field.value ) == "NaN" ) return false;
				return parseFloat( field.value ) < min;
			}
