// JavaScript Document

//* UPDATE AW 02.06.2010*//
// funktioniert nicht im IE und sorgt dafür das übriges JS (Lightbox und co.) nicht mehr funktionieren

 // Zoom class
var Zoom = {
	currentZoomFactor: 0,

	setStylesheet: function(zoomFactor, save) {
		if (save) {
			$.ajax({
				type: 'GET',
				url: 'fileadmin/develop/php/ajax.zoom.php',
				data: 'action=set&zoomFactor=' + zoomFactor
			});
		}

		this.currentZoomFactor = zoomFactor;
		$('.fontCss').attr('disabled', 'disabled');
		$('#fontCss' + this.currentZoomFactor).attr('disabled', '');
	},

	increase: function() {
		if (this.currentZoomFactor < 3) {
			this.setStylesheet(parseInt(this.currentZoomFactor+1), true);
		}
	},

	decrease: function() {
		if (this.currentZoomFactor > 0) {
			this.setStylesheet(parseInt(this.currentZoomFactor-1), true);
		}
	}
};

// Pager class
var Pager = {
	previousPage: function(selector) {
		var activePageNo = parseInt($(selector + ' .page:visible').index()) + 1;
		if (activePageNo > 1) {
			this.showPage(selector, (activePageNo - 1));
		}
	},

	nextPage: function(selector) {
		var activePageNo = parseInt($(selector + ' .page:visible').index()) + 1;
		if ($(selector + ' .page' + (activePageNo + 1)).length > 0) {
			this.showPage(selector, activePageNo + 1);
		}
	},

	showPage: function(selector, pageNo) {
		$(selector + ' .page').hide();
		$(selector + ' .page' + pageNo).show();

		$(selector + ' .activeLinkWrap').removeClass('activeLinkWrap').addClass('inactiveLinkWrap');
		$(selector + ' .browseBoxWrap').each(function() {
			$(this).find('.inactiveLinkWrap:eq(' + pageNo + ')').removeClass('inactiveLinkWrap').addClass('activeLinkWrap');
		});
	}
};

// jquery extension
jQuery.fn.outerHTML = function(s) {
    return (s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html());
};

function showLightbox(param) {
	$(".dialog_" + param).dialog({
		height: 560,
		modal: true,
		autoOpen: false,
		width: 450
	});

	$('.dialog_' + param).dialog('open');
	return false;
}

$(document).ready(function() {
	$('body').addClass('js');

	var activeMenuItem = -1;
	var deadMenuItems = new Object();
	$('#nav .list-dropdown ul ul ul li.hasSubItems').hover(function() {
		var element = $(this);
		deadMenuItems[element.index()] = 0;

		if (activeMenuItem != element.index()) {
			activeMenuItem = element.index();
			window.setTimeout(function() {
				if (activeMenuItem == element.index()) {
					element.find('ul').addClass('active');
				}
			}, 400);
		}
	},
	function() {
		var element = $(this);
		deadMenuItems[element.index()] = 1;
		window.setTimeout(function() {
			if (activeMenuItem == element.index()) {
				activeMenuItem = -1;
			}

			if (deadMenuItems[element.index()] == 1) {
				element.find('ul').removeClass('active');
			}
		}, 400);
	});

	if ($('#newsArchiveYearSelector select').val() == -1) {
		$('#newsArchiveMonthSelector').hide();
	}

	$('#newsArchiveYearSelector select').change(function() {
		if ($(this).val() != -1) {
			$('#newsArchiveMonthSelector').show();
		}
		else {
			$('#newsArchiveMonthSelector select').val(-1);
			$('#newsArchiveMonthSelector').hide();
		}
	});

	//$('.border-grey').equalHeights();

	$('.box-form .contactForm #klinikum').change(function() {
		$('#contactForm-clinicSelect').html('');

		if ($(this).val() != 'null') {
			$.ajax({
				type: 'GET',
				url: 'fileadmin/develop/php/ajax.getLocationClinics.php',
				data: 'houseName=' + $(this).val(),
				success: function(response) {
					if (response != '0') {
						$('#contactForm-clinicSelect').html('<p class="clearfix"><label>&nbsp;</label><span>' + response + '</span></p>');
					}
				}
			});
		}
	});

	if($.browser.msie) {
		/* IE obscures the option text for fixed-width selects if the text
		 * is longer than the select. To work around this we make the width
		 * auto whenever the drop down is visible.
		 */
		$("#clinicfinderQuicksearch select.ieDynamic").livequery(function(){
			/* Use mousedown rather than focus because the focus event gets
			 * interrupted and the dropdown does not appear
			 */
			$(this)
			.mousedown(function(){
				if($(this).css("width") != "auto") {
					var width = $(this).width();
					$(this).data("origWidth", $(this).css("width"))
						   .css("width", "auto");
					/* if the width is now less than before then undo */
					if($(this).width() < width) {
						$(this).css("width", $(this).data("origWidth"));
					}
				}
			})
			/* Handle blur if the user does not change the value */
			.blur(function(){
				$(this).css("width", $(this).data("origWidth"));

			})
			/* Handle change of the user does change the value */
			.change(function(){
				$(this).css("width", $(this).data("origWidth"));

			});
		});
	}

	// Jquery.ShowHide
	$(".showhide-content").hide();

	$(".showhide").toggle(function(){
		$(this).addClass("active");
		$(this).val("schließen");
		}, function () {
		$(this).removeClass("active");
		$(this).val("weitere Informationen");
	});

	$(".showhide").click(function(){
		$(this).next(".showhide-content").slideToggle("slow,");
	});

	$(".showhide-2").toggle(function(){
		$(this).addClass("active");
		$(this).val("schließen");
		}, function () {
		$(this).removeClass("active");
		$(this).val("Verantwortungsbereich anzeigen");
	});

	$(".showhide-2").click(function(){
		$(this).next(".showhide-content").slideToggle("slow,");
	});

	// Jquery.Accordion
	$(".accordion").accordion({
		autoHeight: false,
		active: false,
		collapsible: true
	});

	// Jquery.Datepicker
	$("#datepicker").datepicker();

	// Jquery.Dialog
	$(".dialog").dialog({
		modal: true,
		autoOpen: false
	});

	// Jquery.Dialog
	$(function() {
		$("#dialog").dialog({
			height: 560,
			modal: true,
			autoOpen: false
		});

		/* +++ UPDATE AW +++ */
		for(var i=1; i<10; i++){
			$(".dialog_"+i).dialog({
				height: 560,
				modal: true,
				autoOpen: false
			});
		}
		/* --- UPDATE AW --- */

		$('#open').click(function() {
			$('#dialog').dialog('open');
			return false;
		});
	});

	$('.link-recommend').click(function() {
		$('#recommendformDialog').dialog('open');
		return false;
	});
	
	//$('.link-register').click(function() {
		//$('#registrationformDialog').dialog('open');
		//$('#registrationformDialog').dialog({width: '600px'});
		//$("#registrationformDialog").dialog('open','width',600);

		//('#registrationformDialog').dialog({width: '550px'});
		//$('#registrationformDialog').dialog('open');

		return false;
	//});

	$('.link-contact').click(function() {
		//$('#contactformDialog').dialog('open');
		$('#contactformDialog').dialog('open')({ height: 1530 });
		return false;
	});

	// Jquery.Carousell
	// small: image in text
	$('.csc-textpic-border .csc-textpic-imagecolumn').each(function() {
		var imagesHtml = '';
		$(this).find('dl dt').each(function() {
			imagesHtml += '<li>' + $(this).html() + '</li>';
		});

		if (imagesHtml != '') {
			$(this).html('<ul>' + imagesHtml + '</ul><div class="clearfix"><a class="left link-back" href="#">vorheriges Bild</a><a class="right link-fwd" href="#">nächstes Bild</a></div>');
			$('.csc-textpic-border .csc-textpic-imagecolumn').jCarouselLite({
				btnNext: ".link-fwd",
				btnPrev: ".link-back",
				visible: 1
			});
		}
	});

	// big: image gallery
	$('.carousell div').each(function() {
		var wrapper = $(this).parents('.module-imgslide');
		var firstImage = $(this).find('li img.big').first();
		wrapper.find('.imageActive').attr('src', firstImage.attr('src'));

		if (firstImage.parent().find('span.gender').length > 0) {
			wrapper.find('.imageDescription').html(firstImage.attr('title') + '<br />\
				<strong>Geschlecht:</strong> ' + firstImage.parent().find('span.gender').text() + '<br />\
				<strong>Geburtstag:</strong> ' + firstImage.parent().find('span.birthday').text() + '<br />\
				<strong>Uhrzeit:</strong> ' + firstImage.parent().find('span.time').text() + '<br />\
				<strong>Gewicht:</strong> ' + firstImage.parent().find('span.weight').text() + ' g'
			);
		}
		else {
			wrapper.find('.imageDescription').text(firstImage.attr('title'));
		}

		$(this).find('li').each(function() {
			$(this).find('img.big').attr('alt', $(this).index()+1);
		});

		var imagesCount = $(this).find('li').length;
		wrapper.find('.imagesCount').text(imagesCount);

		if (imagesCount > 3) {
			$(this).jCarouselLite({
				btnNext: ".next",
				btnPrev: ".prev"
			});
		}
		else {
			$(this).parent().find('.prev').remove();
			$(this).parent().find('.next').remove();
			$(this).find('li').attr('style', 'overflow: hidden; float: left; width: 115px; height: 74px;');
		}
	});

	$('.carousell img.preview').click(function() {
		var wrapper = $(this).parents('.module-imgslide');
		var bigImage = $(this).prev();

		wrapper.find('.imageActive').attr('src', bigImage.attr('src'));
		wrapper.find('.imageNumberActive').text(bigImage.attr('alt'));

		if ($(this).next().length > 0) {
			wrapper.find('.imageDescription').html(bigImage.attr('title') + '<br />\
				<strong>Geschlecht:</strong> ' + $(this).parent().find('span.gender').text() + '<br />\
				<strong>Geburtstag:</strong> ' + $(this).parent().find('span.birthday').text() + '<br />\
				<strong>Uhrzeit:</strong> ' + $(this).parent().find('span.time').text() + '<br />\
				<strong>Gewicht:</strong> ' + $(this).parent().find('span.weight').text() + ' g'
			);
		}
		else {
			wrapper.find('.imageDescription').text(bigImage.attr('title'));
		}
	});
});

