<!-- START OF Data Collection Server TAG -->
<!-- Copyright 2002 NetIQ Corporation -->
<!-- V2.1 -->

// globals for All Pages
// browser
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isIE5 = (navigator.appVersion.indexOf("5.") != -1) ? true : false;
var isIE6 = (navigator.appVersion.indexOf("6.") != -1) ? true : false;
var isNS = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
// platform 
var isWin = (navigator.appVersion.indexOf("Win") != -1) ? true : false;
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
// Things we are looking for
var flashVersion = 1;
var isFlashinstalled = false;
var isDirectorInstalled = false;
var isShockwaveInstalled = false;
// Flash Variables, init
var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed
var flash6Installed = false;		// boolean. true if flash 6 is installed
var flash7Installed = false;		// boolean. true if flash 7 is installed
var flash8Installed = false;		// boolean. true if flash 8 is installed

var dcs_imgarray = new Array;
var dcs_ptr = 0;
var dCurrent = new Date();
var DCS=new Object();
var WT=new Object();
var DCSext=new Object();

var dcsADDR = "dcs.mattel.com";
var dcsID = "dcsa6iqhogtqmjqlqbnsj4i6z_1t6j";
var blnFlash = false;
var debug = false;

if (dcsID == ""){
	var TagPath = dcsADDR;
} else {
	var TagPath = dcsADDR+"/"+dcsID;
}
DCS.dcsuri = "";
DCS.dcsqry = "";

function dcs_var(){
	WT.tz = dCurrent.getTimezoneOffset();
	WT.ul = navigator.appName=="Netscape" ? navigator.language : navigator.userLanguage;
	WT.cd = screen.colorDepth;
	WT.sr = screen.width+"x"+screen.height;
	WT.jo = navigator.javaEnabled() ? "Yes" : "No";
	WT.ti = document.title;
	WT.js = "Yes";
	DCS.dcsdat = dCurrent.getTime();
	if ((window.document.referrer != "") && (window.document.referrer != "-")){
		if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4) ){
			DCS.dcsref = window.document.referrer;
		}
	}
	
	if (DCS.dcsuri == "")	{
	DCS.dcsuri = window.location.pathname;
}
	if (DCS.dcsqry == "")	{
	DCS.dcsqry = window.location.search;
}
	DCS.dcssip = window.location.hostname;
}


function A(N,V){
	return "&"+N+"="+escape(V);
}

function dcs_createImage(dcs_src)
{
	if (document.images){
		dcs_imgarray[dcs_ptr] = new Image;
		dcs_imgarray[dcs_ptr].src = dcs_src;
		dcs_ptr++;
	}
	//alert(dcs_imgarray.length);
}

function dcsMeta(){
	var MRV="";
	var F=false;
	var myDocumentElements;
	if (document.all){
		F = true;
		myDocumentElements=document.all.tags("meta");
	}
	if (!F && document.documentElement){
		F = true;
		myDocumentElements=document.getElementsByTagName("meta");
	}
	if (F){
		for (var i=1; i<=myDocumentElements.length;i++){
			myMeta=myDocumentElements.item(i-1);
			if (myMeta.name.indexOf('WT.')==0){
				WT[myMeta.name.substring(3)]=myMeta.content;
			}
			if (myMeta.name.indexOf('DCSext.')==0){
				DCSext[myMeta.name.substring(7)]=myMeta.content;
			}
			if (myMeta.name.indexOf('DCS.')==0){
				DCS[myMeta.name.substring(4)]=myMeta.content;
			}
		}
	}
}
// ===================== setDebug(onOrOff) ==================================
//for testing - this function will display all parameters that get passed to the dcs server for 
//flash and tile components by typing it into the browser address bar ex: javascript:setDebug(true|false);
function setDebug(onOrOff){
	debug=onOrOff;
	if (debug) {
		alert('WT Flash/Tile debug on')
	} else {
		alert('WT Flash/Tile debug off')
	}
}

