
$(document).ready(function(){
    setTimeout('WT_tag_search()', 500)
});

function thisPage()
{
    var sPath = window.location.pathname;
    var sPageQ = sPath.substring(sPath.lastIndexOf('/') + 1);
    var sPage = sPageQ.split("?");

    return sPage;
}

function WT_tag_search()
{

		//each item in this array is an array which describes a particular thing we want to track
		//	selector,   page uri,     Page title,   link location,  link name,  different (40)
	    //	selector,   DCS.dcsuri,   WT.ti,        WT.z_ll,        WT.z_ln,    WT.dl
var WT_tag_search = new Array(
	//product pages styles, pack sizes, colors, whatever
	new Array("#products_tab_packSizes", "/products/"+thisPage(), thisPage(), "Products", "Pack Sizes", "40"),
	new Array("#products_tab_Prints", "/products/" + thisPage(), thisPage(), "Products", "Designs", "40"),
	new Array("#products_tab_printsDesigns", "/products/" + thisPage(), thisPage(), "Products", "Designs & Accents", "40"),
	new Array("#products_tab_printsSeasonal", "/products/" + thisPage(), thisPage(), "Products", "Seasonal Designs", "40"),
	new Array("#viva_testimonial", "/products/" + thisPage(), thisPage(), "Products", "Testimonials module", "40"),
	new Array(".products_wtb", "/products/" + thisPage(), thisPage(), "Products", "Where to Buy", "40"),
    
    new Array(".sendMeOffers #frmSubmit", "/send-me-offers/", "Send Me Offers", "Send Me Offers", "Submit", "40"),

    //new Array(".qtqMeetthe1steppersBioButton", "/quitthequilt/", "Quit the Quilt", "Quit the Quilt", "Read Bios", "40"),
    new Array("#meetMike", "/grab-and-grasp/", "GrabandGrasp", "GrabandGrasp", "left-Learnmore", "40"),
    new Array("#grabandgrasp", "/grab-and-grasp/", "GrabandGrasp", "GrabandGrasp", "Right-learnmore", "40"),
    new Array(".MRWorks", "/grab-and-grasp/", "GrabandGrasp", "GrabandGrasp", "mike-rowe-works", "40"),
    new Array(".watch", "/grab-and-grasp/", "GrabandGrasp", "GrabandGrasp", "VideoplayButton", "40"),
    new Array(".fbGame", "/grab-and-grasp/", "GrabandGrasp", "GrabandGrasp", "Match-Game", "40"),
    
    

    new Array(".navigation li.products", "TopNav.aspx", "Top Nav", "Top Nav", "Products", "40"),
    new Array(".navigation li.products .bigRoll", "TopNav.aspx", "Top Nav", "Top Nav", "White", "40"),
    new Array(".navigation li.products .designs", "TopNav.aspx", "Top Nav", "Top Nav", "Designs", "40"),
    new Array(".navigation li.products .chooseASize", "TopNav.aspx", "Top Nav", "Top Nav", "Chose a Size", "40"),

    new Array(".navigation li.savings", "TopNav.aspx", "Top Nav", "Top Nav", "Savings", "40"),
    new Array(".navigation li.commercial", "TopNav.aspx", "Top Nav", "Top Nav", "GrapAndGrasp", "40"),
   // new Array(".navigation li.quitTheQuilt", "TopNav.aspx", "Top Nav", "Top Nav", "Quit the Quilt", "40"),
    new Array(".navigation li.whereToBuy", "TopNav.aspx", "Top Nav", "Top Nav", "Where to Buy", "40"),

    new Array("#viva_footer .footerFaq", "FooterLinks", "Footer", "Footer", "FAQs", "40"),
    new Array("#viva_footer .footerPrivacy", "FooterLinks", "Footer", "Footer", "PrivacyPolicy", "40"),
    new Array("#viva_footer .footerTerms", "FooterLinks", "Footer", "Footer", "Terms & Conditions", "40"),
    new Array("#viva_footer .footerContact", "FooterLinks", "Footer", "Footer", "Contact Us", "40"),
    new Array("#viva_footer .footerProfile", "FooterLinks", "Footer", "Footer", "Update Profile", "40"),
    new Array("#viva_footer .footerUnsub", "FooterLinks", "Footer", "Footer", "Unsubscribe from Newsletter", "40")
);

	for(row=0; row < WT_tag_search.length; row++) //run this for each row of the array, it's easier this way
	{
	    thisTag = WT_tag_search[row];		
		if ($(thisTag[0]).length > 0)
		{
			WT_tag_exec(thisTag[0], thisTag[1], thisTag[2], thisTag[3], thisTag[4], thisTag[5]);
		}
	}

}


function WT_tag_exec(selector, dcsuri, ti, ll, ln, dl)
{	
	var counter = 1;

	$(selector).each(function () {

	    $(this).mousedown(function () {
	        //console.log('DCS.dcsuri,' + dcsuri + ', WT.ti, ' + ti + ', WT.z_ll, ' + ll + ", WT.z_ln, " + ln + ", WT.dl, " + dl);
	        dcsMultiTrack('DCS.dcsuri', dcsuri, 'WT.ti', ti, 'WT.z_ll', ll, "WT.z_ln", ln, "WT.dl", dl);
	    })
	})
}

