var api = false;

function forgotPwd() {

					if (!document.getElementById("forgotDiag")) {
						$("body").append("<div id=\"forgotDiag\"></div>");
					}
					$("#forgotDiag").html("<br /> <b>Kérlek adja meg az e-mail címét amivel regisztrált! </b><br /><div id=\"ajax\"></div><br /> <input type=\"text\" id=\"forgotEmail\" name=\"mail\" /><br /> <em>A megadott e-mail címre küldünk egy új jelszót</em>");	
					
				
					$("#forgotDiag").dialog({
						modal: true,
						width: 400,
						autoOpen: false,
						title: "Elfelejtett jelszó...",
						buttons: {
							"Új jelszó küldése": function() {
									var mail = $("#forgotEmail").val();
									var portalid = $("#portalid").val();
									
									$.post("/documents/seo/forgotpwd.php", {
										email: mail,
										portalid: portalid
									}, function(xml) {
										$("#forgotDiag #ajax").html(xml);
										var timeOutID = setTimeout(function() { $("#forgotDiag").dialog("destroy"); }, 2000);
									});
								
							},
							"Mégse": function() {
								$(this).dialog("destroy");
							}
						}
					});
				
					$("#forgotDiag").dialog("open");
}

function errorMessage(text) {
	
	if (!document.getElementById("errMsg")) {
		$("#main_div").append("<div id=\"errMsg\"></div>");
	}
	
	$("#errMsg").dialog({
	modal: true,
	title: "Hiba történt!",
	autoOpen: true, 
	open: function() {
		$(this).html(text);
	},
	buttons: {
		"Rendben": function() {
			$(this).dialog("destroy");
		}
	}
	});
	
	return false;
	
}

function alertMessage(text, title) {
	
	if (!document.getElementById("alertMsg")) {
		$("#main_div").append("<div id=\"alertMsg\"></div>");
	}
	
	$("#alertMsg").dialog({
	modal: true,
	bgiframe: true,
	title: title,
	autoOpen: true, 
	open: function() {
		$(this).html(text);
	},
	buttons: {
		"OK": function() {
			$(this).dialog("destroy");
		}
	}
	});
	
	return false;
	
}

function fnMessage(text, title, action) {
	
	if (!document.getElementById("fnMsg")) {
		$("body").append("<div id=\"fnMsg\"></div>");
	}
	
	if (title=="") { title="Információ!"; }
	
	$("#fnMsg").dialog({
	modal: true,
	title: title,
	autoOpen: true, 
	open: function() {
		$(this).html(text);
	},
	buttons: {
		"Rendben": function() {
			action();
			$(this).dialog("destroy");
		}
	}
	});
	
	return false;
}


