﻿

$(document).ready(function() {

var companytag = '';
var producttag = '';
$("#coName, #coUrl, #coTitle, #coLink").live('click', function() {
    urchinTracker('/ClickTracker/Shop/' + companytag);
});

$("#prodTitle, #productLink").live('click', function() {
    urchinTracker('/ClickTracker/Shop/' + companytag + '/' + producttag);
});

    //Full Caption Sliding (Hidden to Visible)
    $('.pcspot').hover(function() {
        $(".pcspot_curtain", this).stop().animate({ top: '70px' }, { queue: false, duration: 160 });
    }, function() {
        $(".pcspot_curtain", this).stop().animate({ top: '180px' }, { queue: false, duration: 160 });
    });
    $('.pcspot_curtain_host').click(function() {

        var pcid = ($(this).attr("pc"));
        var pcimage = ($("#SRC_" + pcid));
        companytag = $(".pcspot_curtain_host[pc='" + pcid + "'] .companyname").text().replace(/[^a-zA-Z0-9]+/g, '');
        producttag = $(".pcspot_curtain_host[pc='" + pcid + "'] .productname").text().replace(/[^a-zA-Z0-9]+/g, '');


        //fill left column
        $("#productLogo").html($(".pcspot_curtain_host[pc='" + pcid + "'] .pcspot_image").html());
        $("#coName").html($(".pcspot_curtain_host[pc='" + pcid + "'] .companyname").html());
        $("#coName").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #companyUrl").attr('href'));

        $("#coAddress").html($(".pcspot_curtain_host[pc='" + pcid + "'] .companyaddress").html());
        $("#coUrl").html($(".pcspot_curtain_host[pc='" + pcid + "'] #companyUrl").text());
        $("#coUrl").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #companyUrl").attr('href'));

        //fill upper product area 
        $("#prodTitle").html($(".pcspot_curtain_host[pc='" + pcid + "'] .productname").html());
        $("#prodTitle").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #productUrl").attr('href'));

        $("#prodMsg").html($(".pcspot_curtain_host[pc='" + pcid + "'] .salesMessage").html());
        $("#productLink").html(('Learn more about the ') + ($(".pcspot_curtain_host[pc='" + pcid + "'] #prodCaption").html()));
        $("#productLink").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #productUrl").attr('href'));

        //fill lower company area
        $("#coTitle").html($(".pcspot_curtain_host[pc='" + pcid + "'] .companyname").html());
        $("#coTitle").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #companyUrl").attr('href'));

        $("#coMsg").html($(".pcspot_curtain_host[pc='" + pcid + "'] .companymessage").html());
        $("#coLink").html(('Visit ') + ($(".pcspot_curtain_host[pc='" + pcid + "'] .companyname").html()));
        $("#coLink").attr("href", $(".pcspot_curtain_host[pc='" + pcid + "'] #companyUrl").attr('href'));

        $.facebox({ div: '#productDetails' });

        $(document).bind('close.facebox', function() {
            $('#productDetails', '#companyInfo', '#coName', '#coMessages', '#prodSalesMsg', '#coUrl', '#coTitle', '#coLink', '#prodTitle', '#productLink').html('');
        });

    });
});

//jQuery(document).trigger('close.facebox');
//$('#facebox .content').empty();
