$(function() {
	
	if ($("#osoba").attr('checked') == true)
		$("fieldset#firma_f, label.op").hide();
	else
		$("fieldset#klient_indywidualny_f, label.op").hide();
	
	$("#osoba").click(function(){
		$("#klient_indywidualny_f").show();
		$("#firma_f").hide();
	});
	$("#firma").click(function(){
		$("#firma_f").show();
		$("#klient_indywidualny_f").hide();
	});
	
	$("table.table_01 tr").hover(function(){
		$(this).addClass('hover');
		$(this).children("td.opts").children("a").show();
	}, function(){
		$(this).removeClass('hover');
		$(this).children("td.opts").children("a").hide();
	});
	
	$("table.table_01 td.opts a").hide();
	
	$("#info_sms, #info_email").hide();
	
	$("#ostatnie_akcje li a").click(function(){
		
		var offset = $(this).offset();
		
		$("#"+$(this).attr('rel')).css('top', offset.top-50).show().fadeTo(500, 0.9);
		$("#"+$(this).attr('rel')).click(function(){
			$(this).hide();
		});
		return false;
	});



	$("#pingButton").click(function(){


	});
});



function test(type, inputVar, outputDiv)
{
  inputVar  = document.getElementById(inputVar).value;

  advAJAX.post({
	url: "http://monity.pl/ajax/"+ type +".html",
	parameters : {
            "page" : inputVar,
	},
	onSuccess : function(obj) { document.getElementById(outputDiv).innerHTML = obj.responseText; },
	onError : function(obj) { alert("Wystapil blad: " + obj.status); }
    }); 
}


function powiadomieniaShow()
{
  typ = document.getElementById('typField').value;

  if(typ =="e") {
    document.getElementById('opisField').style.display = '';  
    document.getElementById('wartoscField').style.display = '';  
    document.getElementById('submitField').style.display = '';        
    document.getElementById('wartoscValue').innerHTML = 'Email:';        
  } else if(typ == "t") {
    document.getElementById('opisField').style.display = '';  
    document.getElementById('wartoscField').style.display = '';  
    document.getElementById('submitField').style.display = '';    
    document.getElementById('wartoscValue').innerHTML = 'Telefon:';        
  } else {
    document.getElementById('opisField').style.display = 'none';  
    document.getElementById('wartoscField').style.display = 'none';  
    document.getElementById('submitField').style.display = 'none';      
  }
}

function rodzajMonitorowaniaShow()
{
  typ = document.getElementById('rodzajMonitorowaniaField').value;

  if(typ =="d") {
    document.getElementById('zabronioneSlowaField').style.display = 'none';  
    document.getElementById('wymaganeSlowaField').style.display = 'none';  
  } else if(typ == "s") {
    document.getElementById('zabronioneSlowaField').style.display = 'none';  
    document.getElementById('wymaganeSlowaField').style.display = 'none';  
  } else if(typ == "z") {
    document.getElementById('zabronioneSlowaField').style.display = '';  
    document.getElementById('wymaganeSlowaField').style.display = '';  
  }

}

function rodzajPortuShow()
{
  typ = document.getElementById('rodzajMonitorowaniaField').value;

  if(typ =="dowolny") {
    document.getElementById('dowolnyPortField').style.display = '';  
  } else {
    document.getElementById('dowolnyPortField').style.display = 'none';  
    document.getElementById('dowolnyPort').value = '';  
  }

}



function potwierdzUsunStrona()
{
  var agree=confirm("Jesteś pewien że chcesz trwale usunąć z monitoringu tą stronę ?");
  if (agree)
  	return true ;
  else
  	return false ;

}

function potwierdzUsunFrazaStrona()
{
  var agree=confirm("Jesteś pewien że chcesz trwale usunąć z monitoringu tą stronę ?\n Wszystkie monitorowane frazy zostaną także usunięte!");
  if (agree)
  	return true ;
  else
  	return false ;

}

function potwierdzUsunFrazaSlowo()
{
  var agree=confirm("Jesteś pewien że chcesz trwale usunąć z monitoringu tą frazę ?");
  if (agree)
  	return true ;
  else
  	return false ;

}



function pokazTip(id)
{

//  inputVar  = document.getElementById(inputVar).value;

  advAJAX.post({
	url: "http://monity.pl/ajax/pobierztip.html",
	parameters : {
            "klucz" : id,
	},
	onSuccess : function(obj) { document.getElementById('tip').innerHTML = obj.responseText; },
	onError : function(obj) { alert("Wystapil blad: " + obj.status); }
    }); 

}

function regulaminNovem()
{
  var zaznaczony = document.getElementById('regulamin').checked;
  var cid = document.getElementById('cid').value;
  var mail = document.getElementById('novem_mail').value;

  if(cid == "" || mail == "")
    {
      alert("Aby skorzystać z oferty dla wydawców Novem wpisz swój Novem ID oraz Email.");
      return false;  
    }


  if(cid != "" && mail != "")
    if(!zaznaczony)
    {
      alert("Aby skorzystać z oferty dla wydawców Novem musisz zaakceptować regulamin.");
      return false;  
    }

  return true;
}

function isNumberKey(evt)
{
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57))
   return false;
   return true;
}


$(document).ready(
  function()
  {
    $("#novemlink").click(
      function()
      {
        $("#ostabelka").show("slow",
        function() {  } );
        $("#novemlink").hide("slow",
        function() {  } );

      });
  });