function getTopiclocations() {
	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getTopiclocations.php',
		data: 'topicid=' + $('#topic').val(),
		success: function(response) {
			$('#location').html(response);
		}
	});
}

function getLocationtopics() {
	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getLocationtopics.php',
		data: 'locationid=' + $('#location').val(),
		success: function(response) {
			$('#topic').html(response);
		}
	});
}

function getLectures() {
	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getLectures.php',
		data: 'topicid=' + topicId + '&locationid=' + $('#location').val(),
		success: function(response) {
			$('#tx_awlectures_results').html(response);
		}
	});
}

function gotoLocation(param) {
	var url     = self.location.href;
	var needle  = url.lastIndexOf('id');
	//alert(needle);
	//url 		= url.substring(0,needle+3) + param;
	//alert(param);
	url = 'http://www.vivantes.de/index.php?id='+param;
	//alert(url);
	location.href = url;
}

function updateQuickfinder(element, reset) {
	changedElement = $(element).attr('id');

	if (reset == true) {
		$('#quicksearch_location').val('null');
	}

	var clinicPID = $('#quicksearch_location').val();
	var clinicID = $('#quicksearch_clinic').val();
	var doctorID = $('#quicksearch_doctor').val();

	if (changedElement == 'quicksearch_location') {
		clinicID = 'null';
		doctorID = 'null';
	}
	else if (changedElement == 'quicksearch_clinic') {
		doctorID = 'null';
	}

	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getLocations.php',
		data: 'clinicPID=' + clinicPID + '&clinicID=' + clinicID + '&doctorID=' + doctorID,
		success: function(response) {
			$('#quicksearch_location_span').html(response);
		}
	});

	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getLocationClinics.php',
		data: 'clinicPID=' + clinicPID + '&clinicID=' + clinicID + '&doctorID=' + doctorID,
		success: function(response) {
			$('#quicksearch_clinic_span').html(response);
		}
	});

	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getClinicDoctors.php',
		data: 'clinicPID=' + clinicPID + '&clinicID=' + clinicID + '&doctorID=' + doctorID,
		success: function(response) {
			$('#quicksearch_doctor_span').html(response);
		}
	});
}

function showPrintVersion() {
/* 	if(document.getElementById('header'))
		document.getElementById('header').style.display   						    = 'none';
	if(document.getElementsByClassName('module-head clearfix')[0])
		document.getElementsByClassName('module-head clearfix')[0].style.display    = 'none';
	if(document.getElementsByClassName('module-welcome clearfix')[0])
		document.getElementsByClassName('module-welcome clearfix')[0].style.display = 'none';
	if(document.getElementById('ariadne'))
		document.getElementById('ariadne').style.display   						    = 'none';
	if(document.getElementById('clinic-select'))
		document.getElementById('clinic-select').style.display  		       	    = 'none';
	if(document.getElementById('col-1'))
		document.getElementById('col-1').style.display  				            = 'none';
	if(document.getElementById('footer'))
		document.getElementById('footer').style.display   						    = 'none';
	if(document.getElementById('colnav'))
		document.getElementById('colnav').style.display   						    = 'none'; */
}

