$(document).ready(function(){
	$('#search input.text').focus(function() {
		if ($(this).attr('value') == $(this).attr('origValue')) {
			$(this).attr('value', '');
		}
	});
	
	$('#search input.text').blur(function() {
		if ($(this).attr('value') == '') {
			$(this).attr('value', $(this).attr('origValue'));
		}
	});
	
	$('#content a.print').click(function()
	{
		window.open(window.document.location.href + '?print','','scrollbars=yes,menubar=yes,height=600,width=540,resizable=yes,toolbar=yes,location=no,status=no');
	});
	
	
	$(window).load(function()
	{
		$('div.news div.image a img, div.news a.image img, #content .product_box .left .image a img, #content .product_box .right .image a img').each(function()
		{
			var w = $(this).width();
			var h = $(this).height();
			$(this).css('padding-left', (128 - w ) / 2);
			$(this).css('padding-top', (96 - h ) / 2);
		});

		$('div.offer_box a.image img').each(function()
		{
			var w = $(this).width();
			var h = $(this).height();
			$(this).css('padding-left', (134 - w ) / 2);
			$(this).css('padding-top', (112 - h ) / 2);
		});
		
		$('#gallery div.gallery_picture a img').each(function()
		{
			var w = $(this).width();
			var h = $(this).height();
			$(this).css('padding-left', (125 - w ) / 2);
			$(this).css('padding-top', (85- h ) / 2);
		});
	});
	
	
	if ($('#contact_form')) {
		$('#contact_form input[type=button].send_kerdoiv').click(function()
		{
			$('#contact_form').submit();
		});
		
		$('#contact_form input[type=button].send').click(function()
		{
			if($('#contact_form input[name="name"]').val() == "") 
			{
				alert('A Név mezőt ki kell tölteni!');
				$('#contact_form input[name="name"]').focus();
				return false;
			}
			
			if($('#contact_form input[name=email]').val() == "") 
			{
				alert('Az Email mezőt ki kell tölteni!');
				$('#contact_form input[name=email]').focus();
				return false;
			}
			
			var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
			
			if(!re.test($('#contact_form input[name=email]').val())) 
			{
				alert('Kérjük valós Email címet adjon meg.');
				$('#contact_form input[name=email]').focus();
				return false;
			}
			
			if($('#contact_form textarea[name=message]').val() == "") 
			{
				alert('Az Üzenet mezőt ki kell tölteni!');
				$('#contact_form textarea[name=message]').focus();
				return false;
			}
			
			$('#contact_form').submit();
		});
	}
});
