
function checkRequiredFields(formObj)
{
	// sprawdzanie czy po naciśnięciu submit wymagane pola są wypełnione
	ok = true;
    $(formObj).find(".requiredField").each(function(){
			if (this.value === '')
	        {
          		ok = false;
          		$(this).css("background", "#ff9");
        	}
        	else
        	{
          		$(this).css("background", "#fff");
        	}
      	});
	if (ok)
	{
		return true;
	}
	alert('Nie wypełniono wszystkich wymaganych pól!');
    return false;
}


inits = {
	requiredField_init: function(){
		$(".requiredField[@type!='hidden']").after('<span class="redStar">*</span>');
		$("form").each(
				function()
				{
					if ($(":input", this).hasClass("requiredField"))
					{
						$(this).submit(function(){return checkRequiredFields(this);})
					}
				}
			);
	},

	
	lightBox_init: function (){
		var groups = {};
		var groups_n = 0;
		var orig_rel = 'lightbox';
		// Create the groups
		$.each($('[@rel*='+orig_rel+']'), function(index, obj){
			// Get the group
			var rel = $(obj).attr('rel');
			// Are we really a group
			if ( rel == orig_rel )
			{	// We aren't
				rel = groups_n; // we are individual
			}
			// Does the group exist
			if ( typeof groups[rel] == 'undefined' )
			{	// Make the group
				groups[rel] = [];
				groups_n++;
			}
			// Append the image
			groups[rel].push(obj);
		});
		// Lightbox groups
		$.each(groups, function(index, group){
			$(group).lightBox();
		});
		// Done
		return true;
	},
	
	flash_init: function() {
/*
		if ($("#IdDivObjectImg").length > 0)
		{
			var so1 = new SWFObject(base_url + "img/ega.swf", "banner", "915", "270", "9", "#ffffff");
			so1.addParam("wmode", "transparent");
			so1.write("IdDivObjectImg");
		}
*/
	},
	
	input_init: function(){
		$("input[@type=text], textarea")
			.bind("focus", function(){$(this).addClass("input-over");})
			.bind("blur", function(){$(this).removeClass("input-over");});
		$(":input[type=radio], :input[type=checkbox], :input[type=file]").css({width: "auto"});
		$(":input[type=radio], :input[type=checkbox]").css({border: "none", background: "transparent"});
		$(".text").unbind("focus").unbind("blur");
	}
	
};



// uruchamia kod po zaladowaniu dokumentu
$(document).ready(
		function()
		{
			inits.requiredField_init();
			inits.flash_init();
			inits.input_init();
			inits.lightBox_init();
			// png fix
			$("img[@src$=.png], .png").ifixpng();
			
			$('.tabele table').each(
					function()
					{
						$('tr:odd > td', this).each(
								function()
								{
									$(this).addClass("stripe");
								}
							);
					}
				);
			
			

		}
	);



		
