$(document).ready(function() {
	
	$("#csekkol-1").click(function() {
		$("#szallinformacio").html($("#mondom-1").val());
	});
	$("#csekkol-2").click(function() {
		$("#szallinformacio").html($("#mondom-2").val());
	});
	$("#csekkol-3").click(function() {
		$("#szallinformacio").html($("#mondom-3").val());
	});
	$("#csekkol-4").click(function() {
		$("#szallinformacio").html($("#mondom-4").val());
	});
	$("#csekkol-5").click(function() {
		$("#szallinformacio").html($("#mondom-5").val());
	});
	$("#csekkol-6").click(function() {
		$("#szallinformacio").html($("#mondom-6").val());
	});
		
	$(".lecsukos").hide();
	$(".tanfolyamnev").click (function() {
	 $(this).next(".lecsukos").slideToggle(100);
	});

	$(".jelentkezem").click(function(){
		if ($(this).next(".formoscucc").innerHeight() < 5)
		{
        $(this).next(".formoscucc").animate({height: "180px"},"slow");
		}
		else
		{
        $(this).next(".formoscucc").animate({height: "0px"},"slow");
		}
	}); 
	
	$(".soppkosarbakat").hover (function () {
        $(this).next(".kosarbatesz").fadeIn(500);
      }, 
      function () {
        $(this).next(".kosarbatesz").fadeOut(100);
      }
    );

	
	$("#refi").autocomplete('keresohoz.php', {
		width: 260,
		selectFirst: false
	});
	$("#refi").result(function(event, data, formatted) {
		if (data)
			$("#termekid").val(data[1]);
			$("#namehu").val(data[2]);
			$("#nameen").val(data[3]);
	});
	
	$("#namehu").autocomplete('keresohoznamehu.php', {
		width: 260,
		selectFirst: false
	});
	$("#namehu").result(function(event, data, formatted) {
		if (data)
			$("#termekid").val(data[1]);
			$("#refi").val(data[2]);
			$("#nameen").val(data[3]);
	});
	
	$("#nameen").autocomplete('keresohoznameen.php', {
		width: 260,
		selectFirst: false
	});
	$("#nameen").result(function(event, data, formatted) {
		if (data)
			$("#termekid").val(data[1]);
			$("#refi").val(data[2]);
			$("#namehu").val(data[3]);
	});
	
	$('#flessterkep').flash({
    src: 'terkep.swf',
    width: 508,
    height: 236
	});
	$('#flessterkepbp').flash({
    src: 'terkep2.swf',
    width: 508,
    height: 236
	});
	
	if ($('#kosbelsotarto').height()<parseInt(430))
		{ $('#kosbelsotarto').css('overflow','hidden'); }
        else
        { $('#kosbelsotarto').css('overflow-y','scroll');
	      $('#kosbelsotarto').css('overflow-x','hidden'); }	
		  
	$("#loginos").hide();
	$(".belep").click(function(){
		$("#belepes").animate({"left": "520px"}, "slow");
		$("#loginos").css("display","block");
	});
	$(".keres").click(function(){
		 if ($(".kereses").is(":hidden")) {
        $(".kereses").animate({height: "64px"},"slow");
      } else {
        $(".kereses").animate({height: "0px"},"slow");
      }

	});
	$(".msg_body").hide();
	$("#kinyit").click(function(){
	if ($(".msg_body").is(':hidden')) { 
		$(".msg_body").slideToggle(100);
		$("#kinyit").text('Összes bezárása');
		}
		else {
		$(".msg_body").slideToggle(100);
		$("#kinyit").text('Összes kinyitása');
		}
	});
	$(".msg_head").click(function(){
		$(this).next(".msg_body").slideToggle(250);
	});
	$("#refnum").autocomplete('search.php', {
		width: 260,
		selectFirst: true
	});
	$("#refnum").result(function(event, data, formatted) {
		if (data)
			$("#id").val(data[1]);
			$("#name").val(data[2]);
			$("#tname").text(data[2]);
			$("#price").val(data[3]);
			$("#tar").text('Ára: ' + data[3] + ' Ft.-');
	});
	 $("input:radio[name=szallosszeg]").click(function () {
	 $(".errorrend").hide(); 
	 $("#szallid").val($("input:radio[name=szallosszeg]:checked").next().val());
      var $ertek = parseInt($("input:radio[name=szallosszeg]:checked").val()); 
      $("#szallossz").val($ertek);
	  if ($ertek>0) { $("#szallo").text($ertek + ' Ft.-'); } else { $("#szallo").text('Ingyenes'); }
	  var $kupkedvezmeny = parseInt($("#kuponkedv").val());
	  $("#legeslegvege").val($ertek+(parseInt($("#vege").val()))-$kupkedvezmeny);
	  $("#mindo").text($ertek+(parseInt($("#vege").val())-$kupkedvezmeny) + ' Ft.-');
    });
	  $('#elkuldendo').submit(function() { 
        $(this).ajaxSubmit( {
		target: '#uzenet',
        beforeSubmit: szallitcsekk,
		success: termekelkuldve
		}); 
 	     return false; 
    });
	
    $('.formoscucc form').submit(function() {
        $(this).ajaxSubmit({ 
		target: '#uzenet',
        success: showResponse
	    }); 
 	     return false; 
    }); 
		 $(".harmadik li").click(function() {
			$("#nemlatszik").hide();
			$.ajax({
 			 type: "post",
 			 url: "termekelojon.php",
			 data: { termekid: $(this).next("#ideid" ).val() },
			 success: function(response){
			$("#nemlatszik").html(response);
    		var windowWidth = $("#fotarto").width();
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".elotermektart").height();
	var popupWidth = 346;
	var elocss = {
				'opacity' : '0.6',
				'width' : '2000px',
				'height' : '2000px',
				'top' : '0px',
				'left' : '0px',
				'display' : 'block'
				}
	var amielocss = {
		'position' : 'absolute',
		'top': ((windowHeight/2-popupHeight/2)+$(document).scrollTop())-200,  
		'left': windowWidth/2-popupWidth/2,
		'opacity' : '1.0'
	}
	$("#elohatter").css (elocss);
	$("#elohatter").fadeIn('slow');
	$("#nemlatszik").show('fast');
	$(".elotermektart").css(amielocss);
	$(".elotermektart").fadeIn('slow');
		$(".elotermektart").click(function(){
		eltunik ();
	});
	$("#elohatter").click(function(){
		eltunik ();
	});
	function eltunik () {
		$("#elohatter").fadeOut('slow');
		$(".elotermektart").fadeOut('slow');
		$("#nemlatszik").hide('slow');
	}
  			}
				});
    		});		
	 $(".termkepes").click(function() {
		$("#nemlatszik").hide();
			$.ajax({
 			 type: "post",
 			 url: "termekelojon.php",
			 data: { termekid: $(this).next("#ididid" ).val() },
			 success: function(response){
			$("#nemlatszik").html(response);
    		var windowWidth = $("#fotarto").width();
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".elotermektart").height();
	var popupWidth = 346;
	var elocss = {
				'opacity' : '0.6',
				'width' : '2000px',
				'height' : '2000px',
				'top' : '0px',
				'left' : '0px',
				'display' : 'block'
				}
	var amielocss = {
		'position' : 'absolute',
		'top': ((windowHeight/2-popupHeight/2)+$(document).scrollTop())-200,  
		'left': windowWidth/2-popupWidth/2,
		'opacity' : '1.0'
	}
	$("#elohatter").css (elocss);
	$("#elohatter").fadeIn('slow');
	$("#nemlatszik").show('fast');
	$(".elotermektart").css(amielocss);
	$(".elotermektart").fadeIn('slow');
		$(".elotermektart").click(function(){
		eltunik ();
	});
	$("#elohatter").click(function(){
		eltunik ();
	});
	function eltunik () {
		$("#elohatter").fadeOut('slow');
		$(".elotermektart").fadeOut('slow');
		$("#nemlatszik").hide('slow');
	}
  			}
				});
    		});								
