// Blendet job-sub-kategorien ein & aus
// -> jobs/hinzufuegen_1.asp -> 
//								<select name="job_kategorie_1" id="job_kategorie_1" onchange="toggleSelections('subSelection1','job_kategorie_1_sub_' + this.value);">
//									<option selected="selected" value="0">Bitte wählen...</option>
//									<option value="1">Bau</option>
//									...
//								</select>
//								<div style="display: none;" id="job_kategorie_1_sub_1" class="subSelection1">
//									<select style="width: 205px; margin-left: 30px;" name="job_kategorie_1_sub_1">
//										<option value="0">Bitte wählen...</option>
//										<option value="67">Architektur</option>
//										...
//									</select>
//								</div>
function toggleSelections(hide,show) {

	var myObjColl = $$('.'+hide);
	for (var i = 0, j = myObjColl.length; i < j; i++) {
		if (myObjColl[i].style.display != 'none') {
			Effect.Fade(myObjColl[i], {queue:'end'});
		}
	}
	
	if ($(show)) {
		Effect.Appear(show, {queue:'end'});
	}
	
}

// Macht ein Inserat sicht- / unsichtbar
// -> jobs/uebersicht.asp 
function toggleActiv(stat,act) {
	
	var status = 0;
	if (stat) {
		status = 1;	
	}
	
	new Ajax.Request('/sites/jobs/ajax/sichtbar.asp',
	{
		method:'post',
		parameters: {id: act, sichtbar: status},
		onFailure: function(){ 
			//alert('Fehler!');
		}
		
	});
}

// speichert das ein/ausblenden der erweiterten suche in eine session
function saveSearchToggle() {
	// suche wird eingeblendet
	if ($('erweiterte_suche').style.display == 'none') {
		setDiv = '1';
	} else {
		setDiv = '0';
	}
	new Ajax.Request('/sites/global_ajax/suche_sichtbar.asp',
	{
		method:'post',
		parameters: {sichtbar: setDiv},
		onFailure: function(){ 
			//alert('Fehler!');
		}
		
	});
}

// Tabellen-Zeilen-Highlighting
function loadTRmarks() {
	if(!document.getElementsByTagName) return false;  
	var rows = $$('tr.highlight');  
	
	for (var i=0; i<rows .length; i++) {  
		rows[i].onmouseover = function() { $(this).style.backgroundColor = '#E1E1E1';}  
		rows[i].onmouseout =  function() { $(this).style.backgroundColor = '#FFFFFF';}  
	}
}

Event.observe(window, 'load', loadTRmarks);




// send to a friend
function sendToFriend(id) {
	
	new Ajax.Request('/sites/jobs/sendtofriend.asp',
	{
		method:'post',
		parameters: {jobid: id},
		onFailure: function(){ 
			$('sendtofriendinfo').innerHTML = 'Es ist eine Fehler aufgetreten.';
		},
		onFailure: function(){ 
			$('sendtofriendinfo').innerHTML = 'Es ist eine Fehler aufgetreten.';
		}
		
	});
}


var actBox = '';

function loadLogo(logo) {
	if ($('loader')) {
		//$('loader').innerHTML = '<img src=\'/media/images/layout/ajax_loader.gif\' />';
		$('loader').innerHTML = '<img src=\'/media/upload/logos/' + logo + '\' />';
	} else {
		//alert('loader not found');	
	}
}


function newSearch(id) {
	url = '';
	if (id == 1) {
		url = '/bau/stellen.html';	
	}
	if (id == 62) {
		url = '/bildung/stellen.html';	
	}
	if (id == 2) {
		url = '/chemie_pharma/stellen.html';	
	}
	if (id == 5) {
		url = '/dienstleistungen/stellen.html';	
	}
	if (id == 4) {
		url = '/it/stellen.html';	
	}
	if (id == 3) {
		url = '/logistik/stellen.html';	
	}
	if (id == 6) {
		url = '/technik/stellen.html';	
	}
	if (id == 142) {
		url = '/gastro_hotel/stellen.html';	
	}
	
	if (url != '') {
		$('form1').action = url;
		$('form1').submit();
	}
}

function reloadCounter(maximum,elname,ccount) {
	$(elname + 'Info').innerHTML = ccount + " / " + maximum + " Zeichen";
	$(elname + 'Len').value = ccount;
	if (ccount > maximum) {
		$(elname + 'Info').style.color = '#d00';
	} else {
		$(elname + 'Info').style.color = '#666';
	}
	if ($(elname + 'Info').style.display == 'none') {
		Effect.Appear(elname + 'Info');
	}
}

function myHandleEvent(e) {

	if (e.type == 'keyup' || e.type == 'mousedown' || e.type == 'focus' || e.type == 'change'){
		var charcount = tinyMCE.activeEditor.getDoc().body.innerHTML.stripScripts().stripTags().gsub(' ',' ').unescapeHTML().length;		
		if (tinyMCE.activeEditor.id == 'firma_dienstleistungen') {
			reloadCounter(1600,'dienstleistungen',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_produkte') {
			reloadCounter(1600,'produkte',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_firmeneinheiten') {
			reloadCounter(400,'firmeneinheiten',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_kunden') {
			reloadCounter(1600,'kunden',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_leitung') {
			reloadCounter(400,'leitung',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_zertifikate') {
			reloadCounter(400,'zertifikate',charcount);
		}
		if (tinyMCE.activeEditor.id == 'firma_geschichte') {
			reloadCounter(1600,'geschichte',charcount);
		}
	}
	
	//alert("event:" + e.type);
	return true; // Continue handling

}

function jobLoeschen(jid) {
	check = confirm("Wollen Sie dieses Inserat wirklich l&ouml;schen?");
	if (check == true) {
		new Ajax.Request('/sites/jobs/ajax/del_job.asp',
		  {
			method:'post',
			parameters: {id: jid},
			onSuccess: function(){
			  Effect.Fade($('ltr'+jid));
			}
		  });
		  
	}
}
