/* Touch Clarity. http://www.touchclarity.com
 * Copyright (c) Touch Clarity Ltd 2001-2006. All rights reserved. Patent Pending.
 */
 
// Change the value of tc_logging_active to switch off logging on the site.
if (typeof tc_logging_active=='undefined') {tc_logging_active = true;}

// Required configuration parameters
tc_site_id = "422";
tc_server_url = "directline.touchclarity.com";
tc_log_path = "/touchclarity";
var TT_Time = new Date();
if(typeof tc_extra_info == "undefined")
tc_extra_info = ""
tc_extra_info += "TT_Hour="+TT_Time.getDay()+TT_Time.getHours();

// Regexs and the cluster that will be logged for them, most specific matches must come first
// e.g "house(hold)([\w]+)insur(e|ing|ance)" : "house", <-- last item should not have a comma
var tc_search_terms = {
"^home insurance$" : "home-insurance",
"^house insurance$" : "home-insurance",
"home owner insurance" : "home-insurance",
"home contents insurance" : "home-insurance",
"home insurance quote" : "home-insurance",
"home insurance uk" : "home-insurance",
"cheap home insurance" : "home-insurance",
"online home insurance" : "home-insurance",
"home insurance company" : "home-insurance",
"holiday home insurance" : "home-insurance",
"^car insurance$" : "car-insurance",
"cheap car insurance" : "car-insurance",
"online car insurance" : "car-insurance",
"car insurance quote" : "car-insurance",
"car insurance rate" : "car-insurance",
"car insurance uk" : "car-insurance",
"womens car insurance" : "car-insurance",
"car insurance company" : "car-insurance",
"budget car insurance" : "car-insurance",
"young driver car insurance" : "car-insurance",
"wedding insurance" : "home-weddings",
"wedding ring insurance" : "home-weddings",
"wedding insurance uk" : "home-weddings",
"compare wedding insurance" : "home-weddings",
"cheap wedding insurance" : "home-weddings",
"wedding car insurance" : "home-weddings",
"wedding insurance plan" : "home-weddings",
"best wedding insurance" : "home-weddings",
"wedding cancellation insurance" : "home-weddings",
"wedding insurance cover" : "home-weddings",
"over 50's insurance" : "home-over-50",
"over 50's home insurance" : "home-over-50",
"over 60's home insurance" : "home-over-50",
"senior citizens insurance" : "home-over-50",
"pensioner home insurance" : "home-over-50",
"over 50's insurance uk" : "home-over-50",
"over 50s home insurance company" : "home-over-50",
"garden insurance" : "home-garden",
"shed insurance" : "home-garden",
"lawn mower insurance" : "home-garden",
"house insurance" : "home-generic-non-contents",
"compare house insurance" : "home-generic-non-contents",
"cheapest house insurance" : "home-generic-non-contents",
"best house insurance" : "home-generic-non-contents",
"student house insurance" : "home-generic-non-contents",
"house insurance online" : "home-generic-non-contents",
"house insurance cover" : "home-generic-non-contents",
"house insurance comparison" : "home-generic-non-contents",
"budget house insurance" : "home-generic-non-contents",
"house hold insurance" : "home-generic-non-contents",
"uk new home insurance rate" : "home-first-time-buyer",
"home insurance northern ireland" : "home-northern-ireland",
"house insurance northern ireland" : "home-northern-ireland",
"building insurance northern ireland" : "home-northern-ireland",
"building and contents insurance northern ireland" : "home-northern-ireland",
"contents insurance" : "home-accidental-damage",
"building insurance" : "home-accidental-damage",
"house contents insurance" : "home-accidental-damage",
"contents insurance uk" : "home-accidental-damage",
"cheap contents insurance" : "home-accidental-damage",
"jewellery insurance" : "home-accidental-damage",
"house insurance" : "home-house",
"compare house insurance" : "home-house",
"cheapest house insurance" : "home-house",
"best house insurance" : "home-house",
"student house insurance" : "home-house",
"house insurance online" : "home-house",
"house insurance cover" : "home-house",
"house insurance comparison" : "home-house",
"budget house insurance" : "home-house",
"house hold insurance" : "home-house",
"car driver insurance new" : "car-new-drivers",
"drivers insurance new" : "car-new-drivers",
"car cheap driver insurance new" : "car-new-drivers",
"driver new" : "car-new-drivers",
"car driver insurance new quote" : "car-new-drivers",
"car driver insurance new young" : "car-new-drivers",
"woman car insurance" : "car-women",
"cheap car insurance for women" : "car-women",
"car insurance for girl" : "car-women",
"womens car inurance company" : "car-women",
"woman car insurance uk" : "car-women",
"london women car insurance" : "car-women",
"car insurance woman uk" : "car-women",
"motor insurance for woman" : "car-women",
"woman only car insurance" : "car-women",
"car insurance quote woman" : "car-women",
"student car insurance" : "car-students",
"cheap student car insurance" : "car-students",
"student car discount insurance" : "car-students",
"student car insurance uk" : "car-students",
"student car driver insurance " : "car-students",
"student nurse car insurance" : "car-students",
"cheap car insurance" : "car-cheap",
"cheap car insurance quote" : "car-cheap",
"cheap car insurance uk" : "car-cheap",
"cheap car insurance online" : "car-cheap",
"cheap motor car insurance" : "car-cheap",
"very cheap car insurance" : "car-cheap",
"cheap car insurance quote uk" : "car-cheap",
"cheap car insurance in uk" : "car-cheap",
"cheap car insurance company" : "car-cheap",
"cheap online car insurance quote" : "car-cheap",
"young driver car insurance" : "car-young-drivers",
"young driver insurance" : "car-young-drivers",
"cheap car insurance for young driver" : "car-young-drivers",
"young driver" : "car-young-drivers",
"young driver motor insurance" : "car-young-drivers",
"cheap insurance for young driver" : "car-young-drivers",
"car insurance quote for young driver" : "car-young-drivers",
"over 50's insurance" : "car-over-50",
"over 50's car insurance" : "car-over-50",
"over 60's car insurance" : "car-over-50",
"senior citizens car insurance" : "car-over-50",
"pensioner car insurance" : "car-over-50",
"over 50's car insurance uk" : "car-over-50",
"pet insurance" : "pet-insurance",
"dog insurance" : "pet-insurance",
"cat insurance" : "pet-insurance",
"pet health insurance" : "pet-insurance",
"cheap pet insurance" : "pet-insurance",
"pet insurance quote" : "pet-insurance",
"insurance pet veterinary" : "pet-insurance",
"pet dog insurance" : "pet-insurance",
"pet cat insurance" : "pet-insurance",
"pet insurance plan" : "pet-insurance",
"10 year fixed mortgages" : "fixed-mortgages",
"fixed  four year mortgage 95%" : "fixed-mortgages",
"fixed rate mortgage direct line" : "fixed-mortgages",
"fixed rate mortgage deals" : "fixed-mortgages",
"best 5 year fixed rate mortgage" : "fixed-mortgages",
"5yr fixed mortgages" : "fixed-mortgages",
"mortgages fixed for life" : "fixed-mortgages",
"direct line fixed mortgage deals" : "fixed-mortgages",
"10 year fixed rate mortgages" : "fixed-mortgages",
"Fixed Rate Buy to Let Mortgages" : "fixed-mortgages",
"fixed rate mortgages" : "fixed-mortgages",
"fixed mortgages" : "fixed-mortgages",
"DIRECT LINE TRACKER MORTGAGE" : "tracker-mortgages",
"flexible tracker mortgage" : "tracker-mortgages",
"discount mortgage" : "tracker-mortgages",
"discount mortgages" : "tracker-mortgages",
"critical illness insurance" : "critical-illness",
"critical illness cover" : "critical-illness",
"critical illness" : "critical-illness",
"critical illness life insurance" : "critical-illness",
"life insurance and critical illness cover" : "critical-illness",
"critical illness cover uk" : "critical-illness",
"critical illness life cover" : "critical-illness",
"home emergency insurance" : "home-emergency",
"home emergency cover" : "home-emergency",
"travel insurance" : "travel-insurance",
"holiday insurance" : "travel-insurance",
"annual travel insurance" : "travel-insurance",
"cheap travel insurance" : "travel-insurance",
"travel insurance uk" : "travel-insurance",
"direct travel insurance" : "travel-insurance",
"online travel insurance" : "travel-insurance",
"worldwide travel insurance" : "travel-insurance",
"travel health insurance" : "travel-insurance",
"travel medical insurance" : "travel-insurance",
"multi-trip travel insurance" : "travel-insurance",
"travel insurance quote" : "travel-insurance",
"loan" : "loan",
"car loan" : "loan",
"motor loan" : "loan",
"personal loan" : "loan",
"secured loan" : "loan",
"bad credit loan" : "loan",
"business loan" : "loan",
"consolidation loan" : "loan",
"home equity loan" : "loan",
"unsecured loan" : "loan",
"life insurance" : "life-insurance",
"life assurance" : "life-insurance",
"life insurance quote" : "life-insurance",
"term life insurance" : "life-insurance",
"whole life insurance" : "life-insurance",
"life insurance uk" : "life-insurance",
"cheap life insurance" : "life-insurance",
"mortgage life insurance" : "life-insurance",
"life insurance company" : "life-insurance",
"life insurance policy" : "life-insurance",
"term life insurance quote" : "life-insurance",
"european breakdown cover" : "euro-breakdown",
"european car breakdown cover" : "euro-breakdown",
"european breakdown" : "euro-breakdown",
"european breakdown insurance" : "euro-breakdown",
"european car breakdown" : "euro-breakdown",
"breakdown" : "breakdown",
"breakdown cover" : "breakdown",
"breakdown insurance" : "breakdown",
"breakdown recovery" : "breakdown",
"breakdown services" : "breakdown",
"car breakdown services" : "breakdown",
"car breakdown" : "breakdown",
"savings account" : "savings",
"individual savings account" : "savings",
"saving" : "savings",
"pensioners saving" : "savings",
"saving and investment" : "savings",
"best savings rate" : "savings",
"offshore savings account" : "savings",
"online savings account" : "savings",
"isa savings" : "savings"
};