function  dcs_TAG(TagImage){
	if (debug) {		
		var D 
		D = "***DCS Collection***\n";
		D = D +"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+TagImage+"/dcs.gif?" + "\n";
		for (N in DCS) D = D + N + "=" + DCS[N] + "\n";
		D = D + "\n\n***WT Collection***\n";
		for (N in WT) D = D + N + "=" + WT[N] + "\n";
		D = D + "\n\n***DCSext Collection***\n";
		for (N in DCSext) D=D + N + "=" + DCSext[N] + "\n";		
		
		alert(D + "\n\n# of Calls to DCS " + dcs_imgarray.length);
	} 	
	var P ="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+TagImage+"/dcs.gif?";
	for (N in DCS){P+=A( N, DCS[N]);}
	for (N in WT){P+=A( "WT."+N, WT[N]);}
	for (N in DCSext){P+=A( N, DCSext[N]);}
	dcs_createImage(P);		
}


// This is a sample of the function that would be called if you needed to re-run the script.
//function dcs_ReRun(URI,QRY){
//	DCS.dcsuri = URI;
//	DCS.dcsqry = QRY;
//	dcs_TAG();
//}
dcsMeta();
dcs_var();
makeWTVars();
detectAll();
dcs_TAG(TagPath);
//if (debug) {
//	displayAll();
//}

function ClearCG(){
	for (N in WT){
		delete WT[N];
	}
	for (N in DCSext){
		//if (N.indexOf('CG')==0){
			delete DCSext[N];
		//}
	}
}

function FlashTrack(){
        DCS.dcsuri = null; 
        ClearCG();
		dcs_var();
        for (var I=0;I<arguments.length;I++){ 
                /*if (arguments[I].indexOf('WT.')==0){ 
                        WT[arguments[I].substring(3)]=arguments[I+1]; 
                        I++; 
                } */
                if (arguments[I].indexOf('DCS.')==0){ 
                        DCS[arguments[I].substring(4)]=arguments[I+1]; 
                        I++; 
                } 
                if (arguments[I].indexOf('DCSext.')==0){ 
                        DCSext[arguments[I].substring(7)]=arguments[I+1]; 
                        I++; 
                } 
                if (arguments[I].indexOf('dcsID')==0){ 
                        dcsID=arguments[I+1]; 
                        I++; 
                } 
        } 

        if (dcsID == ""){ 
                var TagPath = dcsADDR; 
        } else { 
                var TagPath = dcsADDR+"/"+dcsID; 
        } 

        DCS.dcsdat = dCurrent.getTime(); 

        if( DCS.dcsuri == null ){ 
                DCS.dcsuri = WT.ti+".ftrk"; 
        } 
         dcs_TAG(TagPath);
		
		// following line for testing only
		// will display parameters if hostname = fpdev, but never for live
		//if (DCS.dcssip == "fpdev"){
		//if (debug) {
		//	displayAll();
		//}
} 

// ===================== makeWTVars() ==================================
// takes the querystring, if any, and adds to the DCSext collection
function makeWTVars()
{
	var dcsqriOrig = window.location.search;
	var dcsqri;
	var temp;
	var loc = String(window.location)
	
	// if querystring exists
	if (dcsqriOrig.indexOf("?") != -1){
		dcsqriOrig = "";
		dcsqri = DCS.dcsqry.substring(1,DCS.dcsqry.length); // take string after "?"
		
		if (dcsqri.indexOf("=") != -1){
			dcsqri = dcsqri.split('&'); // split into name/value pairs
			
			for (var i = 0; i < dcsqri.length; i++){ // add to WT collection
				if (dcsqri[i].indexOf('WT.') != -1){
					temp = dcsqri[i].split('=');
					if (temp[1]){
						WT[temp[0].replace("WT.", "")] = temp[1];
					}
				}
				else{// add to DCSext collection for customer parameters
					temp = dcsqri[i].split('=');
					if (temp[1]){
						DCSext[temp[0]] = temp[1];
					}
				}
			}
		}
		
		// if target exists
		if (loc.indexOf("#") != -1){
			var target = String("target");
			DCSext[target] = loc.substring(loc.indexOf("#") + 1,loc.length);

		}
	}
}

//================================ detectAll() ========================================
function detectAll(){
	detectPlatform();
	detectFlash();
if ( (isIE) && (!isMac) ) 
{
	detectWMP();
}
	detectBrowser();
}

