/* File displays the following:-

1. ShareASale tracking
2. PMG tracking
3. Search Ignite tracking
4. Linkshare pixel tracking
5. Clickable SEM tracking
6. Google adwords rev pixel tracking


ShareASale tracking - Only ThankYou Page Tracking Required
PMG tracking -- Only ThankYou Page Tracking Required
Linkshare pixel tracking - Only ThankYou Page Tracking Required
Google adwords rev pixel tracking -- Only ThankYou Page Tracking Requireds


*/

jQuery.fn.affiliate = function() {
	var merchAffiliate = function() {};

	merchAffiliate.initialize = function() {
		this.callAffiliate();
    },



    merchAffiliate.callAffiliate = function() {
    	var searchIgniteId;
    	if(jQuery("#searchIgniteId").attr("value")){
    		searchIgniteId= jQuery("#searchIgniteId").val();
    	}
    	var clickableTrackingId;
    	if(jQuery("#clickableTrackingId").attr("value") != ""){
    	clickableConfirmationId= jQuery("#clickableTrackingId").val();
    	}
    	<!-- Search Ignite BEGIN click tracking script  version 4.0 -->
    	if(searchIgniteId){
		jQuery('body').append(jQuery('<script language="javascript" type="text/javascript" src="https://track.searchignite.com/si/CM/Tracking/ClickTracking.aspx?siclientid='+searchIgniteId+'&jscript=1"><\/script>'));
    	}
    	<!-- Search Ignite End click tracking script  version 4.0 -->


    	<!-- Clickable BEGIN tracking script -->
    	if(searchIgniteId){

    	function cct(){this.cct_action_name;this.cct_idsite;this.conversion_value;this.user_id="";this.cct_customvar=new Array;this.cct_conversion_id;this.conversion_label;this.channel="";this.referrer_domain="";this.search_term="";this.network="";this.ctt_id;this.ctt_kw;this.ctt_entity;this.clkdttm;this.session_id="";this.cct_transactionID="";this.ctt_adid="";this.ctt_nwtype="";this.ctt_cli="^^^";this.cct_url=(location.protocol=="https:"?"https://":"http://")+"cn.clickable.net";var w=250;var y="7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip";var o=new Object;o["Paid Search"]=4;o["Website Referral"]=3;o["Organic Search"]=2;o.Direct=1;var v=new Object;v.PS="Paid Search";v.EM="Email Marketing";v.BN="Banner Ad";v.VI="Video";v.SR="Social Referral";v.OS="Organic Search";v.WR="Website Referral";v.DR="Direct";var z=new Object;z.ADWORDS="q";z.BING="q";z.GOOGLE="q";z.YAHOO="p";z.ADCENTER="q";z.LIVE="q";z.ASK="q";z.AOL="query";z.MSN="q";this.cct_plug_normal=function(i){if(f.indexOf(i)!=-1&&(navigator.mimeTypes[i].enabledPlugin!=null)){return"1"}return"0"};this.cct_plug_ie=function(i){pk_found=false;jQuery('body').append(jQuery('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n pk_found = IsObject(CreateObject("'+i+'")) </SCRIPT>\n'));if(pk_found){return"1"}return"0"};var c="0";if(navigator.javaEnabled()){c="1"}var q=navigator.userAgent.toLowerCase();var k=(navigator.appName.indexOf("Netscape")!=-1);var m=(q.indexOf("msie")!=-1);var d=((q.indexOf("win")!=-1)||(q.indexOf("32bit")!=-1));var u=(navigator.cookieEnabled)?"1":"0";if((typeof(navigator.cookieEnabled)=="undefined")&&(u=="0")){document.cookie="cct_testcookie";u=(document.cookie.indexOf("cct_testcookie")!=-1)?"1":"0"}var l="0",b="0",r="0",B="0",g="0",t="0";if(d&&m){l=this.cct_plug_ie("SWCtl.SWCtl.1");b=this.cct_plug_ie("ShockwaveFlash.ShockwaveFlash.1");if(this.cct_plug_ie("PDF.PdfCtrl.1")=="1"||this.cct_plug_ie("PDF.PdfCtrl.5")=="1"||this.cct_plug_ie("PDF.PdfCtrl.6")=="1"){r="1"}B=this.cct_plug_ie("Quicktime.Quicktime");g=this.cct_plug_ie("rmocx.RealPlayer G2 Control.1");t=this.cct_plug_ie("wmplayer.ocx")}else{var f="";for(var s=0;s<navigator.mimeTypes.length;s++){f+=navigator.mimeTypes[s].type.toLowerCase()}l=this.cct_plug_normal("application/x-director");b=this.cct_plug_normal("application/x-shockwave-flash");r=this.cct_plug_normal("application/pdf");B=this.cct_plug_normal("video/quicktime");g=this.cct_plug_normal("audio/x-pn-realaudio-plugin");t=this.cct_plug_normal("application/x-mplayer2")}var A="";try{A=top.document.referrer}catch(j){if(parent){try{A=parent.document.referrer}catch(h){A=""}}}if(A==""){A=document.referrer}this.cct_escape=function(i){if(typeof(encodeURIComponent)=="function"){return encodeURIComponent(i)}else{return escape(i)}};var n="";if(document.title&&document.title!=""){n=escape(encodeURI(document.title))}var x;this.getAdId=function(){return this.GetURLParameter(location.href,"ctt_adid")};this.getNetworkType=function(C){if(C.toLowerCase()=="facebook"||C.toLowerCase()=="fox"){return"C"}var i=this.GetURLParameter(location.href,"ctt_nwtype").toLowerCase();if(C.toLowerCase()=="google"){if(i=="content"){return"C"}else{return"S"}}else{if(C.toLowerCase()=="yahoo"){if(i=="cnt"){return"C"}else{return"S"}}else{if(C.toLowerCase()=="msn"){if(i.charAt(0)=="c"){return"C"}else{return"S"}}else{return""}}}};this.removeDashFromTransId=function(i){if(i!="undefined"&&i!=""&&i!=null){while(i.indexOf("-",0)>=0){i=i.replace("-","")}return i}else{return""}};this.cct_getUrlLog=function(){this.cct_customvar_str="";if(typeof this.cct_customvar=="undefined"){this.cct_customvar=false}if(this.cct_customvar){for(var E in this.cct_customvar){if(!Array.prototype[E]){this.cct_customvar_str+="&"+this.cct_customvar[E]}}}var C=new Date();var D=document.referrer;this.referrer_domain=this.GetTopLevelDomain(this.GetDomainNameFromUrl(D));this.network=this.GetNetwork(D,this.GetURLParameter(location.href,"ctt_nw"));this.channel=this.GetChannel(location.href,this.network,this.GetTopLevelDomain(this.GetDomainNameFromUrl(location.href)),this.referrer_domain,D);this.search_term=((this.channel==v.OS||this.channel==v.PS)?this.GetSearchTerm(D,this.network):"");this.ctt_id=this.GetURLParameter(location.href,"ctt_id");this.ctt_entity=this.GetURLParameter(location.href,"ctt_entity");this.ctt_kw=this.GetURLParameter(location.href,"ctt_kw");this.ctt_nwtype=this.getNetworkType(this.network);if(this.ctt_nwtype=="C"){this.search_term=""}this.ctt_adid=this.getAdId();this.ctt_cli=this.GetURLParameter(location.href,"ctt_cli");if(this.ctt_cli==""){this.ctt_cli="^^^"}this.ctt_cli=this.ctt_cli.replace(/x/g,"^");var F=this.cct_url+"?url="+escape(encodeURI(document.location.href))+"&action_name="+encodeURI(this.cct_action_name)+"&idsite="+this.cct_idsite+"&res="+screen.width+"x"+screen.height+"&col="+screen.colorDepth+"&h="+C.getHours()+"&m="+C.getMinutes()+"&s="+C.getSeconds()+"&fla="+b+"&dir="+l+"&qt="+B+"&realp="+g+"&pdf="+r+"&wma="+t+"&java="+c+"&cookie="+u+"&rd="+encodeURI(this.referrer_domain)+"&ctt_nw="+this.network+"&st="+escape(encodeURI(this.search_term))+"&ctt_ch="+this.channel+"&ctt_adid="+this.ctt_adid+"&ctt_nwtype="+this.ctt_nwtype+"&title="+n+"&urlref="+escape(encodeURI(document.referrer))+"&currd="+this.GetTopLevelDomain(this.GetDomainNameFromUrl(document.location.href))+"&ctt_id="+this.GetAdUnit()+"&sid="+(this.session_id==""?this.guid():this.session_id)+"&uid="+this.user_id+"&ctt_kw="+this.ctt_kw+"&convId="+(this.conversion_label==null?this.cct_conversion_id:this.conversion_label)+"&clkdttm="+this.clkdttm+"&transID="+this.removeDashFromTransId(this.cct_transactionID)+"&cv="+this.getConversionValue(this.conversion_value)+"&ctt_entity="+this.ctt_entity+"&ctt_cli="+this.ctt_cli+"&ctt_ran="+Math.floor(Math.random()*10001)+this.cct_customvar_str;return F};this.GetAdUnit=function(){if(this.ctt_entity=="MK"){return this.GetURLParameter(location.href,"ctt_nwtype").substring(0,1).toUpperCase()+this.ctt_id}else{return this.ctt_id}};this.GetDomainNameFromUrl=function(i){var D=i.toLowerCase();var C=i.indexOf("://");if(C>0){C=C+3}else{C=0}D=D.substring(C);C=D.indexOf("/");if(C>0){D=D.substring(0,C)}return D};this.GetSearchTerm=function(C,D){var i="";i=this.GetURLParameter(C,z[D.toUpperCase()]);if(i==""||i==undefined){i=this.GetURLParameter(C,"q")}if(i==""||i==undefined){i=this.GetURLParameter(C,"p")}if(i==""||i==undefined){i=this.GetURLParameter(C,"query")}if(i==""||i==undefined){i=this.GetURLParameter(C,"userQuery")}if(i!=undefined){return i}else{return""}};this.GetURLParameter=function(E,D){var F=E.indexOf("&"+D+"=");if(F==-1){F=E.indexOf("?"+D+"=");if(F==-1){return""}}F=F+D.length+2;var C=E.substring(F,E.length);var i=C.indexOf("&");if(i>=0){return C.substring(0,i)}else{return C}};this.cct_log=function(C){try{if(C!=null){var i=this.decac(C).split("|");this.cct_idsite=i[0];this.cct_action_name=i[1]}if(this.cct_idsite=="98123781-c01e-4d5a-930f-d546b6ab659c"){return}if(__ckp__i.indexOf("|"+this.cct_action_name+"|")>=0){return}else{__ckp__i=__ckp__i+"|"+this.cct_action_name+"|"}if(x&&(!this.cct_action_name||this.cct_action_name=="")){return}var E=this.cct_getUrlLog();jQuery('body').append(jQuery('<img src="'+E+'" style="border:0; width: 0; height: 0" />'));if(!this.cct_action_name||this.cct_action_name==""){x=1}this.cct_init_tracker()}catch(D){}};this.cct_flashlog=function(D){try{if(D!=null){var i=this.decac(D).split("|");this.cct_idsite=i[0];this.cct_action_name=i[1]}if(x&&(!this.cct_action_name||this.cct_action_name=="")){return}if(this.cct_idsite=="98123781-c01e-4d5a-930f-d546b6ab659c"){return}var G=this.cct_getUrlLog();var F=document.getElementsByTagName("body");if(F!=null){var C=document.createElement("img");C.src=G;F[0].appendChild(C)}if(!this.cct_action_name||this.cct_action_name==""){x=1}this.cct_init_tracker()}catch(E){}};this.S4=function(){return(((1+Math.random())*65536)|0).toString(16).substring(1)};this.guid=function(){return(this.S4()+this.S4()+"-"+this.S4()+"-"+this.S4()+"-"+this.S4()+"-"+this.S4()+this.S4()+this.S4())};this.cct_add_event=function(F,E,C,i){if(F.addEventListener){F.addEventListener(E,C,i);return true}else{if(F.attachEvent){var D=F.attachEvent("on"+E,C);return D}else{F["on"+E]=C}}};var p,a;this.cct_init_tracker=function(){p=this.cct_idsite;a=this.cct_url;if(document.getElementsByTagName){linksElements=document.getElementsByTagName("a")}};this.cct_dummy=function(){return true};this.GetNetwork=function(E,D){var F=D.toLowerCase();if(F!=""&&F!=undefined){return F}else{var C=this.GetURLParameter(location.href,"ctt_adnw");if(C!=""&&C!=undefined){return C}var i=E.toLowerCase();if(i.indexOf(".google.")>-1){return"Google"}else{if(i.indexOf(".yahoo.")>-1){return"Yahoo"}else{if(i.indexOf(".msn.")>-1){return"MSN"}else{if(i.indexOf(".aol.")>-1){return"AOL"}else{if(i.indexOf(".ask.")>-1){return"Ask"}else{if(i.indexOf(".live.")>-1){return"Live"}else{if(i.indexOf(".bing.")>-1){return"Bing"}else{if(i.indexOf(".facebook.")>-1){return"Facebook"}else{if(i.indexOf(".foxaudiencenetwork.")>-1){return"Fox"}else{return""}}}}}}}}}}};this.cct_pause=function(C){var i=new Date();var D=i.getTime()+C;while(i.getTime()<D){i=new Date()}};this.cct_track=function(){var i=new Image();var C=this.cct_getUrlLog();i.onLoad=function(){this.cct_dummy()};i.src=C;this.cct_pause(w)};this.cct_click=function(E){var C;if(typeof E=="undefined"){var E=window.event}if(typeof E.target!="undefined"){C=E.target}else{if(typeof E.srcElement!="undefined"){C=E.srcElement}else{return true}}var D=new String(C.getAttribute("href"));var F=new RegExp("\\.("+y+")$","i");var i=(F.test(D)?"download":"link");if(D!="null"&&C.hostname!=undefined&&(C.hostname!=window.location.hostname||i=="download")){cct.cct_track()}return true};this.GetChannel=function(G,F,I,i,D){var H=this.GetURLParameter(G,"ctt_ch").toUpperCase();var E=v[H];if(E!=undefined){return E}if(H==""||H==undefined){var C=z[F.toUpperCase()];if(C!=undefined){query_str=this.GetURLParameter(D,C);if(query_str!=""&&query_str!=undefined){return v.OS}else{return v.WR}}else{if(i==""){return v.DR}else{if((this.GetTopLevelDomain(I)==this.GetTopLevelDomain(i))&&F==""){return v.DR}else{if((this.GetTopLevelDomain(I)!=this.GetTopLevelDomain(i))&&F==""){return v.WR}else{return v.DR}}}}}};this.GetTopLevelDomain=function(i){var D=i.split(".");var C=D.length;if(C<=2){return i}else{if(D[0].toLowerCase().indexOf("www")>=0){if(C==3){return D[1]+"."+D[2]}else{if(D[C-2].length<=3){return D[C-3]+"."+D[C-2]+"."+D[C-1]}else{return D[C-2]+"."+D[C-1]}}}else{if(D[C-2].length<=3){return D[C-3]+"."+D[C-2]+"."+D[C-1]}else{return D[C-2]+"."+D[C-1]}}}};this.getConversionValue=function(C){if(C==null||C==undefined){return"0"}C=C+"";var i=C.replace(/,/g,"");var D=i.match(/\d*[.]\d*/g);if(D==null){D=i.match(/\d+/g)}if(D==null){return"0"}if(D.length!=1||D.length==0){return"0"}else{return D[0]}};this.sc=function(i){return""};this.CookieCheck=function(i){return""};this.d2h=function(C){var i=C.toString(16);return(i.length==1?"0"+i:i)};this.h2d=function(i){return parseInt(i,16)};this.decac=function(G){if(G.length<7){return"|"}var H=this.h2d(G.substring(0,2));var D=this.h2d(G.substring(2,4));var F="";var C="";for(var E=5;E<G.length;E=E+2){F=F+G.substring(E,E+1);if(C.length<H){C=C+String.fromCharCode(G.charCodeAt(E+1))}else{F=F+String.fromCharCode(G.charCodeAt(E+1))}}F=F.substring(0,D);C=C.substring(0,H);F=F.substring(0,8)+"-"+F.substring(8,12)+"-"+F.substring(12,16)+"-"+F.substring(16,20)+"-"+F.substring(20);return F+"|"+C}}var cct=new cct();try{if(__ckp__i==undefined){var __ckp__ii=0}}catch(e){__ckp__i=""};
    	document.cookie=cct.CookieCheck(document.cookie);
    	cct.cct_log(clickableTrackingId);
    	}
    	<!-- Clickable END tracking scrip -->

 },

merchAffiliate.initialize();

};



//invoke popovers on page load
jQuery(window).load(function(){
   jQuery(document).affiliate();
});

