
function sendnewpwd() {

	var email = $("#forgotEmail").val();

	$.post("/documents/fuzesgyarmat/php/forgotpwd.php", { 
			email: email 
		}, function(xml) {
			
			document.getElementById("forgot_ajax").innerHTML = xml;
			
			var Timeout = setTimeout(function() {
					
				if (!document.getElementById("forgotDialog")) {
					$("#forgotDialog").dialog("destroy").remove();
				}
			}, 3000);
			
		});
		
}

function errorMessage(text) {
	
	if (!document.getElementById("errMsg")) {
		$("body").append("<div id=\"errMsg\"></div>");
	}
	
	$("#errMsg").dialog({
		modal: true,
		title: "Hiba történt!",
		autoOpen: true, 
        resizable: false,
        height: 200,
		open: function() {
			$(this).html(text);
		},
		buttons: {
			"Rendben": function() {
				$(this).dialog("destroy");
			}
		}
	});
     
    $(".ui-dialog").css("zIndex", 399900);
    $(".ui-widget-overlay").css("zIndex", 399000);
    
	return false;
	
}

function alertMessage(text, title) {
	
	if (!document.getElementById("alertMsg")) {
		$("body").append("<div id=\"alertMsg\"></div>");
	}
	
	$("#alertMsg").dialog({
	modal: true,
	bgiframe: true,
	title: title,
    resizable: false,
	autoOpen: true, 
	open: function() {
		$(this).html(text);
	},
	buttons: {
		"OK": function() {
			$(this).dialog("destroy");
		}
	}
	});
    
    $(".ui-dialog").css("zIndex", 399900);
    $(".ui-widget-overlay").css("zIndex", 399000);
	
	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,
    resizable: false,
	autoOpen: true, 
	open: function() {
		$(this).html(text);
	},
	buttons: {
		"Rendben": function() {
			action();
			$(this).dialog("destroy");
		}
	}
	});
	
    $(".ui-dialog").css("zIndex", 399900);
    $(".ui-widget-overlay").css("zIndex", 399000);
    
	return false;
}


function Register() {
    
    if (!document.getElementById("regForm")) {
        $("body").append("<iframe name=\"regFrame\" allowTransparency=\"true\" id=\"regFrame\" />");
        $("body").append("<div id=\"regForm\" />");
    }

    rLeft = $(window).width()/2-250;
    
    $("#regFrame").css({
        position: "absolute",
        left: rLeft+5,
        top: 55,
        width: 500,
        padding: 0,
        height: 370,
        background: "#fff",
        WebkitBorderRadius: 10, 
        MozBorderRadius: 10, 
        BorderRadius: 10,
        zIndex: 299990,
        display: "none"
     }).stop().show(800);
        
    $("#regForm").load("/documents/fuzesgyarmat/php/regform.php").css({
        position: "absolute",
        left: rLeft,
        top: 50,
        width: 500,
        padding: 10,
        height: 370,
        background: "#fff",
        border: "1px solid #ccc",
        WebkitBorderRadius: 10, 
        MozBorderRadius: 10, 
        BorderRadius: 10,
        zIndex: 299999
    }).show("drop", 800).animate({
        width: 500
    }, 1000).expose({api: true, closeOnClick: false, closeOnEsc: false});
        
    
}

function userInfo(id) {
    
    if (!document.getElementById("userInfo")) {
        $("body").append("<iframe name=\"userInfoFrame\" id=\"userInfoFrame\" allowTransparency=\"true\" />");
        $("body").append("<div id=\"userInfo\" />");
    }

    rLeft = $(window).width()/2-250;
   
     $("#userInfoFrame").css({
        position: "absolute",
        left: rLeft+5,
        top: 55,
        width: 500,
        padding: 0,
        height: 400,
        background: "#fff",
        WebkitBorderRadius: 10, 
        MozBorderRadius: 10, 
        BorderRadius: 10,
        display: "none",
        zIndex: 299990
    }).stop().show(800);
        
    $("#userInfo").load("/documents/fuzesgyarmat/php/userinfo.php?userid="+id).css({
        position: "absolute",
        left: rLeft,
        top: 50,
        width: 500,
        padding: 10,
        height: 400,
        background: "#fff",
        border: "1px solid #ccc",
        WebkitBorderRadius: 10, 
        MozBorderRadius: 10, 
        BorderRadius: 10,
        zIndex: 299999
    }).show("drop", 800).animate({
        width: 500
    }, 1000).expose({api: true, closeOnClick: false, closeOnEsc: true, onClose: function() { $("#userInfoFrame").hide(); $("#userInfo").hide("drop", 800, function() { $("#userInfoFrame").remove(); $("#userInfo").remove(); }); } }).disableSelection();
    
}

function sendActivation() {
        var email = $("#regForm #email").val();
        var fullname = $("#fullname").val();
        var username = $("#username").val();
        var pwd = $("#pwd").val();
        var pwd1 = $("#pwd1").val();
        var error = 0;
        var errorString = "";
        
        if (pwd!=pwd1 || pwd.length<3) {
            error = 1;
            errorString += "A megadott jelszavak nem egyeznek, vagy túl rövid a megadott jelszó! (minimum 5 karakter) \r\n";                 
        }
        
        if (fullname.length<5) {
            error = 1;
            errorString += "A megadott név túl rövid! \r\n"; 
        }
        
        if (email.indexOf("@")<1 || email.length<4) {
            error = 1;
            errorString += "A megadott E-mail cím nem megfelelő! \r\n";
        }     
           
        if (username.length<4)
        {
            error = 1;
            errorString += "A megadott Felhasználó név túl rövid! (min. 4 karakter!) <br />";
        }
        
        if (error==0) {
            $.post("/documents/fuzesgyarmat/php/register.php", {
                mode: 0,
                email: email,
                fullname: fullname,
                username: username,
                password: pwd
            }, function(xml) {
                alertMessage(xml, "Regisztr&aacute;ci&oacute; az oldalra", function() { $.mask().close(); });
            });
        } else {
            errorMessage(errorString);
        }
}