//=================================== detectPlatform() ================================
function detectPlatform(){
	var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();
	var arrPlatform = new Array(
						new Array("win95", "Windows 95"),
						new Array("windows 95", "Windows 95"),
						new Array("win16", "Windows 3.1"),
						new Array("16bit", "Windows 3.1"),
						new Array("windows 3.1", "Windows 3.1"),
						new Array("windows 16-bit", "Windows 3.1"),
						new Array("win 9x 4.90", "Windows ME"),
						new Array("windows nt 5.0", "Windows 2000"),
						new Array("windows 2000", "Windows 2000"),
						new Array("windows nt 5.1", "Windows XP"),
						new Array("win32", "Windows 32"),
						new Array("32bit", "Windows 32"),
						new Array("win98", "Windows 98"),
						new Array("windows 98", "Windows 98"),
						new Array("winnt", "Windows NT"),
						new Array("windows nt", "Windows NT"),
						new Array("os/2", "OS 2"),
						new Array("ibm-webexplorer", "OS 2"),
						new Array("68k", "Mac 68k"),
						new Array("68000", "Mac 68k"),
						new Array("ppc", "Mac PowerPC"),
						new Array("powerpc", "Mac PowerPC"),
						new Array("mac", "Mac"),
						new Array("sunos 4", "Sun 4"),
						new Array("sunos 5", "Sun 5"),
						new Array("i86", "Sun i86"),
						new Array("sunos", "Sun"),
						new Array("irix", "Irix"),
						new Array("irix 5", "Irix 5"),
						new Array("irix 6", "Irix 6"),
						new Array("hp-ux", "HP Unix"),
						new Array("aix", "Aix"),
						new Array("aix 1", "Aix 1"),
						new Array("aix 2", "Aix 2"),
						new Array("aix 3", "Aix 3"),
						new Array("aix 4", "Aix 4"),
						new Array("inux", "Linux"),
						new Array("sco", "SCO Unix"),
						new Array("unix_sv", "SCO Unix"),
						new Array("unix_system_v", "Unixware"),
						new Array("ncr", "mpras"),
						new Array("reliantunix", "Reliant Unix"),
						new Array("dec", "DEC Alpha"),
						new Array("osf1", "DEC Alpha"),
						new Array("dec_alpha", "DEC Alpha"),
						new Array("alphaserver", "DEC Alpha"),
						new Array("ultrix", "DEC Alpha"),
						new Array("alphastation", "DEC Alpha"),
						new Array("sinix", "Sinix"),
						new Array("freebsd", "Free BSD"),
						new Array("bsd", "BSD"),
						new Array("x11", "Unix"),
						new Array("vax", "VMS"),
						new Array("openvms", "VMS")
					)
	var sPlatform;
	
	for (i = 0; i < arrPlatform.length; i++){
		if (agt.indexOf(arrPlatform[i][0]) != -1){
			sPlatform = arrPlatform[i][1];
			break;
		}
	}
	if (sPlatform)
		DCSext['platform'] = sPlatform;
	else
		DCSext['platform'] = 'Unknown';
	
	//alert(DCSext['platform']);
}

//======================================== detectFlash() =================================
function detectFlash(){

	var maxVersion = 8;					// highest version we can actually detect

		if(isMac){  // fail safe for IE 4 in Mac
 			flashVersion = 0;
		  }
	
		// Detect Flash Version for NetScape
		if (isNS || (isMac && isIE5)){								// does navigator.plugins exist?
			if (navigator.plugins["Shockwave Flash 2.0"] 	// yes>> then is Flash 2 
			|| navigator.plugins["Shockwave Flash"]){		// or flash 3+ installed?
				
				// set convenient references to flash 2 and the plugin description
				var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
				// a flash plugin-description looks like this: Shockwave Flash 4.0 r5
				// so we can get the major version by grabbing the character before the period
				// note that we don't bother with minor version detection. do that in your movie with $version
				flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

				// we know the version, now set appropriate version flags
				flash3Installed = flashVersion == 3;
				flash4Installed = flashVersion == 4;
				flash5Installed = flashVersion == 5;
				flash6Installed = flashVersion == 6;
				flash6Installed = flashVersion == 7;
				flash6Installed = flashVersion == 8;								
			}
		}
		// end of detecting flash for Netscrape


		if(((isIE) || (isIE5)) && isWin  ){ // don't write vbscript tags on anything but ie win
			document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
			document.write(' on error resume next \n');
			document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
			document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
			document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');	
			document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');	
			document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');	
			document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');							
			document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
		}
		// end of IE (PC) detection
	
		// loop through all versions we're checking, and set actualVersion to highest detected version
		for (var i = 6; i <= maxVersion; i++) {	
				
			if (eval("flash" + i + "Installed") == true) {
				isFlashinstalled = true
				flashVersion = i;								
			}
		}
		
		if (flashVersion)
			DCSext['flashVersion'] = flashVersion;
		else
			DCSext['flashVersion'] = 'Unknown';
		
		//alert(DCSext['flashVersion']);

} // end of flash detectiion function

