$(function() {
	var offsetX = -450;
	var offsetY = -220;
	jQuery('#imgs a').hover(function(e){
	//mouse on
		var href = jQuery(this).attr('href');
		jQuery('<img id="largeimage" src="' + href +'" alt="image" />')
		.css('top', e.pageY+offsetY)
		.css('left', e.pageX+offsetX)
		.appendTo('body');
	}, function(){
	//mouse off
		jQuery('#largeimage').remove();
	});
	
	jQuery('#imgs a').mousemove(function(e){
		jQuery('#largeimage')
		.css('top', e.pageY+offsetY)
		.css('left', e.pageX+offsetX);
	});
});
$(function() {
	var offsetX = 50;
	var offsetY = -80;
	jQuery('#images a').hover(function(e){
	//mouse on
		var href = jQuery(this).attr('href');
		jQuery('<img id="largeimage" src="' + href +'" alt="image" />')
		.css('top', e.pageY+offsetY)
		.css('left', e.pageX+offsetX)
		.appendTo('body');
	}, function(){
	//mouse off
		jQuery('#largeimage').remove();
	});
	
	jQuery('#images a').mousemove(function(e){
		jQuery('#largeimage')
		.css('top', e.pageY+offsetY)
		.css('left', e.pageX+offsetX);
	});
});
$(function() {
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.sub_info_menu").tabs("div.info_blocks > div");
});
$(function() {
    $('.ask_error').hide();
    $('#ask_submit').click(function() {
        $('.ask_error').hide(); 
        var name = $("input#name").val();
		if (name.length < 3) {
            $("label#name_error").show();
            $("input#name").focus();
            return false;
        }
    	var email = $("input#email").val();
    	if (email.length < 5) {
          $("label#email_error").show();
          $("input#email").focus();
          return false;
        }
    	var question = $("textarea#question").val();
    	if (question.length <= 10) {
          $("label#question_error").show();
          $("textarea#question").focus();
          return false;
       }
       
       var goodID = $("input#goodID").val();
         
       var dataString = 'name='+ name + '&email=' + email + '&question=' + question + '&goodID=' + goodID;
      $.ajax({
        type: "POST",
        url: "send_question.php",
        data: dataString,
        success: function() {
            $('#question_form').html("<p></p>")
            .append("<strong>Greitai su Jumis susisieksime.</strong>");
      }
     });
    return false;
    }) 
});
$(function() {
    $('.form_error').hide();
    $('#recommend_submit').click(function() {
        $('.form_error').hide(); 
        var name = $("input#name_rec").val();
		if (name.length < 3) {
            $("label#name_error_rec").show();
            $("input#name_rec").focus();
            return false;
        }
    	var email = $("input#email_rec").val();
    	if (email.length < 5) {
          $("label#email_error_rec").show();
          $("input#email_rec").focus();
          return false;
        }
    	
       var comment = $('textarea#comment').val();
       
       var goodID = $("input#goodID").val();
         
       var dataString = 'name=' + name + '&email=' + email + '&comment=' + comment + '&goodID=' + goodID;
      $.ajax({
        type: "POST",
        url: "send_recommend.php",
        data: dataString,
        success: function() {
            $('#recommend_form').html("<p></p>")
            .append("<strong>Sėkmingai rekomendavote prekę draugui.</strong>");
      }
     });
    return false;
    }) 
});

$(function() {
    $('.rollover').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });
});