var _GET = new Array();
function GET(key) {
	if (_GET.length == 0) {
		strGET = document.location.search.substr(1, document.location.search.length);
		if (strGET != '') {
			gArr = strGET.split('&');
			for(i = 0; i < gArr.length; i++) {
				v = '';
				vArr = gArr[i].split('=');
				if (vArr.length > 1) {
					v = vArr[1];
				}

				_GET[unescape(vArr[0])] = unescape(v);
			}
		}
	}

	if (!_GET[key]) {
		return null;
	}

	return _GET[key];
}

function showPopup( param ) {
	var h = 700;
	var w = 705;

	var padding;
	(navigator.appName == "Microsoft Internet Explorer") ? (padding = 10) : (padding = 0);

	var screenw = screen.availWidth;
	var screenh = screen.availHeight;

	var winw    = (w + 15 + padding);
	var winh    = (h + 15 + padding);

	var posx    = (screenw / 2) - (winw / 2);
	var posy    = (screenh / 2) - (winh / 2);

	var url = 'http://www.vivantes.de/vivantes-das-unternehmen/forschung/wissensdatenbank/fachgebiet-popup/?expertID='+param;;
	//window.open(url, "Expertenprofil", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
	window.open(url,"Expertenprofil","top="+posy+",left="+posx+",width="+winw+",height="+winh+",menubar=no,locationbar=no,statusbar=no,resizable=no,toolbar=no,dependent=yes,scrollbars=yes");
}

function getDropdownUrl(element) {
	$(element).parents('.content').first().find('.link-arrow a').attr('href', 'index.php?id=' + $(element).val());
}

