// JavaScript Document
function mod_s(sc,id) {
	window.open(sc+"h/mod_strona.php?id="+id,"strona","status=no,toolbar=no,scrollbars=yes,width=750,height=720,left=0,top=50");
}

function wyrownanie_el(){
	if($("#content-left > div:eq(0)").hasClass("component-small")){
		$("#content-left > div:eq(0)").css({"margin-top" : 5});
		if($("#content-left > div:eq(1)").hasClass("component-small")){
			$("#content-left > div:eq(1)").css({"margin-top" : 5});
		}
	}else{
		$("#content-left > div:eq(0)").css({"margin-top" : 5});
	}
	$("#content-right > div:eq(0)").css({"margin-top" : 5});
	$('.menu4 ul li ul li:first').css({'border-top' : 'none'});
	$('.menu4 ul li ul li:last').css({'border-bottom' : 'none'});
	
}

function enable_dragging(){
	$('.drag').draggable({
			containment : $(this).parent(),
			revert : false,
			start : function(event,ui){
				ui.helper.css({'z-index' : 500, 'cursor' : 'move'});
			},
			drag : function(event,ui){
				var el=$(this);
				el.parent().find(".drag").each(function(){
					if(el.attr('id')!=$(this).attr('id')){
						var x_m=($(this).offset().left+$(this).width()/2);
						var y_m=($(this).offset().top+$(this).height()/2);
						if(ui.offset.top>$(this).offset().top && ui.offset.top<y_m && ui.offset.left>$(this).offset().left && ui.offset.left<x_m){
							if(!$(this).hasClass('component-active')){
								$(this).addClass('component-active');
								$(this).css({
									width : $(this).width()-4
								});
							}
						}else{
							if($(this).hasClass('component-active')){
								$(this).removeClass('component-active');
								$(this).css({
									width : $(this).width()+4
								});
							}
							
						}
					}
				});
										
			},
			stop : function(event,ui){
				$(".component-active").before(ui.helper);
				ui.helper.removeAttr('style');
				ui.helper.css({'position' : 'relative'});
				$('.component-active').removeClass('component-active');
				$(".component-active").css({
					width : $(this).width()+4
				});	
				
				var kolejnosc="";
				
				$(this).parent().find(".drag").each(function(){
					if(kolejnosc==""){
						kolejnosc+=$(this).attr('id');
					}else{
						kolejnosc+=","+$(this).attr('id');
					}
				});
				if($(this).parent().attr('id')=="content-left"){
					var polozenie = 1;
				}else{
					var polozenie = 2;
				}
				$.ajax({
					url: 'panel/a/aKolejnoscEl.php', //wzgledna sciezka do skryptu php
					type: 'POST', //metoda POST/GET
					data: {
						'kolejnosc' : kolejnosc,
						'strona' : gup('p'),
						'polozenie' : polozenie
					} //dane wysylane do skryptu
				});
			}
		});
}

function enable_datepicker(){
	$(".datepicker").datepicker({
			dayNamesMin: ['Nie', 'Pn', 'Wt', 'Sr', 'Czw', 'Pt', 'Sob'],
			monthNames: ['Styczen','Luty','Marzec','Kwiecien','Maj','Czerwiec','Lipiec','Sierpien','Wrzesien','Pazdziernik','Listopad','Grudzien'],
			dateFormat: 'yy-mm-dd',
			showButtonPanel: false,
			numberOfMonths: 1,
			firstDay: 1,
			showButtonPanel: false		
		
		});		
}

function enable_mask(){
	$(".kod").mask("99-999");
	$(".telefon_kom").mask("+99 999-999-999");
	$(".telefon").mask("+99 (99) 999-99-99");
	$(".nip").mask("999-999-99-99");
	$(".pesel").mask("99999999999");
	$(".data_input").mask("9999-99-99");
	$(".rok").mask("9999");
	
	//$(".price").mask("99999.99");
	//console.log('maski')*/
	
}

function enable_gallery(){
	$("a[rel^='Lightbox']").each(function(){
		$(this).attr("rel","Lightbox[gallery]");
	})
	$("a[rel^='Lightbox']").prettyPhoto({theme:'light_rounded'});	
}
