//# Zaladowanie funkcji
$(document).ready(function() {
	
	//window.onresize = arguments.callee;
	//var MyWindowHeight = $(window).height();
	//var MyWindowWidth = $(window).width();
	//var MyScreenHeight = window.screen.height;
	//var MyScreenWidth = window.screen.width;
	
//2			
	BoxPopup = '<div class="PopupKontener">';
		BoxPopup += '<div class="PopupZamknij"><span class="PopupClose">zamknij</span></div>';
		BoxPopup += '<div id="PopupContent"></div>';
	BoxPopup += '</div">';	

	PageId = $(".btn_polec_strone").attr("id");
	BoxIframe = '<iframe scrolling="no" width="100%" height="235" frameborder="0" marginheight="0" marginwidth="0" id="PopupIframe" allowtransparency="true" src="framework/other/polec_strone.php?pid='+PageId+'">';
	
	if ( $(".FooterContent").length == 1 ) {
		$(".PageContent").append(BoxPopup);
	}
	
	$(".PopupClose").click(function() {
		$("#PopupContent").html("");
		$(".btn_polec_strone").css("background-position", "0% 0%");
	  $(".PopupKontener").animate( {opacity: "hide" }, {queue: true, duration: 200} );
	});	
	
	$(".btn_polec_strone").click(function() {
		if ($(".PopupKontener").is(":hidden")) {
			$("#PopupContent").append(BoxIframe);
	  	$(".PopupKontener").animate( {opacity: "show" }, {queue: true, duration: 300} );
	  	$(this).css("background-position", "0% 100%");
		}			
	});	


	

	//FORM + nowy wyglad radio
	$(".RadioClass").css({opacity: 0});
	if ( $(".RadioClass:checked").length != 0 ) {
		$(".RadioClass").each(function() {
			if ($(this).is(":checked")) {
				$(this).parent("label").addClass("RadioSelected");
			}
		});
	}
	$(".RadioLabelClass").click(function() {
										 
		
		//$(this).find("id".iki).removeClass("RadioSelected");
		
		if ($(this).find(".RadioClass").is(":checked")) {
			var iki=($(this).attr("id"));
			$('.form_quiz').find("#"+iki).removeClass("RadioSelected");
			
			//$(".RadioSelected").removeClass("RadioSelected");
			$(this).addClass("RadioSelected");
			
		}
	});


	//FORM + nowy wyglad checkbox
	$(".CheckBoxClass").css({opacity: 0});
	if ( $(".CheckBoxClass:checked").length != 0 ) {
		$(".CheckBoxClass").each(function() {
			if ($(this).is(":checked")) {
				$(this).parent("label").addClass("LabelSelected");
			}
		});
	}
	$(".CheckBoxLabelClass").click(function() {
		if ($(this).find(".CheckBoxClass").is(":checked")) {
			$(this).addClass("LabelSelected");
		} else {
			$(this).removeClass("LabelSelected");
		}
	});


	//lightbox	
	$("a[rel*=lightbox]").lightBox();
	
	
	//# Link banera
	$(".BanerLink").css({opacity: 0});
	
	
	//# narozniki w form alert top
	$(".FormAlertTop").corner("10px");
	
	if ( $(".FormAlertTop").length != 0 ) {
		ThisId = $(".FormAlertTop").attr("id");
		
		setTimeout(function() {
			$(".FormAlertTop").animate( {opacity: "hide"}, {queue: true, duration: 500} );
			if ( ThisId == 'ColorInfo' ) { GoToLink(); }
		}, 4e3 );
		
		function GoToLink() {
			setTimeout( "window.location.href = 'index.php?action=login'", 3e3 );
		}
	}

	
	//# narozniki w menu
	$(".MainMenu").find(".MenuItem").first().corner("tl, 5px");
	$(".MainMenu").find(".MenuItem").last().corner("tr, 5px");
	$(".MainMenu").find(".MainSubMenu").css({opacity: 0.98});
	
	
	// pokaz ukryj element
	$(".TopMenu ul.MainMenu li.MenuItem").hover(function() {
		ThisId = $(this).attr("id");
		if (ThisId != "ActiveItem" && ThisId != "ActiveParent") {
			$(this).css({ backgroundPosition: "0% 0%" });
			$(this).prev(".MenuSpace").css({ backgroundPosition: "0% 0%" });
			$(this).next(".MenuSpace").css({ backgroundPosition: "0% 0%" });
		}
		$(this).find(".MainSubMenu").animate( {opacity: "show"}, {queue: true, duration: 250} );
	},function() {
		ThisId = $(this).attr("id");
		if (ThisId != "ActiveItem" && ThisId != "ActiveParent") {
			$(this).css({ backgroundPosition: "0% 100%" });
			$(this).prev(".MenuSpace").css({ backgroundPosition: "0% 100%" });
			$(this).next(".MenuSpace").css({ backgroundPosition: "0% 100%" });
		}
		$(this).find(".MainSubMenu").animate( {opacity: "hide"}, {queue: true, duration: 150} );
	});	


	// FORM + Input - login	 
  if ( $(".FormZalogujSie input[name=Login]").attr("value") == "" || $(".FormZalogujSie input[name=Login]").attr("value") == undefined ) {
		$(".FormZalogujSie input[name=Login]").attr("value", "adres e-mail");
  }
	$(".FormZalogujSie input[name=Login]").focus( function() {
		if ( $(this).attr("value") == "adres e-mail" ) {
			$(this).attr("value", "");
		}
	});
	$(".FormZalogujSie input[name=Login]").blur( function() {
		if ( $(this).attr("value") == "" || $(this).attr("value") == undefined ) {
			$(this).attr("value", "adres e-mail");
		}
	});


	// FORM + Input - Email	 
  if ( $(".FormZalogujSie input[name=Email]").attr("value") == "" || $(".FormZalogujSie input[name=Email]").attr("value") == undefined ) {
		$(".FormZalogujSie input[name=Email]").attr("value", "adres e-mail");
  }
	$(".FormZalogujSie input[name=Email]").focus( function() {
		if ( $(this).attr("value") == "adres e-mail" ) {
			$(this).attr("value", "");
		}
	});
	$(".FormZalogujSie input[name=Email]").blur( function() {
		if ( $(this).attr("value") == "" || $(this).attr("value") == undefined ) {
			$(this).attr("value", "adres e-mail");
		}
	});
		
	
	// FORM + Input - haslo 
	if ( $(".FormZalogujSie input[name=Haslo]").attr("value") == "" || $(".FormZalogujSie input[name=Haslo]").attr("value") == undefined ) {
		$(".FormZalogujSie input[name=Haslo]").hide();
		$(".FormZalogujSie input[name=Empty]").attr("value", "hasło").show();
	}
	$(".FormZalogujSie input[name=Empty]").focus( function() {
		if ( $(this).attr("value") == "hasło" ) {
			$(this).attr("value", "").hide();
			$(".FormZalogujSie input[name=Haslo]").show().focus();
		}
	});
	$(".FormZalogujSie input[name=Haslo]").blur( function() {
		if ( $(this).attr("value") == "" || $(this).attr("value") == undefined ) {
			$(".FormZalogujSie input[name=Empty]").attr("value", "hasło").show();
			$(this).hide();
		}
	});
	
	
});