function toggleApplicationContent(currentStep,nextStep,hideStep) {
 	var steps      = 5;
	var formCheck  = true;
	var documents  = '';
	var maxUploads = 5;
	var fachbereichValue;

	// form check - step 1
	if(currentStep == 'application-step1' && nextStep == 'application-step2') {
		if(document.getElementById('bewerbung').selectedIndex){
			if(document.getElementById('bewerbung').selectedIndex == 0) {
				document.getElementById('bewerbung').style.backgroundColor = '#D10D40';
				formCheck = false;
			}
			else{
				document.getElementById('bewerbung').style.backgroundColor = '#fff';
			}
		}
		else{
			if(document.getElementById('bewerbung').value == '') {
				document.getElementById('bewerbung').style.backgroundColor = '#D10D40';
				formCheck = false;
			}
			else{
				document.getElementById('bewerbung').style.backgroundColor = '#fff';
			}
		}
		if(document.getElementById('fachbereich').selectedIndex == 0) {
			document.getElementById('fachbereich').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('fachbereich').style.backgroundColor = '#fff';
		}
		if(document.getElementById('anrede').selectedIndex == 0) {
			document.getElementById('anrede').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('anrede').style.backgroundColor = '#fff';
		}
		if(document.getElementById('grad').selectedIndex == 0) {
			document.getElementById('grad').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('grad').style.backgroundColor = '#fff';
		}
		if(document.getElementById('vorname').value == '') {
			document.getElementById('vorname').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('vorname').style.backgroundColor = '#fff';
		}
		if(document.getElementById('nachname').value == '') {
			document.getElementById('nachname').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('nachname').style.backgroundColor = '#fff';
		}
/* 		if(document.getElementById('nationalitaet').value == '') {
			document.getElementById('nationalitaet').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('nationalitaet').style.backgroundColor = '#fff';
		} */
		if(document.getElementById('str').value == '') {
			document.getElementById('str').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('str').style.backgroundColor = '#fff';
		}
		if(document.getElementById('nr').value == '') {
			document.getElementById('nr').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('nr').style.backgroundColor = '#fff';
		}
		if(document.getElementById('plz').value == '') {
			document.getElementById('plz').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('plz').style.backgroundColor = '#fff';
		}
		if(document.getElementById('ort').value == '') {
			document.getElementById('ort').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('ort').style.backgroundColor = '#fff';
		}
		if(document.getElementById('phone').value == '') {
			document.getElementById('phone').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('phone').style.backgroundColor = '#fff';
		}
		if(document.getElementById('e-mail').value == '') {
			document.getElementById('e-mail').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('e-mail').style.backgroundColor = '#fff';
		}

		// fill the summary, which is shown in step 5
		document.getElementById('summary_application_as').innerHTML = document.getElementById('bewerbung').value;
		document.getElementById('summary_anrede').innerHTML = document.getElementById('anrede').value;
		document.getElementById('summary_name').innerHTML = document.getElementById('vorname').value + ' ' + document.getElementById('nachname').value;
		document.getElementById('summary_address').innerHTML = document.getElementById('str').value + ' ' + document.getElementById('nr').value + ' ' + document.getElementById('plz').value + ' ' + document.getElementById('ort').value;
		document.getElementById('summary_email').innerHTML = document.getElementById('e-mail').value;
		if(document.getElementById('fachbereich').value==1) fachbereichValue = 'Ärzte';
		if(document.getElementById('fachbereich').value==2) fachbereichValue = 'Pflege';
		if(document.getElementById('fachbereich').value==3) fachbereichValue = 'Verwaltung';
		if(document.getElementById('fachbereich').value==4) fachbereichValue = 'Medizinisch-technischer Dienst';
		if(document.getElementById('fachbereich').value==5) fachbereichValue = 'Wirtschaft / Versorgung';
		if(document.getElementById('fachbereich').value==6) fachbereichValue = 'Funktionsdienst';
		if(document.getElementById('fachbereich').value==7) fachbereichValue = 'Technische Dienste';
		if(document.getElementById('fachbereich').value==8) fachbereichValue = 'weitere';
		if(document.getElementById('fachbereich').value==9) fachbereichValue = 'Therapeuten';
		if(document.getElementById('fachbereich').value==10) fachbereichValue = 'Assistenzberufe';
		document.getElementById('summary_fachbereich').innerHTML = fachbereichValue;
		document.getElementById('summary_grad').innerHTML = document.getElementById('grad').value;
		document.getElementById('summary_birthday').innerHTML = document.getElementById('geb_day').value+'.'+document.getElementById('geb_month').value+'.'+document.getElementById('geb_year').value;
		//document.getElementById('summary_nationalitaet').innerHTML = document.getElementById('nationalitaet').value;
		document.getElementById('summary_telephone').innerHTML = document.getElementById('phone').value;
		document.getElementById('summary_land').innerHTML = document.getElementById('land').value;

		document.getElementById('summary_fachbereich_step2').innerHTML = fachbereichValue;
		document.getElementById('summary_bewerbungals_step2').innerHTML = document.getElementById('bewerbung').value;


	}
	// form check - step 2
	if(currentStep == 'application-step2' && nextStep == 'application-step3') {
		if(document.getElementById('auswahl').innerHTML.length <= 27) {
			document.getElementById('auswahl').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('auswahl').style.backgroundColor = '#fff';
		}

		// fill the summary, which is shown in step 5
		document.getElementById('summary_entrydate').innerHTML = document.getElementById('eintritt_day').value + '.' + document.getElementById('eintritt_month').value + '.' + document.getElementById('eintritt_year').value;
		document.getElementById('summary_location').innerHTML = document.getElementById('step2_location_choice').value;
	}
	// form check - step 3
	if(currentStep == 'application-step3' && nextStep == 'application-step4') {

		// fill the summary, which is shown in step 5
		document.getElementById('summary_note').innerHTML = document.getElementById('abi').value;
		document.getElementById('summary_examensnote').innerHTML = document.getElementById('examen').value
		document.getElementById('summary_abschlussnote').innerHTML = document.getElementById('abschlussnote').value
		document.getElementById('summary_studiumlaenge').innerHTML = document.getElementById('studium_von_month').value + '.' + document.getElementById('studium_von_year').value + ' bis ' + document.getElementById('studium_bis_month').value + '.' + document.getElementById('studium_bis_year').value
		document.getElementById('summary_studium_anmerkung').innerHTML = document.getElementById('anmerkung').value;
		var promotion = '';
		var leadingship = '';

		if(document.getElementById('promotion').checked)
			promotion = 'Ja';
		else
			promotion = 'Nein';

		document.getElementById('summary_promotion').innerHTML = promotion;

		if(document.getElementById('leadingship').checked)
			leadingship = 'Ja';
		else
			leadingship = 'Nein';

		document.getElementById('summary_leadingship').innerHTML = leadingship;

		document.getElementById('summary_abschluss').innerHTML = document.getElementById('abschluss_month').value + '.' + document.getElementById('abschluss_year').value ;
		document.getElementById('summary_taetigkeit').innerHTML = document.getElementById('taetigkeit').value;
		document.getElementById('summary_berufserfahrung').innerHTML = document.getElementById('erfahrung').value;
		//document.getElementById('summary_facharztfuer').innerHTML = document.getElementById('facharzt').value;
		document.getElementById('summary_sprachkenntnisse').innerHTML = 'Deutsch: ' + document.getElementById('de').value + '<br />';
		document.getElementById('summary_sprachkenntnisse').innerHTML += 'Französisch: ' + document.getElementById('fr').value + '<br />';
		document.getElementById('summary_sprachkenntnisse').innerHTML += 'Englisch: ' + document.getElementById('en').value + '<br />';
		document.getElementById('summary_sprachkenntnisse').innerHTML += 'Russisch: ' + document.getElementById('ru').value + '<br />';
		document.getElementById('summary_sprachkenntnisse').innerHTML += 'Spanisch: ' + document.getElementById('sp').value + '<br />';
		document.getElementById('summary_sprachkenntnisse').innerHTML += 'Weitere Sprachen: ' + document.getElementById('weitere_sprache').value + ' : ' + document.getElementById('weitere_spr').value;
		//document.getElementById('summary_spezialisiertauf').innerHTML = document.getElementById('spezial').value;
		document.getElementById('summary_weitere Kenntnisse').innerHTML = document.getElementById('kenntnisse').value;

		document.getElementById('summary_arbeitgeber').innerHTML  = document.getElementById('pos_von_month1').value+'/'+document.getElementById('pos_von_year1').value+' - '+document.getElementById('pos_bis_month1').value+'/'+document.getElementById('pos_bis_year1').value+' bei '+document.getElementById('arbeitgeber1').value + '<br />';
		document.getElementById('summary_arbeitgeber').innerHTML += document.getElementById('pos_von_month2').value+'/'+document.getElementById('pos_von_year2').value+' - '+document.getElementById('pos_bis_month2').value+'/'+document.getElementById('pos_bis_year2').value+' bei '+document.getElementById('arbeitgeber2').value + '<br />';
		if(document.getElementById('arbeitgeber3'))
			document.getElementById('summary_arbeitgeber').innerHTML += document.getElementById('pos_von_month3').value+'/'+document.getElementById('pos_von_year3').value+' - '+document.getElementById('pos_bis_month3').value+'/'+document.getElementById('pos_bis_year3').value+' bei '+document.getElementById('arbeitgeber3').value + '<br />';
		if(document.getElementById('arbeitgeber4'))
			document.getElementById('summary_arbeitgeber').innerHTML += document.getElementById('pos_von_month4').value+'/'+document.getElementById('pos_von_year4').value+' - '+document.getElementById('pos_bis_month4').value+'/'+document.getElementById('pos_bis_year4').value+' bei '+document.getElementById('arbeitgeber4').value + '<br />';
		if(document.getElementById('arbeitgeber5'))
			document.getElementById('summary_arbeitgeber').innerHTML += document.getElementById('pos_von_month5').value+'/'+document.getElementById('pos_von_year5').value+' - '+document.getElementById('pos_bis_month5').value+'/'+document.getElementById('pos_bis_year5').value+' bei '+document.getElementById('arbeitgeber5').value + '<br />';


	}
	// form check - step 4
	if(currentStep == 'application-step4' && nextStep == 'application-step5') {
		if(document.getElementById('anschreiben').value == '') {
			document.getElementById('anschreiben').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('anschreiben').style.backgroundColor = '#fff';
		}

		if(document.getElementById('anschreiben').value == '') {
			document.getElementById('anschreiben').style.backgroundColor = '#D10D40';
			formCheck = false;
		}
		else{
			document.getElementById('anschreiben').style.backgroundColor = '#fff';
		}

		// fill the summary, which is shown in step 5
		document.getElementById('summary_anschreiben').innerHTML = document.getElementById('anschreiben').value;

		if(document.getElementById('dokument1').value == '') {
			document.getElementById('dokument1').style.backgroundColor = '#fff';
			//formCheck = false;
		}
		else{
			document.getElementById('dokument1').style.backgroundColor = '#fff';
			// fill the summary, which is shown in step 5
			document.getElementById('summary_dokumente').innerHTML = document.getElementById('dokument1').value + '<br />';
		}

		if(document.getElementById('dokument2')) {
			if(document.getElementById('dokument2').value == '') {
				document.getElementById('dokument2').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('dokument2').style.backgroundColor = '#fff';
			}
			// fill the summary, which is shown in step 5
			document.getElementById('summary_dokumente').innerHTML += document.getElementById('dokument2').value + '<br />';
		}

		if(document.getElementById('dokument3')) {
			if(document.getElementById('dokument3').value == '') {
				document.getElementById('dokument3').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('dokument3').style.backgroundColor = '#fff';
			}
			// fill the summary, which is shown in step 5
			document.getElementById('summary_dokumente').innerHTML += document.getElementById('dokument3').value + '<br />';
		}

		if(document.getElementById('dokument4')) {
			if(document.getElementById('dokument4').value == '') {
				document.getElementById('dokument4').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('dokument4').style.backgroundColor = '#fff';
			}
			// fill the summary, which is shown in step 5
			document.getElementById('summary_dokumente').innerHTML += document.getElementById('dokument4').value + '<br />';
		}
		if(document.getElementById('dokument5')) {
			if(document.getElementById('dokument5').value == '') {
				document.getElementById('dokument5').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('dokument5').style.backgroundColor = '#fff';
			}
			// fill the summary, which is shown in step 5
			document.getElementById('summary_dokumente').innerHTML += document.getElementById('dokument5').value + '<br />';
		}

		if(document.getElementById('files1').value == ''){
			document.getElementById('files1').style.backgroundColor = '#fff';
			//formCheck = false;
		}
		else{
			document.getElementById('files1').style.backgroundColor = '#fff';
		}

		if(document.getElementById('files2')){

			if(document.getElementById('files2').value == ''){
				document.getElementById('files2').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('files2').style.backgroundColor = '#fff';
			}
		}

		if(document.getElementById('files3')){
			if(document.getElementById('files3').value == ''){
				document.getElementById('files3').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('files3').style.backgroundColor = '#fff';
			}
		}

		if(document.getElementById('files4')){
			if(document.getElementById('files4').value == ''){
				document.getElementById('files4').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('files4').style.backgroundColor = '#fff';
			}
		}

		if(document.getElementById('files5')){
			if(document.getElementById('files5').value == ''){
				document.getElementById('files5').style.backgroundColor = '#fff';
				//formCheck = false;
			}
			else{
				document.getElementById('files5').style.backgroundColor = '#fff';
			}
		}
	}

	//formCheck = true;

	if(formCheck){
		// hide all application - steps
		for(var i=1; i<=steps; i++){
			document.getElementById('application-step'+i).style.display = 'none';
		}
		// show the specific application - step
		if(currentStep == 'application-step1' && nextStep == 'application-step2' && hideStep == 'step2'){
			document.getElementById('application-step3').style.display = 'block';
		}
		else if(currentStep == 'application-step3' && nextStep == 'application-step2' && hideStep == 'step2'){
			document.getElementById('application-step1').style.display = 'block';
		}
		else{
			document.getElementById(nextStep).style.display = 'block';
		}
	}
}