/* Touch Clarity Plug-ins - do not edit below this point */

// Targeting on Search Terms
var tc_search_hosts = /(google|search.msn|search.aol|ask|altavista|lycos|search.yahoo|excite|imp)/;
function tc_search_lookup(keywords){
	if (!keywords) {return;}
	var keywords = keywords.toLowerCase();
  for ( var key in tc_search_terms ) {
		debug('RegEx: '+key);
		if (keywords.match(key)){
			var category = tc_search_terms[key];
      category = category.replace(/\s/g, '+');
      category = category.split('&').join('&amp;');
	  	if ((typeof tc_extra_info!='undefined') && (tc_extra_info!=='')) { tc_extra_info+='&'; } 
  		else { tc_extra_info=''; }
  		tc_extra_info+='tc_q='+category;
      debug('Category: '+ category);
    	return category;
		}
  }
}
function tc_check_referrer() {
	var ref=document.referrer || document.location.href;
	if (ref==='' && typeof tc_referrer!='undefined') {ref=tc_referrer;}
  debug('Referrer: '+ref);
  ref = tc_parseUrl(ref);
	debug('Host: '+ref.host);
  if (ref.host.match(tc_search_hosts)){
		debug('Search Host: '+RegExp.$1);
		var query = new tc_Query();
	  var params = query.params;
		var keywords = query.chooseBest();
		debug('Keywords: '+keywords);
		return keywords;
  }
	return false;
}

