/* Last Modified: 2011-10-25 swright



http://drh.img.digitalriver.com/DRHM/Storefront/Site/C5_662/cm/multimedia/OT_Files/c5_662_globalTrial.js

https://drh.img.digitalriver.com/DRHM/Storefront/Site/C5_662/cm/multimedia/OT_Files/c5_662_globalTrial.js

http://a248.e.akamai.net/f/248/5462/2h/store.digitalriver.com/DRHM/Storefront/Site/C5_662/cm/multimedia/OT_Files/c5_662_globalTrial.js

https://a248.e.akamai.net/f/248/5462/2h/store.digitalriver.com/DRHM/Storefront/Site/C5_662/cm/multimedia/OT_Files/c5_662_globalTrial.js



*/



// Include DR Site Opt object - common utility functions related to MVT

// Version 2.0

// Unminified version: http://digitalriver.com/drso/drso-2.0.js

var drso={version:'2.0',url:location.href.toLowerCase(),setCookie:function(n,v,options){var de=new Date();options=typeof options==='undefined'?{}:options;options.d=typeof options.d==='undefined'?this.getDomain():options.d;options.e=typeof options.e==='undefined'?null:options.e;de.setTime(de.getTime()+options.e*24*60*60*1000);document.cookie=n+'='+escape(v)+((options.e===null)?'':('; expires='+de.toGMTString()))+'; path=/'+((options.d===null)?'':(';domain='+options.d));},getDomain:function(str){str=!str?drso.url:str.toString().toLowerCase();return str.match(/\.?[\w]+\.(net|org|com?\.?[a-zA-Z]{0,2})/g);},getCookie:function(c_name){if(document.cookie.length>0){var c_start=document.cookie.indexOf(c_name+'='),c_end;if(c_start!==-1){c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(';',c_start);if(c_end===-1){c_end=document.cookie.length;}

return unescape(document.cookie.substring(c_start,c_end));}}

return'';},deleteCookie:function(name){this.setCookie(name,'',{e:-1});},getRefUrl:function(exp){if(!drso.getCookie('op_refUrl')){exp=typeof exp==='undefined'?null:exp;var refUrl=document.referrer?document.referrer.toLowerCase():'none';this.setCookie('op_refUrl',refUrl,{e:exp});}

return this.getCookie('op_refUrl');},clickthruRedirect:function(href,clickthru,clickthruUrlArg,extraParams){var hrefParams='',hrefPrefix='',loc=location.href;extraParams=(typeof(extraParams)==='undefined')?'':extraParams;loc=loc.substring(0,loc.lastIndexOf('/'));if(href.indexOf('//')===0){hrefPrefix=location.protocol;}else if(href.indexOf('/')===0){hrefPrefix=location.protocol+'//'+location.hostname;}else if(href.substring(0,4)!=='http'&&href.substring(0,5)!=='https'){while(/^\.\./.test(href)){loc=loc.substring(0,loc.lastIndexOf('/'));href=href.substring(3);}

href=loc+'/'+href;}

if(href.indexOf('?')!==-1){hrefParams='&'+href.split('?')[1];href=escape(href.split('?')[0]);}

window.location=clickthru+'?'+clickthruUrlArg+'='+hrefPrefix+href+hrefParams+extraParams;},setSessionVar:function(k,v){var w=window.name;v=escape(v);if(w.indexOf(k)!==-1){w=w.replace(w.split(k+'=')[1].split('&')[0],v);}else if(w.length){w=w+'&'+k+'='+v;}else{w=k+'='+v;}

window.name=w;},getSessionVar:function(k){var w=window.name;if(w.indexOf(k)!==-1){return unescape(w.split(k+'=')[1].split('&')[0]);}else{return'';}},log:function(s){if(typeof console==='object'){console.log(s);}},getParam:function(options){var name=null,delimiters=['&','='],haystack=null,pattern=null,result={},hs_split=null,hs_max=0,i=0;options=typeof options==='undefined'?false:options;name=options.name||name;delimiters=options.delimiters||delimiters;haystack=options.haystack||haystack;if(!haystack&&!options.delimiters){haystack=location.search.substring(1);}else if(!haystack&&options.delimiters){haystack=location.pathname;}else if(haystack&&!options.delimiters){haystack=haystack.substring(haystack.indexOf('?')+1);}else if(haystack&&options.delimiters){haystack=haystack.substring(0,haystack.indexOf('?'));}

hs_split=haystack?haystack.split(delimiters[0]):hs_split;hs_max=hs_split?hs_split.length:hs_max;if(!hs_split){return false;}

for(i;i<hs_max;i++){if(hs_split[i].split(delimiters[1])[1]){result[hs_split[i].split(delimiters[1])[0]]=hs_split[i].split(delimiters[1])[1];}}

if(name){return result[name];}

return result;},getSerializedParam:function(argName,argDelimStart,argDelimEnd,argHaystack,caseInsens){var name=argName||undefined,delim_start=argDelimStart||undefined,delim_end=argDelimEnd||undefined,haystack=argHaystack||undefined;return this.getParam({'name':name,delimiters:[delim_start,delim_end],haystack:haystack});},getURLparam:function(name){return this.getParam({'name':name});},getUrlParam:function(name){return this.getParam({'name':name});},disableOT:function(){if(typeof(ptomodule)==='object'&&(drso.getParam({name:'optest'})==='false'||drso.getCookie('optest')==='false')){ptomodule.Enabled=false;}},isNewVisitor:function(exp){exp=typeof exp==='undefined'?90:exp;if(drso.getCookie('op_seenStore')==='true'){if(!drso.getCookie('op_newVisitor')){drso.setCookie('op_newVisitor','false');}}else{drso.setCookie('op_seenStore','true',{e:exp});drso.setCookie('op_newVisitor','true');}

return drso.getCookie('op_newVisitor')==='true'?true:false;},logTemplateMeta:function(){this.log('A trial is running on this page -----------------------------------');this.log(' Campaign ID:   {{$creative.campaignId}}');this.log(' Subject ID: {{$creative.subjectId}}');this.log(' Trial ID:   {{$creative.trialId}}');this.log(' Segment ID: {{$creative.segmentId}} ({{$creative.segmentName}})');this.log(' Wave ID:    {{$creative.waveId}}');this.log(' Creative ID:   {{$creative.creativeId}} ({{$creativeCustomId}})');this.log(' Session ID: {{$creative.sessionId}}');this.log(' Impression ID: {{$creative.impressionId}}');},loadBinaryCounter:function(params){var img=new Image(),d=new Date(),i,qs='';params.path=typeof params.path==='undefined'?null:params.path;params.liid=typeof params.liid==='undefined'?null:params.liid;params.href=typeof params.href==='undefined'?null:params.href;params.qs=typeof params.qs==='undefined'?null:params.qs;params.sid=typeof params.sid==='undefined'?'{{$creative.sessionId}}':params.sid;params.sid=/creative\.sessionId/.test(params.sid)?this.getCookie(params.liid):params.sid;if(!params.path||!params.sid||!params.liid){if(params.href){window.location=params.href;}else{return false;}}else if(params.qs){for(i in params.qs){qs+='&'+i+'='+params.qs[i];}}

if(params.href){img.onload=function(){window.location=params.href;};}

img.src=params.path+'?'+params.liid+'='+params.sid+qs+'&ts='+d.getTime();},init:function(){this.disableOT();}},

    opcounter = {},

    optrial = {};