function closeBox() {
	$("#seoNews").hide("slide", 1000);//css("display", "none");
	$("#seoFrame").remove();//css("display", "none");
	//$("#seoNews").expose().close();
	if (api) $.mask.close();
}

 $(document).ready(function() {
  
	
    $("#Wrapper .spct").mousemove(function(e) {
    
      if ($(this).attr("rel")!="") {
      
      var ertek = $(this).attr("rel");
      
        if (!document.getElementById("titler")) {
          $("body").append("<div id=\"titler\" />");
        }
          $("#titler").html(ertek);
          
          $("#titler").css({
            position: "absolute",
            left: e.pageX+15,
            top: e.pageY+15,
            width: "auto",
            height: "auto",
            opacity: .70,
            padding: 6,
            zindex: 2000,
            color: "#333",
            background: "#dfd",
            border: "1px solid #eee"
          });
      }
      
    }).mouseout(function() {
      $("#titler").remove();
    });
    
    
    $("#seo").mouseover(function(e) {
		$(this).css("background", "url(/images/870/seohover_png_250_2010090311508_970.png)");
     }).mouseleave(function() {
		$(this).css("background", "url(/images/870/seo_png_766_2010090311418_913.png)");
		$("#titler").remove();
     }).click(function() {
	  
		var height_b = $(document).height();
		//var width_b = $(window).width()/2;
		
	  //$("#mainPageNews:first").fadeOut(1000);
	  if (!document.getElementById("seoFrame")) { $("body").append("<iframe id=\"seoFrame\" />"); }
	  if (!document.getElementById("seoNews")) { $("body").append("<div id=\"seoNews\" />"); }
	  
	  
	  $("#seoFrame, #seoNews").css({
		position: "absolute",
		left: 0,
		top: 0,
		width: "40%",
		padding: 10,
		height: height_b,
		background: "#fff",
		border: "3px solid #ddd",
		overflow: "visible",
		zindex: 10000
	  });
	  
	  $("#seoFrame").css({
		opacity: 0,
		zindex: 9999
	  });
	  
      api = $("#seoNews").load("/documents/seo/news.php").show("slide", 800).expose({api: true, color: "#759f3a", closeOnClick: false, closeOnEsc: false }); //fadeIn(1000).
	  api.load();
     }).mousemove(function(e) {

	 var eleft = e.pageX+10;
	 var etop = e.pageY+10;
          $("#titler").css({
            left: eleft,
            top: etop
          });
                  
     });
  
  
           function hideMenu1() {
              if (!$('.specbtn').data('in') && !$('.spmenu').data('in') && !$('.spmenu').data('hidden')) {
                $('.spmenu').fadeOut('fast');
                $('.specbtn').removeClass('active');
                $('.spmenu').data('hidden', true);
              }
            }
            
			$('.specbtn, .spmenu').mouseenter(function() {
              $('.spmenu').fadeIn('fast').css({
                right: 180,
                top: 31
                });
              $('.specbtn').addClass('active');
              $(this).data('in', true);
              $('.spmenu').data('hidden', false);
            }).mouseleave(function() {
              $(this).data('in', false);
              setTimeout(hideMenu1, 500);
            });    
     
    $(".diagMsg").click(function() {
      if (!document.getElementById("Message")) {
        $("body").append("<div id=\"Message\" />");
      }
      
      //var addval = $(this).attr("rel");
      $("#Message").load("/documents/seo/nwl.php");
        
        $("#Message").dialog({
        modal: true,
        autoOpen: true,
        title: "Hírlevél feliratkozás...",
        buttons: {
        "Bezár": function() {
			$(this).dialog("destroy");
        }, 
		"Feliratkozás!": function() {
		
			var sn = $("#Message #subscribe_name").val();
			var se = $("#Message #subscribe_email").val();
			var pid = $("#Message #pid").val();
			var csid = $("#Message #csid").val();
		
			if (sn.length>3 && se.length>5 && pid.length>0 && csid.length>0) {
				$.post("/admin/php/moduls/hirlevel/feliratkozas.php?charset=utf-8", {
					pid: pid,
					csid: csid,
					subscribe_name: sn,
					subscribe_email: se
				}, function(xml) {
					alertMessage("Sikeresen feliratkozott hírlevelünkre!", "Sikeres feliratkozás...");
				});
			} else errorMessage("Túl rövid a megadott e-mail cím <em>(minimum 6 karakter)</em> és/vagy Név <em> (minimum 4 karakter)</em>!");
		}
		
		
        }       
        });
    });
    
    $("#Player1 ul").cycle({
      next: "#P1Next",
      prev: "#P1Prev",
      pager: "#pager1",
      fx: "fade",
      speed: "slow"
    });
    
    $("#Player1").mouseenter(function() {
      $("#pager1, #Player1 .nav").fadeIn("slow");
    }).mouseleave(function() {
      $("#pager1, #Player1 .nav").fadeOut("slow");
    });

     $("#Player2 ul").cycle({
      next: "#P2Next",
      prev: "#P2Prev",
      pager: "#pager2",
      fx: "fade",
      speed: "slow"
    });
    
   $("#Player2").mouseenter(function() {
      $("#pager2, #Player2 .nav").fadeIn("slow");
    }).mouseleave(function() {
      $("#pager2, #Player2 .nav").fadeOut("slow");
    });
    
	$("#loginbtn").mouseenter(function() {
		$(this).addClass("activeLogin");  
	}).mouseleave(function() {
		$(this).removeClass("activeLogin");
	}).click(function() {
		
		$("#RLogin").slideToggle();
		
		if (!document.getElementById("loginBox")) {
			$("body").append("<div id=\"loginBox\" />");
		}
		
		$("#loginBox").html($("#formCont").html());
		
		$("#loginBox").dialog({
			modal: true,
			autoOpen: true,
			bgiframe: true,
			title: "Belépés - Keresőoptimalizálás",
			buttons: {
				"Belépés": function() {
					$("#RLogin").slideToggle();
					$("#loginBox #login").submit();
				},
				"Mégse": function() {
					$("#RLogin").slideToggle();
					$(this).dialog("destroy");
				}				
			},
			close: function() {
					$("#RLogin").slideToggle();
			}
		});
		
	});
		
		$("#loginUser").click(function() {
			if ($("#loginUser").val()=="Felhasználó név") $("#loginUser").val("");
		}).blur(function() {
			if ($("#loginUser").val()=="") $("#loginUser").val("Felhasználó név");
		});
		
		$("#loginPwd").click(function() {
			if ($("#loginPwd").val()=="12345678") { $("#loginPwd").val(""); }
		}).blur(function() {
			if ($("#loginPwd").val()=="")  { $("#loginPwd").val("12345678"); }
		});
		
	$("* #gSearch").click(function() {
		
		if (!document.getElementById("GoogleDialog")) {
			$("body").append("<div id=\"GoogleDialog\" />");
		}
		
		// Keresendő kifejezés: <input type=\"text\" name=\"GoogleInput\" id=\"GoogleInput\" />
		var gw = $(window).width()-80;
		var gh = $(window).height()-80;
		
		$("#GoogleDialog").html("<div class=\"smallGoogle spct\" rel=\"Google keresés...\"></div><br /><br /><iframe name=\"ajax\" src=\"http://www.google.mw/cse?cx=partner-pub-8791355834981687%3Argb74xrqq1h\" id=\"ajax\" style=\"width: 99%;clear: both;display: block; height: "+(gh-140)+"px; overflow: auto;\"></iframe>");
		
				
		$("#GoogleDialog").dialog({
			modal: true,
			autoOpen: true,
			bgiframe: true,
			width: gw,
			height: gh,
			title: "Keresés a Google-ben...",
			buttons: {
				"Bezár": function() { $(this).dialog("destroy"); }
			}
		});
		
	});
	

		$(document).pngFix();
		
});
  