// Cookie utils
function tc_createcookie(name,value,days)
{
  if (days)
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function tc_readcookie(name)
{
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++)
  {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function tc_erasecookie(name)
{
  tc_createcookie(name,"",-1);
}

// URL utils
function tc_parseUrl(data) {
	 	if (!data) {return;}
		var e = /^((http|https):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)(#[\w\-]+)?$/;
		if (data.match(e)) {
				return  {url: RegExp['$&'], protocol: RegExp.$2,host:RegExp.$3,path:RegExp.$4,file:RegExp.$6,query:RegExp.$7,hash:RegExp.$8};
		} else {
    //RegExp contains the last successful match and does not reflect a failed match attempt so empty it
		return  {url:"No url", protocol:"No protocol",host:"No host",path:"No path",file:"No file",query:"No query",hash:"No hash"};
		}
}
function tc_Query () {
  var qString = document.referrer.replace(/^[^\?]+\??/,'') || document.location.href.replace(/^[^\?]+\??/,'');
  qString = qString.replace(/#[^#]*$/, '');
  if ( qString ) {
     this.queryString = qString;
     this.params = this.parseQuery();
  }
}
tc_Query.prototype.parseQuery = function () {  
  var Params = new Object();
  if ( ! this.queryString ) return Params;
  var Pairs = this.queryString.split(/[&;]/);

  for ( var i = 0; i < Pairs.length; i++ ) {
    var KeyVal = Pairs[i].split('=');
    if ( ! KeyVal.length == 2 ) continue;
    if ( ! ( KeyVal[0] || KeyVal[1] ) ) continue;
    var key = unescape( KeyVal[0] );
    var val = unescape( KeyVal[1] );
    val = val.replace(/\+/g, ' ');
    Params[key] = val;
  }
  return Params;
}
tc_Query.prototype.chooseBest = function () {
  var scoredParams = this.scoredParams();
  var max = 0;
  var choice = '';
  for ( var qVal in scoredParams ) {
    if ( scoredParams[qVal] > max ) {
       choice = qVal;
       max = scoredParams[qVal];
     }
  }
  return choice;
}
tc_Query.prototype.scoredParams = function () {
  var params = this.params;
  var Scored = new Object(); // Scored["value"] = numeric_score_of_value

  for ( var key in params ) {
    var val = params[key];
    var weight = 0;
    var wordlikes = val.match(/(\w[-'\w]+\w\s)|(\w[-'\w]+\w)$/gi);
    weight += wordlikes ? wordlikes.length : 0;
    if ( key.match(/^(q|as_q|key|MT|p|s)$/) ) weight += 3;
    if ( key.match(/query|search/i) ) weight+=2;
    var badChars = val.match(/[^-a-zA-Z'" ]/g);
    weight -= badChars ? ( badChars.length * 2 ) : 0;
    weight -= val.match(/query|search/i) ? 1 : 0;
    Scored[val] = weight;
  }
  return Scored;
}

// Targeted of Flash content
// FlashObject v1.3a: Flash detection and embed - http://blog.deconcept.com/flashobject/
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />\"";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\">";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\">";}}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
n.innerHTML='';
n.innerHTML=this.getFlashHTML();
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};
com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
var _28=new com.deconcept.PlayerVersion(0,0,0);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_28=new com.deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_26&&_28.major>_26.major){return _28;}
if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){
try{
_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}catch(e){}}}
return _28;
};
com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.href.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}
var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;

// Debug stub
if (!window.console || !console.firebug) 
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i){
        window.console[names[i]] = function() {};
    }
}
document.write("<scr"+"ipt language='JavaScript' type='text/javascript' src='"+tc_log_path+"/logging-code.js'></scr"+"ipt>\n");

