
///////////////////img


var img_media_edit_kursor_na_zd=false;
var img_media_edit_id=false;
var img_media_edit_path_file=false;



function img_media_edit_kontener(nowy_plik){
	///_cms_img_admin_edit_kontener
	
	
 
	      if($("#img_media_edit_w_kontener_"+_img_media_edit_id).length==1) {
	    	  $("#img_media_edit_w_kontener_"+_img_media_edit_id).val('nowy_plik');
	      } else {
	    	  $('#cms_img_admin_edit_kontener').html(   $('#cms_img_admin_edit_kontener').html() + $("#img_media_edit_w_kontener_"+_img_media_edit_id).val('nowy_plik') );				
	      }
	
}

function img_media_edit_hide1(){
	  img_media_edit_kursor_na_zd=false;
	  TimerID=self.setTimeout("img_megia_edit_ukryj_mini_ikonke('"+img_media_edit_id+"')",9);
	
}


function img_media_edit_start(id,file){
	$('#'+id).live({
		  mouseout: function() {
			  img_media_edit_hide1();
		  },
		  mouseover: function() {
			  img_megia_edit_pokaz_mini_ikonke(id);
			  img_media_edit_id=id;
			  img_media_edit_path_file=file;
		  }
		});
	
}

function img_megia_edit_pokaz_mini_ikonke(id){
	
	var p = $("#"+id);
	var position = p.position();
	$("#img_admin_edit").css( "left",position.left);
	$("#img_admin_edit").css( 'top',position.top );
//	$("#img_admin_edit").css( "display",'' );
	$("#img_admin_edit").show(111);
	img_media_edit_kursor_na_zd=true;
	
	
}
function img_megia_edit_ukryj_mini_ikonke(id){
//	$("#img_admin_edit").css( "display",'none' );
	  
	if(img_media_edit_kursor_na_zd){}else{
		$("#img_admin_edit").hide(1);
		clearTimeout(TimerID);
		img_media_edit_id='';
	}
}
 
function img_media_edit(){
	
	
	$.closeAllWindows();

	//show window
    $.newWindow({
        id: 'windows1',
        title: "",
        width: 400,
        height: 200,
        posx: 250,
        posy: 250,
        content: "<div id='windows1_div'></div>",
        onDragBegin : null,
        onDragEnd : null,
        onResizeBegin : null,
        onResizeEnd : null,
        onAjaxContentLoaded : null,
        statusBar: true,
        minimizeButton: true,
        maximizeButton: true,
        closeButton: true,
        draggable: true,
        resizeable: true
    });
    
    
    ;
  $.post("/index.php",
	"ajax=admin&akcja=_cms_img_edit&img_media_edit_path_file="+base64_encode(img_media_edit_path_file) ,
	function(data){  
	  $('#windows1_div').html(data);
	}); 
    

//	_cms_img_media_edit

}



////img









var komunikt_link;
var komunikt_post;
function komunikt_show(typ,post,link){
//	"akcja:'db_usun',table:'dbl_{$table}',id:'{$r[$k][id]}'"
//	komunikt_show('kolejnosc',{ajax:'admin',$usun})\"
	
	
	komunikt_link=link;
	komunikt_post=post;
	
	if(typ==1 || typ=="usun"){
		box_show("komunikt_box_sys_usun");
	}
	
	

}

function komunikt_on_yes(){
	
	if(komunikt_post){
		$.post("/index.php", komunikt_post,   function(data){ 
			location.reload(true); 
		});
	}
	
	if(komunikt_link){
		location.href=komunikt_link;
	}
	
	box_anuluj();
}

function komunikt_anuluj(){
	komunikt_link='';
	box_anuluj();
}



 var aktu_box_show;
function box_show(id){
	przyciemnij_tlo_show();
  	//$('#komunikt_box_sys_text').html(zawartosc);
	aktu_box_show=id;
	$('#'+id).css("display","");
	$('#komunikt_box_sys').css("width","");
	$('#komunikt_box_sys').css("display","");
	$('#komunikt_box_sys').css({top:'50%',left:'50%',margin:'-'+($('#komunikt_box_sys').height() / 2)+'px 0 0 -'+($('#komunikt_box_sys').width() / 2)+'px'});
	$('#komunikt_box_sys').css("top",($(document).scrollTop())+($(window).height()/2));
	if($('#komunikt_box_sys').css("top")<0) $('#komunikt_box_sys').css("top","0"); 
	
	
	var tmp1 =0;
	tmp1= str_replace('px','',$('#komunikt_box_sys').css('margin-top'));
	var tmp2=0;
	tmp2= str_replace('px','',$('#komunikt_box_sys').css('top'));
	
	tmp1=parseFloat(tmp1);
	tmp2=parseFloat(tmp2);
	
	
	var tmp3=(tmp1+tmp2);
	if(0>tmp3){
		$('#komunikt_box_sys').css('margin-top',parseFloat($('#komunikt_box_sys').css('margin-top'))-tmp3);
		 
	}
	
	
	
}

var wylacz_box_anuluj=0;
function box_anuluj(){
	
	if(wylacz_box_anuluj==1)return false;
	$('#'+aktu_box_show).css("display","none");
	$('#komunikt_box_sys').css("display","none");
	przyciemnij_tlo_hidden();
	$('#komunikt_box_sys').css("width","0px");
	$('#komunikt_box_sys').css("display","none");
}






function przyciemnij_tlo_show(){
	

	$('#przyciemnienie_all_cont').css("display","");
	$('#przyciemnienie_all_cont').css("width",$(document).width());
	$('#przyciemnienie_all_cont').css("height",$(document).height());

	$('#przyciemnienie_all_cont').animate({
	    opacity: 0.75
	  }, 5, function() {
	    // Animation complete.
	  });

}



function przyciemnij_tlo_hidden(){
	
	$('#przyciemnienie_all_cont').css("display","none");
	$('#przyciemnienie_all_cont').css("width","0");
	$('#przyciemnienie_all_cont').css("height","0");

	
}

 








///admin add imput and tiny



function edit_textarea(){

$('textarea').each(function() {
	//alert($(this).attr("class"));
    //alert($(this).children().attr("id"));
	var el = $(this);
	var el2 = $(this).parent();
	
	
 
	var str2 = el.attr("class");
	var exploded2 = str2.split(' ');
	$.each(exploded2, function(key2, value2) { 
		
		if(value2=="cms_textarea"){
			el.css('width',(el2.width()-2));
		}
		
	});

	
	var str = el2.attr("class");
	var exploded = str.split(' ');
	$.each(exploded, function(key, value) { 
		
		 
		if(value=="input"){
			//el.html(htmlspecialchars(el.html(), 'ENT_QUOTES'));

			el2.append('<input style="width:'+(el2.width()-2)+'px" class="cms_input"  name="'+el.attr("name")+'" id="'+el.attr("id")+'" value="'+htmlspecialchars(el.val(), 'ENT_QUOTES')+'" />');
 			el.remove();
		}

		if(value=="tiny-simple"){
			tiny(el.attr("id"),"simple");
		}
		if(value=="tiny-mini"){
			tiny(el.attr("id"),"simple");
		}
		if(value=="tiny"){
			tiny(el.attr("id"),"simple");
		}
		if(value=="tiny-simple-zd"){
			tiny(el.attr("id"),"tiny-simple-zd");
		}
		if(value=="tiny-pdf"){
			tiny(el.attr("id"),"tiny-simple-pdf");
		}
		
		
		
		if(value=="textarea"){
			//tiny(el.attr("id"),"none");
		}
		
	});

    
});


 


}