drso.init();



/* Product SKUs for conversion setup */

optrial.op390o14TrialCookieMonitor = {

    skus: {

        has: {

            en: {

                buy: {

                        multi:'10246825', 

                        single:'10377661'

                    }

            },

            es: {

                buy: {

                        multi:'10246826', 

                        single:'10377662'

                    }

            }

        },

        hab: {

            en: {

                buy: {

                        multi:'10246981', 

                        single:'10377697'

                    }

            },

            es: {

                buy: {

                        multi:'10246982', 

                        single:'10377698'

                    }

            }

        },

        pro: {

            en: {

                buy: {

                        multi:'10246613', 

                        single:'10377625'

                    }

            },

            es: {

                buy: {

                        multi:'10246614', 

                        single:'10377626'

                    }

            }

        }

    },

    getAllBuySkus: function () {

    	var result = [];

	    var skus = optrial.op390o14TrialCookieMonitor.skus;

	    for (var name in skus) {

		    for (var lang in skus[name]) {

			    result.push(skus[name][lang].buy.multi);

			    result.push(skus[name][lang].buy.single);

		    }

	    }

	    return result;

    }

};



if(drso.getCookie('O14_DYN_TARGET') 

	&& drso.getCookie('op390o14trialcookiemonitoring_returningVisitor').length == 0

	&& (/buyoffice\.microsoft\./i.test(location.hostname) || /digitalriver\./i.test(location.hostname))

    && !/downloader\.aspx/i.test(location.pathname)) {

	

    drso.setCookie('op390o14trialcookiemonitoring_returningVisitor', 'true', { e: 120 });

	

	// Counter: c5_662 o14 trial non-conversions

    // Query string: culture, sku

    // JavaScript expressions: location.pathname

	var _o=(typeof opcounter=="object")?opcounter:new Object;_o.D=document;_o.L=_o.D.location;_o.T=

	new Date;_o.Q=new Object;_o.C=new Object;_o.U="http://pto.digitalriver.com/counter/390/-/345/event.js";

	_o.D_ts=Math.round(_o.T.getTime()/1000);_o.D_tzo=_o.T.getTimezoneOffset();_o.D_loc=_o.L.protocol+

	"//"+_o.L.hostname+_o.L.pathname;_o.D_ckl=_o.D.cookie.length;_o.D_ref=_o.D.referrer;function 

	_oI(){var s=_o.L.search;var c=_o.D.cookie;if(s.length>3){for(var a=s.substring(1).split("&")

	,i=0,l=a.length;i<l;i++){var p=a[i].indexOf("=");if(p>0)_o.Q[a[i].substring(0,p)]=unescape(a[i].substring(

	p+1));}}if(c.length>3){for(var a=c.split(";"),i=0,b=a.length;i<b;i++){var v=a[i].split("=");

	while(v[0].substring(0,1)==" ")v[0]=v[0].substring(1,v[0].length);if(v.length==2)_o.C[v[0]]=

	unescape(v[1]);}}}function _oS(){var o=new Object;for(var n in _o)o[n]=_o[n];o.D=o.L=o.T=o.Q=o.C=

	o.U=null;var q='';for(var n in o)if(o[n]!=null && o[n]!="")q+=(q.length>0?"&":(_o.U.indexOf(

	"?")>0?"&":"?"))+n+"="+escape(o[n]);return _o.U+q;}_oI();for(var n in _o.Q)if(n.substring(

	0,2)=="op")_o[n]=_o.Q[n];for(var n in _o.C)if(n.substring(0,2)=="op")_o[n]=_o.C[n];_o["culture"]=

	_o.Q["culture"];_o["sku"]=_o.Q["sku"];_o["location.pathname"]=location.pathname;_o.D.write('<'+

	'script type="text/javascript" src="'+_oS()+'"><\/script>');

}

