var customarray=new Array( 'Afghanistan','Albania','Tirana, Albania','Algeria','Andorra','Angola','Anguilla','Antarctica','Antigua Barbuda','Argentina','Armenia','Aruba','Ascension','Australia','Austria','Azerbaijan','Bahamas','Bahrain','Bangladesh','Barbados','Belarus','Belgium','Belize','Benin','Bermuda','Bhutan','Bolivia','Cochabamba, Bolivia','La Paz, Bolivia','Santa Cruz, Bolivia','Bosnia and Herzegovina','Botswana','Brazil','Belo Horizante, Brazil','Rio de Janeiro, Brazil','Sao Paulo, Brazil','Brunei','Bulgaria','Sofia, Bulgaria','Burkina Faso','Burundi','Cambodia','Cameroon','Douala, Cameroon','Canada','Cape Verde Islands','Cayman Islands','Central African Rep','Chad','Chile','Easter Island, Chile','Santiago, Chile','China','Christmas Island','Cocos Keeling Island','Colombia','Armenia, Colombia','Barranquilla, Colombia','Bogota, Colombia','Cali, Colombia','Medellin, Colombia','Palmira, Colombia','Pereira, Colombia','Comoros and Mayotte','Congo','Congo Dem Rep','Cook Islands','Costa Rica','Croatia','Cuba','Guantanamo Bay, Cuba','Cyprus','Czech Republic','Denmark','Diego Garcia','Djibouti','Dominica','Dominican Republic','East Timor','Ecuador','Cuenca, Ecuador','Guayaquil, Ecuador','Quito, Ecuador','Egypt','El Salvador','Equatorial Guinea','Eritrea','Estonia','Ethiopia','Faroe Islands','Fiji','Finland','France','French Guiana','French Polynesia','Gabon','Gambia','Georgia','Germany','Ghana','Gibraltar','Greece','Greenland','Grenada','Guadeloupe','Guam','Guatemala','Guinea','Guinea Bissau','Guyana','Haiti','Honduras','Hong Kong','Hungary','Iceland','India','Indonesia','Bandung, Indonesia','Jakarta, Indonesia','Surabaya, Indonesia','Iran','Iraq','Baghdad, Iraq','Ireland','Israel','Italy','Ivory Coast','Jamaica','Japan','Jordan','Kazakhstan','Almaty, Kazakhstan','Astana, Kazakhstan','Karaganda, Kazakhstan','Kenya','Kiribati','Kuwait','Kyrgyzstan','Laos','Latvia','Lebanon','Lesotho','Liberia','Libya','Lithuania','Luxembourg','Macao','Macedonia','Madagascar','Malawi','Malaysia','Maldives','Mali','Bamako, Mali','Malta','Marshall Islands','Martinique','Mauritania','Mauritius','Mexico','Guadalajara, Mexico','Mexico City, Mexico','Monterrey, Mexico','Micronesia','Moldova','Monaco','Mongolia','Montenegro','Montserrat','Morocco','Mozambique','Myanmar','Namibia','Nauru','Nepal','Kathmandu, Nepal','Netherlands','New Caledonia','New Zealand','Nicaragua','Niger','Niger Mobile','Nigeria','Niue Islands','Norfolk Island','North Cyprus','North Korea','Northern Marianas','Norway','Oman','Pakistan','Palau','Palestine','Panama','Papua New Guinea','Paraguay','Peru','Rural, Peru','Philippines','Poland','Portugal','Puerto Rico','Qatar','Reunion','Romania','Russia','Moscow, Russia','St Petersburg, Russia','Rwanda','Samoa American','Samoa Western','San Marino','Sao Tome and Principe','Saudi Arabia','Senegal','Serbia','Seychelles','Sierra Leone','Singapore','Slovakia','Slovenia','Solomon Islands','Somalia','South Africa','South Korea','Spain','Sri Lanka','St Kitts and Nevis','St Lucia','St Pierre and Miquelon','St Vincent Grenadines','Sudan','Suriname','Swaziland','Sweden','Switzerland','Syria','Taiwan','Tajikistan','Tanzania','Zanzibar, Tanzania','Thailand','Togo','Tokelau','Tonga','Trinidad and Tobago','Tunisia','Turkey','Ankara, Turkey','Istanbul, Turkey','Turkmenistan','icos, Turkmenistan','Tuvalu','UAE','UK','Ukraine','Uruguay','Montevideo, Uruguay','USA','Alaska, USA','Uzbekistan','Vanuatu','Vatican City','Venezuela','Vietnam','Hanoi, Vietnam','Ho Chi Minh City, Vietnam','Virgin IslandsBritish','Virgin IslandsUS','Wallis and Futuna','Yemen','Zambia','Zimbabwe' ); 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){ /* ---- Public Variables ---- */ this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out) this.actb_lim = 4; // Number of elements autocomplete can show (-1: no limit) this.actb_firstText = false; // should the auto complete be limited to the beginning of keyword? this.actb_mouse = true; // Enable Mouse Support this.actb_delimiter = new Array(';',','); // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete this.actb_startcheck = 1; // Show widget only after this number of characters is typed in. /* ---- Public Variables ---- */ /* --- Styles --- */ this.actb_bgColor = '#888888'; this.actb_textColor = '#FFFFFF'; this.actb_hColor = '#000000'; this.actb_fFamily = 'Verdana'; this.actb_fSize = '11px'; this.actb_hStyle = 'text-decoration:underline;font-weight="bold"'; /* --- Styles --- */ /* ---- Private Variables ---- */ 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(); /* ---- Private Variables---- */ 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" for (i=p;i 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_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(); } /* Mouse */ 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=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); }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= 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 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut); actb_generate(); } return this; }