//
// phpOpenTracker - The Website Traffic and Visitor Analysis Solution
//
// Copyright 2000 - 2005 Sebastian Bergmann. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/* PluginDetect v0.1.3 by Eric Gerds */
var PluginDetect={firstobj:null,digit:0,id:0,head:null,plugin:null,version:[],ActiveXEnabled:null,getNum:function(A){if(!A){return null}var m=/[\d][\d\.\_,-]*/.exec(A);return m?m[0].replace(/[\.\_-]/g,","):null},hasMimeType:function(_3){var _4=new RegExp(name,"i"),s,t,z,M=_3.constructor==String?[_3]:_3;for(z=0;z<M.length;z++){s=navigator.mimeTypes[M[z]];if(s&&s.enabledPlugin){t=s.enabledPlugin;if(t.name&&t.description){return s}}}return null},findNavPlugin:function(N,_6){var i,re=new RegExp(N.constructor==String?N:N.join(".*"),"i");var _8=new RegExp(_6===false?".":"\\d","i");var _9=navigator.plugins;for(i=0;i<_9.length;i++){if((re.test(_9[i].description)&&_8.test(_9[i].description))||(re.test(_9[i].name)&&_8.test(_9[i].name))){return _9[i]}}return null},getAXO:function(_a){var _b,e;try{_b=new ActiveXObject(_a);return _b}catch(e){}return null},num:function(A){return (typeof A!="string"?false:(/\d/).test(A))},compareNums:function(_d,_e){if(!this.num(_d)||!this.num(_e)){return 0}var m1=_d.split(","),m2=_e.split(","),x,p=parseInt;for(x=0;x<m1.length;x++){if(p(m1[x],10)>p(m2[x],10)){return 1}if(p(m1[x],10)<p(m2[x],10)){return -1}}return 0},formatNum:function(num){if(!this.num(num)){return null}var n=num.replace(/[\.\_]/g,","),i;n=n.split(",").concat(["0","0","0","0"]);return n.slice(0,4).join(",")},init:function(_12){var $=this,IE;_12=_12.toLowerCase().replace(/\s/g,"");if(!$[_12]){return false}$.plugin=$[_12];if(typeof $.plugin.minversion=="undefined"){$.plugin.minversion={}}if(typeof $.plugin.version=="undefined"){$.plugin.version=null}if(typeof $.plugin.installed=="undefined"){$.plugin.installed=null}$.isIE=(/*@cc_on!@*/false);$.IEver=-1;if($.isIE){IE=(/msie\s*\d\.{0,1}\d*/i).exec(navigator.userAgent);if(IE){$.IEver=parseFloat((/\d.{0,1}\d*/i).exec(IE[0]),10)}if($.ActiveXEnabled==null){var _14=["Msxml2.XMLHTTP","Microsoft.XMLDOM","Msxml2.DOMDocument","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary"],x;$.ActiveXEnabled=false;for(x=0;x<_14.length;x++){if($.getAXO(_14[x])){$.ActiveXEnabled=true;break}}}if(!$.ActiveXEnabled){return false}}if($.IEver>=5.5){$.head=document.getElementsByTagName("head")[0];if(!$.head.firstChild){$.head.appendChild(document.createElement("object"))}$.firstobj=$.head.firstChild}return true},isMinVersion:function(_15,_16){var $=PluginDetect;if(!$.init(_15)||!$.num(_16)){return null}var p=$.plugin,m=p.minversion;_16=$.formatNum(_16);if(typeof m["a"+_16]=="undefined"){if($.IEver>=5.5&&p.getCodeBaseVersion){m["a"+_16]=$.isActiveXObject(_16)?true:false}else{if(p.installed==null){p.getVersion()}m["a"+_16]=p.version==null?null:($.compareNums(p.version,_16)>=0?true:false)}}$.cleanup();return m["a"+_16]},getVersion:function(_19){var $=PluginDetect;if(!$.init(_19)){return {version:null,installed:null}}var p=$.plugin;if(p.installed==null){p.getVersion()}$.cleanup();return {version:p.version,installed:p.installed}},cleanup:function(){var $=this,x,r=false;if($.firstobj){for(x=0;x<1000;x++){if($.firstobj.previousSibling){if($.firstobj.previousSibling.getAttribute("readyState")!=4){r=true}$.head.removeChild($.firstobj.previousSibling)}else{break}}}if(r&&typeof window.CollectGarbage!="undefined"){window.CollectGarbage()}$.firstobj=null},isActiveXObject:function(_1d){var $=this,result=false,obj,q="AAZA243";obj=document.createElement("object");$.head.insertBefore(obj,$.head.firstChild);obj.outerHTML="<object width=\"1\" height=\"1\" "+"id=\""+q+$.id+"\" "+"classid=\""+$.plugin.classID+"\" "+$.plugin.getCodeBaseVersion(_1d)+">"+($.plugin.HTML?$.plugin.HTML:"")+"</object>";if(document.getElementById(q+$.id)){result=document.getElementById(q+$.id).getAttribute("object")?true:false}$.id++;return result},search:function(_1f,min,max){var $=this,version="",x;if(typeof _1f=="undefined"){$.digit=0;min=max=null;$.version=[0,0,0,0];_1f=$.version[0]}for(x=0;x<4;x++){version+=($.digit==x?_1f:$.version[x])+(x<3?",":"")}if($.isActiveXObject(version)){$.version[$.digit]=min=_1f}else{max=_1f}if(min!=null&&max!=null){if(max-min==1){$.digit++;if($.digit==4){return $.version[0]+"."+$.version[1]+"."+$.version[2]+"."+$.version[3]}else{return $.search(1,0,null)}}else{return $.search(Math.round(min+max)/2,min,max)}}if(min!=null&&max==null){return $.search(!min?1:min*2,min,max)}return null},dummy1:0};PluginDetect.quicktime={mimeType:["video/quicktime","application/x-quicktimeplayer","image/x-macpaint","image/x-quicktime"],progID:"QuickTimeCheckObject.QuickTimeCheck.1",classID:"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",HTML:"",getCodeBaseVersion:function(v){return "codebase=\"#version="+v+"\""},getVersion:function(){var _24=null,p,$=PluginDetect;if(!$.isIE){p=$.findNavPlugin("QuickTime");if(p&&p.name&&$.hasMimeType(this.mimeType)){_24=$.getNum(p.name)}}else{if($.IEver<7){var obj=$.getAXO(this.progID);if(obj&&obj.QuickTimeVersion){_24=obj.QuickTimeVersion.toString(16);_24=_24.charAt(0)+"."+_24.charAt(1)+"."+_24.charAt(2)}}else{_24=$.search()}}this.installed=_24?true:false;this.version=$.formatNum(_24)}};PluginDetect.java={mimeType:"application/x-java-applet",classID:"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",JavaVersions:["1.7.0.15","1.6.0.15","1.5.0.12","1.4.2.13","1.3.1.18"],searchJava:function(M){if(!M){return null}var G,e,x3,x4;var AXO=ActiveXObject;var T=M.split("."),J="JavaPlugin."+T[0]+T[1],v=T[0]+"."+T[1]+".";for(x3=T[2];x3>=0;x3--){for(x4=T[3];x4>=0;x4--){G=x4<10?"0"+x4:x4;try{new AXO(J+x3+"_"+G);return v+x3+"_"+G}catch(e){}}if(J+x3=="JavaPlugin.131"){return null}try{new AXO(J+x3);return v+x3}catch(e){}}return null},HTML:"<param name=\"code\" value=\"\" />",getCodeBaseVersion:function(v){var r=this.getDigits(v),$=PluginDetect;if($.compareNums(v,"1,4,1,02")<0){v=r[0]+","+r[1]+","+r[2]+","+r[3]}else{if($.compareNums(v,"1,5,0,02")<0){v=r[0]+","+r[1]+","+r[2]+","+r[3]+"0"}else{v=Math.round((parseFloat(r[0]+"."+r[1],10)-1.5)*10+5)+","+r[2]+","+r[3]+"0"+",0"}}return "codebase=\"#version="+v+"\""},getDigits:function(n){/([\d]+)[,_\.]([\d]+)[,_\.]([\d]+)[,_\.]([\d]+)/.test(n);return [RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$4]},queryJava:function(){var e,j=window.java;try{if(j&&j.lang&&j.lang.System){return (j.lang.System.getProperty("java.version")+" ")}}catch(e){}return null},getVersion:function(){var _2e=null,$=PluginDetect;if(!$.isIE){var p1,p,mt;p=$.findNavPlugin(["Java","Plug-in"]);mt=$.hasMimeType(this.mimeType);this.installed=(mt||p)&&navigator.javaEnabled()?true:false;if(p){p1=$.getNum(p.description)}if(p1&&mt&&navigator.javaEnabled()){_2e=p1}if(!_2e&&(this.installed||!/firefox/i.test(navigator.userAgent))){p=this.queryJava();if(p){_2e=p;this.installed=true}}}else{var x,tmp=null;if($.IEver>=5.5){_2e=$.search()}else{for(x=0;x<this.JavaVersions.length;x++){tmp=this.searchJava(this.JavaVersions[x]);if(tmp){_2e=tmp;break}}}this.installed=_2e?true:false}this.version=$.formatNum($.getNum(_2e))}};PluginDetect.devalvr={mimeType:"application/x-devalvrx",progID:"DevalVRXCtrl.DevalVRXCtrl.1",classID:"clsid:5D2CF9D0-113A-476B-986F-288B54571614",HTML:"",getCodeBaseVersion:function(v){return "codebase=\"#version="+v+"\""},getVersion:function(){var _32=null,p,$=PluginDetect;if(!$.isIE){p=$.findNavPlugin("DevalVR");if(p&&p.name&&$.hasMimeType(this.mimeType)){_32=p.description.split(" ")[3]}}else{if($.IEver<5.5){if($.getAXO(this.progID)){_32="0,2,9,0"}}else{_32=$.search()}}this.installed=_32?true:false;this.version=$.formatNum(_32)}};PluginDetect.flash={mimeType:["application/x-shockwave-flash","application/futuresplash"],progID:"ShockwaveFlash.ShockwaveFlash",classID:"clsid:D27CDB6E-AE6D-11CF-96B8-444553540000",getVersion:function(){var _33=function(A){if(!A){return null}var m=/[\d][\d\,\.\s]*[rR]{0,1}[\d\,]*/.exec(A);return m?m[0].replace(/[rR\.]/g,",").replace(/\s/g,""):null};var p,$=PluginDetect,e,i,version=AXO=majV=null;if(!$.isIE){p=$.findNavPlugin("Flash");if(p&&p.description&&$.hasMimeType(this.mimeType)){version=_33(p.description)}}else{for(i=15;i>2;i--){AXO=$.getAXO(this.progID+"."+i);if(AXO){majV=i.toString();break}}if(majV=="6"){try{AXO.AllowScriptAccess="always"}catch(e){return "6,0,21,0"}}try{version=_33(AXO.GetVariable("$version"))}catch(e){}if(!version&&majV){version=majV}}this.installed=version?true:false;this.version=$.formatNum(version)}};PluginDetect.shockwave={mimeType:"application/x-director",progID:"SWCtl.SWCtl",classID:"clsid:166B1BCA-3F9C-11CF-8075-444553540000",getVersion:function(){var _37=s=null,e,p,$=PluginDetect;if(!$.isIE){p=$.findNavPlugin("Shockwave for Director");if(p&&p.description&&$.hasMimeType(this.mimeType)){_37=$.getNum(p.description)}}else{try{s=$.getAXO(this.progID).ShockwaveVersion("")}catch(e){}if(typeof s=="string"&&s.length>0){_37=$.getNum(s)}else{if($.getAXO(this.progID+".8")){_37="8"}else{if($.getAXO(this.progID+".7")){_37="7"}else{if($.getAXO(this.progID+".1")){_37="6"}}}}}this.installed=_37?true:false;this.version=$.formatNum(_37)}};PluginDetect.windowsmediaplayer={mimeType:"application/x-mplayer2",progID:"wmplayer.ocx",classID:"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6",getVersion:function(){var _38=null,$=PluginDetect,tmp;if(!$.isIE){this.installed=($.findNavPlugin(["Windows","Media","Plug-in"],false)||$.hasMimeType(["Flip4Mac","Plugin"],false))?true:false}else{tmp=$.getAXO(this.progID);if(tmp){_38=tmp.versionInfo}this.installed=_38?true:false}this.version=$.formatNum(_38)}};
var tm = '';
var dir = '';
var fla = '';
var fla_version = '0';
var pdf = '';
var qt = '';
var rea = '';
var wma = '';
var java = (navigator.javaEnabled()) ? '1' : '0';
var agent = navigator.userAgent.toLowerCase();

