var timeout=500;
var closetimer;
var ddmenuitem;

function mopen(id){	
mcancelclosetime();
if (ddmenuitem!=document.getElementById(id)) mclose();
ddmenuitem = document.getElementById(id);
$(ddmenuitem).fadeIn("400");
}

function mclose(){
if(ddmenuitem) $(ddmenuitem).fadeOut("400");
}

function mclosetime(){
closetimer = window.setTimeout(mclose, timeout);
}

function mcancelclosetime(){
if(closetimer){
window.clearTimeout(closetimer);
closetimer = null;
}}

function over(id){
mclose();
}

document.onclick = mclose; 

function checkbox(){
$("input[@type='checkbox'] + label")
.each( function(){
if ( $(this).prev()[0].checked )
$(this).addClass("checked");
else
$(this).addClass("unchecked");
})
.click( function() {
$(this).toggleClass("checked").prev()[0].checked = !$(this).prev()[0].checked;
$(this).toggleClass("unchecked").prev()[0].checked == $(this).prev()[0].checked;
check();
}).prev().hide();
}



$(document).ready(function() {
checkbox();
   
$('.logowanie').submit(function() {

if ($("#username").val()!='' && $("#pass").val()!='') {
  
$.ajax({async:false, url:'/ajax/host.php?id='+$("#username").val(), success: function(host) {
  if (host!='') $('.logowanie').attr("action", 'https://'+host );
  else alert('Błędny login lub hasło!');  
} }); 
 
} else alert('Podaj login i hasło!');   

if ($('.logowanie').attr("action")) return true; else return false;
 
 });

$('#logowanie2').submit(function() {
  if ($("input[name=konto]").val()!='' && $("input[name=haslo]").val()!='') return true;
 else {alert("Podaj nazwę domeny i hasło!");
 return false;}
 });

$('#logowanie3').submit(function() {
  if ($("input[name=user]").val()!='' && $("input[name=pass]").val()!='') return true;
 else {alert("Podaj login klienta i hasło!");
 return false;}
});
 
$('#domenag').submit(function() {
if ($("input[name=domenag]").val()=='nazwadomeny.pl') $("input[name=domenag]").val('');
$('#domenag').attr('action','/oferta/domeny/rejestracja_domeny,'+$("input[name=domenag]").val()+'.html'); 
return true;
 });

$("input[name=domenag]").focus(function(){ 
if ($("input[name=domenag]").val()=='' || $("input[name=domenag]").val()=='nazwadomeny.pl') {
$("input[name=domenag]").val('');
$("input[name=domenag]").css('color','#000');
}
});

$("a[href*=mailto:]").each(function(){
$(this).attr('href',$(this).attr('href').replace("(a)","@"));
$(this).text($(this).text().replace("(a)","@"));
});

//$("a[href]").each(function(){
//$(this).attr('href');

//$(this).attr('href',$(this).attr('href').replace("(a)","@"));

//});
 
});