var jobCounter        = 2;
var fileuploadCounter = 1;
function appendElement(param){
	var newJobLeftContent   	   = document.createElement('div');
	var newJobRightContent   	   = document.createElement('div');
	var newFileuploadLeftContent   = document.createElement('div');
	var newFileuploadRightContent  = document.createElement('div');
	newFileuploadLeftContent.id    = 'dynamicFileHolderBoxLeft'+(fileuploadCounter+1);
	newFileuploadRightContent.id   = 'dynamicFileHolderBoxRight'+(fileuploadCounter+1);

	if(param=='job'){
		if(jobCounter<5){
			newJobLeftContent.innerHTML  = '<p class="clearfix left w120" style="width: 110px;"><label class="w120">Arbeitgeber:</label><span class="w120" style="width: 140px;"><input type="text" value="" id="arbeitgeber'+(jobCounter+1)+'" name="arbeitgeber'+(jobCounter+1)+'"></span></p>';
			newJobLeftContent.innerHTML += '<p class="clearfix left w120" style="width: 110px;"><label class="w120">Position:</label><span class="w120" style="width: 140px;"><input type="text" value="" id="position'+(jobCounter+1)+'" name="position'+(jobCounter+1)+'"></span></p>';

			newJobRightContent.innerHTML = '<p class="clearfix" >'+
												'<label style="visibility: hidden;">Zeitraum</label>'+
												'<span class="inline_text">von</span>'+
												'<span class="studium_month">'+
													'<select id="pos_von_month'+(jobCounter+1)+'" name="pos_von_month'+(jobCounter+1)+'">'+
														'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
													'</select>'+
												'</span>'+
												'<span class="studium_year">'+
													'<select id="pos_von_year'+(jobCounter+1)+'" name="pos_von_year'+(jobCounter+1)+'">'+
														'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
													'</select>'+
												'</span>'+
												'<span class="inline_text">bis</span>'+
												'<span class="studium_month">'+
													'<select id="pos_bis_month'+(jobCounter+1)+'" name="pos_bis_month'+(jobCounter+1)+'">'+
														'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
													'</select>'+
												'</span>'+
												'<span class="studium_year">'+
													'<select id="pos_bis_year'+(jobCounter+1)+'" name="pos_bis_year'+(jobCounter+1)+'">'+
														'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
													'</select>'+
												'</span>'+
											'</p>';
			jobCounter ++;
			document.getElementById('dynamicJobHolder').appendChild(newJobLeftContent);
			document.getElementById('dynamicJobHolder2').appendChild(newJobRightContent);
		}
		else{
			alert('Eine Angabe von mehr als 5 Arbeitgebern ist nicht möglich.');
		}
	}
	else if(param=='fileupload'){
		if(fileuploadCounter<5){
			newFileuploadLeftContent.innerHTML = '<p class="clearfix">'+
														 '<span class="document_upload">'+
															'<input type="text" value="Dokument '+(fileuploadCounter+1)+'" disabled onclick="this.select()" id="dokument'+(fileuploadCounter+1)+'" name="dokument'+(fileuploadCounter+1)+'">'+
														'</span>'+
														'<span class="document_ic_upload">'+
															'<img width="14" height="14" alt="hinzufügen" src="fileadmin/develop/img/karriere/ic_plus_document.gif">'+
														'</span>'+
													'</p>';

			newFileuploadRightContent.innerHTML = '<p class="clearfix">'+
														'<span class="document_search">'+
															'<input type="file" name="files'+(fileuploadCounter+1)+'" id="files'+(fileuploadCounter+1)+'" size="50" maxlength="100000" />'+
														'</span>'+
												   '</p>'+
												   '<a href="javascript:void(0)" onclick="deleteFileuploadElementsSingle('+(fileuploadCounter+1)+')" title="Dokument löschen">x<a>';
			fileuploadCounter ++;
			document.getElementById('dynamicFileHolder').appendChild(newFileuploadLeftContent);
			document.getElementById('dynamicFileHolder2').appendChild(newFileuploadRightContent);
		}
		else{
			alert('Es sind maximal 5 Anhänge erlaubt');
		}
	}
}

