function openWineURL( linkLoc )
{
    /* Opens the wine.com PFC category page. */
    /* locLink should be in the format: location + details. */
    /* For example: navbar-forhim for a link from the navbar under 'for him' */ 
    /* Or 'homepage-rightpod' for a pod. */
    /* Wine tracking should go in this format: cobrand_linkLoc_groupID_refCode */

    var wineBaseURL = "http://www.wine.com/v6/giftcenter/proflowers.aspx";

    var wine1 = "?S=";
    var wine2 = "&CID=";

    var refCode = GetQueryStringParam("ref");
    
    var loc = location.pathname;
    
    if ( loc.lastIndexOf("-") != -1 )
    {
        var groupID = loc.substring(loc.lastIndexOf("-")+1,loc.length);
    }
    
    var cobrand = getCobrand( location );
   
    if ( refCode == null || refCode == "" )
    {
        refCode = "NoRef";
    }
    if ( groupID == null || groupID == "")
    {
        groupID = "NoCat";
    }
    if ( linkLoc == null || linkLoc == "")
    {
        linkLoc = "NoLoc";
    }
    
    var tracking = cobrand + "_" + linkLoc + "_" + groupID + "_" + refCode;
    
    var wineURL = wineBaseURL + wine1 + tracking + wine2 + tracking;
    window.open(wineURL, "_blank");
}

function getCobrand( url )
{
    loc = url.hostname;
    
    if ( loc.toUpperCase().match("REDENVELOPE") != null )
    {
        return "RED";
    }   
    else if ( loc.toUpperCase().match("PROFLOWERS") != null )
    {
        path = url.pathname; 
        if ( path.toUpperCase().match("CHERRYMOONFARMS") != null )
        {
            return "CMF";
        }
        else if ( path.toUpperCase().match("SECRETSPOON") != null )
        {
            return "SSS";
        }
        else
        {
            return "PFC";
        }
    }
    
    return null;
}