// Omniture Product Specific File
// Desc: Used to store a single vendors information.
// Product: Pubsys (WorkBench)  
////////////////////////////////////////////////////////////////////////////////

/* XMUltra Feed Fix - Added 12/5/2007 - JJ */
// Check for content source
if(mistats.contentsource != undefined)
{
        // Temp var
        var new_cs = mistats.contentsource;

        // Filter HTML encoding and multiple blank spaces
        new_cs = new_cs.replace(/&#60;.+?&#62;/g, "");
        new_cs = new_cs.replace(/\s{2,}/g, "");

        // Reset mistats.contentsource with new
        mistats.contentsource = new_cs;
}
/* End XMUltra Feed Fix */

/* Flag for tracking improper vendor tags */
var pubsys = true;

/* Geography DART geopick - Added 1/25/2008 - JJ */
var mistats_geography;
if(!mistats_geography) mistats.geography = mistats_geography;
/* End Geography DART geopick */

/* Multipage Story Tagging Catcher  - Added 5/20/2008 - JJ */
var baseURL = window.location.href;
var pageNum;

if(baseURL.match(/-p[2-9]/g))
{
        pageNum = baseURL.match(/-p[2-9]/g);
        pageNum = pageNum.toString();
        mistats.cmsid += " | Page: " + pageNum.split('-p')[1];
}
else
{
        splitURL = baseURL.split('.html');
        searchURL = splitURL[0] + '-p2.html';
        for(i=0; i < document.links.length; i++) {
                if(document.links[i] == searchURL) {                        
                        mistats.cmsid += " | Page: 1";
                        break;
                }
        }
}
/* End Multipage Story Tagging Catcher */

/* User interaction detection */

// we will be checking the URL for a hash or query string
// the following line is depcrecated for this file, not sure if its needed elsewhere though - GD 8/19/08
var internalSearch = window.location.hash;

//prospero submit comment
if ( window.location.hash.match('recent_comm') )
{
    mistats.pagename = "Cmnt: " + mistats.pagename;
    mistats.channel += ": Comments";
    mistats.pagelevel += ": Comments";
    mistats.contentsource += "|comment";
}

//prospero view comments
else if( window.location.hash.match('view_comm') )
{
    mistats.pagename = "View Cmnt: " + mistats.pagename;
    mistats.channel += ": View Comments";
    mistats.pagelevel += ": View Comments";
    mistats.contentsource += "|view_comment";
}

//pluck submit comment
else if( window.location.search.match('mi_pluck_action=comment_submitted') )
{
    mistats.pagename = "Cmnt: " + mistats.pagename;
    mistats.channel += ": Comments";
    mistats.pagelevel += ": Comments";
    mistats.contentsource += "|comment";
}

//pluck view more comments
else if( window.location.hash.match(/#Comments_Container/g) || window.location.search.match(/\?commentSort=/g) || window.location.search.match(/\?pageNum=/g) )
{
    mistats.pagename = "View Cmnt: " + mistats.pagename;
    mistats.channel += ": View Comments";
    mistats.pagelevel += ": View Comments";
    mistats.contentsource += "|view_comment";
}

/* end user interaction detection */

/* Pluck selective include */
var MIStatsPluck;
if ( MIStatsPluck == "template" )
{
    document.write("\n<" + "script type='text/javascript' src='http://media.mcclatchyinteractive.com/mistats/vendors/pluck.js'>" + "</" + "script>");
} 
/* End Pluck selective include */

/* MI/Omniture Ajax Function Call */ 
function mistats_resend()  
{  	
	s.linkTrackVars="pageName";  	
	void(s.t());  	
}  
/* End MI/Omniture Ajax Function Call */

/* VMix Eventhandler */
//document.write("\n<" + "script type='text/javascript' src='http://media.sunherald.com/mistats/vendors/vmix_eventhandler.js'>" + "</" + "script>");
/* End VMix Eventhandler */

/* Mobile Tracking Code - Ticket# 727-7330633 - 03/24/08 - JJ*/
if(window.location.pathname.match(/mobile/i))
        mistats.version='1.0|v-mobile'
/* End Mobile Tracking Code */

/* VMix Video Widget Tracking Code - Added: 7/15/09 - JJ*/
var player_loaded = 0;

/* A/B Test Name Tracker - Ticket# 727-8271403 - 09/21/09 -JJ*/
//if(typeof(mistats_testsuffix) != 'undefined')
//{
//        mistats.pagename += '|' + mistats_testsuffix;
//}


function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

function vmixEventHandler(event)
{

                if ((event.type == "player_load") && (!player_loaded))
                {
                        player_loaded = 1;
                        // Updated evenhandler path/file per ticket # 727-8286782  - JJ 
			dhtmlLoadScript("http://media.modbee.com/mistats/vendors/vmix_eventhandler.js");

                } else if (player_loaded) {

                        myPlayerEventHandler( event );
                }
}