$(".infos").click(function() {
		$("#nemlatszik").hide();
			$.ajax({
 			 type: "post",
 			 url: "termekelojon.php",
			 data: { termekid: $(this).next("#idinfo" ).val() },
			 success: function(response){
			$("#nemlatszik").html(response);
    		var windowWidth = $("#fotarto").width();
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".elotermektart").height();
	var popupWidth = 346;
	var elocss = {
				'opacity' : '0.6',
				'width' : '2000px',
				'height' : '2000px',
				'top' : '0px',
				'left' : '0px',
				'display' : 'block'
				}
	var amielocss = {
		'position' : 'absolute',
		'top': ((windowHeight/2-popupHeight/2)+$(document).scrollTop())-200,  
		'left': windowWidth/2-popupWidth/2,
		'opacity' : '1.0'
	}
	$("#elohatter").css (elocss);
	$("#elohatter").fadeIn('slow');
	$("#nemlatszik").show('fast');
	$(".elotermektart").css(amielocss);
	$(".elotermektart").fadeIn('slow');
		$(".elotermektart").click(function(){
		eltunik ();
	});
	$("#elohatter").click(function(){
		eltunik ();
	});
	function eltunik () {
		$("#elohatter").fadeOut('slow');
		$(".elotermektart").fadeOut('slow');
		$("#nemlatszik").hide('slow');
				}
  		}
	});
});								
	$("#reguzenet").hide(); 
		$('#userreg').passroids({ 
       main: '#password',
       verify: '#password2',
       button: '#ok',
       minimum: 0
    });
	$('#userreg').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#reguzenet',
		beforeSubmit: regelott,
		clearForm: false,
        success: regvege
	    }); 
 	     return false; 
    });
	$('#onlineuzi').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#onluz',
		clearForm: true,
        success: onlsiker
	    }); 
 	     return false; 
    });
	var eddigiertek=$("#total").val();
	$("#vasosszeg").val(eddigiertek);
	$('#kuponcsekk').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#kupsik',
		beforeSubmit: vasert,
		clearForm: true,
        success: kuponsiker
	    }); 
 	     return false; 
    });
	
	$('#kuponbe').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#kuponosszegszov',
		clearForm: true,
        success: kuponbesiker
	    }); 
 	     return false; 
    });
	
	$('#ujjel').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#ujjelvalasz',
		clearForm: true,
        success: ujjelszoelkuld
	    }); 
 	     return false; 
    });
	
	$('#hirlevelre').submit(function() { 
        $(this).ajaxSubmit({ 
		target: '#hirlfeliratkozoutan',
		clearForm: true,
        success: feliratkozott
	    }); 
 	     return false; 
    });
	
	$('#termker').submit(function() { 
        $(this).ajaxSubmit({ 
		clearForm: true,
        success: function(response){
			$(".kereses").animate({height: "0px"},"slow");
			$("#nemlatszik").html(response);
    		var windowWidth = $("#fotarto").width();
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".elotermektart").height();
	var popupWidth = 346;
	var elocss = {
				'opacity' : '0.6',
				'width' : '2000px',
				'height' : '2000px',
				'top' : '0px',
				'left' : '0px',
				'display' : 'block'
				}
	var amielocss = {
		'position' : 'absolute',
		'top': ((windowHeight/2-popupHeight/2)+$(document).scrollTop())-200,  
		'left': windowWidth/2-popupWidth/2,
		'opacity' : '1.0'
	}
	$("#elohatter").css (elocss);
	$("#elohatter").fadeIn('slow');
	$("#nemlatszik").show('fast');
	$(".elotermektart").css(amielocss);
	$(".elotermektart").fadeIn('slow');
		$(".elotermektart").click(function(){
		eltunik ();
	});
	$("#elohatter").click(function(){
		eltunik ();
	});
	function eltunik () {
		$("#elohatter").fadeOut('slow');
		$(".elotermektart").fadeOut('slow');
		$("#nemlatszik").hide('slow');
				}
  		}
	    }); 
 	     return false; 
    });
	
	 $(".infogomb").click(function() {
		$("#alkatbovebb").hide();
			$.ajax({
 			 type: "post",
 			 url: "alkatelojon.php",
			 data: { alkid: $(this).next("#alkatid" ).val() },
			 success: function(response){
			$("#alkatbovebb").html(response);
    		var windowWidth = $("#fotarto").width();
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".elotermektart").height();
	var popupWidth = 346;
	var elocss = {
				'opacity' : '0.6',
				'width' : '2000px',
				'height' : '2000px',
				'top' : '0px',
				'left' : '0px',
				'display' : 'block'
				}
	var amielocss = {
		'position' : 'absolute',
		'top': ((windowHeight/2-popupHeight/2)+$(document).scrollTop())-200,  
		'left': windowWidth/2-popupWidth/2,
		'opacity' : '1.0'
	}
	$("#elohatter").css (elocss);
	$("#elohatter").fadeIn('slow');
	$("#alkatbovebb").show('fast');
	$(".elotermektart").css(amielocss);
	$(".elotermektart").fadeIn('slow');
		$(".elotermektart").click(function(){
		eltunik ();
	});
	$("#elohatter").click(function(){
		eltunik ();
	});
	function eltunik () {
		$("#elohatter").fadeOut('slow');
		$(".elotermektart").fadeOut('slow');
		$("#alkatbovebb").hide('slow');
	}
  			}
		});
    });								 
}); 
function szallitcsekk(formData, jqForm) {
	   var form = jqForm[0];
	if (form.szallid.value<1)
		{ $(".errorrend").text('Szállítási módot kötelező választani!');
			return false;
		}
		else { return true; }
	}
