/* ============================== sophus3 ==============================

   logging script for                                                               17/08/2010

   

   www.audi.it

   

   Version 5.0.1

   Copyright (c) Sophus Ltd 2010. All rights reserved. Patent Pending.

   http://www.sophus3.com

   =====================================================================*/

   

/*=============================== Switch ==============================*/   

   if (typeof s3_logging_active == 'undefined') s3_logging_active = true;

   // If you want to switch off the tracking use the following line instead:

   // s3_logging_active = false;

/*=====================================================================*/



/* =========================== Customisation ===========================*/

   // required configuration parameters

   s3_site_id = 69;

   s3_server_url = "auto.sophus3.com";

/*=====================================================================*/



/* ============================= Parameter =============================*/

   // attaches querystring parameters to thr page alias

   

   // If you want to to use a limited list of parameters, activate the array below

   /*var usePair = new Array();

   usePair['campaignid'] = 1;

   usePair['campaignid'] = 1;

   usePair['advertiserid'] = 1;

   usePair['bannerid'] = 1;

   */

   

   if (typeof tc_page_alias != 'undefined') {

	   

	s3_page_alias = tc_page_alias;

	   

	if (location.search != null && location.search.length > 1) {

		

		if(typeof usePair == 'undefined'){ // append entire query string

			if (s3_page_alias.indexOf('?') == -1) {

				s3_page_alias = s3_page_alias + location.search;

			}

			else {

				s3_page_alias = s3_page_alias + "&" + location.search.substring(1);

			}

		}

		

		else{ // append selected parameters

			var locSearch = location.search.substring(1);

			var s3Params = locSearch.split('&');

			var s3_params = '';

			var nextAppender = (s3_page_alias.indexOf('?') == -1) ? '?' : '&';



			for (var i=0; i<s3Params.length; i++) {

				if (s3Params[i].indexOf('=') != -1) {

					var pair = s3Params[i].split('=');

					if (usePair[pair[0]] == 1) {

						s3_params += nextAppender + s3Params[i];

						nextAppender = '&'; // Change from ? to &

					}

				}

			}

			s3_page_alias += s3_params;

		}

	}

   }

/*=====================================================================*/



/*=========================== StandardCode ============================*/

/*             DO NOT MAKE CHANGES TO THE CODE BELOW !                */

	

   function s3_configured() {

	s3_tag_version = "5.0.1";// see 501 comments

	s3_dtimeout = 5000;

	s3_d_loc = window.location;

	s3_sent = 0;

	if (typeof s3_server_url== 'undefined' ||typeof s3_site_id== 'undefined' ) return false;

	s3_timeout=(typeof s3_timeout== 'undefined' ?s3_dtimeout:s3_timeout*1000);

	s3_encfn=(typeof encodeURIComponent!= 'undefined' ?encodeURIComponent:escape);

	s3_http="http"+(s3_d_loc.href.substring(0,6)=="https:"?"s":"")+"://";

	s3_server_url=s3_http+s3_server_url;

	s3_url=((typeof s3_page_alias!= 'undefined')?s3_page_alias:s3_d_loc.href);

	s3_referrer=(typeof s3_referrer!= 'undefined' &&s3_referrer!=""&&s3_referrer!=null?s3_referrer:(typeof document.referrer== 'undefined' ?s3_ud:(document.referrer==null?"null":(document.referrer==""?"empty":document.referrer))));

	s3_time = new Date().getTime();

	return true;

   }





   function s3_log(alias, displayed) {

	if (!s3_logging_active) return;

	alias=s3_fixURL(alias);

	s3_image=new Image();

	s3_image.src=s3_get_log_URL_s3log("i",alias,new Date().getTime(), displayed);

  }

	function tc_log(alias, displayed) {

		s3_log(alias, displayed);

	}





   function s3_dltime() {

	if (!(document.getElementById||document.all)) return false;

	if (s3_logging_active&&(typeof s3_done!="undefined")&&s3_done&&!s3_sent) { setTimeout("s3_dltime()",1000);return false; }

	var sent=s3_sent;

	s3_image=new Image();

	s3_image.name = "s3d";

	s3_image.src=s3_get_log_URL("d");

	return sent;

   }

	function tc_dltime() {

		s3_dltime();

	}



   function s3_get_log_URL(type,locn,time,displayed) {

	if (typeof type== 'undefined' ) type='i';

	var url=s3_server_url+"/"+type+"?siteID="+s3_site_id;

	if (type!="d") {

		url+="&ts="+(typeof time!= 'undefined' ?time:s3_time);

		

		var al = s3_isAlias(locn);

		if (typeof s3_containers!= 'undefined' ) for(cc in s3_containers) url+="&ccID="+s3_containers[cc];

		if (type=="c") url+="&log=no";

		if (al) url+="&alias=true";

		if (typeof displayed!= 'undefined' ) url+=displayed;

		if (locn== 'undefined' ) locn=s3_d_loc;

		locn=s3_encfn(locn);

		while (locn.length>1999-url.length) locn=locn.substring(0,locn.lastIndexOf(s3_encfn("&")));

		url+="&location="+locn;

		var dg=new Object();

		dg.tagv=s3_tag_version;

		dg.tz=0-(new Date().getTimezoneOffset());

		dg.r=s3_encfn(s3_referrer);

		if (al) dg.aliased=s3_encfn(s3_d_loc.href);

		dg.title=s3_encfn(document.title);

		dg.flv=  s3_getFlashVersion(); 

		var plg = s3_getPlugInz();

		dg.Rep = plg.Rep;

		dg.Qut = plg.Qut;

		dg.WMP = plg.WMP;

		dg.ARe = plg.ARe;

		dg.Jav = plg.Jav;

		dg.SiL = plg.SiL;

			

		if (screen) {dg.cd=screen.colorDepth;dg.ah=screen.availHeight;dg.aw=screen.availWidth;dg.sh=screen.height;dg.sw=screen.width;dg.pd=screen.pixelDepth;}

		for (var key in dg) { var param="&"+key+"="+dg[key]; if (url.length+param.length<2000) url+=param; else break; }

	} else {

		url+="&dlts="+s3_time+"&dl="+(new Date().getTime()-s3_time);

		

	}

	return url;

   }



   function s3_get_log_URL_s3log(type,locn,time,displayed) {

		return s3_get_log_URL(type,locn,time,displayed) + "&s3log=1";

   }

   

   function s3_get_log_URL_s3red(type,locn,time,displayed) {

		return s3_get_log_URL(type,locn,time,displayed) + "&s3red=1";

   }

   

  function tc_redirect(target,url,alias,winproperties,products,script) {

	s3_redirect(target,url,alias,winproperties,products,script);

  } 

   

