
jQuery(document).ready(function(){
	
jQuery(".zebra tr").mouseover(function() {jQuery(this).addClass("over");}).mouseout(function() {jQuery(this).removeClass("over");});
jQuery(".zebra tr:even").addClass("alt");

 

jQuery(".switchable").click(function() {jQuery(this).toggleClass("switched");return false;});

jQuery(".clickable").click(function() {
	z=jQuery(this).attr("href");
	document.location=z;
	return false;
	;});
	
jQuery(".clickable-close").click(function() {
	 window.close();
	return false;
	;});
	
jQuery(".window-print").click(function() {
	 window.print();
	return false;
	;});
 
jQuery(".clickable-window").click(function() {
	z=jQuery(this).attr("href");
	nazwa=jQuery(this).attr("winname");
	//prop=jQuery(this).attr("winprop");
	prop='menubar=yes, toolbar=no, location=no, scrollbars=yes, ' +
'resizable=yes, status=yes,width=600, height=400';
	win=window.open(z,nazwa,prop)
	//document.location=z;
	if (window.focus) {win.focus()}
	return false;
	;});
	
jQuery(".clickable-confirm").click(function() {
	z=jQuery(this).attr("href");
	t=jQuery(this).attr("confirmtitle");
	if(confirm(t)){
		document.location=z;
	}
	return false;
	;});
	
	
jQuery(".toggleable-box").click(function() {
	z=jQuery(this).attr("rel");
	 
	jQuery("#"+z).toggle();
	return false;
	;});
	
jQuery(".numeric").numeric(".");


	
 
	
 

jQuery(".jsDateOrg").each(
function(el){
       var va=$(this).val();
       var id=$(this).attr("id");
       //console.log(id);
       var cova=timestamp2string(va);
       //console.log(cova);
       $("#"+id+"Js").val(cova);
      }
);
 	

jQuery(".jsDate").change(function(){
	//pobierz cene z dest i podstaw pod source
	 var rel=$(this).attr('rel');
	 var va=$(this).val();
	 var cova=string2timestamp(va);
	 jQuery("#"+rel).val(cova);
	// console.log("change: "+rel+" "+cova);
	 return true;
});

$('input.jsDate').attachDatepicker(
{dateFormat: 'dd-mm-yy'}
); 

});


function timestamp2string(val){	
		 v=new Date();
		 val=val*1000;
		 v.setTime(val);
		if(!v){
		 	v=0;
		 }
		 if(v<=0){
		 	//console.log("data jest nieustalona: "+val);
		 	return "";
		 }else{
			 var curr_date = v.getDate();
			var curr_month = v.getMonth();
			curr_month=curr_month+1;
			var curr_year = v.getFullYear();
			 v=curr_date + "-" + curr_month + "-" + curr_year;
			return v;
		 }
		 
		 
}

function string2timestamp(str){	
		//dd-mm-yy
		aa=str.split('-');
		//console.log(aa);
		myDate=new Date(); 
		 
		myDate.setDate(aa[0]);
		myDate.setMonth(aa[1]-1);
		myDate.setFullYear(aa[2]);
		ret=myDate.getTime();
		ret=ret/1000;
		return ret ;
}


function goback(){	
	 history.go(-1);
		return false;
}

 
 

