//(c)2006-2010 Max Edwards - www.maxedwards.com
//
function insertMTL() {
var e = 'info /#/ nowtravel.org.uk'.replace(' /#/ ', '@');
document.write('<a href="m' + 'ai' + 'lt' + 'o:' + e + '">' + e + '</a>');
}
var AWC_PageView = '';
var AWC_IFrame = '';
var AWC_ExtLink = '';
var AWC_ExtForm = '';
var AWC_Mailto = 'Lead';
var ClickLog_IFrame = true;
var ClickLog_ExtLink = true;
var ClickLog_ExtForm = true;
var ClickLog_Mailto = true;
var ExtLinkMode = 'BLANK';
var ExtFormMode = 'BLANK';
var adWordsConversionID = '1071638707';
var serverName='www.nowtravel.org.uk';
var appPath='';
var activeCC='??';
var fallbackCC='UK';
var loadCSSH=false
function replaceAll(s, text, by, ignoreCase) {
var rai = -1;
var textlc=text.toLowerCase();
if(ignoreCase) rai = s.toLowerCase().indexOf(textlc);else rai = s.indexOf(text);
var its = 0;
while (rai>=0 && its < 5000) {
its++;
if(rai>0)
s = s.slice(0, rai) + by + s.slice(rai+text.length);
else
s = by + s.slice(rai+text.length);
if(ignoreCase) rai = s.toLowerCase().indexOf(textlc, rai+by.length);else rai = s.indexOf(text, rai+by.length);
}
if(its>=5000) alert('OVERFLOW!');
return s;
}
function trim(s) {return ltrim(rtrim(s));}
var whitespace = ' \t\n\r';
function rtrim(s) {
while (whitespace.indexOf(s.charAt(s.length-1)) >= 0 && s.length > 0)
if(s.length == 1) s='';else s = s.slice(0, -1);
return s;
}
function ltrim(s) {
while (whitespace.indexOf(s.charAt(0)) >= 0 && s.length > 0)
if(s.length == 1) s='';else s = s.slice(1);
return s;
}
function getRefToDiv(divID) {return getRefToElement(divID);}
function getRefToElement(id) {
if( document.layers ) {
return document.layers[id];}
if( document.getElementById ) {
return document.getElementById(id);}
if( document.all ) {
return document.all[id];}
if( document[id] ) {
return document[id];}
return false;
}
function getInnerText(obj) {
if(typeof(obj.innerText) != 'undefined') return (obj.innerText);
if(typeof(obj.textContent) != 'undefined') return(obj.textContent);
if(typeof(obj.text) != 'undefined') return(obj.text);
return null;
return obj.innerText || obj.textContent || obj.text;
}
function setInnerText(obj, txt) {
if(typeof(obj.innerText) != 'undefined') {obj.innerText = txt;return}
if(typeof(obj.textContent) != 'undefined') {obj.textContent = txt;return}
if(typeof(obj.text) != 'undefined') {obj.text = txt;return}
return null;
}
function addEvent(obj, eventname, func) {
if(typeof obj.addEventListener != 'undefined')
obj.addEventListener(eventname, func, false);
else
if(typeof obj.attachEvent != 'undefined') {
obj.attachEvent('on' + eventname, func);
}else {
eval('obj.on' + eventname + ' = func;');
}
}
function addLoadEvent(func) {
if(typeof window.addEventListener != 'undefined')
window.addEventListener('load', func, false);
else
if(typeof document.addEventListener != 'undefined')
document.addEventListener('load', func, false);
else
if(typeof window.attachEvent != 'undefined')
window.attachEvent('onload', func);
else {
if(typeof window.onload == 'function') {
var existing = window.onload;
window.onload = function() {
existing();
func();
}
}
else window.onload = func;
}
}
function addResizeEvent(func) {
if(typeof window.addEventListener != 'undefined')
window.addEventListener('resize', func, false);
else
if(typeof document.addEventListener != 'undefined')
document.addEventListener('resize', func, false);
else
if(typeof window.attachEvent != 'undefined')
window.attachEvent('onresize', func);
else {
if(typeof window.onload == 'function') {
var existing = window.onresize;
window.onresize = function() {
existing();
func();
}
}
else window.onresize = func;
}
}
function XMLfetch(loc, async, asyncCallbackFunction) {
var XMLrequest = createXMLHttpRequest();
if(XMLrequest) {
if(typeof(async) == 'undefined') async = false;
if(async) {
if(typeof(asyncCallbackFunction) == 'undefined') {
asyncCallbackFunction = function() {
if(XMLrequest.readyState==4) {
}
}
}
XMLrequest.onreadystatechange = asyncCallbackFunction;
}
try {XMLrequest.open("GET", loc, async);}catch (e) {
}
var ok = false;
try {XMLrequest.send('');ok = true;}catch (e) {}
if(!ok)
try {XMLrequest.send();ok = true;}catch (e) {}
if(ok && !async) return XMLrequest.responseText;else return '';
}else {
return '';
}
}
function createXMLHttpRequest() {
try { return new ActiveXObject("Msxml2.XMLHTTP");}catch (e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP");}catch (e) {}
try { return new XMLHttpRequest();}catch(e) {}
return null;
}
function dumpObject(obj) {
n = '';
for (property in obj) {
n += property + ' = \'' + eval('obj.' + property) + '\' ';
}
alert(n)
}
function setAllCheckboxes(aForm, aValue) {
var all = aForm.elements;
for (var i = 0;i < all.length;++i) {
if(all[i].nodeName.match(/^input$/i) && all[i].type.match(/^checkbox$/i))
all[i].checked = aValue;
}
}
function Random(N) {
return Math.floor(N * (Math.random() % 1));
}
function randomInt(MinV, MaxV) {
return MinV + Random(MaxV - MinV + 1);
}
var abIDcount = 0;
function makeAutoBanner(width, height, rangeStart, rangeFinish, keywords, baseURL) {
if(!baseURL) baseURL = appPath;
var urlJoin = '?';
var coun = '';
if(activeCC != '' && activeCC != '??') coun = activeCC;
var src= baseURL + '/autoban2_' + width + 'x' + height + coun + '/' + rangeStart + '/' + rangeFinish;
if(keywords) if(keywords != '') {
src += urlJoin + 'q=' + escape(keywords);
urlJoin = '&';
}
abIDcount += 1;
if(abIDcount == 1) {
src += urlJoin + 'id=1';
urlJoin = '&';
}
document.write('<iframe frameborder="0" width="' + width + '" height="' + height + '" src="' + src + '" border="0" marginwidth="0" marginheight="0" scrolling="no" style="background:transparent;"></iframe>');
}
function getStyle(obj,styleProp)
{
if(obj.currentStyle)
return obj.currentStyle[styleProp];
else if(window.getComputedStyle)
return document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
return eval('obj.style.' + styleProp);
}
function elementVisible(obj) {
do {
if(getStyle(obj,'display').toUpperCase()=='NONE') return false;
if(getStyle(obj,'visibility').toUpperCase()=='HIDDEN') return false;
obj=obj.parentNode;
}while (obj.tagName.toUpperCase() != 'BODY');
return true;
}
var _SR_divPrefix;
var _SR_width;
var _SR_height;
var _SR_numBans;
var _SR_sideScroll;
var _SR_animate_interval_ms = 50;
var _SR_animate_duration_ms = 1000;
var _SR_minSecondsSpacing = 15;
var _SR_maxSecondsSpacing = 21;
var _SR_deferInit = true;
var __SR = new Array();
function SR_createRotator() {
__SR.length++;
__SR[__SR.length-1] = new SR_rotatorObject(__SR.length-1);
}
function SR_rotatorObject(arrayIndex) {
this.myIndex = arrayIndex;
this.prefix = _SR_divPrefix;
this.width = _SR_width;
this.height = _SR_height;
this.sideScroll = _SR_sideScroll;
this.numBans = _SR_numBans;
this.animate_interval_ms = _SR_animate_interval_ms;
this.animate_duration_ms = _SR_animate_duration_ms;
this.minSecondsSpacing = _SR_minSecondsSpacing;
this.maxSecondsSpacing = _SR_maxSecondsSpacing;
this.deferInit = _SR_deferInit;
this.banNew = randomInt(1, this.numBans);
this.banOld = -1;
if(this.sideScroll)
this.destVal = this.width;
else
this.destVal = this.height;
this.curVal = this.destVal;
var steps = this.animate_duration_ms / this.animate_interval_ms;
if(this.sideScroll)
this.animate_increment = Math.round(this.width / steps, 0);
else
this.animate_increment = Math.round(this.height / steps, 0);
if(this.animate_increment < 1) this.animate_increment = 1;
this.ensureNextBannerLoaded = function() {
var objNew = getRefToElement(this.prefix + this.banNew);
var objLinks = objNew.getElementsByTagName('a');
if(objLinks.length>0) {
var objImgs = objLinks[0].getElementsByTagName('img');
if(objImgs.length>0) {
var defSrc = getAttr(objImgs[0], 'defSrc');
if(defSrc) if(defSrc!='') if(defSrc.indexOf('http') == 0) {
objImgs[0].src = defSrc;
objImgs[0].removeAttribute('defSrc');
}
}
}
return true;
}
this.doNextStep = function() {
var objNew = getRefToElement(this.prefix + this.banNew);
this.ensureNextBannerLoaded();
if(this.banOld < 0) {
if(this.sideScroll) {
objNew.style.display = 'inline';
}else {
objNew.style.display = 'block';
}
}else {
this.curVal += this.animate_increment;
if(this.curVal > this.destVal) this.curVal = this.destVal;
if(this.sideScroll) {
objNew.style.width = this.curVal + 'px';
objNew.style.display = 'inline';
}else {
objNew.style.height = this.curVal + 'px';
objNew.style.display = 'block';
}
objNew.style.visibility = 'visible';
var objOld = getRefToElement(this.prefix + this.banOld);
if(this.curVal == this.destVal) {
objOld.style.display = 'none';
}else {
if(this.sideScroll)
objOld.style.width = (this.destVal - this.curVal) + 'px';
else
objOld.style.height = (this.destVal - this.curVal) + 'px';
}
}
if(this.curVal == this.destVal) {
var prog = (this.banNew-1) / (this.numBans-1);
var delay = this.minSecondsSpacing * prog + this.maxSecondsSpacing * (1 - prog);
this.banOld = this.banNew;
this.banNew = (this.banNew % this.numBans) + 1;
this.curVal = 0;
if(delay>3)
setTimeout('__SR[' + this.myIndex + '].ensureNextBannerLoaded();', Math.round((delay - 3) * 1000, 0));
else
this.ensureNextBannerLoaded();
setTimeout('__SR[' + this.myIndex + '].doNextStep();', Math.round(delay * 1000, 0));
}else {
setTimeout('__SR[' + this.myIndex + '].doNextStep();', this.animate_interval_ms);
}
}
this.doNextStep();
}
function getAttr(node, attr) {
var v = '';
try {v=node.getAttribute(attr);}catch (e) {
return '';
}
return v;
}
function availableWidth() {
if(typeof(window.innerWidth) != 'undefined') return window.innerWidth;
if(typeof(document.documentElement.clientWidth) != 'undefined') return document.documentElement.clientWidth;
return document.body.clientWidth;
}
function availableHeight() {
if(typeof(window.innerHeight) != 'undefined') return window.innerHeight;
if(typeof(document.documentElement.clientHeight) != 'undefined') return document.documentElement.clientHeight;
return document.body.clientHeight;
}
function googleVideo(docID, wid, hei, startP) {
var r = '';
r += '<embed style="width:' + wid + 'px;height:' + hei + 'px;" id="VideoPlayback" flashvars="initialTime=' + startP + '"';
r += ' type="application/x-shockwave-flash" quality="best" bgcolor="#000000"';
r += ' src="http://video.google.com/googleplayer.swf?docId=' + docID + '"></embed>';
return r;
}
function youTube(docID, wid, hei, dummy) {
var r = '';
r += '<object width="' + wid + '" height="' + hei + '">';
r += '<param name="movie" value="http://www.youtube.com/v/' + docID + '"></param>';
r += '<embed src="http://www.youtube.com/v/' + docID + '" type="application/x-shockwave-flash"';
r += ' width="' + wid + '" height="' + hei + '"></embed></object>';
return r;
}
function makeGoogleSearch(kw) {
var h = '';
var asID = '';
if(serverName=='www.spinge.com') asID='eet89urclj4';
if(serverName=='www.nowtravel.org.uk') asID='jlguuhfvzbc';
if(serverName=='www.maxoffice.org.uk') asID='tpnp38z9nhw';
if(asID!='') {
h += '<br /><br /><form action="http://www.google.com/cse" id="cse-search-box">';
h += '<div>';
h += '<input type="hidden" name="cx" value="partner-pub-3891734730917860:' + asID + '" />';
h += '<input type="hidden" name="ie" value="ISO-8859-1" />';
h += '<input type="text" name="q" size="31" value="' + kw + '"/>';
h += '<input type="submit" name="sa" value="Search" />';
h += '</div>';
h += '</form>';
h += '<scr' + 'ipt type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></scr' + 'ipt>';
}
document.write(h);
}
addLoadEvent(checkTargets);
var lCC = false;
var lTZ = false;
var lSCR = false;
var redir = '';
var AWC_JSredir = '';
function doLoggingAndRedirects() {
if(lCC || lTZ || lSCR) {
var url = 'http://' + serverName + appPath + '/log';
url += '/l';if(lCC && typeof(sGeobytesLocationCode)!='undefined')
url += escape(sGeobytesLocationCode);
url += '/z';if(lTZ) { var d = new Date();url += d.getTimezoneOffset();}
url += '/s';if(lSCR) url += screen.width + 'x' + screen.height;
XMLfetch(url, (redir == ''));
}
if(redir != '') {
if(redir.indexOf('!!CC!!') >= 0) {
var CC = fallbackCC;
if(typeof(sGeobytesLocationCode) != 'undefined')
if(sGeobytesLocationCode != 'unknown')
CC = sGeobytesLocationCode.slice(0,2);
redir = redir.replace('!!CC!!', CC);
}
if(redir.toLowerCase().indexOf('http') == 0)
if(redir.toLowerCase().indexOf('http://' + serverName.toLowerCase()) < 1) {
adWordsConversion(AWC_JSredir);
XMLfetch('http://' + serverName + appPath + '/_ExitVia_JSREDIRECT.aspx?dest=' + escape(redir));
}
location.replace(redir);
}
}
var iframeDims = '';
var iframeNo = 0;
var iframeProvider = '';
var iframeExtraInfo = '';
function checkTargets() {
adWordsConversion(AWC_PageView);AWC_PageView = '';
if(loadCSSH) {CSSH_parseStylesheets();}
doLoggingAndRedirects();
var r = '';
var links = document.getElementsByTagName('a');
r += '\nNon-standard links:\n';
var h;
if(links.length > 0) {
for (var i=0;i<links.length;i++) {
h = links[i].href.toString().toLowerCase();
extLink = h.indexOf('http') == 0
extLink = extLink && (h.indexOf(location.toString().slice(0, 8 + serverName.length)) != 0);
if(extLink) {
r += links[i].href + ' (EXTERNAL)\n';
if(ExtLinkMode == 'BLANK') links[i].target='_blank';
if(ExtLinkMode == 'SAME') links[i].target='';
addEvent(links[i], 'click', logLINKclick);
}
if(h.indexOf('mailto:') == 0) {
r += links[i].href + ' (MAILTO)\n';
addEvent(links[i], 'click', logMAILTOclick);
}
}
}
var forms = document.getElementsByTagName('form');
r += '\nexternal forms:\n';
var act;
if(forms.length > 0) {
for (var i=0;i<forms.length;i++) {
act = forms[i].action.toString().toLowerCase();
if(act.indexOf(serverName)<0 && act.indexOf('http')==0) {
r += forms[i].action + '\n';
if(ExtFormMode == 'BLANK') forms[i].target='_blank';
if(ExtFormMode == 'SAME') forms[i].target='';
addEvent(forms[i], 'submit', logFORMsubmit);
}
}
}
if(document.all) {
var x = document.getElementsByTagName("iframe");
if(typeof x == "undefined") {
return;
}
if(x.length ==0) {
return;
}
for (iframeNo=0;iframeNo<x.length;iframeNo++) {
identifyIframe(x[iframeNo]);
x[iframeNo].onfocus = logIFRAMEclick;
}
}else {
window.addEventListener('beforeunload', FFpageExit, false);
window.addEventListener('mousemove', FFgetMouse, true);
}
}
var FFpx;
var FFpy;
function FFgetMouse(e) {FFpx=e.pageX;FFpy=e.clientY;}
function findY(obj) {
var y = 0;
while (obj) {y += obj.offsetTop;obj = obj.offsetParent;}
return(y);
}
function findX(obj) {
var x = 0;
while (obj) {x += obj.offsetLeft;obj = obj.offsetParent;}
return(x);
}
function FFpageExit(e) {
var x = document.getElementsByTagName("iframe");
if(typeof x == "undefined") {
return;
}
if(x.length ==0) {
return;
}
for (iframeNo=0;iframeNo<x.length;iframeNo++) {
var iLeft = findX(x[iframeNo]);
var iTop = findY(x[iframeNo]);
var xMatch = (FFpx > (iLeft - 10) && FFpx < (parseInt(iLeft) + parseInt(x[iframeNo].width) + 15));
var yMatch = (FFpy > (iTop - 10) && FFpy < (parseInt(iTop) + parseInt(x[iframeNo].height) + 10));
if(xMatch && yMatch) {
identifyIframe(x[iframeNo]);
logIFRAMEclick(e);
}else {
}
}
}
function identifyIframe(obj) {
iframeDims = obj.width + 'x' + obj.height;
iframeExtraInfo = obj.extraInfo;if(!iframeExtraInfo) iframeExtraInfo = '';
iframeProvider = 'unknown+provider&fullSource=' + obj.src;
var x = obj.src;
if(!x) return;
x = x.toString().toLowerCase();
if(x.indexOf('googlesyndication') > -1) {iframeProvider = 'googlesyndication';return;}
if(x.indexOf('tradedoubler') > -1) {iframeProvider = 'tradedoubler';return;}
if(x.indexOf('/_debug/_write') > -1) {iframeProvider = 'AdSenseDevserverSubstitute';return;}
if(x.indexOf('/autoban') > -1) {iframeProvider = 'LinkPlexAutoBanner';return;}
}
function isRightClick_v2(e) {
var but = -1;
if(typeof e != "undefined")
if(typeof e.which != "undefined")
but = e.which;
if(typeof event != "undefined")
if(typeof event.button != "undefined")
but = event.button;
return (but == 2 || but == 3);
}
function isRightClick(e) {
var but = -1;
if(document.all) but=event.button;else but=e.which;
return (but == 2 || but == 3);
}
function logIFRAMEclick(e) {
if(isRightClick(e)) return true;
if(document.all) l = window.event.srcElement;else l = e.target;
adWordsConversion(AWC_IFrame);AWC_IFrame = '';
if(ClickLog_IFrame) {
XMLfetch('http://' + serverName + appPath + '/_ExitVia_IFRAME.aspx?name=' + l.name + '&iframeNo=' + (iframeNo+1) + '&dimensions=' + iframeDims + '&provider=' + iframeProvider + '&extraInfo=' + iframeExtraInfo.toString());
ClickLog_IFrame = false;
}
if(typeof _uacct != "undefined") {
if(l.src.indexOf("pagead2.googlesyndication.com/pagead/iclk") > -1) {
urchinTracker("/GoogleAdSenseClick");
}else if(l.src.indexOf("pagead2.googlesyndication.com/pagead/ads") > -1) {
urchinTracker("/GoogleAdLinkClick");
}else if(l.src.indexOf("adwords.google.com") > -1) {
urchinTracker("/GoogleAdwordsSignup");
}else if(l.src.indexOf("services.google.com") > -1) {
urchinTracker("/AdsByGoogleFeedback");
}else if(l.src.indexOf("mm.chitika.net") > -1) {
urchinTracker ("/ChitikaClick");
}else if(l.src.indexOf("overture.com") > -1) {
urchinTracker("/YPNClick");
}else if(l.src.indexOf("publisher.yahoo.com") > -1) {
urchinTracker("/YahooPublisherFeedback");
}
}
}
function logLINKclick(e) {
if(isRightClick(e)) return true;
if(document.all) l = window.event.srcElement;else l = e.target;
var leaving = (ExtLinkMode == 'SAME' || l.target=='');
adWordsConversion(AWC_ExtLink);if(leaving) AWC_ExtLink = '';
if(ClickLog_ExtLink) {
XMLfetch('http://' + serverName + appPath + '/_ExitVia_HYPERLINK.aspx?innerText=' + escape(l.innerText) + '&name=' + escape(l.name) + '&title=' + escape(l.title) + '&id=' + escape(l.id) + '&href=' + escape(l.href), !leaving);
if(leaving) ClickLog_ExtLink = false;
}
}
function logMAILTOclick(e) {
if(isRightClick(e)) return true;
if(document.all) l = window.event.srcElement;else l = e.target;
adWordsConversion(AWC_Mailto);AWC_Mailto = '';
if(ClickLog_Mailto) {
XMLfetch('http://' + serverName + appPath + '/_ExitVia_MAILTO.aspx?innerText=' + escape(l.innerText) + '&name=' + escape(l.name) + '&title=' + escape(l.title) + '&id=' + escape(l.id) + '&href=' + escape(l.href), true);
}
}
function logFORMsubmit(e) {
if(document.all) l = window.event.srcElement;else l = e.target;
var leaving = (ExtLinkMode == 'SAME' || l.target=='');
adWordsConversion(AWC_ExtForm);if(leaving) AWC_ExtForm = '';
if(ClickLog_ExtForm) {
XMLfetch('http://' + serverName + appPath + '/_ExitVia_FORM.aspx?action=' + escape(l.action) + '&name=' + escape(l.name) + '&id=' + escape(l.id), !leaving);
if(leaving) ClickLog_ExtForm = false;
}
}
function adWordsConversion(label) {
if(typeof label == "undefined") return;
if(label == '') return;
crossDomainTrackerLoad('http://www.googleadservices.com/pagead/conversion/' + adWordsConversionID + '/?value=1&label=' + label + '&script=0');
}
var tmpImage=new Image();
function crossDomainTrackerLoad(url) {
if(typeof document.createElement != "undefined") {
var anImg = document.createElement( 'img' );
anImg.setAttribute('id','tmpTrackingImage');
anImg.setAttribute('width',1);
anImg.setAttribute('height',1);
document.body.appendChild( anImg );
addEvent(anImg, 'load', removeTmpTrackerImage);
anImg.setAttribute("src", url);
}else {
tmpImage.src = url;
}
}
function removeTmpTrackerImage()
{
var anImg = getRefToElement('tmpTrackingImage');
if(anImg) anImg.parentNode.removeChild(anImg);
}
function checkAgreement() {
if(getRefToDiv('agreeTerms').checked) return true;
alert('Please confirm that you have read and agree to my Terms & Conditions.\n\nI cannot commence any type of work for you INCLUDING:\n\n- fulfilling a request for a quote\n- meeting to discuss possible work\n\non any terms other than those expressed therein.\n\nAny contact you make with me shall be taken as full agreement to my terms.\n\nTherefore it is vital that you have properly read and understood them.');
return false;
}
function doSearch() {
kw = trim(getRefToElement('searchBox').value);
if(kw == '') {
alert('Please enter a phrase first.');
}else {
kw = replaceAll(kw, '&', '(and)');
kw = escape(kw)
kw = replaceAll(kw, '%20', '+');
var l = appPath + tagRoot + kw;
document.location = l;
}
}
function checkKey(e) {
var k;
if(document.all) k=window.event.keyCode;else k=e.keyCode;
if(k == 13) generate();
}
function autoCompExt_Go(kw) {
doSearch();
}
function goPage(p) {
document.forms[1].page.value=p;
document.forms[1].submit();
}
function showTS() {
getRefToElement('TSX').style.display='block';
getRefToElement('TSB').style.display='none';
}
function showMS() {
getRefToElement('MSX').style.display='block';
getRefToElement('MSB').style.display='none';
}
function addEvent(obj,event_name,func_name){
if(obj.attachEvent){
obj.attachEvent("on"+event_name, func_name);
}else if(obj.addEventListener){
obj.addEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = func_name;
}
}
function removeEvent(obj,event_name,func_name){
if(obj.detachEvent){
obj.detachEvent("on"+event_name,func_name);
}else if(obj.removeEventListener){
obj.removeEventListener(event_name,func_name,true);
}else{
obj["on"+event_name] = null;
}
}
function stopEvent(evt){
evt || window.event;
if(evt.stopPropagation){
evt.stopPropagation();
evt.preventDefault();
}else if(typeof evt.cancelBubble != "undefined"){
evt.cancelBubble = true;
evt.returnValue = false;
}
return false;
}
function getElement(evt){
if(window.event){
return window.event.srcElement;
}else{
return evt.currentTarget;
}
}
function getTargetElement(evt){
if(window.event){
return window.event.srcElement;
}else{
return evt.target;
}
}
function stopSelect(obj){
if(typeof obj.onselectstart != 'undefined'){
addEvent(obj,"selectstart",function(){ return false;});
}
}
function getCaretEnd(obj){
if(typeof obj.selectionEnd != "undefined"){
return obj.selectionEnd;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
try{
var Lp = M.duplicate();
Lp.moveToElementText(obj);
}catch(e){
var Lp=obj.createTextRange();
}
Lp.setEndPoint("EndToEnd",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
function getCaretStart(obj){
if(typeof obj.selectionStart != "undefined"){
return obj.selectionStart;
}else if(document.selection&&document.selection.createRange){
var M=document.selection.createRange();
try{
var Lp = M.duplicate();
Lp.moveToElementText(obj);
}catch(e){
var Lp=obj.createTextRange();
}
Lp.setEndPoint("EndToStart",M);
var rb=Lp.text.length;
if(rb>obj.value.length){
return -1;
}
return rb;
}
}
function setCaret(obj,l){
obj.focus();
if(obj.setSelectionRange){
obj.setSelectionRange(l,l);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',l);
m.collapse();
m.select();
}
}
function setSelection(obj,s,e){
obj.focus();
if(obj.setSelectionRange){
obj.setSelectionRange(s,e);
}else if(obj.createTextRange){
m = obj.createTextRange();
m.moveStart('character',s);
m.moveEnd('character',e);
m.select();
}
}
String.prototype.addslashes = function(){
return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
}
String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}
function curTop(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetTop;
obj = obj.offsetParent;
}
return toreturn;
}
function curLeft(obj){
toreturn = 0;
while(obj){
toreturn += obj.offsetLeft;
obj = obj.offsetParent;
}
return toreturn;
}
function isNumber(a) {
return typeof a == 'number' && isFinite(a);
}
function replaceHTML(obj,text){
while(el = obj.childNodes[0]){
obj.removeChild(el);
}
obj.appendChild(document.createTextNode(text));
}
function actb(obj,ca){
this.actb_timeOut = -1;
this.actb_lim = 12;
this.actb_firstText = true;
this.actb_mouse = true;
this.actb_delimiter = new Array(';',',');
this.actb_startcheck = 1;
this.actb_bgColor = '#CEE';
this.actb_textColor = '#666';
this.actb_hColor = '#FFC';
this.actb_fFamily = 'Verdana';
this.actb_fSize = '12px';
this.actb_hStyle = 'text-decoration:underline;font-weight="bold"';
var actb_delimwords = new Array();
var actb_cdelimword = 0;
var actb_delimchar = new Array();
var actb_display = false;
var actb_pos = 0;
var actb_total = 0;
var actb_curr = null;
var actb_rangeu = 0;
var actb_ranged = 0;
var actb_bool = new Array();
var actb_pre = 0;
var actb_toid;
var actb_tomake = false;
var actb_getpre = "";
var actb_mouse_on_list = 1;
var actb_kwcount = 0;
var actb_caretmove = false;
this.actb_keywords = new Array();
this.actb_keywords = ca;
var actb_self = this;
actb_curr = obj;
addEvent(actb_curr,"focus",actb_setup);
function actb_setup(){
addEvent(document,"keydown",actb_checkkey);
addEvent(actb_curr,"blur",actb_clear);
addEvent(document,"keypress",actb_keypress);
}
function actb_clear(evt){
if(!evt) evt = event;
removeEvent(document,"keydown",actb_checkkey);
removeEvent(actb_curr,"blur",actb_clear);
removeEvent(document,"keypress",actb_keypress);
actb_removedisp();
}
function actb_parse(n){
if(actb_self.actb_delimiter.length > 0){
var t = actb_delimwords[actb_cdelimword].trim().addslashes();
var plen = actb_delimwords[actb_cdelimword].trim().length;
}else{
var t = actb_curr.value.addslashes();
var plen = actb_curr.value.length;
}
var tobuild = '';
var i;
if(actb_self.actb_firstText){
var re = new RegExp("^" + t, "i");
}else{
var re = new RegExp(t, "i");
}
var p = n.search(re);
for (i=0;i<p;i++){
tobuild += n.substr(i,1);
}
tobuild += "<font style='"+(actb_self.actb_hStyle)+"'>"
for (i=p;i<plen+p;i++){
tobuild += n.substr(i,1);
}
tobuild += "</font>";
for (i=plen+p;i<n.length;i++){
tobuild += n.substr(i,1);
}
return tobuild;
}
function actb_generate(){
if(document.getElementById('tat_table')){ actb_display = false;document.body.removeChild(document.getElementById('tat_table'));}
if(actb_kwcount == 0){
actb_display = false;
return;
}
a = document.createElement('table');
a.cellSpacing='1px';
a.cellPadding='2px';
a.style.position='absolute';
a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
a.style.left = curLeft(actb_curr) + "px";
a.style.backgroundColor=actb_self.actb_bgColor;
a.id = 'tat_table';
document.body.appendChild(a);
var i;
var first = true;
var j = 1;
if(actb_self.actb_mouse){
a.onmouseout = actb_table_unfocus;
a.onmouseover = actb_table_focus;
}
var counter = 0;
for (i=0;i<actb_self.actb_keywords.length;i++){
if(actb_bool[i]){
counter++;
r = a.insertRow(-1);
if(first && !actb_tomake){
r.style.backgroundColor = actb_self.actb_hColor;
first = false;
actb_pos = counter;
}else if(actb_pre == i){
r.style.backgroundColor = actb_self.actb_hColor;
first = false;
actb_pos = counter;
}else{
r.style.backgroundColor = actb_self.actb_bgColor;
}
r.id = 'tat_tr'+(j);
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = actb_self.actb_fFamily;
c.style.fontSize = actb_self.actb_fSize;
c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
c.id = 'tat_td'+(j);
c.setAttribute('pos',j);
if(actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick=actb_mouseclick;
c.onmouseover = actb_table_highlight;
}
j++;
}
if(j - 1 == actb_self.actb_lim && j < actb_total){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = 'arial narrow';
c.style.fontSize = actb_self.actb_fSize;
c.align='center';
replaceHTML(c,'\\/');
if(actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick = actb_mouse_down;
}
break;
}
}
actb_rangeu = 1;
actb_ranged = j-1;
actb_display = true;
if(actb_pos <= 0) actb_pos = 1;
}
function actb_remake(){
document.body.removeChild(document.getElementById('tat_table'));
a = document.createElement('table');
a.cellSpacing='1px';
a.cellPadding='2px';
a.style.position='absolute';
a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
a.style.left = curLeft(actb_curr) + "px";
a.style.backgroundColor=actb_self.actb_bgColor;
a.id = 'tat_table';
if(actb_self.actb_mouse){
a.onmouseout= actb_table_unfocus;
a.onmouseover=actb_table_focus;
}
document.body.appendChild(a);
var i;
var first = true;
var j = 1;
if(actb_rangeu > 1){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = 'arial narrow';
c.style.fontSize = actb_self.actb_fSize;
c.align='center';
replaceHTML(c,'/\\');
if(actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick = actb_mouse_up;
}
}
for (i=0;i<actb_self.actb_keywords.length;i++){
if(actb_bool[i]){
if(j >= actb_rangeu && j <= actb_ranged){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
r.id = 'tat_tr'+(j);
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = actb_self.actb_fFamily;
c.style.fontSize = actb_self.actb_fSize;
c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
c.id = 'tat_td'+(j);
c.setAttribute('pos',j);
if(actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick=actb_mouseclick;
c.onmouseover = actb_table_highlight;
}
j++;
}else{
j++;
}
}
if(j > actb_ranged) break;
}
if(j-1 < actb_total){
r = a.insertRow(-1);
r.style.backgroundColor = actb_self.actb_bgColor;
c = r.insertCell(-1);
c.style.color = actb_self.actb_textColor;
c.style.fontFamily = 'arial narrow';
c.style.fontSize = actb_self.actb_fSize;
c.align='center';
replaceHTML(c,'\\/');
if(actb_self.actb_mouse){
c.style.cursor = 'pointer';
c.onclick = actb_mouse_down;
}
}
}
function actb_goup(){
if(!actb_display) return;
if(actb_pos == 1) return;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos--;
if(actb_pos < actb_rangeu) actb_moveup();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_godown(){
if(!actb_display) return;
if(actb_pos == actb_total) return;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos++;
if(actb_pos > actb_ranged) actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_movedown(){
actb_rangeu++;
actb_ranged++;
actb_remake();
}
function actb_moveup(){
actb_rangeu--;
actb_ranged--;
actb_remake();
}
function actb_mouse_down(){
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos++;
actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
actb_curr.focus();
actb_mouse_on_list = 0;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_mouse_up(evt){
if(!evt) evt = event;
if(evt.stopPropagation){
evt.stopPropagation();
}else{
evt.cancelBubble = true;
}
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos--;
actb_moveup();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
actb_curr.focus();
actb_mouse_on_list = 0;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_mouseclick(evt){
if(!evt) evt = event;
if(!actb_display) return;
actb_mouse_on_list = 0;
actb_pos = this.getAttribute('pos');
actb_penter();
}
function actb_table_focus(){
actb_mouse_on_list = 1;
}
function actb_table_unfocus(){
actb_mouse_on_list = 0;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_table_highlight(){
actb_mouse_on_list = 1;
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
actb_pos = this.getAttribute('pos');
while (actb_pos < actb_rangeu) actb_moveup();
while (actb_pos > actb_ranged) actb_movedown();
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
}
function actb_insertword(a){
if(actb_self.actb_delimiter.length > 0){
str = '';
l=0;
for (i=0;i<actb_delimwords.length;i++){
if(actb_cdelimword == i){
prespace = postspace = '';
gotbreak = false;
for (j=0;j<actb_delimwords[i].length;++j){
if(actb_delimwords[i].charAt(j) != ' '){
gotbreak = true;
break;
}
prespace += ' ';
}
for (j=actb_delimwords[i].length-1;j>=0;--j){
if(actb_delimwords[i].charAt(j) != ' ') break;
postspace += ' ';
}
str += prespace;
str += a;
l = str.length;
if(gotbreak) str += postspace;
}else{
str += actb_delimwords[i];
}
if(i != actb_delimwords.length - 1){
str += actb_delimchar[i];
}
}
actb_curr.value = str;
setCaret(actb_curr,l);
actb_mouse_on_list = 0;
actb_removedisp();
if(window.autoCompExt_Go) autoCompExt_Go(str);
}else{
actb_curr.value = a;
actb_mouse_on_list = 0;
actb_removedisp();
}
}
function actb_penter(){
if(!actb_display) return;
actb_display = false;
var word = '';
var c = 0;
for (var i=0;i<=actb_self.actb_keywords.length;i++){
if(actb_bool[i]) c++;
if(c == actb_pos){
word = actb_self.actb_keywords[i];
break;
}
}
actb_insertword(word);
l = getCaretStart(actb_curr);
}
function actb_removedisp(){
if(actb_mouse_on_list==0){
actb_display = 0;
if(document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table'));}
if(actb_toid) clearTimeout(actb_toid);
}
}
function actb_keypress(e){
if(actb_caretmove) stopEvent(e);
return !actb_caretmove;
}
function actb_checkkey(evt){
if(!evt) evt = event;
a = evt.keyCode;
caret_pos_start = getCaretStart(actb_curr);
actb_caretmove = 0;
switch (a){
case 38:
actb_goup();
actb_caretmove = 1;
return false;
break;
case 40:
actb_godown();
actb_caretmove = 1;
return false;
break;
case 13: case 9:
if(actb_display){
actb_caretmove = 1;
actb_penter();
return false;
}else{
return true;
}
break;
default:
setTimeout(function(){actb_tocomplete(a)},50);
break;
}
}
function actb_tocomplete(kc){
if(kc == 38 || kc == 40 || kc == 13) return;
var i;
if(actb_display){
var word = 0;
var c = 0;
for (var i=0;i<=actb_self.actb_keywords.length;i++){
if(actb_bool[i]) c++;
if(c == actb_pos){
word = i;
break;
}
}
actb_pre = word;
}else{ actb_pre = -1}
if(actb_curr.value == ''){
actb_mouse_on_list = 0;
actb_removedisp();
return;
}
if(actb_self.actb_delimiter.length > 0){
caret_pos_start = getCaretStart(actb_curr);
caret_pos_end = getCaretEnd(actb_curr);
delim_split = '';
for (i=0;i<actb_self.actb_delimiter.length;i++){
delim_split += actb_self.actb_delimiter[i];
}
delim_split = delim_split.addslashes();
delim_split_rx = new RegExp("(["+delim_split+"])");
c = 0;
actb_delimwords = new Array();
actb_delimwords[0] = '';
for (i=0,j=actb_curr.value.length;i<actb_curr.value.length;i++,j--){
if(actb_curr.value.substr(i,j).search(delim_split_rx) == 0){
ma = actb_curr.value.substr(i,j).match(delim_split_rx);
actb_delimchar[c] = ma[1];
c++;
actb_delimwords[c] = '';
}else{
actb_delimwords[c] += actb_curr.value.charAt(i);
}
}
var l = 0;
actb_cdelimword = -1;
for (i=0;i<actb_delimwords.length;i++){
if(caret_pos_end >= l && caret_pos_end <= l + actb_delimwords[i].length){
actb_cdelimword = i;
}
l+=actb_delimwords[i].length + 1;
}
var ot = actb_delimwords[actb_cdelimword].trim();
var t = actb_delimwords[actb_cdelimword].addslashes().trim();
}else{
var ot = actb_curr.value;
var t = actb_curr.value.addslashes();
}
if(ot.length == 0){
actb_mouse_on_list = 0;
actb_removedisp();
}
if(ot.length < actb_self.actb_startcheck) return this;
if(actb_self.actb_firstText){
var re = new RegExp("^" + t, "i");
}else{
var re = new RegExp(t, "i");
}
actb_total = 0;
actb_tomake = false;
actb_kwcount = 0;
for (i=0;i<actb_self.actb_keywords.length;i++){
actb_bool[i] = false;
if(re.test(actb_self.actb_keywords[i])){
actb_total++;
actb_bool[i] = true;
actb_kwcount++;
if(actb_pre == i) actb_tomake = true;
}
}
if(actb_toid) clearTimeout(actb_toid);
if(actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
actb_generate();
}
return this;
}
// JSOK