/*
  TradesmanTruck.com
  ##############################
  Updated:
      January 23, 2012
  Developer:
      Jeff Vogelpohl
      http://www.geekinit.com
*/

/*
  <script type="text/javascript" src="assets/scripts/tradesman_api.js"></script>
*/

$(document).ready(function() {
    var $zqclicked = 0;
    $("#zqbox").val("search the site...");
    $("#zqbox").click(function() {
      $zqclicked = $zqclicked + 1;
      switch ($zqclicked) {
          case 1:
            $(this).val("");
            break;
      }
    });
    $("a[rel='lightbox']").fancybox( {
        'overlayShow'	: true,
        'overlayOpacity' : 0.95,
        'overlayColor' : '#000000',
        'titlePosition' : 'inside',
        'showCloseButton' : true,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic'
    });
    
    $.showPreview = function(imageSource) {
        $("#previewImage").attr("src",imageSource);
    };
    
    $.checkIfValid = function(elementName) {
        elementObject = $(elementName);
        if (elementObject.find("input").val() == "")
        {
          elementObject.find("input").css("border","3px solid #ff0000");
        }
        else
        {
          elementObject.find("input").css("border","1px solid #000000");
        }
    };

    $.checkIfValid($("#divPostName"));
    $.checkIfValid($("#divPostPhone"));
    $.checkIfValid($("#divPostEmail"));
    $.checkIfValid($("#divPostZip"));
    $.checkIfValid($("#divPostVerification"));

    $("#divPostName").focusin(function() {
        $.checkIfValid($(this))
    }).focusout(function() {
        $.checkIfValid($(this))
    });

    $("#divPostPhone").focusin(function() {
        $.checkIfValid($(this))
    }).focusout(function() {
        $.checkIfValid($(this))
    });

    $("#divPostEmail").focusin(function() {
        $.checkIfValid($(this))
    }).focusout(function() {
       $.checkIfValid($(this))
    });

    $("#divPostZip").focusin(function() {
        $.checkIfValid($(this))
    }).focusout(function() {
       $.checkIfValid($(this))
    });

    $("#divPostVerification").focusin(function() {
        $.checkIfValid($(this))
    }).focusout(function() {
       $.checkIfValid($(this))
    });
});
