home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kompuutteri Kaikille K-CD 2000 #13
/
K-CD-2000-13.iso
/
Web
/
Amused
/
www.amused.com
/
js
/
ad-amused.js
Wrap
Text File
|
2000-06-08
|
3KB
|
88 lines
/**** FUNCTION DESCRIPTION ****/
/* returns string of characters between first occurrence of 2 delimeters (startStr & endStr).
checkStr is the string to be checked. If endStr is not available,
getWord returns the string between startStr and the end of checkStr
called from writeAd() */
function getWord(checkStr, startStr, endStr) {
var returnString = null;
var start = end = 0;
var length = 0;
/* If checkStr is a JavaObject, we must call length() as a method. Otherwise, it is a JavaScript property of "string" */
length = (typeof(checkStr) == "object") ? checkStr.length() : checkStr.length;
start = checkStr.indexOf(startStr);
if (start != -1) {
start += startStr.length;
end = checkStr.indexOf(endStr,start);
if (end != -1) {
returnString = checkStr.substring(start,end);
}
else {
returnString = checkStr.substring(start,length);
}
}
if ((returnString != "") && (returnString != null)) {
return returnString;
}
else {
return -1;
}
}
/**** FUNCTION DESCRIPTION ****/
/* Called from page location where ad needs to be written. Writes DoubleClick code based on information in adString passed to function.
site = Ad Site (e.g. "uproar.amused")
page = Page we're on (mostly "restofsite")
size = WidthxHeight (e.g. "468x60")
tile = Page Position (to differentiate multiple ads on page)
rich = Is this rich media? If not, we'll write simple creative
ord = Cache busting miscellaneous number
*/
function writeAd(adString) {
var primarySrc = "http://ad.doubleclick.net/";
var site = getWord(adString,"site=","&");
var page = getWord(adString,"page=","&");
var size = getWord(adString,"size=","&");
var tile = getWord(adString,"tile=","&");
var rich = (adString.indexOf('richmedia=true')) ? true : false;
var date = new Date();
var ord = "ord=";
ord += date.getTime();
ord += "?";
site = (site == -1) ? "" : site + "/";
page = (page == -1) ? "" : page +";";
size = (size == -1) ? "sz=468x60;" : "sz="+size +";";
tile = (tile == -1) ? "tile=1;" : "tile=" + tile + ";";
var width = getWord(size,"sz=","x");
var height = getWord(size,"x","&");
if (rich) {
var iframeString = '<i'+'frame SRC="'+primarySrc+'adi/'+site+page+size+tile+ord+'" width="'+width+'" height="'+height+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no">';
var scriptString = '<s'+'cript language="JavaScript1.1" src="'+primarySrc+'adj/'+site+page+'abr=!ie;'+size+tile+ord+'"></s'+'cript>';
var hrefString = '<a href="'+primarySrc+'jump/'+site+page+size+tile+ord+'" target="_blank">';
var imgString = '<img name="'+size+'" src="'+primarySrc+'ad/'+site+page+size+tile+ord+'" border="0" width="'+width+'" height="'+height+'"></a>';
}
else {
var hrefString = '<a href="'+primarySrc+'jump/'+site+page+'abr=!ie;'+size+tile+ord+'">';
var imgString = '<img src="'+primarySrc+'ad/'+site+page+'abr=!ie;'+size+tile+ord+'" border=0 height="'+height+'" width="'+width+'"></a>';
}
document.write('<'+'!-- Begin DoubleClick Ad -->');
if (rich) {
document.write(iframeString);
document.write(scriptString);
document.write('<noscript>');
document.write(hrefString);
document.write(imgString);
document.write('</noscript>');
document.write('</iframe>');
}
else {
document.write(hrefString);
document.write(imgString);
}
document.write('<'+'!-- End DoubleClick Ad -->');
}