/**
 * @author jm
 * 30-09-2008
 *
 * Bezug der Ip Adresse aus php Datei in <span id='ip'></span> : Carmarket pi2   
 *
 *
 */










$(function(){
  $("select#fahrzeug_art").change(function(){
	
	
	
		  
  	if ($(this).val()==2)
	         {
             $("#netto").attr("checked","checked");
             $("#netto_chkbox").show();
               }
         else
         {
         $("#netto").attr('checked','');
             $("#netto_chkbox").hide();
         
         }	 
  
    $.getJSON("/typo3conf/ext/user_carmarket/pi1/select.php",{id: $(this).val(), category: 'typ', ajax: 'true'}, function(j){
      
      var options = '<option value="0">Beliebig</option>';
	 
	  if (j.length==0)
	  	{ $("select#fahrzeug_typ").attr('disabled','disabled');  }
		else
		{ $("select#fahrzeug_typ").attr('disabled','');  }
		
      for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#fahrzeug_typ").html(options);
      
      $("select#fahrzeug_typ option:eq(0)").attr("selected", "selected")
 	 
 	 
 	 
 	 		 
    })
  })
})


$(function(){
  $("select#fahrzeug_marke").change(function(){
    $.getJSON("/typo3conf/ext/user_carmarket/pi1/select.php",{id: $(this).val(),category: 'marke', ajax: 'true'}, function(j){
      var options = '<option value="0">Beliebig</option>';
      
	  
	   if (j.length==0)
	  	{ $("select#fahrzeug_model").attr('disabled','disabled');  }
		else
		{ $("select#fahrzeug_model").attr('disabled','');  }
	  
	  for (var i = 0; i < j.length; i++) {
        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#fahrzeug_model").html(options);
      $("select#fahrzeug_model option:eq(0)").attr("selected", "selected")
	  
    })
  })
})
















 $.fn.clearForm = function() {
           return this.each(function() {
   
          var type = this.type, tag = this.tagName.toLowerCase();
   
          if (tag == 'form')
   
            return $(':input',this).clearForm();
   
          if (type == 'text' || type == 'password' || tag == 'textarea')
   
            this.value = '';
   
          else if (type == 'checkbox' || type == 'radio')
   
            this.checked = false;
  
          else if (tag == 'select')
  
            this.selectedIndex = 0;
  
        });
  
      };
   
$(document).ready(function() {
   	 
   	  
	  
	  
	
	 
	 
	 
	 /* $('#intForm').ajaxForm(function() { 
                $("#info-mailer").html("Thank you for your comment!"); 
            }); 
	  
	  */
	  
	  
	  if($("select#fahrzeug_art").val() == 2)
            {
            $("#netto_chkbox").show();
            }
          else
          {
          $("#netto_chkbox").hide();
          }
   	  
   	  
   	  
   	  
          $('.reset').click(function(){
            
           $('form').clearForm();
            //$('form').css("border","3px solid red");
            var options = '';
           $("select#fahrzeug_model").attr('disabled','disabled');
           $("select#fahrzeug_typ").attr('disabled','disabled');
           $("select#fahrzeug_model").html(options);
           $("select#fahrzeug_typ").html(options);
            
            
          });
		  
		  
		  
		  
		  $('.fzgbild_klein').bind("click", function(event){
				
				event.preventDefault();
				
				var img_src = this;
				
				$(".fzgbild").attr({ 
          				src: img_src,
         				title: "Fahrzeugbild",
          				alt: "Fahrzeugbild"
        				});
				
			});
   			
			
			$('#back').bind("click", function(event){
				
				event.preventDefault();
				history.back();
								
			});
			
			
			$('#drucken').bind("click", function(event){
				
				event.preventDefault();
				window.print();
								
			});
	  
	    
	   $("#Internes > table").hide(); 
	   
	   var ip = $("#ip").html();  
	   
	   if (ip == '195.135.149.98')
		  // if (ip == '192.168.178.102')	   
	   	{
	   	$("#Internes").css("height","300px")
	   	$("#Internes").append("<button>Interne Informationen einblenden/ausblenden</button>");
		  $("#Internes > button").click(function () { 
      						$("#Internes > table").toggle('slow'); 
       																			 });

		  }
			
			
			
   });   
