Learn how to use jQuery at the Blog

Smith and Hall « visit

  • Added 10 months ago
  • 117 Lines of Code shown
  • 2 Links of Interest
http://smithandhall.com.au
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Smith and Hall - http://smithandhall.com.au

$(document).ready( function() {
  /* Form Code */
  $("#freeGuideForm").submit(function(){
    if ($("#g_name").val()=='') $("#g_name_li").effect("shake", { times: 3 }, 100);
    else if ($("#g_mobile").val()=='') $("#g_mobile_li").effect("shake", { times: 3 }, 100);
    else if ($("#g_email").val()=='') $("#g_email_li").effect("shake", { times: 3 }, 100);
    else return true;
    return false;
  }); 

  $("#enquiryForm").submit(function(){
    if ($("#e_name").val()=='') $("#e_name_li").effect("shake", { times: 3 }, 100);
    else if ($("#e_mobile").val()=='') $("#e_mobile_li").effect("shake", { times: 3 }, 100);
    else if ($("#e_email").val()=='') $("#e_email_li").effect("shake", { times: 3 }, 100);
    else return true;
    return false;
  });

  $("#emailFriendForm").submit(function(){
    if ($("#my_name").val()=='') $("#my_name_li").effect("shake", { times: 3 }, 100);
    else if ($("#friend_name").val()=='') $("#friend_name_li").effect("shake", { times: 3 }, 100);
    else if ($("#friend_email").val()=='') $("#friend_email_li").effect("shake", { times: 3 }, 100);
    else return true;
    return false;
  });

  //Note that this is for competition not rsvp for events
  $("#rsvpForm").submit(function(){
    if ($("#r_fname").val()=='') $("#r_fname_li").effect("shake", { times: 3 }, 100);
    else if ($("#r_lname").val()=='') $("#r_lname_li").effect("shake", { times: 3 }, 100);
    else if ($("#r_email").val()=='') $("#r_email_li").effect("shake", { times: 3 }, 100);
    else if ($("#r_mobile").val()=='') $("#r_mobile_li").effect("shake", { times: 3 }, 100);
    else if ($("#r_postcode").val()=='') $("#r_postcode_li").effect("shake", { times: 3 }, 100);
    else return true;
    return false;
  });

  /* Gallery Code */
  $("#showAdv").click(function(){
    $("#advancedSearch").slideToggle(400);
    return false;
  });

  $('#cf').click(function() { 
    $("#cf").addClass('current');
    $("#gr").removeClass('current');
    $("#content").removeClass('three'); 
    $("#galleryGrid").hide();
    searchRefresh();
//    $("#imageFlowContainer").fadeIn(400);
    return false;
  });

  $('#gr').click(function() { 
    $("#cf").removeClass('current');
    $("#gr").addClass('current');
    $("#content").addClass('three'); 
    $("#imageFlowContainer").hide();
    $("#galleryGrid").fadeIn(400);
    return false;
  });

  $('#quickfind').change(
    function() {
     searchRefresh();
     $('#artist').val($('#quickfind').val());
    }
  ); 

  $('#artist').change(
    function() {
     $('#quickfind').val($('#artist').val());
     searchRefresh();
    }
  );

  $('#price').change(function(){searchRefresh()}); 
  $('#medium').change(function(){searchRefresh()}); 
  $('#genre').change(function(){searchRefresh()}); 
  $('#characteristic').change(function(){searchRefresh()}); 
  $('#style').change(function(){searchRefresh()}); 
  $('#career').change(function(){searchRefresh()}); 
  $('#size').change(function(){searchRefresh()}); 
  $('#colour').change(function(){searchRefresh()}); 
  
});


function searchRefresh() {
  $("#imageFlowContainer").hide();
  $("#galleryGrid").hide();
  $("#loadIndicator").show();
  $("#galleries").load('/galajax/?r='+$('#rental').val()+'&a='+$('#quickfind').val()
                      +'&p='+urlencode($('#price').val())
                      +'&m='+urlencode($('#medium').val())
                      +'&g='+urlencode($('#genre').val())
                      +'&c='+urlencode($('#characteristic').val())
                      +'&s='+urlencode($('#style').val())
                      +'&ca='+urlencode($('#career').val())
                      +'&si='+urlencode($('#size').val())
                      +'&co='+urlencode($('#colour').val()), '', 
  function(responseText) {
    var instanceOne = new ImageFlow();
    instanceOne.init({ ImageFlowID:'myImageFlow', reflections: false, reflectionP: 0.4, opacity: true, imageFocusM: 1, xStep: 100 });
    $("#loadIndicator").hide();

    if ($("#cf").hasClass('current'))
      $("#imageFlowContainer").fadeIn(400);
    else
      $("#galleryGrid").fadeIn(400);
    }
  );
}

function urlencode(str) {
  return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}