﻿//+---------------------------------------------------------------------------+
//| Copyright (c) 2011 AT Internet.                                           	   |
//| All rights reserved.                                                                         |
//| For help with this library contact support@atinternet.com                 |
//| Version At Rich media Ext 1.0.001                                                  |
//+---------------------------------------------------------------------------+

xtsd = "http://logi241";
xtsite = "477464";

var static = {
		type: 'video',
		location: 'ext',
                n2: '0',
                clink: null,
                custom: null,
                refresh: '5',
                quality: '1',
                stream: '1',
                mode: 'clip',
                extension: '1'
            };

		 
//do not modify below

 (function(){
                
    // Listen for the ready event for any vimeo video players on the page
    var vimeoPlayers = document.querySelectorAll('iframe'),
        player;
 
    for (var i = 0, length = vimeoPlayers.length; i < length; i++) {
        if(/player.vimeo.com/.test(vimeoPlayers[i].getAttribute('src'))){              
            player = vimeoPlayers[i];     
            $f(player).addEvent('ready', ready);   
        }               
    }
          
     function ready(str1) {
        
        var player_id = str1;
      
        var froogaloop = $f(player_id);  
         
        var xtplayer=player_id,xtaction=null,xtduration=0,xtsize=0,xturl=top.location.href,xtRmp=0,xtRmpf=0,xtRmbufp=0;        
        
        froogaloop.api('getDuration', function (value, player_id) {
             xtduration = Math.round(value);             
        });                    
        
        froogaloop.api('getVideoUrl', function (value, player_id) {
             xtvimid = value;
        }); 
        
        froogaloop.addEvent('loadProgress', function(data) {                       
            xtRmbufp = Math.round(data.percent * data.duration);
            xtsize = data.bytesTotal;                       
        });	                   
                              
        froogaloop.addEvent('playProgress', function(data) {               
            xtRmp = Math.round(data.seconds);                      
        });	                  
             
        froogaloop.addEvent('play', function(data) {            
            xtAct('play');
        });	               
             
        froogaloop.addEvent('pause', function(data) {
            xtAct('pause');
        });	             
                      
        froogaloop.addEvent('finish', function(data) {
            xtAct('stop');	               
        });	                   
                              
        froogaloop.addEvent('seek', function(data) {                        
            xtRmpf = xtRmp;
            xtRmp = Math.round(data.seconds);
            xtAct('move');	                  
        });	                  
                        
        function xtAct(xtaction){      
            xtRmp = (xtRmp < 0) ? 0 : xtRmp;
            xtRmp = (xtRmp > parseInt(xtduration, 10)) ? parseInt(xtduration, 10) : xtRmp;
            xtRmbufp = isNaN(xtRmbufp) ? 0 : xtRmbufp;
            xtRmbufp = (xtRmbufp > parseInt(xtduration, 10)) ? parseInt(xtduration, 10) : xtRmbufp;
            var xtrmp = 'rmp=' + xtRmp + '&rmpf=' + xtRmpf + '&rmbufp=' + xtRmbufp;
            xtRm(
                static.type+(xtplayer?'&plyr='+xtplayer:''),
                static.n2,
                content.region+'::'+content.blogger+'::'+xtvimid+(static.clink?'&clnk='+static.clink:'')+(xturl?'&m9='+xturl:''),
                xtaction,
                static.custom,
                static.refresh,
                xtduration,
                xtrmp,
                static.quality,
                static.stream,
                static.location,
                static.mode,
                xtsize,
                static.extension              
            );
        }                                          
    }
 })();
   
var xtPlyrTab = new Array();

function xtRm(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) {
    var xtStr = '&p=' + x3 + '&s2=' + x2 + '&type=' + x1 + '&a=' + x4 + '&m5=' + x11 + '&m6=' + x12 ;
    xtStr += ((x5 != null) && (x5 != '0')) ? '&' + x5 : '';
    xtStr += ((x7 != null) && (x4 != 'pause') && (x4 != 'stop')) ? '&m1=' + x7 + '&' + x8 + '&m3=' + x9 + '&m4=' + x10 + '&m7=' + x13 + '&m8=' + x14 : '';
    xtStr += ((x6 != null) && (x6 != '0') && (x7 != null)) ? '&rfsh=' + x6 : '';
    
    xtHit(xtStr);       
    
    if ((x6 != null) && (x6 != '0') && ((x4 == 'play') || (x4 == 'refresh'))) {
        var xtTime = (Math.floor(x6) > 1500) ? 1500000 : (Math.floor(x6) < 5) ? 5000 : Math.floor(x6) * 1000;
        if (typeof(xtPlyrTab[x1]) != 'undefined'){window.clearTimeout(xtPlyrTab[x1]);}
        xtPlyrTab[x1] = window.setTimeout("xtRm('" + x1 + "','" + x2 + "','" + x3 + "','refresh','0','" + x6 + "',null,'" + x8 + "','" + x9 + "','" + x10 + "','" + x11 + "','" + x12 + "')", xtTime);
    } 
    else if (((x4 == 'pause') || (x4 == 'stop')) && (typeof(xtPlyrTab[x1]) != 'undefined')){
        window.clearTimeout(xtPlyrTab[x1]);
    }
}

function xtHit(x1) {  
    var xtImg = new Image();
    var xtDate = new Date();
    var xtSrc = xtsd + '.xiti.com/hit.xiti?s=' + xtsite + x1 + '&hl=' + xtDate.getHours() + 'x' + xtDate.getMinutes() + 'x' + xtDate.getSeconds();
    if (parseFloat(navigator.appVersion) >= 4) {
	    xtSrc += '&r=' + screen.width + 'x' + screen.height + 'x' + screen.pixelDepth + 'x' + screen.colorDepth;
    } 
    xtImg.src=xtSrc;    
    xtImg.onload = function () {
	    xtImg.onload = null;
    };          
}
