
  $(document).ready(function(){

    $('div.checkbox').each(function(nr,obj){
    
    
        var inp = $(obj).find('input');
        var anc = $(obj).find('a');
        anc[0].isactive = false;
        anc[0].inp = inp[0];
        anc[0].className = 'checkboxoff';

        $(anc[0]).click(function(){
        
            if(this.isactive) this.isactive = false;
            else
            if(!this.isactive) this.isactive = true;
            
            if(this.isactive)
            {this.inp.value = 1;this.className = 'checkboxon';}
            else
            {this.inp.value = 0;this.className = 'checkboxoff';}
			
			selectedEntriesInfo(this);
        
        });
        
        
    });

   
   initMenues();
   intitModeSwitch();






  });


 var initTextFields = function(){
 
 
 	$('input').each(function(nr,obj){
	    
		if($(obj).attr('type') == 'text')
		$(obj).click(function(){
		
			this.value = '';
		});
	});
	
		
	
 } 
  
 var deleteEntries = function(el){


    $(el).each(function(nr,obj){

        var inp = $(obj).find('input');
        var anc = $(obj).find('a');
        inp[0].value = 0;
        anc[0].isactive = false;
        anc[0].className = 'checkboxoff';

    });

}
  
  var saveCheckBoxes = function(){
  
  
        var saves = new Array();
        
          $('div.checkbox').each(function(nr,obj){
        
        
                var inp = $(obj).find('input');
                
                inp.each(function(nr,obj){
                
                        saves.push(obj.value);
                });
        
        
        });
        
       
  
  }

 
 
 var requestList = function(f,nr) 
 {

    closeAllMenues();
    var url = $(f).attr('action');
    if(nr == 0)
    $.post(url, $(f).serialize(),function(data){ 
    $("#stellenliste").html(data); 
    tb_init('#stellenliste a.thickbox, #stellenliste area.thickbox, #stellenliste input.thickbox');
    
    },'html');
    else
    $.post(url+'?nr='+nr, $(f).serialize(),function(data){ $("#stellenliste").html(data);tb_init('a.thickbox, area.thickbox, input.thickbox'); },'html');
 } 
  

 var requestList2 = function(f,nr) 
 {
    closeAllMenues();
    var url = $(f).attr('action');
    if(nr == 0)
    $.post(url, $(f).serialize(),function(data){ 
    $("#stellenliste").html(data); 
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    tb_show(null, DETAILVIEW , false);
    },'html');
    else
    $.post(url+'?nr='+nr, $(f).serialize(),function(data){ 
    $("#stellenliste").html(data);
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    
    },'html');
 } 


 var requestList3 = function(f,id) 
 {
    closeAllMenues();nr=1;
    var url = $(f).attr('action');
    if(nr == 0)
    $.post(url, $(f).serialize(),function(data){ 
    $("#stellenliste").html(data); 
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    tb_show(null, DETAILVIEW , false);
    },'html');
    else
    $.post(url+'?id='+id, $(f).serialize(),function(data){ 
    $("#stellenliste").html(data);
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    tb_show(null, DETAILVIEW , false);
    },'html');
 } 



   var initMenues = function(){
     
           $('div.pulldown').wrapInner('<div style="padding-top:5px;"></div>');
           
           $('a.bpulldown').each(function(nr,obj){

               var pd = $('div.pulldown');

               obj.pdheight = $(pd[nr]).height();
               $(pd[nr]).css('height','0px');
               obj.isOpen = false;
               obj.nr = nr;
               obj.pd = $('div.pulldown');
               $(obj).click(function(){

                   this.blur();
                   if(this.isOpen)
                   {
                       $(this.pd[this.nr]).css('height','0px');
                       this.isOpen = false;
                   }
                   else
                   if(!this.isOpen){
                       $(this.pd[this.nr]).css('height',this.pdheight+'px');
                       this.isOpen = true;
                   }

                   
               });
               
           });

    $('div.pulldown').css('visibility','visible');
       
   }


var closeAllMenues = function(){


	$('div.pulldown').css('height','0px');
        $('a.bpulldown').each(function(nr,obj){
		
		obj.isOpen = false;

        }) 
       
}






var intitModeSwitch = function(){
            
	$('a.smodus').each(function(nr,obj){
                
	    obj.nr = nr;
	    
	    obj.switchcontent = $('div.switchpd');
	    $('div.switchpd').each(function(nr,obj){
	    if(nr > 0)    
	       $(obj).css('display','none');
	    });
	    $(obj).click(function(){
	    	
	        switch(this.nr) {	        
	            case 0: $('#modus').attr('value','bnd');
	            		$('#divSelectStellensucheBundeslaender').css('background','transparent url(/css/img/bgSelectboxBundesland_active.jpg) no-repeat scroll 0 -19px');
	            break;
	            case 1: $('#modus').attr('value','plz');
        				$('#divSelectStellensucheUmkreis').css('background','transparent url(/css/img/bgSelectboxUmkreis_active.jpg) no-repeat scroll 0 -19px');	            
	            break;                            
	            case 2: $('#modus').attr('value','nl');
        				$('#divSelectStellensucheNiederlassungen').css('background','transparent url(/css/img/bgSelectboxNiederlassungen_active.jpg) no-repeat scroll 0 -19px');
	            break;
	            default: $('#modus').attr('value','bnd');
        				 $('#divSelectStellensucheBundeslaender').css('background','transparent url(/css/img/bgSelectboxBundesland_active.jpg) no-repeat scroll 0 -19px');
	        }
	
	        this.switchcontent.each(function(nr,obj){
	            $(obj).css('display','none');
	        });
	        this.aktiv = true;
	        $(this.switchcontent[this.nr]).css('display','block');
	        
	        $('a.reiterActive').removeClass('reiterActive');
	        $(this).addClass('reiterActive');
	    });

    });
}  





var selectedEntriesInfo = function(obj){


    var counter = 0;
    var menue = $(obj).parents();

    if ($(menue[2]).attr('id') == 'bundesl' || $(menue[2]).attr('id') == 'niederl' ) {
    	var c = $(menue[5]).children().children();
    }
    else {
    	var c = $(menue[5]).children();
    }
    
	var eid = $(menue[2]).attr('id');
		
	$('#'+eid+' a').each(function(nr,obj){
	
		if($(obj).attr('class') == 'checkboxon'){counter++;}
	
	});
	

	if(counter > 0)
		$(c[0]).html(counter+' ausgewählt');
	else
		$(c[0]).html('nichts ausgewählt');

}




		var printContent = function(){
		
		        var content = '';
		        $('.printable').each(function(nr,obj){

                         content+= $(obj).html()+'<br /><br />';
                         });
                        
                        
			var w = window.open('','','width=800,height=600');
			w.document.open();
			w.document.write('<html><head><title>Brunel GmbH</title><style>a{display:none;}</style></head><body style="font-family:arial,helvetica,sans-serif;font-size:12px;line-height:150%;">'+content+'</body></html>');
			w.document.close();
		        w.print();
		}
		
		
		var openJobAgent = function(obj){
		
		
			var f = obj.form;
			var posteddata = $(f).serialize();
                       	var url = f.elements['jobagent'].value;
		        $.post(url, posteddata,function(data){ 
			
                                        
                                        
					tb_show(null, '#TB_inline?height=300&width=400', false);
                                        $('#TB_ajaxContent').html(data);            

			
			});
		}