if (Components.utils.import) {
  try {
    Components.utils.import("rel:Microformats.js");
    Components.utils.import("rel:hCard.js");
	Components.utils.import("rel:hReviewAggregate.js");
	Components.utils.import("rel:hReview.js");
    Components.utils.import("rel:money.js");
    EXPORTED_SYMBOLS = ["hProduct"];
  } catch (ex) {}
}

function hProduct(node) {
  if (node) {
    Microformats.parser.newMicroformat(this, node, "hProduct");
  }
}
hProduct.prototype.toString = function() {
  return this["fn"];
}

var hProduct_definition = {
  mfVersion: 0.8,
  description: "hProduct",
  mfObject: hProduct,
  className: "hproduct",
  required: ["fn"],
  properties: {
    "fn" : {
      required: true
    },
	"photo" : {
      plural: true,
      subproperties: {
        "link" : {
          virtual: true,
          datatype: "anyURI"
        },
        "text" : {
          virtual: true
        }
      }
    },
	"url" : {
      subproperties: {
        "link" : {
          virtual: true,
          datatype: "anyURI"
        },
      }
    },
	"price" : {
      subproperties : {
        "money" : {
          virtual: true,
          datatype: "microformat",
          microformat: "money"
        }
      }
    },
	"hreview" : {
		plural:	true,
		microformat: "hReview",
		datatype: "microformat"
    },
	"hreview-aggregate" : {
        microformat: "hReviewAggregate",
		datatype: "microformat"
    },
	"brand" : {
    },
	"availability" : {
    },
	"description" : {
    },
	"identifier" : {
    },
	"category" : {
    },
	"price" : {

    },
    "summary" : {
    },
	validate: function(node, error) {
		var errormsg;
		var hreview = Microformats.parser.getMicroformatProperty(node, "hReview", "hreview");
		if (hreview) {
		  if (hreview instanceof hReview) {
			if (!item.fn) {
			  errormsg =  "No fn specified on the hCard for the item";
			}
		  } 
		}
	}
  }
};

Microformats.add("hProduct", hProduct_definition);

var hproduct_firefox_bookmark = {
  scope: {
    semantic: {
      "hProduct" : "hProduct",
    }
  }
};

var hproduct_google_search = {
  scope: {
    semantic: {
      "hProduct" : "item.fn"
    }
  }
};

var hproduct_yahoo_search = {
  scope: {
    semantic: {
      "hProduct" : "item.fn"
    }
  }
};

SemanticActions.add("firefox_bookmark", hproduct_firefox_bookmark);
SemanticActions.add("google_search", hproduct_google_search);
SemanticActions.add("yahoo_search", hproduct_yahoo_search);