function s3_redirect(target,url,alias,winproperties,products,script) {

	if (typeof url==s3_ud||url=="") return;

	if (typeof script==s3_ud||script=="") script="s3_d_loc.href='"+url+"'";

	url=s3_fixURL(url);

	if (typeof alias==s3_ud) alias=url;

	alias=s3_fixURL(alias);

	if (typeof target==s3_ud||target==""||target=="_self") {

		if (s3_logging_active) {

			s3_timer=new Image();

			s3_timer.onload=function() { eval(script); clearTimeout(s3_timeout_id); }

			s3_timer.onerror=function() { eval(script); clearTimeout(s3_timeout_id); }

			s3_timer.src=s3_get_log_URL_s3red("i",alias,new Date().getTime());

			s3_timeout_id=setTimeout(script,s3_timeout);

		} else { eval(script); }

	} else if (typeof target=="object"&&target.document) {

		if (s3_logging_active) { s3_timer=new Image();s3_timer.src=s3_get_log_URL_s3red("i",alias); }

		target.location.href=url;

	} else { s3_open_window(target,url,alias,winproperties,products); }

}

   

function s3_open_window(name,url,alias,winproperties,products) {

	if (typeof url==s3_ud||url=="") return false;

	if (s3_logging_active) { s3_timer=new Image();s3_timer.src=s3_get_log_URL("i",alias,new Date().getTime()); }

	if (typeof winproperties==s3_ud) return window.open(url,name);

	else { return window.open(url,name,winproperties) }

}



   function s3_getFlashVersion() {

	/*501

	   var s3_flashversion = -1;

	// ie 

	try { 

		try { 

		// avoid fp6 minor version lookup issues 

		// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 

		var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 

		try { axo.AllowScriptAccess = 'always'; } 

		catch(e) { return '6,0,0'; } 

	} catch(e) {} 

	s3_flashversion = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 

	// other browsers 

	}

	catch(e) { 

		try { 

			if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 

				s3_flashversion = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 

			} 

		} catch(e) {} 

	} 

	return s3_flashversion.split(',').shift(); 

	501*/ 

	

	return "no detection";

   }





   function s3_fixURL(url) {

	if (url=="") { return s3_d_loc.href }

	if ((url.substring(0,4)!='http')&&(url.substring(0,1)!="/")) { url=s3_d_loc.pathname.substring(0,s3_d_loc.pathname.lastIndexOf('/')+1)+url }

	if (url.substring(0,1)=="/") { url=s3_http+s3_d_loc.host+url }

	var s3anchor = window.location.hash;

	if(s3anchor.length>0){

		if (url.indexOf("?") == -1) url = url + "?";

		else url = url + "&";

		url = url + "s3anchor=" + s3anchor.substring(1);

	}

	return url;

   }





   function s3_isAlias(alias) {

	alias=(typeof alias!= 'undefined' ?alias:(typeof s3_page_alias== 'undefined' ?"":s3_page_alias));

	alias=s3_fixURL(alias);

	if (alias.indexOf("?")>0) alias=alias.substring(0,alias.indexOf("?"));

	return (alias != s3_http+s3_d_loc.host+s3_d_loc.pathname);

   }





   function s3_loader() {

	s3_ud = "undefined";

	if (s3_logging_active&&s3_configured()&&(typeof s3_done== 'undefined' ||s3_done==false)) {

		url=s3_fixURL(s3_url);

		s3_image=new Image();

		s3_image.name = "s3i";

		s3_image.onload=function(){s3_sent=true;}

		s3_image.src=s3_get_log_URL("i",url,s3_time);

	}

	s3_done = true;

   }



   function s3_getPlugInz() {

	   

	var PlugIn=new Object();      

	   

	s3_ReP = "no detection";

	s3_QuT = "no detection";

	s3_WMP = "no detection";

	s3_Are = "no detection";

	s3_Jav = "no detection";

	s3_SiL = "no detection";

	/*501

	try{

		s3_nse = "";

		for (var i=0;i<navigator.mimeTypes.length;i++) s3_nse += navigator.mimeTypes[i].type.toLowerCase();

		if (s3_nse != "") {

			s3_ReP = s3_detectNS("audio/x-pn-realaudio-plugin");

			s3_QuT = s3_detectNS("video/quicktime");

			s3_WMP = s3_detectNS("application/x-mplayer2");

			s3_Are = s3_detectNS("application/pdf");

			s3_Jav = s3_detectNS("application/x-java-applet");

			s3_SiL = s3_detectNS("application/x-silverlight");

		}

		else {

		

			if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {

				document.writeln('<script language="VBscript">');

				document.writeln('\'do a one-time test for a version of VBScript that can handle this code');

				document.writeln('detectableWithVB = False');

				document.writeln('If ScriptEngineMajorVersion >= 2 then');

				document.writeln('  detectableWithVB = True');

				document.writeln('End If');

				document.writeln('\'this next function will detect most plugins');

				

				document.writeln('Function detectActiveXControl(activeXControlName)');

				document.writeln('  on error resume next');

				document.writeln('  detectActiveXControl = False');

				document.writeln('  If detectableWithVB Then');

				document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');

				document.writeln('  End If');

				document.writeln('End Function');

				document.writeln('\'and the following function handles QuickTime');

				

				document.writeln('Function detectQuickTimeActiveXControl(activeXControlName)');

				document.writeln('  on error resume next');

				document.writeln('  detectQuickTimeActiveXControl = False');

				document.writeln('  If detectableWithVB Then');

				document.writeln('    detectQuickTimeActiveXControl = False');

				document.writeln('    hasQuickTimeChecker = false');

				document.writeln('    Set hasQuickTimeChecker = CreateObject(activeXControlName)');

				document.writeln('    If IsObject(hasQuickTimeChecker) Then');

				document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');

				document.writeln('        detectQuickTimeActiveXControl = True');

				document.writeln('      End If');

				document.writeln('    End If');

				document.writeln('  End If');

				document.writeln('End Function');

				document.writeln('</scr' + 'ipt>');

			

				s3_ReP = detectActiveXControl("rmocx.RealPlayer G2 Control");

				s3_QuT = detectQuickTimeActiveXControl("QuickTimeCheckObject.QuickTimeCheck");

				s3_WMP = detectActiveXControl("MediaPlayer.MediaPlayer");

				s3_Are = detectActiveXControl("PDF.PdfCtrl");

				if (s3_Are==false) s3_Are = detectActiveXControl("AcroPDF.PDF");

				s3_Jav = detectActiveXControl("JavaWebStart.isInstalled");

				s3_SiL = detectActiveXControl("AgControl.AgControl");

			}

		}

	}

	

	catch (e) {



		s3_ReP = "error1";

		s3_QuT = "error1";

		s3_WMP = "error1";

		s3_Are = "error1";

		s3_Jav = "error1";

		s3_SiL = "error1";

		

	}

	

	PlugIn.Rep=s3_ReP;

	PlugIn.Qut=s3_QuT;

	PlugIn.WMP=s3_WMP;

	PlugIn.ARe=s3_Are;

	PlugIn.Jav=s3_Jav;

	PlugIn.SiL=s3_SiL;

	

	501*/ 

	

	return PlugIn;

}



function s3_detectNS(s3_ClassID) {

	try{

		if (s3_nse.indexOf(s3_ClassID) != -1) {

			if (navigator.mimeTypes[s3_ClassID].enabledPlugin != null) return true;

		}

		else return false

	}

	catch(e) {

		return "error2"

	}

}

   

s3_loader();