function deleteFileuploadElements(){
	var newFileuploadLeftContent   = document.createElement('div');
	var newFileuploadRightContent  = document.createElement('div');

	document.getElementById('dynamicFileHolder').innerHTML =
											'<p class="clearfix">'+
												 '<label>Titel des Dokuments: </label>'+
												 '<span class="document_upload">'+
													'<input type="text" value="Dokument 1" disabled id="dokument1" name="dokument1" onclick="this.select()">'+
												'</span>'+
												'<span class="document_ic_upload">'+
													'<img width="14" height="14" alt="hinzufügen" src="fileadmin/develop/img/karriere/ic_plus_document.gif">'+
												'</span>'+
											'</p>';

	document.getElementById('dynamicFileHolder2').innerHTML =
											'<div id="dynamicFileHolderBoxRight1">'+
											'<p class="clearfix">'+
											'<label class="document_search">Auswahl Ihrer Dokumente: </label>'+
												'<span class="document_search">'+
													'<input type="file" id="files1" name="files1" size="50" maxlength="100000">'+
												'</span>'+
										    '</p>'+
											'<a title="Dokumente löschen" onclick="deleteFileuploadElements()" href="javascript:void(0)" style="margin-top:21px;">x</a>'+
											'</div>';
	fileuploadCounter = 1;
}

function deleteFileuploadElementsSingle(param){
	var d = document.getElementById('dynamicFileHolder');
	d.removeChild(document.getElementById('dynamicFileHolderBoxLeft'+param));

	var d2 = document.getElementById('dynamicFileHolder2');
	d2.removeChild(document.getElementById('dynamicFileHolderBoxRight'+param));
	fileuploadCounter --;
}

function deleteJobElements(){
		document.getElementById('dynamicJobHolder').innerHTML  =
										'<p class="clearfix left w120" style="width: 110px;">'+
											'<label class="w120">Arbeitgeber:</label>'+
											'<span class="w120" style="width: 140px;">'+
												'<input type="text" value="" id="arbeitgeber1" name="arbeitgeber1">'+
											'</span>'+
										'</p>'+
										'<p class="clearfix left w120" style="width: 110px;">'+
											'<label class="w120">Position:</label>'+
											'<span class="w120" style="width: 140px;">'+
												'<input type="text" value="" id="position1" name="position1">'+
											'</span>'+
										'</p>'+
										'<p class="clearfix left w120" style="width: 110px;">'+
											'<label class="w120">Arbeitgeber:</label>'+
											'<span class="w120" style="width: 140px;">'+
												'<input type="text" value="" id="arbeitgeber2" name="arbeitgeber2">'+
											'</span>'+
										'</p>'+
										'<p class="clearfix left w120" style="width: 110px;">'+
											'<label class="w120">Position:</label>'+
											'<span class="w120" style="width: 140px;">'+
												'<input type="text" value="" id="position2" name="position2">'+
											'</span>'+
										'</p>';

		document.getElementById('dynamicJobHolder2').innerHTML =
										'<p class="clearfix">'+
											'<label style="visibility: hidden;">Zeitraum</label>'+
											'<span class="inline_text">von</span>'+
											'<span class="studium_month">'+
												'<select id="pos_von_month1" name="pos_von_month1">'+
													'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
												'</select>'+
											'</span>'+
											'<span class="studium_year">'+
												'<select id="pos_von_year1" name="pos_von_year1">'+
													'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
												'</select>'+
											'</span>'+
											'<span class="inline_text">bis</span>'+
											'<span class="studium_month">'+
												'<select id="pos_bis_month1" name="pos_bis_month1">'+
													'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
												'</select>'+
											'</span>'+
											'<span class="studium_year">'+
												'<select id="pos_bis_year1" name="pos_bis_year1">'+
													'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
												'</select>'+
											'</span>'+
										'</p>'+
										'<p class="clearfix">'+
											'<label style="visibility: hidden;">Zeitraum</label>'+
											'<span class="inline_text">von</span>'+
											'<span class="studium_month">'+
												'<select id="pos_von_month2" name="pos_von_month2">'+
													'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
												'</select>'+
											'</span>'+
											'<span class="studium_year">'+
												'<select id="pos_von_year2" name="pos_von_year2">'+
													'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
												'</select>'+
											'</span>'+
											'<span class="inline_text">bis</span>'+
											'<span class="studium_month">'+
												'<select id="pos_bis_month2" name="pos_bis_month2">'+
													'<option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>'+
												'</select>'+
											'</span>'+
											'<span class="studium_year">'+
												'<select id="pos_bis_year2" name="pos_bis_year2">'+
													'<option value="heute">Heute</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option>'+
												'</select>'+
											'</span>'+
										'</p>';
		jobCounter = 2;
}

function checkJobQuickfinderValues() {
	formCheck = true;

	if(document.getElementById('jobno').value== '' && document.getElementById('quickfinderJobcategory').selectedIndex == 0 && document.getElementById('quickfinderJoblocation').selectedIndex == 0){
		formCheck = false;
		alert('Bitte geben Sie entweder eine Jobnummer an oder wählen eine Fachrichtung bzw. einen Standort.');
	}

	return formCheck;
}

