var $j = jQuery.noConflict();


jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
                if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$j(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$j(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$j(this).parents("form").each(function() {
			//Bind parent form submit
			$j(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};

		$j(document).ready(function() {
			//Assign default value to form field #1
			$j("#city_from").DefaultValue("- miejscowość -");
                        $j("#startCity").DefaultValue("- miejscowość -");
                        $j("#finishCity").DefaultValue("- miejscowość -");
                        $j("#country_from").DefaultValue("- kraj -");
                        $j("#startpostcode").DefaultValue("- kod -");
                        $j("#city_to").DefaultValue("- miejscowość -");
                        $j("#country_to").DefaultValue("- kraj -");
                        $j("#finishpostcode").DefaultValue("- kod -");
                        $j("#calendarDate").DefaultValue("- data -");
		});

jQuery.fn.reset = function() {
	this.each(function(){
		if($(this).is('form')) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).append(button);
			button.click().remove();
		} else if($(this).parent('form').size()) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).parent('form').append(button);
			button.click().remove();
		} else if($(this).find('form').size()) {
			$(this).find('form').each(function(){
				var button = jQuery(jQuery('<input type="reset" />'));
				button.hide();
				$(this).append(button);
				button.click().remove();
			});
		}
	})
	return this;
};

function resetForm(id) {
	$j('#'+id).each(function(){
	        this.reset();
	});
}