//var moz = (navigator.appName.indexOf("Netscape") != -1);
//var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

function plugMoz(plugin) {
	if (tm.indexOf(plugin) != -1 && (navigator.mimeTypes[plugin].enabledPlugin !== null)) {
		return '1';
	}else {
		return '0';
	}
}

function plugIE(plugin) {
	find = false;
	document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n find = IsObject(CreateObject("' + plugin + '"))</SCRIPT>\n');
	if (find) {
		return '1';
	}else {
		return '0';
	}
}

function detectFlashVersion() {
	for(var i=10; i>0; i--) {
		flashVersion = 0;
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
			flashVersion = i;
			return flashVersion;
		}
		catch(e) {}
	}
}

if (isWin && isIE) {
	dir 		= plugIE("SWCtl.SWCtl.1");
	pdf 		= (plugIE("PDF.PdfCtrl.1") == '1' || plugIE('PDF.PdfCtrl.5') == '1' || plugIE('PDF.PdfCtrl.6') == '1') ? '1' : '0';
	qt 			= plugIE("QuickTime.QuickTime");
	rea 		= plugIE("rmocx.RealPlayer G2 Control.1");
	wma_v 		= PluginDetect.getVersion('WindowsMediaPlayer');
	wma			= (wma_v.installed) ? '1' : '0';
	fla 		= plugIE("ShockwaveFlash.ShockwaveFlash.1");
	if(fla) {
		fla_version = detectFlashVersion();
	}
}else {
	for (var i=0; i < navigator.mimeTypes.length; i++) {
		tm += navigator.mimeTypes[i].type.toLowerCase();
	}
	dir 		= plugMoz("application/x-director");
	pdf 		= plugMoz("application/pdf");
	qt 			= plugMoz("video/quicktime");
	rea 		= plugMoz("audio/x-pn-realaudio-plugin");
	wma 		= plugMoz("application/x-mplayer2");
	fla 		= plugMoz("application/x-shockwave-flash");
	if(fla) {
		var string 	= navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin.description;
		fla_version = parseInt(string.substring(string.indexOf(".")-1), 10);
	}
}

