<!-- //


function ReadyFunctions()
{
		startClientsAnimation(1, 'fotogaleria');
		
		var name = $("#name"),
			email = $("#email"),
			password = $("#password"),
			allFields = $([]).add(name).add(email).add(password),
			tips = $("#validateTips");

		function updateTips(t) {
			tips.text(t).effect("highlight",{},1500);
		}
		
		function checkLength(o,n,min,max) {

			if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				updateTips(n + " "+min+" znaków.");
				return false;
			} else {
				return true;
			}

		}
		
		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}

		
		$("#dialog").dialog({
			bgiframe: true,
			autoOpen: false,
			height: 300,
			modal: true,
			buttons: {
				'Poleć serwis': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');

					bValid = bValid && checkLength(name,"Podane imię i nazwisko  musi składać się przynajmniej z",3,200);
					bValid = bValid && checkLength(email,"Podany adres e-mai jest za którki. Min ",6,200);
										
					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					bValid = bValid && checkRegexp(email,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"Nieprawidłowy adres e-mail. Przykład: ui@jquery.com");
					
					
					if (bValid) {
						jQuery.post("/pl/ajax/polec_znajomemu", {e: email.val(), n: name.val() }, 
						 function(data)
						 {
							if(data == 'OK')
							{
								updateTips('Wiadomość została wysłana');
								$("#name").val('');
								$("#email").val('');
							}
							else
							{
								o.addClass('ui-state-error');
								updateTips(data);
							}
						 });

					//	$(this).dialog('close');
					}
				},
				Anuluj: function() {
					$(this).dialog('close');
				}
			},
			close: function() {
				allFields.val('').removeClass('ui-state-error');
			}
		});
				
				// Dialog Link
				$('#recommend_link').click(function(){
					$('#dialog').dialog('open');
					return false;
				});
				
					
		

}


function startClientsAnimation(index, typ)
{
	var ilosc = jQuery('.'+typ).length;
	jQuery('#'+typ+'_'+index).fadeTo(300,0, function () {
											
											jQuery('.'+typ).hide();
											jQuery('.'+typ).css("opacity", "0");
											
											index++;
											if(index <= ilosc)
											{
												
												jQuery('#'+typ+'_'+index).show();
												jQuery('#'+typ+'_'+index).fadeTo(300,1,  function () {
														   setTimeout("startClientsAnimation("+index+", '"+typ+"');",5000);
																							   });
												
											}
											else
											{
												jQuery('#'+typ+'_1').show();
												jQuery('#'+typ+'_1').fadeTo(300,1,  function () {
														   setTimeout("startClientsAnimation(1, '"+typ+"');",5000);
																							   });
											}
												
										});
}


function BullStatistic()
{
	var colorDepth = window.screen.colorDepth;
	var res = window.screen.width + "," + window.screen.height;
	var referer = escape(document.referrer);
	document.write('<img src="/statystyka/zlicz.php?colors=' + colorDepth + '&resolution=' + res + '&referer=' + referer + '" style="width:0;height:0;" />');
}

function Clear(value, id)
{
	if(jQuery('#'+id).val() == value)
	{
		jQuery('#'+id).val('');
	}
}

function ChangeLogs(id)
{
	jQuery('#'+id).toggle();
}

function changePic(url,id)
{
	jQuery("#"+id).attr("src",url); 
}

function WyslijEmail(uzytkownik, domena, temat)
{
	var OtworzProgramPocztowy = "mailto:" + uzytkownik + "@" + domena + "?Subject=" + temat;
	window.location = OtworzProgramPocztowy;
}

function SendForm(form,send)
{
//	jQuery("#send").val(jQuery("#"+send).val());
	jQuery("#"+form).submit();
}

function WartoscDomyslna(id, val)
{	
	jQuery("#"+id).val(val);
}

function ShowCalendar(miesiac, rok)
{
	jQuery.get("/ajax/kalendarz.php", { rok: rok, miesiac: miesiac },
		function(data)
		{
			jQuery('#calendarBox').html(data);
  		}
	);
}

