// Navigation Animation, Form Checking and Form Clearing

    
<!-- Let's do the animation -->
var $j = jQuery.noConflict();

  $j(function() {
    // set opacity to nill on page load
    $j("ul#nav span").css("opacity","0");
    // on mouse over
    $j("ul#nav span").hover(function () {
      // animate opacity to full
      $j(this).stop().animate({
        opacity: 1
      }, "fast");
    },
    // on mouse out
    function () {
      // animate opacity to nill
      $j(this).stop().animate({
        opacity: 0
      }, "slow");
    });
  });

/* Select the appropriate navigation tab */
    
var $b = jQuery.noConflict();

$b(function(){
   var path = location.pathname.substring(1);
   if ( path )
     $b('#nav a[href$="' + path + '"]').attr('class', 'selected');
 });

/* BEGIN DRAG DROP */
var $t = jQuery.noConflict();
    $t(function() {
      
    //cache selector
    var images = $t("#container img"),
      title = $t("title").text() || document.title;
    
      //make images draggable
      images.draggable({
      //create draggable helper
      helper: function() {
        return $t("<div>").attr("id", "helper").html("<span>" + title + "</span><img id='thumb' src='" + $t(this).attr("src") + "'>").appendTo("body");
      },
      cursor: "pointer",
      cursorAt: { left: -10, top: 20 },
      zIndex: 99999,
      //show overlay and targets
      start: function() {
        $t("<div>").attr("id", "overlay").css("opacity", 0.7).appendTo("body");
      $t("#tip").remove();
      $t(this).unbind("mouseenter");
      $t("#targets").css("left", ($t("body").width() / 2) - $t("#targets").width() / 2).slideDown();
      },
      //remove targets and overlay
      stop: function() {
        $t("#targets").slideUp();
      $t(".share", "#targets").remove();
        $t("#overlay").remove();
      $t(this).bind("mouseenter", createTip);
      }
    });
    
    //make targets droppable
    $t("#targets li").droppable({
      tolerance: "pointer",
      //show info when over target
      over: function() {
        $t(".share", "#targets").remove();
        $t("<span>").addClass("share").text("Share on " + $t(this).attr("id")).addClass("active").appendTo($t(this)).fadeIn();
      },
      drop: function() {
        var id = $t(this).attr("id"),
        currentUrl = window.location.href,
        baseUrl = $t(this).find("a").attr("href");

      if (id.indexOf("twitter") != -1) {
        window.location.href = baseUrl + "/home?status=" + title + ": " + currentUrl;
      } else if (id.indexOf("delicious") != -1) {
        window.location.href = baseUrl + "/save?url=" + currentUrl + "&title=" + title;
      } else if (id.indexOf("facebook") != -1) {
        window.location.href = baseUrl + "/sharer.php?u=" + currentUrl + "&t=" + title;
      } else if (id.indexOf("digg") != -1) {
        window.location.href = baseUrl + "/submit?url=" + currentUrl + "&title=" + title;
      } else if (id.indexOf("stumble") != -1) {
        window.location.href = baseUrl + "/submit?url=" + currentUrl + "&title=" + title;
      }   
      }
      });
    
      var createTip = function(e) {
      //create tool tip if it doesn't exist
      ($t("#tip").length === 0) ? $t("<div>").html("<span>Drag this image to share this product<\/span><span class='arrow'><\/span>").attr("id", "tip").css({ left:e.pageX + 30, top:e.pageY - 16 }).appendTo("body").fadeIn(1000) : null;
    };
    
    images.bind("mouseenter", createTip);
    
    images.mousemove(function(e) {
    
      //move tooltip
          $t("#tip").css({ left:e.pageX + 30, top:e.pageY - 16 });
        });
    
      images.mouseleave(function() {
    
      //remove tooltip
      $t("#tip").remove();
      });
    });


/*END DRAG DROP */


jQuery.noConflict();
     
     // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
       jQuery("sizeChart_content").hide();
     });
     
     // Use Prototype with $(...), etc.
     //$('someid').hide();



function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

/* Clear default form value script */
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
  with (document){ if (getElementById){
    var obj = getElementById(objId);} if (obj) obj.value = newText;
  }
}
