jQuery(document).ready(function() {
	
	$('.share_email').fancybox({
	    scrolling: 'no',
	    width: 370,
	    height: 500,
	    autoDimensions: false,
	    autoScale: false
	  });

  $('.share').shareIt({
    title: "Megosztás",
    facebook_icon: "/theme/images/facebook.png",
    iwiw_icon: "/theme/images/iwiw.png"
  });

	// initialize scrollable
	$(function() {				
		$("#product-scroll").scrollable({ circular: true }).autoscroll({interval: 8000, autopause: true}).navigator({
			navi: "ul#status",
			naviItem: 'a',
			activeClass: 'active',
			history: true				
		});
	});
	
	$(function() {		
		// initialize vertical scrollable
		$("#calculator-scroll").scrollable({ circular: true, vertical: true });	
	});
	
	/*  init a default value for the specified text input  */
	$('#search-input').click(function(){if (this.value === 'keresett kifejezés') $(this).attr('value','');});
	$('#search-input').blur(function(){if (this.value === '') $(this).attr('value','keresett kifejezés');});
	
  $('.product_surface').keyup(function (e) {
 	  var id = $(this).attr('id');
 	  pattern = /product_(\d+)_surface/;
 	  id = pattern.exec(id)[1];
     var m2 = this.value;
     var covarageValue = $('.product_'+id+'_coverage_value').val();
     var covarageDimension = $('.product_'+id+'_coverage_dimension').val();

		 if(covarageDimension == "m2_per_liter"){
	     amount = Math.ceil( m2 / covarageValue );
			}
			else if(covarageDimension == "kg_per_m2"){
				amount = Math.ceil( covarageValue * m2 );
			}

     $('.product_'+id+'_amount').val( amount.toString() );
     // $('.product_'+id+'_recomended_price').val( price.toString() );
   });

/*
	$('#login').click(function(){if (this.value === 'Felhasználónév') $(this).attr('value','');});
	$('#login').blur(function(){if (this.value === '') $(this).attr('value','Felhasználónév');});

	$('#password').click(function(){if (this.value === 'jelszó') $(this).attr('value','');});
	$('#password').blur(function(){if (this.value === '') $(this).attr('value','jelszó');});
*/

	  $('.gallerybox').fancybox();
	
	  $(".imgbox h4").click(function() {
	    $(this).siblings(".gallerybox").first().click();
	  });

});

function print_mail_to_link(lhs, rhs, classname, name) { 
	if(classname == "") {
		document.write("<a href=\"mailto");
	} else {
		document.write("<a class=\"" + classname + "\" href=\"mailto");
	}
	document.write(":" + lhs + "@");
	if(name == "") {
		document.write(rhs + "\">" + lhs + "@" + rhs + "<\/a>");
	} else {
		document.write(rhs + "\">" + name + "<\/a>");
	}
}