function PolecZnajomemu(lang, info)
{
	jQuery.post("/"+lang+"/ajax/polec_znajomemu", {e: jQuery('#polec_email').val(), n: jQuery('#polec_imie_nazwisko').val() }, 
	 function(data)
	 {
		if(data == info)
		{
			jQuery('#polec_email').val('');
			jQuery('#polec_imie_nazwisko').val(''); 	
		}
		
		jQuery('#polec_info').html(data); 
		jQuery('#polec_imie_nazwisko').focus(); 
	 });
}


function Newsletter(lang)
{
	if(jQuery('#add').attr("checked") == true)
	{
		action = 'add';	
	}
	else
	{
		action = 'remove';	
	}
	
	jQuery.post("/"+lang+"/ajax/newsletter", { a: action, e: jQuery('#newsletter_email').val() }, function(data){ jQuery('#newsletter_info').html(data); jQuery('#newsletter_email').focus(); });
}

function CheckValidEmail(adres)
{
   a = adres.search(/@/i);
   a1 = adres.substring(0,a);
   a2 = a1.length;
   a = a + 1;
   b = adres.indexOf(".");
   b1 = adres.substring(a,b);
   b2 = b1.length;
   b = b + 1;
   c = adres.length;
   c1 = adres.substring(b,c);
   c2 = c1.length;
   if(adres.indexOf("@") != "-1" && adres.indexOf(".") != "-1" && a2 >= 1 && b2 >= 1 && c2 >= 1)
   {
   	return true;
   }
   else
   {
   	return false;
   }
}

function OtworzEdytor(pole)
{
	var oknoEdytor = null;
  	oknoEdytor = window.open("edytor.php?pole="+pole, "edytor", "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,copyhistory=no,width=800,height=800,left=0,top=0");
	oknoEdytor.focus();
}

function ZoomText(zoom,contener)
{
	if(zoom == "+1") jQuery('#'+contener).css('font-size',(parseInt(jQuery('#'+contener).css('font-size')) + 2)+'px');
	else if(zoom == "-1") jQuery('#'+contener).css('font-size',(parseInt(jQuery('#'+contener).css('font-size')) - 2)+'px');
	else jQuery('#'+contener).css('font-size','11px');
}

function PowiekszZdjecie(url)
{
	var okno = null;
	if(okno) okno.close();
	var width = 800;
	var height = 600;
	if(window.screen)
  	{
   	ScrWidth = window.screen.width;
		ScrHeight = window.screen.height;
  	}
	var PosX = Math.round((ScrWidth - width) / 2);
  	var PosY = Math.round((ScrHeight - height) / 2);
	
	okno = window.open("", "", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
  	okno.document.open();
  	okno.document.clear();
  	okno.document.write("<HTML><head><meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\"><title>CMS BullDesign - powiêkszenie zdjêcia</title></HEAD><body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0><a href='javascript:window.close()'><img src="+url+" alt='Kliknij gdziekolwiek aby zamkn±æ to okno.' border='0'></a></BODY></HTML>");
  	okno.document.close();
  	okno.focus();
}

function keepMeAlive(imgName)
{
   myImg = document.getElementById(imgName);
   if (myImg) myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
}

function selectAll(box)
{
	for(var i=0; i<box.length; i++) {
		box.options[i].selected = true;
	}
}

function sprawdz(wiadomosc)
{
	var czy_potwierdzony = confirm(wiadomosc);
   if(czy_potwierdzony) { return true; }
	else { return false; }
}

function SetActive(obj)
{
	var data = obj.id.split("_");
	jQuery.post("ajax.php?m=ustaw-aktywnosc", { id: data[2], value: obj.checked, lang: data[1], module: data[3] },	
	  	function(data){
			if(data != "OK") alert("B³±d: " + data);
	});
}

function ZaznaczOdznaczWszystkie(f,pole,akcja)
{
	var checkboxy = document.getElementById(f).getElementsByTagName('input');
	for(i = 0; i < checkboxy.length; i++)
	if(checkboxy[i].type == 'checkbox' && checkboxy[i].name.substr(0,3) == pole)
	{
		checkboxy[i].checked = akcja;
	}
}

sfHover = function() {

	var sfEls = document.getElementById("nav").getElementsByTagName("LI");

	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {

			this.className+=" sfhover";

		}

		sfEls[i].onmouseout=function() {

			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");

		}

	}

}

if (window.attachEvent) window.attachEvent("onload", sfHover);

// -->