function setLocationChoice(){
	var choiceValue = document.getElementById('standorte').value;
	var choiceHtml  = '';
	var elSel = document.getElementById('auswahl');

	if(choiceValue == 'avk')
		choiceHtml = 'Auguste-Viktoria-Klinikum';
	if(choiceValue == 'hbk')
		choiceHtml = 'Humboldt-Klinikum';
	if(choiceValue == 'kau')
		choiceHtml = 'Klinikum Am Urban';
	if(choiceValue == 'khd')
		choiceHtml = 'Klinikum Hellersdorf';
	if(choiceValue == 'kfl')
		choiceHtml = 'Klinikum im Friedrichshain-Landsberger Allee';
	if(choiceValue == 'kfp')
		choiceHtml = 'Klinikum im Friedrichshain-Prenzlauer Berg';
	if(choiceValue == 'knk')
		choiceHtml = 'Klinikum Neukölln';
	if(choiceValue == 'ksp')
		choiceHtml = 'Klinikum Spandau';
	if(choiceValue == 'wbk')
		choiceHtml = 'Wenkebach Klinikum';

	if(choiceValue =='all') {
		var optionArr = new Array();

		optionArr[0] = new Array();
		optionArr[0]["value"] = "avk";
		optionArr[0]["html"]  = "Auguste-Viktoria-Klinikum";
		optionArr[1] = new Array();
		optionArr[1]["value"] = "hbk";
		optionArr[1]["html"]  = "Humboldt-Klinikum";
		optionArr[2] = new Array();
		optionArr[2]["value"] = "kau";
		optionArr[2]["html"]  = "Klinikum Am Urban";
		optionArr[3] = new Array();
		optionArr[3]["value"] = "khd";
		optionArr[3]["html"]  = "Klinikum Hellersdorf";
		optionArr[4] = new Array();
		optionArr[4]["value"] = "kfl";
		optionArr[4]["html"]  = "Klinikum im Friedrichshain-Landsberger Allee";
		optionArr[5] = new Array();
		optionArr[5]["value"] = "kfp";
		optionArr[5]["html"]  = "Klinikum im Friedrichshain-Prenzlauer Berg";
		optionArr[6] = new Array();
		optionArr[6]["value"] = "knk";
		optionArr[6]["html"]  = "Klinikum Neukölln";
		optionArr[7] = new Array();
		optionArr[7]["value"] = "ksp";
		optionArr[7]["html"]  = "Klinikum Spandau";
		optionArr[8] = new Array();
		optionArr[8]["value"] = "wbk";
		optionArr[8]["html"]  = "Wenkebach Klinikum";

		for(var i=0; i<optionArr.length; i++){
			var elOptNew   = document.createElement('option');
			elOptNew.text  = optionArr[i]["html"];
			elOptNew.value = optionArr[i]["value"];

			try {
				elSel.add(elOptNew, null);
			}
			catch(ex) {
				elSel.add(elOptNew); // IE only
			}
		}
		document.getElementById('step2_location_choice').value = 'Auguste-Viktoria-Klinikum,Humboldt-Klinikum,Klinikum Am UrbanKlinikum Hellersdorf,Klinikum im Friedrichshain-Landsberger Allee,Klinikum im Friedrichshain-Prenzlauer Berg,Klinikum Neukölln,Klinikum Spandau,Wenkebach Klinikum';
	}
	else{
		var elOptNew   = document.createElement('option');
		elOptNew.text  = choiceHtml;
		elOptNew.value = choiceValue;


		try {
			elSel.add(elOptNew, null);
		}
		catch(ex) {
			elSel.add(elOptNew); // IE only
		}
		document.getElementById('step2_location_choice').value += choiceHtml + ',';
	}

}


$(document).ready(function() {
	var currentUrl = location.href;

	if(currentUrl == 'http://www.vivantes.de/karriere/offene-stellen/offene-stellen-im-ueberblick/' || currentUrl == 'http://www.vivantes.de/karriere/offene-stellen/') {
		var catLength = 10;
		var catIds = '';
		for(var i = 0; i<catLength; i++){
			if(getElementsByClassName('jobCategory')[i].checked){
				catIds += getElementsByClassName('jobCategory')[i].value + ',';
			}
		}
		catIds = catIds.substring(0,catIds.length-1);

		$.ajax({
			type: 'GET',
			url: 'fileadmin/develop/php/ajax.getCategoryLocations.php',
			data: 'jobCategories=' + catIds,
			success: function(response) {
				$('#locationListing').html(response);
			}
		});
	}
});

function getCategoryLocations(){
	var catLength = 10;
	var catIds = '';
	for(var i = 0; i<catLength; i++){
		if(getElementsByClassName('jobCategory')[i].checked){
			catIds += getElementsByClassName('jobCategory')[i].value + ',';
		}
	}
	catIds = catIds.substring(0,catIds.length-1);

	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.getCategoryLocations.php',
		data: 'jobCategories=' + catIds,
		success: function(response) {
			$('#locationListing').html(response);
		}
	});
}