function track(client_id) {

	// EDIT THIS VARIABLE TO POINT TO THE CORRECT URL FOR YOUR SERVER
	if(document.URL.indexOf('.dev') !== -1) {
		tracker = 'http://potimage.dev';
	}else {
		tracker = 'http://potimage.sandstein.de';
	}


	// get the user agent name ----------------------------------
	v = navigator.appName;

	// get the screen resolution --------------------------------
	c = 0;
	if (v != "Netscape") {c = screen.colorDepth;}
	else {c = screen.pixelDepth;}

	resolution = window.screen.width + 'x' +
	                 window.screen.height;
	
	// get the document's title ---------------------------------
	if(doc !== ''){
		t = escape(doc);
	}else{
		t = escape(document.URL);
	}
	//if(document.title) {t = escape(document.title);}

	// get the document's referrer ------------------------------
	f = escape(document.referrer);
	
	// getting data ready to send -------------------------------
	r = tracker + '?' + 
	  'document=' + t + '&' +
	  'client_id=' + client_id + '&' +
	  'referer=' + f + '&' +
	  'js_data[resolution]=' + resolution + '&' +
	  'js_data[c_depth]=' + c + '&' +
	  'js_data[director]=' + dir + '&' +
	  'js_data[pdf]=' + pdf + '&' +
	  'js_data[quicktime]=' + qt + '&' +
	  'js_data[real_player]=' + rea + '&' +
	  'js_data[media_player]=' + wma + '&' +
	  'js_data[flash]=' + fla + '&' +
	  'js_data[flash_version]=' + fla_version;

	// add any conversion detail
	if(typeof(pot_conversion_sale)!="undefined"){
		r = r+'&'+'sale='+pot_conversion_sale;
	}
	if(typeof(pot_conversion_inquiry)!="undefined"){
		r = r+'&'+'inquiry=1';
	}
	if(typeof(pot_conversion_signup)!="undefined"){
		r = r+'&'+'signup=1';
	}
	if(typeof(pot_conversion_email)!="undefined"){
		r = r+'&'+'email='+escape(pot_conversion_email);
	}
	if(typeof(pot_conversion_zip)!="undefined"){
		r = r+'&'+'zip='+escape(pot_conversion_zip);
	}
	if(typeof(pot_conversion_country)!="undefined"){
		r = r+'&'+'country='+escape(pot_conversion_country);
	}
	if(typeof(pot_conversion_name)!="undefined"){
		r = r + '&' + 'name=' + escape(pot_conversion_name);
	}
	
	// member details
	//?m[0][m_id]=1&m[0][e_id]=1&m[0][q]=bla&m[0][type]=list
	if(typeof(pot_params) != "undefined"){
		r = r + pot_params;
	}

	rand = Math.round(1000 * Math.random());
	r = r + '&' + 'b=' + rand;  //force the page to load the IMG
	document.open();
	document.write('<div style="display:hidden"><img src="'+r+'" alt="" width="1" height="1" border="0"></div>');
	document.close();
}