//OnLoad
//window.onload = onLoadinit;
//ReSize
//window.onresize = onResizeinit;

$(function() {
	addZoomIcon();
	//loadurl('index.php?m=16897&content=1','banner');
	$("#banner").load("index.php?m=16897&content=1");
	setupZoom();
	//selectSearchType();

	//clientGate.init();
	var c = $('#catalogs');
	if(c.length) {
		var i = c.find('.catalog-item, .catalog-item2');
		i.each(function() {
			var $this = $(this);
			if($this.attr('data-file')) {
				var url = '/fajl.php?id=' + $this.attr('data-file') + '&save=1';
				$this.append('<a href="' + url + '" class="pnglink">Letöltés</a>');
			}
		});
		i.filter(':nth-child(3n)').after('<div style="clear:both;"></div>');
	}
});

/*function onLoadinit() {
	loadurl('index.php?m=16897&content=1','banner');
	setupZoom();
	selectSearchType('product');
	addZoomIcon();
}
function onResizeinit(){
	
}*/


function selectSearchType() {
	/*var form = document.forms['searchform'];
	
	for( i = 0; i < form.searchtype.length; i++ )
		{
			if( form.searchtype[i].checked == true )
			type = form.searchtype[i].value;
		}*/
		
	/*var keresoinput = document.getElementById("keresoinput");
	
	if (type == "product") {
		document.searchform.action = '/index.php?m=16903';
		keresoinput.innerHTML='<input type="text" name="fXid" class="input" value="cikkszám (min. 4 betű)" onblur="if(this.value==\'\') this.value=\'cikkszám (min. 4 betű)\';" onfocus="this.value=\'\';">';
	} else if (type == "page") {
		document.searchform.action = '/index.php?m=search';
		keresoinput.innerHTML='<input type="text" name="INC_string" class="input" value="kulcsszó" onblur="if(this.value==\'\') this.value=\'kulcsszó\';" onfocus="this.value=\'\';"/>';
	}*/

	/*jQuery*/
	$("input#search_product").attr("checked","checked");
	$("form#search").attr("action",'/index.php?m=16903');
	$("#keresoinput input").attr("name",'fXid');
	$("#keresoinput input").attr("title",'Cikkszám (min. 4 karakter)');
	
	$("input#search_product").click(function(){
		$("form#search").attr("action",'/index.php?m=16903');
		$("#keresoinput input").attr("name",'fXid');
		$("#keresoinput input").attr("title",'Cikkszám (min. 4 karakter)');
	});

	$("input#search_page").click(function(){
		$("form#search").attr("action",'/index.php?m=search');
		$("#keresoinput input").attr("name",'INC_string');
		$("#keresoinput input").attr("title",'Írjon be egy kulcsszót...');
	});
}


function addZoomIcon(){
	$("#content_content a[href*=kep.php]:has(img)").prepend('<span class="zoomicon"></span>');
    $("#content_content a[href*=kep.php]:has(img)").hover(function(){
				titleText = $(this).attr("title");
				//alert(titleText);
				altText = $(this).children("img").attr("alt");
				$(this).removeAttr("title");
				$(this).children("img").removeAttr("alt");
				$(this).children("span.zoomicon").css({left: $("img", this).position().left+$("img", this).width()-16,top: $("img", this).position().top+$("img", this).height()-16});
        $(this).children("span.zoomicon").show();
    },function(){
        $(this).children("span.zoomicon").hide();
				$(this).attr("title",titleText);
				$(this).children("img").attr("alt",altText);
    });
		$("#content_content a[href*=kep.php]:has(img)").click(function(){
			$(this).children("span.zoomicon").hide();
			if(titleText!='')
			$(this).attr("title",titleText);
			else
			$(this).attr("title",altText);
		});
}


var clientGate = {

	init: function() {
		this.placeholder('cgUsername');
		this.placeholder('cgPassword');
	},


	placeholder: function(id) {
		var input = $('#' + id);
		input.focus(function() {
			if(input.val() == input.attr('title')) input.val('');
		}).blur(function() {
			if(!input.val().length) input.val(input.attr('title'));
		});
		input.blur();
	}

};