CookieStringKey=location.href;
var expiresz = new Date();
expiresz.setDate(expiresz.getDate() + 1);
if (CookieStringKey.indexOf('Starter') != -1) {
    document.cookie = 'op_oobestarter=yes;expires=' + expiresz.toGMTString()+';domain=.microsoft.com;path=/;'
}
if (CookieStringKey.indexOf('OOBE') != -1) {
    document.cookie = 'op_oobestarter=yes;expires=' + expiresz.toGMTString()+';domain=.microsoft.com;path=/;'
}



// Sets cookie to indicate the conversion experience.  Created for Black Friday 2011.
$(document).ready(function(){

var expiresa = new Date();
expiresa.setDate(expiresa.getDate() + 5);
var bfSKU='empty';
if(document.location.href.indexOf("default.aspx") != -1){
  bfSKU=$('.image a:eq(0)').attr('href');
  if((bfSKU.indexOf("10246825")!=-1)||(bfSKU.indexOf("10246826")!=-1)||(bfSKU.indexOf("10246981")!=-1)||(bfSKU.indexOf("10246982")!=-1)||(bfSKU.indexOf("10246613")!=-1)||(bfSKU.indexOf("10246614")!=-1)){  
    document.cookie = 'op_conversion=true;expires=' + expiresa.toGMTString()+';domain=.microsoft.com;path=/;'
  }
}
if(document.location.href.indexOf("product.aspx") != -1){
  bfSKU=c5_site_meta.product_info.current_sku;
  if((bfSKU=="10246825")||(bfSKU=="10246826")||(bfSKU=="10246981")||(bfSKU=="10246982")||(bfSKU=="10246613")||(bfSKU=="10246614")){  
    document.cookie = 'op_conversion=true;expires=' + expiresa.toGMTString()+';domain=.microsoft.com;path=/;'
  }
}
if(document.location.href.indexOf("basket.aspx") != -1){
  var bfSKUc='empty';
  var bfSKUt='empty';
  bfSKUt=$('.basketContent .productName').text();
  if(bfSKUt.indexOf("Office")!=-1){
    bfSKUc=$('.item:contains("Office") .image a:first').attr('href');
  }
  if((bfSKUc.indexOf("10246825")!=-1)||(bfSKUc.indexOf("10246826")!=-1)||(bfSKUc.indexOf("10246981")!=-1)||(bfSKUc.indexOf("10246982")!=-1)||(bfSKUc.indexOf("10246613")!=-1)||(bfSKUc.indexOf("10246614")!=-1)){  
    document.cookie = 'op_conversion=true;expires=' + expiresa.toGMTString()+';domain=.microsoft.com;path=/;'
  }
}

});


//c5_662 Buy Try USA Subject All Pages
(function(){var _o=ptomodule;_o.U="https://ssl.pto.digitalriver.com/by/trial/390/p/allpages1.433/490/content.js";
_o.ST="script";_o.SA={"type":"text/javascript"};_o.B();_o.R(1000,null,null,null);})();