function termekelkuldve()  { 
	document.location.href="index.php?p=98";
}
function showResponse(responseText)  { 
	$("#uzenet").html('<div>' + responseText + '</div>');
	$( 'html, body' ).animate( { scrollTop: 0 }, 0 );
	$(".lecsukos").hide();
}
function regvege () {
		$("#reguzenet").slideToggle(300);
}

function regelott (formData, jqForm, options) {
	if ($('#vasfelt').attr('checked')) {
	var form = jqForm[0]; 
    if (parseInt($("input:radio[name=uaz]:checked").val())!=1) 
	{
		if (!form.szallnev.value || !form.szallirsz.value || !form.szallvaros.value || !form.szallcim.value)
		{
		$("ok").attr("disabled","true");
		$("#reguzenet").show();
        $("#reguzenet").html('<div class="regerror">Ha a szállítási cím nem ugyan az, mint a számlázási cím, akkor a szállítási adatok kitöltése kötelező!</div>'); 
        return false; 
    	}
	}
	$("ok").attr("disabled","false");
	$("#reguzenet").hide();
	}
	else {
		$("ok").attr("disabled","true");
		$("#reguzenet").show();
        $("#reguzenet").html('<div class="regerror">A vásárlási feltételeket el kell fogadni!</div>'); 
        return false; 
	}
}
function onlsiker(responseText)  { 
$("#onluz").html('<div>' + responseText + '</div>');
$('#onluzelkuld').attr('disabled', 'true');
}
function vasert () {
	$("#kupsik").animate({height: "0px"},5);
}
function kuponsiker () {
	$("#kupsik").animate({height: "40px"},"slow");
}
function kuponbesiker (responseText) {
	$("#kuponosszegszov").html(''+ responseText +'');
	$("#kuponosszegszov").animate({height: "45px"},"slow");
	$("#kuponosszegszov").next("#kuponkedv").val(parseInt($kupertek));
	$("#kupido").val($kupido);
	
	if ($("#szallossz").val()!=0 ) {
	$("#szallid").val($("input:radio[name=szallosszeg]:checked").next().val());
    var $ertek = parseInt($("input:radio[name=szallosszeg]:checked").val()); 
    $("#szallossz").val($ertek);
	}
	else { var $ertek=0; }
	  var $kupkedvezmeny = parseInt($kupertek);
	  $("#legeslegvege").val($ertek+(parseInt($("#vege").val()))-$kupkedvezmeny);
	  $("#mindo").text($ertek+(parseInt($("#vege").val())-$kupkedvezmeny) + ' Ft.-');
}
function ujjelszoelkuld (responseText) {
	$(".elfi").hide();
	$("#ujjelvalasz").text(''+ responseText +'');
	$("#ujjelvalasz").animate({height: "30px"},"slow");
}
function feliratkozott () {
	$("#hirlevelfeliratkozo").hide();
	$("#hirlfeliratkozoutan").animate({height: "176px"},"slow");
}
