var errorstr = '';

///////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
	if(window.AntiSpam_mailto) AntiSpam_mailto();
	$('input[type=text]:not(.typetext)').addClass('typetext');
	$('input[type=password]:not(.typetext)').addClass('typetext');
	$('input[type=checkbox]:not(.typecheckbox)').addClass('typecheckbox');
	$('input[type=radio]:not(.typeradio)').addClass('typeradio');
	$('input[type=file]:not(.typefile)').addClass('typefile');
	$('input[type=submit]:not(.typesubmit)').addClass('typesubmit');
	$('input[type=reset]:not(.typesubmit)').addClass('typesubmit');
	if($().TextAreaResizer) $('textarea.resizable:not(.processed)').TextAreaResizer();

	if($().lightbox) $('a[rel*=lightbox]').lightbox({
		fileLoadingImage : 'res/jquery/lightbox/loading.gif',
		fileBottomNavCloseImage : 'res/jquery/lightbox/close.gif',
		overlayOpacity : 0.8,
		borderSize : 10,
		displayTitle: true,
		strings : {
			prevLinkTitle: 'Előző kép',
			nextLinkTitle: 'Következő kép',
			prevLinkText:  '&laquo; Előző',
			nextLinkText:  'Következő &raquo;',
			closeTitle: 'Bezár',
			image: 'Kép ',
			of: ' / '
			},
		fitToScreen: true// resize images if they are bigger than window
		});

	if(window.LANG && LANG=='en'){
		if($().lightbox) $('a[rel*=lightbox]').lightbox({
			fileLoadingImage : 'res/jquery/lightbox/loading.gif',
			fileBottomNavCloseImage : 'res/jquery/lightbox/close.gif',
			overlayOpacity : 0.8,
			borderSize : 10,
			displayTitle: true,
			strings : {
				prevLinkTitle: 'Next image',
				nextLinkTitle: 'Previous image',
				prevLinkText:  '&laquo; Previous',
				nextLinkText:  'Next &raquo;',
				closeTitle: 'Close',
				image: 'Image ',
				of: ' / '
				},
			fitToScreen: true// resize images if they are bigger than window
			});
		};

	if(window.deftext) deftext.init();
//	if(window.alphaFixIE) alphaFixIE();

	if(window.customOnLoad_doc) customOnLoad_doc();
	if(window.errorstr) setTimeout('alert(errorstr);', 100);
	});

///////////////////////////////////////////////////////////////////////////////
function AntiSpam_mailto(){
	$("span[class='email']").each(function(){
		var mailtoVal = $(this).html().replace('[KUKAC]', '@').replace('[PONT]', '.');
		var titleVal = $(this).attr('title').replace('[KUKAC]', '@').replace('[PONT]', '.');
		if(!titleVal) titleVal = mailtoVal;
		var s = mailtoVal.match(/subject=([^&]*)/);
		if(s) mailtoVal = mailtoVal.replace(/(subject=)([^&]*)/, '$1'+escape(s[1]));
		$(this).replaceWith('<a href="mailto:'+mailtoVal+'" class="email">'+titleVal+'</a>')
		});
	}

///////////////////////////////////////////////////////////////////////////////
function form_check(formname, notnull, class_good, class_bad){
	var obj_form = document.forms[formname];
	if(!obj_form) return false;

	var badpresent = false;
	for(var i=0; i<notnull.length; i++){
		var obj_notnull = obj_form[notnull[i]];
		if(obj_notnull.value.length == 0){
			obj_notnull.className = class_bad;
			if(!badpresent) obj_notnull.focus();
			badpresent = true;
			}
		else obj_notnull.className = class_good;
		}
	return !badpresent;
	}