//======================================== detect windows media player =================================
function detectWMP()
{
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('On error resume next \n');
	document.write('var lngMP70 = "undefined"\n');
	document.write('lngMP70 = (IsObject(CreateObject("WMPlayer.OCX")))\n');
	document.write('</SCR' + 'IPT\> \n');
	
	DCSext['WindowsMediaPlayer'] = "No"; //default to 0 in case no version was detected and an error was reported. 

	if (lngMP70)
	{
		DCSext['WindowsMediaPlayer'] = "Yes";
	}	
//alert (DCSext['WindowsMediaPlayer']);
}

//============================= dislayAll() ======================================
// for testing - this function will display all parameters that get passed to
// the dcs server by typing it into the browser address bar ex: javascript:displayAll();
function displayAll(){
	var sVars;	
	
	sVars = "****DCS Collection****\n";
	for (N in DCS) sVars = sVars + N + "=" + DCS[N] + "\n";
	sVars = sVars + "\n****WT Collection****\n";
	for (N in WT) sVars = sVars + N + "=" + WT[N] + "\n";
	sVars = sVars + "\n****DCSext Collection****\n";
	for (N in DCSext) sVars = sVars + N + "=" + DCSext[N] + "\n";
	
	alert(sVars + "\n\n# Of Calls to DCS " + dcs_imgarray.length); 	
}

// ========================= TrackInterstitial() ===============================
// This function 'head-fakes' functionality of old interstatial pages such as golink.asp, kwtrack.asp etc.
// Receives:	type = string to denote tracking type
//				paramName = name applied to DCSext parameter
//				paramValue = value applied to DCSext parameter
// 05/26/05- Added "case 'fpaspx':" to spoof links to be tracked with similar WT .net reports
function TrackInterstitial(type, paramName, paramValue, path){
	var sPage;
	var sType = type.toLowerCase();
	
	dcsMeta();
	dcs_var();
	paramValue = paramValue.toString();	
	
	switch (sType){
		case 'homepage':
			sPage = 'golink.asp';
			break;
		case 'search':
			sPage = 'kwtrack.asp';
			break;
		case 'demo':
			sPage = 'demoview.asp';
			break;	
		case 'game':
			sPage = 'game.asp';	
			break;
		case 'coloring':
			sPage = 'coloringpage.asp';
			break;
		case 'microsite':
			sPage = 'microsite.asp';
			break;	
		case 'lpproduct':
			sPage = 'littlepeople/products/product.asp';
			break;	
		case 'lpgame':
			sPage = 'littlepeople/game.asp';
			break;
		case 'path':
			sPage = path;
			break;
		case 'rebate':
			sPage = path + paramValue + '_print.asp';
			break;
		case 'sweeps':
			sPage = 'ref/'+ path + '/' + paramValue.toLowerCase() + '_' + paramName.toLowerCase() + '.asp';
			break;
		case 'video':
			sPage = path + 'videoOfferForm.asp';
			break;
		case 'party':
			sPage = 'party.asp';
			break;
		case 'onlinegame':
			sPage= 'onlinegame.asp';
			break; 
		case 'fpaspx':
			sPage = path;
			break;			
		case 'ecomm':					
			sPage = path;			
			break;			
		case 'pid':					
			sPage = path;			
			break;		
		case 'sku':					
			sPage = path;			
			break;						
		case 'etrack':					
			sPage = path;			
			break;													
	}
	
	if (sType == "fpaspx"){
		DCS.dcsuri = '/fp.aspx';
		DCSext[paramName] = paramValue;
		DCSext.s= sPage;
		dcs_TAG(TagPath);
		}
	else if (sType == "pid"){		
		DCS.dcsuri = '/fp.aspx';
		DCSext.s= sPage;		
		DCSext.pid = paramName;		
		DCSext.realp = paramValue;		
		dcs_TAG(TagPath);			
		}					
	else if (sType == "sku"){		
		DCS.dcsuri = '/fp.aspx';
		DCSext.s= sPage;		
		DCSext.sku = paramName;		
		DCSext.realp = paramValue;		
		dcs_TAG(TagPath);					
		}									
	else if (sType == "ecomm"){		
		DCS.dcsuri = '/fp.aspx';
		DCSext.s= 'fpstore';
		DCSext[paramName] = paramValue;		
		DCSext.realp = sPage;		
		dcs_TAG(TagPath);			
		}		
	else if (sType == "etrack"){		
		DCS.dcsuri = '/ecomm.aspx';		
		DCSext[paramName] = paramValue;		
		DCSext.ClickType = sPage;				
		dcs_TAG(TagPath);
		}		
	else{		
		DCS.dcsuri = '/us/' + sPage;		
		DCSext[paramName] = paramValue;
		dcs_TAG(TagPath);
		}			
}

