/* -------------------------------------------------------Page:           receptek.jsCreated:        November 2011Last Mod:       Nov. 24. 2011jQuery System in receptek.net--------------------------------------------------------- Gabor Csogleicsogleig@gmail.com--------------------------------------------------------- */  /* Disable auto complete in Chrome */if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {	jQuery(window).load(function(){		jQuery('input:-webkit-autofill').each(function(){			var text = jQuery(this).val();			var name = jQuery(this).attr('name');			jQuery(this).after(this.outerHTML).remove();			jQuery('input[name=' + name + ']').val(text);		});	});}	/* Watermarks, etc... */function aprosagok() {	jQuery('.number').watermark('Például: 10', {useNative: false});	jQuery('.Mennyiseg').watermark('Mennyiség...', {useNative: false});	jQuery('.Alapanyag').watermark('Alapanyag...', {useNative: false});		jQuery(".Alapanyag").autocomplete({		source : "options.php?op=Alapanyagok",		matchContains: false,		minLength: 2	});}/* ********************************************************** *//* User settings *//* ********************************************************** *//* Email alerts */function alerts(obj) {	var loader 	= obj.find("#loader");	loader.show();		jQuery.ajax({		url			: "beallitasok.inc.php?op=alerts",		contentType	: "application/json; charset=utf-8",		async		: true,		cache		: false,		dataType	: "json",		success		: function(data) {			loader.hide();			if(data.Ertesito1>0) {jQuery("#Ertesito1").attr("checked","checked");}			if(data.Ertesito2>0) {jQuery("#Ertesito2").attr("checked","checked");}			return false;		}	});}/* ********************************************************** *//* jQuery funtions begin *//* ********************************************************** */jQuery(function(){	var captchaUrl = "admin/includes/captcha/includes/process.php";	var captchaMsg = "Nem megfelelő biztonsági kód. Kattintson a képre, ha új kódot szeretne.";		/* Font ReSizer */	jQuery('.betumeret').click(function(){		var ourText = jQuery('#ebal, #ejobb p');		var currFontSize = ourText.css('fontSize');					var finalNum = parseFloat(currFontSize, 10);		var stringEnding = currFontSize.slice(-2);		if(this.id == 'large') {			finalNum *= 1.1;		}		else if (this.id == 'small'){			finalNum /=1.1;		}		var rounded = Math.round(finalNum);		if(rounded==13){			jQuery('#small').attr('id','small-no');		}		else if(rounded==21){			jQuery('#large').attr('id','large-no');		}		else if(rounded>13 && rounded<21){			jQuery('#large-no').attr('id','large');			jQuery('#small-no').attr('id','small');		}				ourText.css('fontSize', rounded + stringEnding);	});		/* Submit forms */	jQuery("a.submitForm").click(function() {		jQuery(this).parents('form:first').submit();		return false;	});		/* Sub category menu */						jQuery('a.alkat_btn').click(function() {		jQuery(this).parent("li").find("ul").toggle('slow');		return false;	});		/* Print */	jQuery('.print_btn').click(function(){		print();		return false;	});			/* Email address complete */	jQuery(".mailselect").change(function() {		//var obj = jQuery("#Email");		var obj = jQuery(this).parent("td").find("input");			var values=obj.val().split("@");		obj.val("");		obj.val(values[0] + "" + jQuery(this).val()); 		obj.focus();	});		/* Zip code and town autocomplete */	jQuery('#Irsz').blur(function() {		jQuery.ajax({			url			: "admin/telepulesek.php?op=irsz&irsz="+jQuery(this).val(),			contentType	: "application/json; charset=utf-8",			async		: true,			cache		: false,			dataType	: "json",			success		: function(data) {				jQuery("#Varos").val(data.telep);			} 		});	});	jQuery("#Varos").autocomplete({		source : "admin/telepulesek.php?op=telep",		matchContains: false,		minLength: 2	});		/* Upload avatar */	jQuery("a.avatar").click(function() {		var newwin 			= window.open('','kepek',',,directories=no,menubar=no,scrollbars=yes,resizable=no');		var url 			= this.href;		var windowName 		= "Profilkép szerkesztése";//$(this).attr("name");		var windowWidth 	= 827;		var windowHeight 	= 637;				newwin.resizeTo(windowWidth,windowHeight);				if(window.innerWidth) {			newwin.innerWidth 	= windowWidth;			newwin.innerHeight 	= windowHeight;			windowWidth 		= newwin.outerWidth;			windowHeight 		= newwin.outerHeight;			newwin.resizeTo(windowWidth,windowHeight);		}		else {			windowWidth			= newwin.document.body.clientWidth;			windowHeight		= newwin.document.body.clientHeight;		}				var sw = screen.availWidth;		var sh = screen.availHeight;		newwin.moveTo(parseInt((sw-windowWidth)/2),parseInt((sh-windowHeight)/2));		newwin.location.href = url;		 		return false;	});			/* Add new items */	jQuery("a.alapAdd").click(function() {		var hova = jQuery("input.Alapanyag:last");		hova.after("<input type='text' id='Mennyiseg[]' name='Mennyiseg[]' class='w100 Mennyiseg'/>\n<input type='text' id='Alapanyag[]' name='Alapanyag[]' class='w100 Alapanyag'/>");				aprosagok();		return false;	});		/* ********************************************************** */	/* User settings */	/* ********************************************************** */	/* Email alerts modify */	jQuery("a.alertsEmail").click(function() {		var form 	= jQuery(this).parents("form:first");		var msg 	= form.find("p");		var loader 	= form.find("#loader");				var ertesito1 = jQuery("#Ertesito1").is(':checked') ? 1 : 0;		var ertesito2 = jQuery("#Ertesito2").is(':checked') ? 1 : 0;					msg.html("");		loader.show();				jQuery.ajax({			url			: "beallitasok.inc.php?op=alertmod&Ertesito1="+ertesito1+"&Ertesito2="+ertesito2,			contentType	: "text/html; charset=utf-8",			async		: true,			cache		: false,			dataType	: "html",			success		: function(data) {				loader.hide();				msg.html(data).fadeIn(50).delay(2000).fadeOut(1000);				alerts(form);			} 		});		return false;	});		/* ********************************************************** */	/* Send mail */	/* ********************************************************** */		var kuldo = jQuery("#Kuldoemail");		kuldo.focus(function()		{			kuldo.valid();		});		var cimzett = jQuery("#Cimzettemail");		cimzett.focus(function()		{			cimzett.valid();		});		jQuery("#kuldes").validate({		rules: {			captcha: {				required: true,				remote: captchaUrl			}		},		messages: {			captcha: captchaMsg		}	});		jQuery("#dialog-form").dialog({		autoOpen: false,		height: 530,		width: 530,		modal: true,		buttons: {			"Email küldése": function() {				jQuery("#kuldes").submit();			},			"Mégsem": function() {				jQuery(this).dialog("close");			}		}	});			jQuery("#send-mail").click(function() {		jQuery("#dialog-form").dialog("open");		return false;	});			jQuery("#dialog-kep").dialog({			autoOpen: false,			height: 430,			width: 530,			modal: true,			buttons: {				"Kép feltöltése": function() {					jQuery("#kepfeltoltes").submit();				},				"Mégsem": function() {					jQuery(this).dialog("close");					//allFields.val("").removeClass("error");				}			},			close: function() {				//allFields.val("").removeClass("error");			}		});				jQuery("#picture-up").click(function() {			jQuery("#dialog-kep").dialog("open");			return false;		});			/* ********************************************************** */	/* System message */	/* ********************************************************** */	jQuery("#dialog-ok, #dialog-hiba").dialog({		autoOpen: false,		modal: true,		width: 350,		buttons: {			"Bezár": function() {				jQuery(this).dialog("close");			}		}	});		});
