﻿// Copyright 2009, Swimfish
// This file relies on $ support, so the $ library must be included
// before this file.

// There are three values that are used by WebCapture
// SF_Fieldset = (Required) The name given to a collection of fields that will 
// populate a back-end system.
// SF_WebContext = (Required if using Working Lists in InterAction) The context 
// that describes the context the user is doing that initiated the request 
// for data.
// SF_Details = (Optional) The actual thing the user was interested in, such as
// a product category or filename.

// Post data to the WebCapture page for processing and storage.
function SF_WebCapture(formId) {
    try {
        var theform = $("#" + formId);
        var action = theform.attr("action");
        var method = theform.attr("method");

        var curDate = new Date();

        theform.attr("action", "http://demo.swimfish.com/webcapture/WebCapture.aspx?dts=" + curDate.getSeconds());
        theform.attr("method", "post");
        theform.submit();

        var redir = "window.location='" + action + "';";

	    setTimeout(redir,500);
   
    }
    catch (ex) {
        //alert("required hidden fields may be missing");
    }
}

function SF_ExtractAttribute(oTag, attribute) {
    if (oTag != null) {
        if (attribute == null)
            attribute = "href";

        try {
            return $(oTag).attr(attribute);
        }
        catch (ex) {
            return "";
        }
    }
    else
        return "";
}
