$(document).ready(function() {
	$('#view').change(function(){
		$('#project-search input[@name="jobview"]').val($(this).val());
		if($('#project-search input[@name="linfo"]').val() == "en")
			document.getElementById("project-search").action = "/cms/en/job-offers/from-our-customers";
		else
			document.getElementById("project-search").action = "/cms/de/jobangebote/bei-unseren-kunden";
		document.getElementById("project-search").method = "POST";
		document.getElementById("project-search").target = "_top";
		$('#project-search').submit();
	});
	$('#count').change(function(){
		$('#project-search input[@name="count"]').val($(this).val());
		if($('#project-search input[@name="linfo"]').val() == "en")
			document.getElementById("project-search").action = "/cms/en/job-offers/from-our-customers";
		else
			document.getElementById("project-search").action = "/cms/de/jobangebote/bei-unseren-kunden";
		document.getElementById("project-search").method = "POST";
		document.getElementById("project-search").target = "_top";
		$('#project-search').submit();
	});
   $("#plz").click(function(){
		if($(this).attr('value')=='PLZ' || $(this).attr('value')=='Postleitzahl' || $(this).attr('value')=='Zipcode' || $(this).attr('value')=='Zip code'){
			$(this).attr('value','');
		}
   });
   $("#filter-places").click(function() {
     	$("#place-list").show();
     	ProjectFilter.updateIcons();
   });
   $("#filter-modus").click(function() {
     	$("#modus-list").show();
     	ProjectFilter.updateIcons();
   });
   $("#modus-icon").click(function() {

		if($("#modus-list").css('display')=='none'){
   			$("#modus-list").show();
   		}else{
   			$("#modus-list").hide();
   		}
   		ProjectFilter.updateIcons();
   });
   $("#place-icon").click(function() {
   		if($("#place-list").css('display')=='none'){
   			$("#place-list").show();
   		}else{
   			$("#place-list").hide();
   		}
   		ProjectFilter.updateIcons();
   });
   $("#filter-modus").click(function() {
     	$("#modus-list").show();
     	ProjectFilter.updateIcons();
   });
   $("#modus-list").find("input").each(function(i) {
     	if($(this).attr('id')!='modus-all'){
     		$(this).click(function() {
     			$("#modus-all").attr('checked','');
  	 		});
     	}
   });
   $("#place-list").find("input").each(function(i) {
     	if($(this).attr('id')!='place-all'){
     		$(this).click(function() {
     			$("#place-all").attr('checked','');
  	 		});
     	}
   });

   $("#modus-all").click(function() {
   		if($(this).attr('checked')!=''){
   			$("#modus-list").find("input").each(function(i) {
     			if($(this).attr('id')!='modus-all'){
		     		$(this).attr('checked','');
		     	}
   			});
   		}
   });
   $("#place-all").click(function() {
   		if($(this).attr('checked')!=''){
   			$("#place-list").find("input").each(function(i) {
   				if($(this).attr('id')!='place-all'){
		     		$(this).attr('checked','');
		     	}
   			});
   		}
   });
   $(".project").click(function() {
   		$(this).find("a").each(function(i) {
   			location.href = $(this).attr('href');
   		});
   });
 });
 var ProjectFilter = {
 	updateIcons:function(){
	 	if($("#modus-list").css('display')!='none'){
   			$("#modus-icon").attr('src','/images/icon/minus.gif');
   		}else{
   			$("#modus-icon").attr('src','/images/icon/plus.gif');
   		}
		if($("#place-list").css('display')!='none'){
   			$("#place-icon").attr('src','/images/icon/minus.gif');
   		}else{
   			$("#place-icon").attr('src','/images/icon/plus.gif');
   		}
	 }
 }