// ====================================== detectBrowser() ============================================
// Finds browser name and version, currently detects for ie 5+, netscape4+
function detectBrowser(){
	var iVersion;
	var sAppVersion = navigator.appVersion;
	var sUsrAgt = navigator.userAgent;
	
	
	if (isIE){
		sBrowser = "Internet Explorer";
		sAppVersion = sAppVersion.substring(sAppVersion.indexOf("MSIE ")+5, sAppVersion.length);
		iVersion = sAppVersion.substring(sAppVersion, sAppVersion.indexOf(";"));
	}
	// Netscape
	// For version test, use navigator.appVersion if Netscape 4, else use navigator.userAgent
	else if (isNS){
		sBrowser = "Netscape";
		var arrVersion = new Array(6, 7); // Array for newer versions of Netscape for use with userAgent property
		
		if (sAppVersion.indexOf("4") != -1){
			// Test for mac b/c navigator.appVersion is a little different
			if (isMac)
				iVersion = sAppVersion.substring(0, sAppVersion.indexOf("C"));
			else
				iVersion = sAppVersion.substring(0, sAppVersion.indexOf("["));
		}
		else{
			for (var i = 0; i < arrVersion.length; i++){
				if (sUsrAgt.lastIndexOf(arrVersion[i]) != -1){
					iVersion = sUsrAgt.substring(sUsrAgt.indexOf(arrVersion[i]), sUsrAgt.length);
				}
				else
					iVersion = "< 4"
			}
		}
	}
	// Other
	else{
		sBrowser = "Other";
		iVersion = 0;
	}
	iVersion = iVersion.substring(0,3);
	
	DCSext['Browser'] = sBrowser + " " + iVersion;
}

// simple add event script to handle call to trackInterstitial for this script
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}

// add the event to add listeners on window load
addEvent(window, 'load', addClickListeners, false);

// add event listeners on all links with a track attribute
function addClickListeners() {
	var links = document.getElementsByTagName('a');
	
	for (var i=0; i<links.length; i++) {
		if (links[i].getAttribute('track')) {
			EventHelper.AddEvent(links[i], 'click', callTrackInterstitial, false);
		}
	}
}

// function to call tracking
function callTrackInterstitial(e) {
	var theLink = e.currentTarget != undefined ? e.currentTarget : this;
	var parts = theLink.getAttribute('track').split('|');
	var report = parts[0] ? parts[0] : '';
	var param = parts[1] ? parts[1] : '';
	var value = parts[2] ? parts[2] : '';
	var  currentPage = parts[3] ? parts[3] : '';

	switch (parts.length) {
		case 1 :
			TrackInterstitial('homepage', 'Section', parts[0]);
			break;
		case 2 :
			break;
		case 3 :
			TrackInterstitial(report, param, value);
			break;
		case 4 :
			TrackInterstitial(report, param, value, currentPage);
			break;
		default :
			break;
	}
}