$(function(){
	// ajax loader
	$("#loading").hide();
	$("#loading").ajaxStart(function(){
	  $(this).show();
	});
	$("#loading").ajaxStop(function(){
	  $(this).hide();
	});
	// bekezdes hack
	$(".left .bekezdes_cim:first").css("margin-top","5px");
	$(".right .bekezdes_cim:first").css("margin-top","5px");
	// fade
	//$(".left").css("display","none");
	//$(".right").css("display","none");
	//$(".left").fadeIn("slow");
	//$(".right").fadeIn("slow");
	// domain input onlick
	$(".domainsearch .input").click( function(){
		if ($(".domainsearch .input").val() == "választott domain név"){
			$(".domainsearch .input").val("");
		}
	});
	// submit altalanos
	$(".submit").hide();
	$(".submit").after('<table cellpadding="0" cellspacing="0" class="subimg"><tr><td class="left_td"></td><td class="center_td">'+$(".submit").val()+'</td><td class="right_td"></td></tr></table>');
	$(".subimg").click(function(){
		$(".submit").parents("form").submit();
	});
	// submit 2
	$(".submit2").hide();
	$(".submit2").after('<table cellpadding="0" cellspacing="0" class="subimg2"><tr><td class="left_td"></td><td class="center_td">'+$(".submit2").val()+'</td><td class="right_td"></td></tr></table>');
	$(".subimg2").click(function(){
		$(".submit2").parents("form").submit();
	});
	$(".subimg").css("cursor","pointer")
	$(".subimg2").css("cursor","pointer")
	// submit domainsearch
	$(".domainsearch .subimg").click(function(){domainsearch()});
	// enterre is keressen
	$(".domainsearch .input").keypress(function(event){
		if(event.keyCode==13){
			domainsearch();
		}
	});
	// domain reg ellenorzes
	$(".domainreg .subimg2").unbind();
	$(".domainreg .subimg2").click(function(){domainregformcheck()});

});

function domainsearch(){
	if ($(".domainsearch .input").val()!= "választott domain név"){
		$("#domainresult").empty();
		if (document.getElementById('tld').options[document.getElementById('tld').selectedIndex].value == "all"){// osszes
			for (var c=0;c<8;c++){
				var url="/domain/keres/"+$(".domainsearch .input").val()+"."+document.getElementById('tld').options[c].value;
				$.get(url,function(data){
					$("#domainresult").append(data);
				})
			}
		}
		else{
			var url="/domain/keres/"+$(".domainsearch .input").val()+"."+document.getElementById('tld').options[document.getElementById('tld').selectedIndex].value;
			$.get(url,function(data){
				$("#domainresult").append(data);
			})
		}
	}
}

function domainregformcheck(){

	var x = document.getElementById('reg');
	var max = 13;
	var kotelezo = new Array();
	var nincs = 0;

	kotelezo[0] = 1;
	kotelezo[1] = 1;
	kotelezo[2] = 0;
	kotelezo[3] = 0;
	kotelezo[4] = 1;
	kotelezo[5] = 1;
	kotelezo[6] = 0;
	kotelezo[7] = 1;
	kotelezo[8] = 1;
	kotelezo[9] = 1;
	kotelezo[10] = 0;
	kotelezo[11] = 0;
	kotelezo[12] = 0	;

	for (var c=0;c<max;c++){
		if(!(x.elements[c].value) && kotelezo[c]){
			nincs = 1;
		}
	}

	if (nincs){
		tb_show("Teszt","/popup?height=55&width=180&inlineId=hiddenModalContent&modal=true",false);
	}
	else{
		x.submit();
	}

}