//$ = jQuery.noConflict(); 
$(document).ready(function() {
	quick_cars.init();
	
	var inputFocus = function() {
			$(this).removeClass("idleField");
	        if (this.value == this.defaultValue){
	        	this.value = '';
	    	}
	        if(this.value != this.defaultValue){
		    	this.select();
	        }
	    };
	    
	var inputBlur = function() {
	        if (this.value == ''){
	        	$(this).addClass("idleField");
	        	this.value = (this.defaultValue ? this.defaultValue : '');
	    	}
	    };
	
	if ($('#newsletter').length) {
	    $('#newsletter input[type="text"]').addClass("idleField");
		$('#newsletter input[type="text"]').focus(inputFocus);
	    $('#newsletter input[type="text"]').blur(inputBlur);  			 		
	}	
	if ($('#quick-contact').length) {
	    $('#quick-contact input[type="text"]').addClass("idleField");
		$('#quick-contact input[type="text"]').focus(inputFocus);
	    $('#quick-contact input[type="text"]').blur(inputBlur); 
	    
	    $('#quick-contact textarea').addClass("idleField");
		$('#quick-contact textarea').focus(inputFocus);
	    $('#quick-contact textarea').blur(inputBlur); 
		
		$('#quick-contact').submit(function() {
			if ($('#qc-imie').val() == 'Imię i nazwisko...*') $('#qc-imie').val("");
			if ($('#qc-email').val() == 'Adres email...*') $('#qc-email').val("");
			if ($('#qc-tresc').val() == 'Treść...*') $('#qc-tresc').val("");
			return true;	
		});		 			 		
	}		
	
	
});

var quick_cars = {
	current : 0,
	elements_amount : 0,
	run : null, // interval
	speed : 5000,
	fade_speed : 800,
	
	init: function() {	
		this.elements_amount = $('#logos div').size();
		this.next();
		this.run = setInterval('quick_cars.next()', this.speed); 
	},
	
	next: function() {
		this.current++;
		if (this.current > this.elements_amount) {	
			this.current = 1;
		} 

		this.fadeAllOut(this.current);
		
		$('#logo'+this.current).fadeIn(this.fade_speed);
	/*	if ($.browser.msie) {
			$('#car-'+this.current+' *').fadeIn(this.fade_speed);
		} */
	},
	
	fadeAllOut: function(cid) {
		for (var i = 1; i <= this.elements_amount; i++) {
			if (i != cid) {
				$('#logo'+i).fadeOut(this.fade_speed);
			/*	if ($.browser.msie) {
					$('#car-'+i+' *').fadeOut(this.fade_speed);
				}*/
			}
		}				
	}
}