function getCategoryJobs(category){
	$.ajax({
		type: 'GET',
		contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
		url: 'fileadmin/develop/php/ajax.getCategoryJobs.php',
		data: 'category=' + category,
		success: function(response) {
			$('#jobListing').html(response);
		}
	});
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function changeSkyscraperContent() {
/* 	getElementsByClassName('skyscraper_banner')[0].style.top = '350px';
	getElementsByClassName('skyscraper_banner')[0].style.right = '-112px';
	getElementsByClassName('skyscraper_banner')[0].innerHTML = '<a href="javascript:void(0)" onclick="toggleContent(\'container-guckmal\')">'+
																	'<img src="fileadmin/develop/img/guck-mal-link.jpg" border="0" width="92" height="384" />'+
																'</a>';
	var divTag = document.createElement("div");
	divTag.id  = 'container-guckmal';
	divTag.style.width = '950px';
	divTag.style.position = 'absolute';
	divTag.style.left = '-2px';
	divTag.style.top = '0px';
	divTag.style.backgroundColor = '#fff';
	divTag.style.border = '1px solid #ccc';
	divTag.style.display = 'none';
	divTag.className = 'dynamicDiv';
	//divTag.innerHTML = '<img src="fileadmin/develop/img/guck-mal-bg.jpg" border="0" />';

	divTag.innerHTML = '<div id="container-guckmal" style="width: 950px; height: 381px; position: absolute; left: 10px; top: 350px; background: #ffffff url(fileadmin/develop/img/guckmal/layer_bg.jpg) repeat-x top left; border: 1px solid rgb(204, 204, 204); display: block;" class="dynamicDiv">'+
						'<div style="float:left; width:303px; padding: 0 65px 0 33px; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; color: #666666; line-height: 21px;">'+
						'<img border="0" src="fileadmin/develop/img/guckmal/layer_logo.jpg" />'+
						'Eine ganzj&auml;hrige Aktionsreihe auf den Stra&szlig;en und Pl&auml;tzen, bei  den Umz&uuml;gen und Festen. Vivantes pr&auml;sentiert sich als Partner von Gesundheit  und gesundem Leben f&uuml;r alle Berlinerinnen und Berliner.</div>'+
						'<div style="float:left; width:255px"><a href="http://www.facebook.com/vivantes/" target="_blank"><img border="0" src="fileadmin/develop/img/guckmal/layer_fb.jpg"></a></div>'+
						'<div style="float:left; width:294px"><a href="http://www.vivantes.de/vivantes-leben-in-berlin/guck-mal-gesundheit/"><img border="0" src="fileadmin/develop/img/guckmal/layer_tippkarte.jpg"></a></div></div>';
	getElementsByClassName('skyscraper_banner')[0].style.display = 'block';
	document.getElementById('wrapper').appendChild(divTag);	 */

	var skyscraper = $('.skyscraper_banner').first();
	if(skyscraper.length > 0){
		skyscraper.css({
			display: 'block',
			top: '352px',
			right: '-80px'
		});
		skyscraper.html('<div class="layer-guck-mal">'+
				'<a href="javascript:void(0)" >'+
					'<img src="fileadmin/develop/img/guck-mal-link.jpg" border="0" width="92" height="384" />'+
				'</a>'+
				'<div id="container-guckmal" class="dynamicDiv">'+
					'<div style="width: 950px">'+
					'<div style="float:left; width:303px; padding: 0 65px 0 33px; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; color: #666666; line-height: 21px;">'+
						'<img border="0" src="fileadmin/develop/img/guckmal/layer_logo.jpg" />'+
						'Eine ganzj&auml;hrige Aktionsreihe auf den Stra&szlig;en und Pl&auml;tzen, bei  den Umz&uuml;gen und Festen. Vivantes pr&auml;sentiert sich als Partner von Gesundheit  und gesundem Leben f&uuml;r alle Berlinerinnen und Berliner.</div>'+
						'<div style="float:left; width:255px">'+
							'<a href="http://www.facebook.com/vivantes/" target="_blank"><img border="0" src="fileadmin/develop/img/guckmal/layer_fb.jpg"></a>'+
						'</div>'+
						'<div style="float:left; width:294px">'+
							'<a href="http://www.vivantes.de/vivantes-leben-in-berlin/guck-mal-gesundheit/"><img border="0" src="fileadmin/develop/img/guckmal/layer_tippkarte.jpg"></a>'+
						'</div>'+
					'</div>'+
					'</div>'+
				'</div>'+
			'</div>'
		);

		var guckMalButtonAnimation;
		var guckMalIsVisible = false;
		$('.layer-guck-mal').hover(function() {
			guckMalButtonAnimation = window.setTimeout(function() {
				$('#container-guckmal').animate({'width': 'toggle'});
				guckMalIsVisible = true;
			}, 500);
		},
		function() {
			window.clearTimeout(guckMalButtonAnimation);
			if (guckMalIsVisible === true) {
				$('#container-guckmal').stop(true, true).animate({'width': 'toggle'});
			}

			guckMalIsVisible = false;
		});
	}
}

function toggleContent(selector){
	if($(selector + ':visible').length > 0) {
		$(selector).hide();
	}
	else {
		$(selector).show();
	}
}

function checkApplicationForm(){
	var checkForm = true;

	if(document.getElementById('vorname').value == '') {
		document.getElementById('vorname').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('vorname').style.backgroundColor = '#fff';
	}

	if(document.getElementById('nachname').value == '') {
		document.getElementById('nachname').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('nachname').style.backgroundColor = '#fff';
	}

	if(document.getElementById('str').value == '') {
		document.getElementById('str').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('str').style.backgroundColor = '#fff';
	}

	if(document.getElementById('nr').value == '') {
		document.getElementById('nr').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('nr').style.backgroundColor = '#fff';
	}

	if(document.getElementById('plz').value == '') {
		document.getElementById('plz').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('plz').style.backgroundColor = '#fff';
	}

	if(document.getElementById('ort').value == '') {
		document.getElementById('ort').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('ort').style.backgroundColor = '#fff';
	}

	if(document.getElementById('phone').value == '') {
		document.getElementById('phone').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('phone').style.backgroundColor = '#fff';
	}

	if(document.getElementById('e-mail').value == '') {
		document.getElementById('e-mail').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('e-mail').style.backgroundColor = '#fff';
	}

	if(document.getElementById('anschreiben').value == '') {
		document.getElementById('anschreiben').style.backgroundColor = '#D10D40';
		checkForm = false;
	}
	else{
		document.getElementById('anschreiben').style.backgroundColor = '#fff';
	}

	if(document.getElementById('bewerbung').selectedIndex  >=0){
		if(document.getElementById('bewerbung').selectedIndex == 0){
			document.getElementById('bewerbung').style.backgroundColor = '#D10D40';
			checkForm = false;
		}
		else{
			document.getElementById('bewerbung').style.backgroundColor = '#fff';
		}
	}
	else{
		if(document.getElementById('bewerbung').value == ''){
			document.getElementById('bewerbung').style.backgroundColor = '#D10D40';
			checkForm = false;
		}
		else{
			document.getElementById('bewerbung').style.backgroundColor = '#fff';
		}
	}

	if(!checkForm){
		return false;
	}
	else{
		return true;
	}
}

/* AW: creates the Layerbutton (top/right) */
function generateLayerContent() {
 	var layerLinkDiv = document.createElement("div");
	var layerLinkDivClassName = 'skyscraperDarksite';
	
	/* AW: link structure */
	layerLinkDiv.className  = layerLinkDivClassName;
	layerLinkDiv.style.display = 'none';
	layerLinkDiv.style.left = '960px';
	layerLinkDiv.style.top = '231px';
	layerLinkDiv.style.position = 'absolute';	
	layerLinkDiv.innerHTML =  '<a id="darksite" onclick="showDarkSiteLayer()" class="link-darksite" href="#"><img src="fileadmin/develop/img/btn_darksite.png"/></a>';
	
	document.getElementById('wrapper').appendChild(layerLinkDiv);
		
	/* AW: save first visit of user in session */
	$.ajax({
		type: 'GET',
		url: 'fileadmin/develop/php/ajax.showDarkSiteInitial.php',
		success: function(response){
			if (response != '0'){
				responseDiv =  document.createElement("div");
				responseDiv.style.display = 'none';
				responseDiv.innerHTML = response;			
				document.getElementById('wrapper').appendChild(responseDiv);
				
				/* AW: first visit = show layer on pageload */
				if(response=='true'){
					//showDarkSiteLayer();
				}				
			}
		}
	});	
}

/* AW: show the darksite layer - layer gets generated via typoscript in main template */
function showDarkSiteLayer() {
	//$('.darksiteContent').dialog('open');
	$('.darksiteContent').dialog({width: '610px'});
	$('.darksiteContent').dialog('open');
	return false;
}

