/* bmv12.js
* Collect Generic V10 data & Screensize/FlashVersion/Connection Type
* Non Cookie Version
* 20050118@kmcgowan
* 20100312@modified by lkozak
*/
var bmLd = false;

function getBMqs(prot) {
	var n = new Date();

	if (parent.frames) {
	   var ref = parent.document.referrer  ;
	} else {
		var ref = document.referrer  ;
	}

    var qs = escape(window.location) + '*' + escape(ref) + '*' + (navigator.javaEnabled()) + '/';
    if (window.screen) {
        qs += screen.width+'x'+screen.height + '/' + screen.colorDepth + '/'
    } else {
        qs += '//'
    };
	
    qs += getConnection() + '/';
	qs += getFlashVersion() + '/';
    qs += n.getTime() + '/';
    
	//document.write(qs);
	/* Remove Cookie Request */
    //    var bmImg1 = '<img name="bmImg1" border=0 height=1 width=1 onLoad="nxtImg(\'bmImg2\', \'' + prot + '\', \'' + qs + '\')">';
    var bmImg2 = '<img name="bmImg2" border=0 height=1 width=1>';
    //    document.write(bmImg1);
    document.write(bmImg2);
    //    nxtImg('bmImg1', prot, n.getTime());
    nxtImg('bmImg2', prot, qs);
}


function nxtImg(img, prot, qs){
   if((!document.images) || bmLd) return;
   bmLd = true;
   var n = '';
   /* Remove Cookie Request */
   if(img == "bmImg1")
      {
         n = prot + '://www.bmmetrix.com/VC' + qs;
      }
   else if(img == "bmImg2")
   {
      n = prot + '://www.bmmetrix.com/V12' + qs;
   }
   if(document.images[img].src.indexOf(n)<0)
   {
      document.images[img].src = n;
   }
   bmLd = false;
}

/* browser [height,width/connectiontype] */
function getConnection(){
    var bmWidth = 0, bmHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        bmWidth = window.innerWidth;
        bmHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        bmWidth = document.documentElement.clientWidth;
        bmHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        bmWidth = document.body.clientWidth;
        bmHeight = document.body.clientHeight;
    }

    if(typeof bmCC == "undefined") {
        var bmConnType = "undef";
    } else {
        var bmConnType = bmCC.connectionType;
    }
    var bmData = bmWidth + ',' + bmHeight + '/' + bmConnType;
    return bmData;
}

/* Flashversion */
var actualVersion = 0;
var flash_noVersion = 999;
var flashVersion_DONTKNOW = 99;
function getFlashVersion() {
	var latestFlashVersion = 98; 
	var isIE4UP  = ((navigator.userAgent.toLowerCase().indexOf("msie") != -1) && parseInt(navigator.appVersion) >= 4) ? true : false;    
	var isWin32 = ((navigator.userAgent.toLowerCase().indexOf("win") != -1) && navigator.userAgent.indexOf("16bit")== -1) ? true : false;  
  	var flashVersion =0; 

  	if (navigator.plugins != null && navigator.plugins.length >0) {
    	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
      		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashPlug = navigator.plugins['Shockwave Flash' + isVersion2];
			if (typeof flashPlug == 'object') { 
				for (var i = latestFlashVersion; i >= 2; i--) {
            		if (flashPlug.description.indexOf(i + '.') != -1) {
               			flashVersion = i; 
               			break;
            		}
        		}
      		}
     	}
    actualVersion = flashVersion; 
 	} 
 	else if (navigator.mimeTypes && navigator.mimeTypes.length){
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x &&x.enabledPlugin )
			actualVersion = flash_noVersion;  
		else
			actualVersion = flashVersion_DONTKNOW; 
	}

	else if (isIE4UP && isWin32 ){
		var doc = '<scr' + 'ipt language="VBScript"\> \n';
      	doc += 'On Error Resume Next \n';
      	doc += 'Dim obFlash \n';
      	doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      	doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      	doc += '   If IsObject(obFlash) Then \n';
      	doc += '      actualVersion = i \n';
      	doc += '      Exit For \n';
      	doc += '   End If \n';
      	doc += 'Next \n';
      	doc += '</scr' + 'ipt\> \n';
      	document.write(doc);
  	}
  
	else if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
	else {
		  actualVersion = flashVersion_DONTKNOW;
	}
	return actualVersion;
}

