// declarations and definitions
var overtureDataArray;
var overtureError;
function buildOvertureURL(overtureID, maxAdCount, isSearch) {
var url = 'http://cmhtml.overture.com/d/search/p/guardian/js/uk/ctxt/';
url += '?maxCount=' + maxAdCount + '&keywordCharEnc=latin1&outputCharEnc=latin1';
var mkt;
switch ('nld') {
case 'gbr':
mkt = 'uk';
break;
case 'fr':
mkt = 'fr';
break;
case 'de':
mkt = 'de';
break;
case 'usa':
case 'ca':
mkt = 'us';
break;
default:
mkt = 'row';
}
var sitename
if (isSearch == 1) {
sitename = 'search';
} else {
sitename = 'Guardian';
}
url += '&Partner=' + buildPartnerCode(mkt, sitename);
url += '&mkt=' + mkt;
url += '&ctxtId=' + overtureID;
return url;
}
function buildPartnerCode(mkt, site) {
// For the rest of the world we send a mkt value of 'row', but use 'uk' in the partner code
if ( mkt == 'row' ) {
mkt = 'uk';
}
var partnerCode = 'guardian_';
partnerCode += mkt;
partnerCode += '_ctxt_';
partnerCode += site.toLowerCase();
return partnerCode
}
// Replace the portion of the string after last space before the trimPoint with ellipses
function trimAndEllipses(string, trimPoint) {
if (string.length > trimPoint) {
var spaceBeforeTrimPoint = string.lastIndexOf(" ", trimPoint);
var trimmedString = string.substring(0, spaceBeforeTrimPoint);
return trimmedString.concat("...");
} else {
return string;
}
}
// abstraction for element containing Overture results table
function OvertureDocument() {
// properties
this.htmlText = new String();
if(overtureIsIECompatible) {
// writing to iframe
this.document = parent.document;
} else if(overtureIsDOM) {
// will be in iframe at this point
this.document = parent.document;
} else {
// will be in main body
this.document = document;
}
// methods
this.inspect = function() {
alert(this.htmlText);
};
this.writeln = function(text) {
this.htmlText += text + '\n';
};
this.write = function(text) {
this.htmlText += text;
};
this.flush = function(isSearch) {
parent.setOvertureContent(this.htmlText, isSearch);
this.htmlText = '';
};
this.getElementById = function(name) {
if(overtureIsDOM) {
return this.document.getElementById(name);
} else {
if(overtureIsIECompatible) {
return this.document.all[name];
} else {
return eval('this.document.'+name);
}
}
};
}
var overtureDocument = new OvertureDocument();
//
// OvertureData
//
// The following function is used for the old drop-down display method, no longer used
// render the text of overture result
function overtureDataRenderFunction(mouseOverId) {
overtureDocument.write('');
if(overtureCanDoMouseovers) overtureDocument.write('
Advertiser links |
---|
![]() |
'); mouseOverId = 'overtureResult' + i; data.renderData(mouseOverId); overtureDocument.writeln(' |
![]() |
![]() |
' + data.description + '
'); overtureDocument.writeln('' + data.trimmedHost + ''); } overtureDocument.writeln(''); } break; } return 0; } function createOvertureDataArray (originalArray) { var newArray = new Array(); var counter = 0; var title = ''; var description = ''; var siteHost = ''; var clickURL = ''; for (i in originalArray) { switch (counter) { case 0: description = originalArray[i]; break; case 2: clickURL = originalArray[i]; break; case 3: title = originalArray[i]; break; case 4: siteHost = originalArray[i]; break; case 5: var overtureObj = new OvertureData(title, description, siteHost, clickURL); newArray[newArray.length] = overtureObj; counter = -1; } counter++; } return newArray; } function overtureMouseOver(name) { if(overtureCanDoMouseovers) { overtureShow(name); if(overtureIsBadIEVersion) overtureResize(name,true); } return 0; } function overtureMouseOut(name) { if(overtureCanDoMouseovers) { overtureHide(name); if(overtureIsBadIEVersion) overtureResize(name,false); } return 0; } // called by iframe to set content of overture div var overtureText; function setOvertureContent(text, isSearch) { // Don't bother doing anything if there's no content to set if (text != '') { overtureText = text; if(overtureIsBadIEVersion) { window.setTimeout('setOvertureContent2(' + isSearch + ')',500); } else { setOvertureContent2(isSearch); } } } function setOvertureContent2(isSearch) { var obj = overtureGetElementById('OvertureDiv'); var hldobj = overtureGetElementById('OvertureDivHolder'); // Rendering after the event in Mac IE causes problems, so don't! if (!overtureIsMacIEVersion) { obj.innerHTML = overtureText; hldobj.style.display = 'block'; hldobj.style.visibility = 'visible'; } } function overtureFindPosY(obj) { var curtop = 0; if (document.getElementById || document.all) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (document.layers) curtop += obj.y; return curtop; } // fix-up for IE 5.x's inability to have elements overlap frames var overtureOriginalHeight = 0; function overtureResize(name,expand) { var x = document.getElementById('overture'); var y = document.getElementById(name); if(expand) { overtureOriginalHeight = x.offsetHeight; var xoff = overtureFindPosY(x); var yoff = overtureFindPosY(y); var diff = (yoff+y.offsetHeight) - (xoff+x.offsetHeight); if(diff > 0) { x.style.height = (x.offsetHeight + diff) + 'px'; } } else { x.style.height = overtureOriginalHeight + 'px'; } } // render iframe and script tags for creation of Overture box function renderOvertureBox(overtureID, isSearch, displayMode, maxAdCount) { if( !overtureIsFatalOperaVersion && !overtureIsFatalMacIEVersion && !overtureIsNetscape4Compatible) { document.writeln('