function saveUserDatas() {
    
        var email = $("#userInfo #email").val();
        var fullname = $("#fullname").val();
        var username = $("#username").val();
        var oldpassword = $("#oldpassword").val();
        var pwd = $("#pwd").val();
        var pwd1 = $("#pwd1").val();
        var error = 0;
        var errorString = "";
        
        if (pwd!=pwd1 && pwd.length>3) {
            error = 1;
            errorString += "A megadott jelszavak nem egyeznek! <br/> ";                 
        }
        
        if (fullname.length<5) {
            error = 1;
            errorString += "A megadott név túl rövid! <br /> "; 
        }
        
        if (email.indexOf("@")<1 || email.length<4) {
            error = 1;
            errorString += "A megadott E-mail cím nem megfelelő! <br /> ";
        }
        
        if (username.length<4)
        {
            error = 1;
            errorString += "A megadott Felhasználó név túl rövid! (min. 4 karakter!) <br />";
        }
        
        if (error==0) {
            $.post("/documents/fuzesgyarmat/php/register.php", {
                mode: 1,
                email: email,
                fullname: fullname,
                username: username,
                oldpassword: oldpassword,
                password: pwd
            }, function(xml) {
                alertMessage(xml, "Adatok m&oacute;dos&iacute;t&aacute;sa");
            });
        } else {
            errorMessage(errorString);
        }
}
    
function needReg() {
    errorMessage("A funkció használatához Regisztráció szükséges!");
}
 


function forgotpwd() {

    if (!document.getElementById("forgotDiag")) {
    	$("body").append("<div id=\"forgotDiag\" />");
    }
    
    $("#forgotDiag").html("<br /> <b>Kérünk, adja meg e-mail címét amivel a rendszerbe regisztrált! </b><br /><div id=\"ajax\"></div><br /> <input type=\"text\" id=\"forgotEmail\" class=\"ui-input ui-state-default ui-corner-all ui-helper-clearfix\" style=\"float: left; width: 370px; padding: 2px; margin-bottom: 10px;\" name=\"mail\" /><br /> <div class=\"ui-widget ui-state-highlight ui-corner-all ui-helper-clearfix\" style=\"float: left; clear: both; width: 98%; padding: 3px;\">A megadott e-mail címre küldünk egy új jelszót, melyet később meg tud változtatni az oldalon történő belépés után, az \"Adataim\" menüponton keresztül!</div>");	
    
    $("#forgotDiag").dialog({
    	modal: true,
        bgiframe: true,
        autoOpen: true,
    	width: 400,
        height: 270,
    	title: "Elfelejtett jelszó",
    	buttons: {
    		"Új jelszó küldése": function() {
    				var mail = $("#forgotEmail").val();
    				$.post("/documents/fuzesgyarmat/php/forgotpwd.php", {
    					email: mail
    				}, function(xml) {
    					$("#forgotDiag #ajax").html(xml);
    					var timeOutID = setTimeout(function() { $("#forgotDiag").dialog("destroy"); }, 2000);
    				});
    			
    		},
    		"Mégse": function() {
    			$(this).dialog("destroy");
    		}
    	}
    });
	$(".ui-dialog").css("zIndex", 399900);
    $(".ui-widget-overlay").css("zIndex", 399000);

}

var min=8;
var max=18;

$(function() {
    $('ul.sf-menu').superfish();
    
    if (document.getElementById("Player"))
    {
        $("#Player ul").cycle(
        {
        	fx: "fade",
        	pager: "#pager",
        	next: "#next",
        	prev: "#prev",
        	timeout: 5000,
        	speed: 1500
        });
    
    $("#Player").mouseenter(function() { $("#Player .navigation").fadeIn(400); }).mouseleave(function() {$("#NavBar").fadeOut(400); }); 
    }
     
      
    $(".ui-button, .sendnewstdsearchbut").button();
    
});

function increaseFontSize() {
   var p = $("#Content a, #Content p, #fulltext_2, #fulltext_1, #Content ul *");
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}

function decreaseFontSize() {
   var p = $("#Content a, #Content p, #fulltext_2, #fulltext_1, #Content ul *");
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}



function newTimeCheck(group, num)
{
    
    if (!document.getElementById("loginForm"))
    {
        
        if (!document.getElementById("newTime"))
            $("body").append("<div id=\"newTime\"></div>");
        
        
        
        ntLeft = $(window).width()/2-200;
   
        $("#newTime").css({
            position: "fixed",
            left: ntLeft,
            top: 100,
            width: 400,
            height: 150,
            background: "#fff",
            MozBorderRadius: 10,
            BorderRadius: 10,
            WebkitBorderRadius: 10
        })
        .load("/documents/fuzesgyarmat/php/timecheck.php")
        .show(500, function() { $(this).expose({api:true, color: "#00601b", closeOnClick: false, onClose: function() { $("#newTime").remove(); } }); });
        
    }
    else
    {
        fnMessage("<b>Az időpontfoglaláshoz előbb regisztrálni kell, vagy be kell lépni!</b>", "Bejelentkezés", function() {
            $("#loginForm").expose({api:true, color: "#00601b"});
        });
    }
    
}
