var link = '/dean/web/';
function sendForm(div, action){
	var form = $("#"+div);
	if(action) form.attr('action', action);
	form.submit();
}

function implode (glue, pieces) {
    var i = '', retVal='', tGlue='';
    if (arguments.length === 1) {        pieces = glue;
        glue = '';
    }
    if (typeof(pieces) === 'object') {
        if (pieces instanceof Array) {            return pieces.join(glue);
        }
        else {
            for (i in pieces) {
                retVal += tGlue + pieces[i];                tGlue = glue;
            }
            return retVal;
        }
    }    else {
        return pieces;
    }
}

function addToFavorites(){
	var url = "http://dean26.pl"; 
	var title = "Dean26.pl"; 

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}

function getMiasta(select_id, url, class_name){
	$("#miasta_list").attr("disabled", "disabled");
    $("#loading_bar").fadeIn("slow");
	var id = $("#"+select_id).val();
			
	$.post(url, { id : id, class_name : class_name },
  	function(data){
    	if(data.length > 0){
    		$("#miasta").html(data); 
    	} else {
    		alert('Coś poszło nie tak');
    	}
    	$("#loading_bar").fadeOut("slow");
    	$("#miasta_list").attr("disabled", false);
  	});
}

$(document).ready(function(){
	
    $('.tip').mouseover(function(){

  	  var id = this.id;
  	  var tresc = $("#tresc_"+id).html();
  	  
  	  var a = $("#"+id);
	  var offset = a.offset();	
	  
	  $("#info_"+id).remove();
	  $("body").append("<div id=\"info_"+id+"\" class=\"tooltip\" style=\"top:"+(offset.top+20)+"px;left:"+(offset.left+5)+"px;\"></div>");
      $("#info_"+id).html(tresc);
		

    });
    
   	$('.tip').mouseout(function(){
  	  var id = this.id;
  	  var tresc = this.title;	  
	  $("#info_"+id).remove();
    });  
    
	
    $(".forum_show tr:even").addClass("forum_show_def");
	$(".forum_show tr:odd").addClass("forum_show_abc");
	$(".forum_show tr").mouseover(function() {
    	$(this).addClass("forum_show_tr_hover");
	}).mouseout(function() {
    	$(this).removeClass("forum_show_tr_hover");
	});
	
    $(".wyniki tr:even").addClass("wyniki_def");
	$(".wyniki tr:odd").addClass("wyniki_abc");
	$(".wyniki tr").mouseover(function() {
    	$(this).addClass("wyniki_tr_hover");
	}).mouseout(function() {
    	$(this).removeClass("wyniki_tr_hover");
	});
		
    $(".najazd_post:even").addClass("forum_show_def");
	$(".najazd_post:odd").addClass("forum_show_abc");
	$(".najazd_post").mouseover(function() {
    	$(this).addClass("forum_show_tr_hover");
	}).mouseout(function() {
    	$(this).removeClass("forum_show_tr_hover");
	});
		

    $("#checked_box").toggle(
      function () {
      	$("#checked_box").attr('checked', 'true');
        $('.ptaszki').attr('checked', 'true');
      },
      function () {
      	$("#checked_box").removeAttr('checked');
        $('.ptaszki').removeAttr('checked');
      }
    );
	
	$('#email_addres').click(function(e){
		if($(this).val() == 'Twój adres email...') $(this).val("");		
	})	

});
