/*!
 * C3S JavaScript Library v1.0
 * Copyright 2011, AOL UK
 * Requires jQuery 1.5 or above
 */
var C3S=C3S||{msg:"",adDebugCount:1,protocol:window.location.protocol,getCentralRepoHost:function(){return(this.isDefined(this.centralRepoHost)&&this.exists(this.centralRepoHost.replace(/^\s+|\s+$/,"")))?this.centralRepoHost:"partners.aol.co.uk"},getCobrand:function(){if(!this.isDefined(io_c3sd)){return}return(this.isDefined(io_c3sd.cobrand))?io_c3sd.cobrand:"aoluk"},getLegalFooter:function(c){if(!this.isDefined(io_c3sd)){return}var b=(this.isDefined(io_c3sd.cobrand))?io_c3sd.cobrand:"aoluk";var a=(jQuery(c).length>0)?jQuery(c):false;if(a){jQuery.ajax({url:"/",type:"GET",data:{a:"get-legal-footer",cobrand:b},dataType:"html",async:true,success:function(d){a.replaceWith(d)},error:function(d,f,e){alert("error "+f)}})}},getLegalFooterJSON:function(e){if(!this.isDefined(io_c3sd)){return}var b=(this.isDefined(io_c3sd.cobrand))?io_c3sd.cobrand:"aoluk",a=(jQuery(e).length>0)?jQuery(e):((jQuery("#global-legal-footer").length>0)?jQuery("#global-legal-footer"):false),d="http://"+this.getCentralRepoHost()+"/?a=unity-legal-footer&cobrand="+b;if(a){var c=function(j){var f=j.links.length,h=0,g="";do{g+='<li><a title="'+j.links[h].name+'" href="'+j.links[h].href+'" target="'+j.links[h].target+'">'+j.links[h].name+"</a></li>";h++}while(h<=(f-1));a.find(" > UL").html(g)};if(C3S.protocol==="https:"){C3S.consoleOutput("Secure call :: Legal footer :: Aol CDN");switch(b){case"aoluk":case"realuk":d="https://s.aolcdn.com/os/uk-unity/partners/scripts/aoluk-realuk-footerlinks.secure.js";break;case"aolbb":case"bbclient":d="https://s.aolcdn.com/os/uk-unity/partners/scripts/aolbb-bbclient-footerlinks.secure.js";break;default:d="https://s.aolcdn.com/os/uk-unity/partners/scripts/aoluk-realuk-footerlinks.secure.js";break}}jQuery.ajax({url:d,dataType:"jsonp",success:c,jsonpCallback:"drawLegalFooter"})}},getRealNav:function(){var b=function(c){jQuery("body").eq(0).prepend(c)},a="http://"+this.getCentralRepoHost()+"/?a=unity-real-nav";if(C3S.protocol==="https:"){C3S.consoleOutput("Secure call :: Real Layer :: Aol CDN");a="https://s.aolcdn.com/os/uk-unity/partners/scripts/realnav.secure.js"}jQuery.ajax({url:a,dataType:"jsonp",success:b,error:function(){C3S.consoleOutput("Real nav seems to be broken!")},jsonpCallback:"drawRealNav"})},setOmnitureProps:function(){if(!this.isDefined(io_c3sd)||!this.isDefined(s_265)){return}s_265.prop17=(this.isDefined(io_c3sd.omniture)&&this.isDefined(io_c3sd.omniture["prop17"]))?io_c3sd.omniture["prop17"]:"aoluk";s_265.prop21=(this.isDefined(io_c3sd.omniture)&&this.isDefined(io_c3sd.omniture["prop21"]))?io_c3sd.omniture["prop21"]:"portal"},setOmnitureSAccount:function(){if(!this.isDefined(io_c3sd)){return}s_account=(this.isDefined(io_c3sd.omniture)&&this.isDefined(io_c3sd.omniture["s_account"]))?io_c3sd.omniture["s_account"]:((/\.sandbox\./.test(location.hostname))?"aolukqa1,aolukqa3,devaolsvc":"aolukjunglobal,aolukjunportal")},writeAd:function(a){if(!this.isDefined(io_c3sd)){return}return(this.isDefined(io_c3sd.ads)&&this.isDefined(io_c3sd.ads[a]))?io_c3sd.ads[a]:"undefined"},setHeaderElements:function(a,k,r){var n=jQuery("ul#aol-links"),o=n.find("a#aol-header-multiauth-signin");if(o.length>0){if(this.isAolClient()){var c=window.setInterval(function(){o=o.parent();var s=n.find("#aol-header-multiauth-user"),t=n.find("#aol-header-multiauth-user").length>0;o.add(s).remove();if(t){window.clearInterval(c)}},200)}else{o.parent().show()}}this.channel=(!this.isDefined(r)||r===""||r==null)?"unity":r;if(arguments.length<2&&typeof arguments[0]!=="undefined"){if(typeof arguments[0]!=="object"){this.context=arguments[0]}else{this.header=arguments[0]}}else{this.context=a;this.header=k}if(!this.isDefined(io_c3sd)){return}var b=false,p,j;this.context=(this.isDefined(this.context)&&this.exists(jQuery(this.context)))?jQuery(this.context):jQuery("#header");this.header=(this.isDefined(this.header)&&typeof this.header==="object")?this.header:{};var i=(this.isDefined(this.header.wsform)&&this.exists(jQuery(this.header.wsform,this.context)))?jQuery(this.header.wsform,this.context):jQuery("#aol-header-web-search",this.context);var h=i.find("input[name=s_it]");var e=(this.isDefined(this.header.csform)&&this.exists(jQuery(this.header.csform,this.context)))?jQuery(this.header.csform,this.context):jQuery("#aol-header-site-search",this.context);var g=e.find("input[name=s_it]");var l=(this.isDefined(this.header.homelink)&&this.exists(jQuery(this.header.homelink,this.context)))?jQuery(this.header.homelink,this.context):jQuery("#en_gb_home > a",this.context);var q=(this.isDefined(this.header.iconswrapper)&&this.exists(jQuery(this.header.iconswrapper,this.context)))?jQuery(this.header.iconswrapper,this.context):jQuery("#header-tools",this.context);var ll = ( this.isDefined( this.header.logolink ) && this.exists( jQuery(this.header.logolink, this.context) ) ) ? jQuery(this.header.logolink, this.context) : jQuery('a#logo', this.context);if(this.exists(q)){b=true;var d=q.find("a[data-email=true]");var f=q.find("a[data-aim=true]");p=(d.length>0)?d:q.find("#mailContent > a");j=(f.length>0)?f:q.find("#aimContent > a")}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["web-search-url"])){var m=io_c3sd.header["web-search-url"];(m.match(/\/aol/i))?m:m+"aol/search";C3S.msg+=(this.exists(i))?i.attr({action:m}):"Web search form reference is not supplied <br />";switch(this.channel){case"hotsearch":jQuery("ul#clearFix > li#search-tab-web > a").attr({href:m,"data-s_it":(this.isDefined(io_c3sd.header["invocation-type"]))?io_c3sd.header["invocation-type"]:""});jQuery("ul#clearFix > li#search-tab-images > a").attr({href:m.replace(/\/search$/i,"/image"),"data-s_it":(this.isDefined(io_c3sd.header["invocation-type"]))?io_c3sd.header["invocation-type"]:""});break}}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["invocation-type"])){C3S.msg+=(this.exists(h))?h.val(io_c3sd.header["invocation-type"]):"Web search s_it variable doesn't seem to exist <br />"}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["channel-search-url"])){C3S.msg+=(this.exists(e))?e.attr({action:io_c3sd.header["channel-search-url"]}):"Channel search form reference is not supplied <br />"}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["invocation-type-channel"])){C3S.msg+=(this.exists(g))?g.val(io_c3sd.header["invocation-type-channel"]):"Channel search s_it variable doesn't seem to exist <br />"}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["home-url"])){C3S.msg+=(this.exists(l))?l.attr({href:io_c3sd.header["home-url"]}):"Home link reference is not supplied <br />"}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["home-url"])){C3S.msg+=(this.exists(ll))?ll.attr({href:io_c3sd.header["home-url"]}):"Home link reference is not supplied <br />"}if(b){if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["email-url"])){C3S.msg+=(this.exists(p))?p.attr({href:io_c3sd.header["email-url"]}):"Email icon reference is not supplied <br />"}if(this.isDefined(io_c3sd.header)&&this.isDefined(io_c3sd.header["aim-url"])){C3S.msg+=(this.exists(j))?j.attr({href:io_c3sd.header["aim-url"]}):"AIM icon reference is not supplied <br />"}j.bind("click",function(s){s.preventDefault();if(C3S.isNotEmpty(this.href)){C3S.showPopup(300,600,0,0,this.href)}else{alert("AIM URL reference seems to be empty!")}})}if(this.isDefined(io_c3sd.cobrand)&&io_c3sd.cobrand==="realuk"){this.getRealNav()}if(location.hostname.match(/\.sandbox\.|\.?stag(e|ing|eaol|ingaol)\.|\.?dev\./i)){if(C3S.exists(C3S.msg.replace(/\[object\s+object\]/gi,""))){C3S.msg='<span style="color:red">C3S: [errors] <br /> '+C3S.msg.replace(/\[object\s+object\]/gi,"")+"</span>"}else{C3S.msg='<span style="color:blue">C3S: Your implementation seems to be correct!</span>'}jQuery("body").eq(0).prepend('<p style="background:#fff;font: bold 12px georgia;margin: 10px auto;width: 984px;">'+C3S.msg+"</p>")}},showAdMns:function(){var i=location.search,j=document,h,n="";isIE=(j.all)?true:false;if(!i||i==""||i==null){C3S.adDebugCount=-1;return}if(i.toLowerCase().indexOf("mode")!==-1){h=i.replace(/(\?.*)?mode\s*=\s*(debug).*/,"$2");if(h.replace(/^\s+|\s+$/,"")!=="debug"){C3S.adDebugCount=-1;return}}else{C3S.adDebugCount=-1;return}var e=j.createElement("div");e.style.display="none";e.setAttribute("id","ads_debug");if(C3S.adDebugCount==1){if(typeof j.getElementById("right")!=="undefined"&&j.getElementById("right")!==null){j.getElementById("right").insertBefore(e,j.getElementById("right").childNodes[0]);n="display: block;margin: 0 auto 30px; width: 300px;"}else{j.getElementsByTagName("body")[0].insertBefore(e,j.getElementsByTagName("body")[0].childNodes[0]);n="background: #fff;display: block;left: 24%;margin: 40px auto 30px;position: fixed;top: 0;width: 984px;z-index: 9999;"}}if(typeof adsDivs!=="undefined"&&adsDivs.length>0){var c="<table><tbody>";c+='<tr><td bgcolor="#ebf4ff"> Ad Size </td><td bgcolor="#ebf4ff"> Ad MN </td></tr>';if(typeof adsNt!=="undefined"&&adsNt.replace(/^\s+|\s+$/,"")!==""){c+="<td> Ad network ID</td><td>"+adsNt+"</td>"}if(io_c3sd!=="undefined"&&io_c3sd.cobrand!=="undefined"){c+="<tr><td>Cobrand</td><td>"+io_c3sd.cobrand+"</td></tr>"}if(io_c3sd!=="undefined"&&io_c3sd.section_key!=="undefined"){c+="<tr><td>Section Key</td><td>"+io_c3sd.section_key+"</td></tr>"}for(var m in adsDivs){c+="<tr>";var p=(adsDivs[m].mn!=="undefined")?adsDivs[m].mn:"No mn supplied";c+="<td>"+adsDivs[m].w+"x"+adsDivs[m].h+"</td><td>MN: "+p+"</td>";c+="</tr>"}c+="</tbody></table>";var b=j.getElementById("ads_debug");b.innerHTML="";b.innerHTML=c;var o=b.getElementsByTagName("table")[0];o.setAttribute("width","100%");for(var g=0;g<o.firstChild.childNodes.length;g++){if(!isIE){o.firstChild.childNodes[g].setAttribute("style","border: 1px solid #3386BE; border-right: none")}if(o.firstChild.childNodes[g].hasChildNodes()){for(var f=0;f<o.firstChild.childNodes[g].childNodes.length;f++){if(isIE){o.firstChild.childNodes[g].childNodes[f].style.setAttribute("cssText","border: 1px solid #3386BE; padding: 4px;")}else{o.firstChild.childNodes[g].childNodes[f].setAttribute("style","border-right: 1px solid #3386BE; padding: 4px;")}}}}if(C3S.adDebugCount==1){if(!isIE){b.setAttribute("style",n)}else{b.style.setAttribute("cssText",n)}}}C3S.consoleOutput("Writing ad table : attempt: "+C3S.adDebugCount+" : Success!");C3S.adDebugCount++},isAolClient:function(){return this.getCobrand()==="bbclient"||navigator.userAgent.indexOf("AOL")!==-1},isDefined:function(a){return typeof a!=="undefined"},exists:function(a){return a.length>0},isNotEmpty:function(a){return a!==""||a!==null},showPopup:function(b,e,d,a,c){var f=window.open(c,"-","top="+d+",left="+a+",height="+e+",width="+b+",directories=no,titlebar=no,scrollbars=no,status=no,menubar=no,toolbar=no");if(window.focus){f.focus()}},trim:function(a){return a.replace(/^\s+|\s+$/g,"")},consoleOutput:function(a){if(!document.all){if(console&&console!=="undefined"&&console.log&&console.log!=="undefined"){console.log(a)}}}};var _ad_timer=window.setInterval(function(){C3S.showAdMns();if(C3S.adDebugCount==6){C3S.consoleOutput("Writing ad table : complete!");window.clearInterval(_ad_timer)}if(C3S.adDebugCount==-1){C3S.consoleOutput("Writing ad table : not requested!");window.clearInterval(_ad_timer)}},3000);
