AJS = {
BASE_URL: "",
drag_obj: null,
drag_elm: null,
_drop_zones: [],
_cur_pos: null,
_unloadListeners: function() {
if(AJS.listeners)
AJS.map(AJS.listeners, function(elm, type, fn) {AJS.removeEventListener(elm, type, fn)});
AJS.listeners = [];
},
getElement: function(id) {
if(AJS.isString(id) || AJS.isNumber(id))
return document.getElementById(id);
else
return id;
},
getScrollTop: function() {
var t;
if (document.documentElement && document.documentElement.scrollTop)
t = document.documentElement.scrollTop;
else if (document.body)
t = document.body.scrollTop;
return t;
},
isObject: function(obj) {
return (typeof obj == 'object');
},
isArray: function(obj) {
return obj instanceof Array;
},
removeElement: function(/*elm1, elm2...*/) {
var args = AJS.flattenList(arguments);
AJS.map(args, function(elm) { AJS.swapDOM(elm, null); });
},
isDict: function(o) {
var str_repr = String(o);
return str_repr.indexOf(" Object") != -1;
},
isDefined: function(o) {
return (o != "undefined" && o != null)
},
getIndex: function(elm, list/*optional*/, eval_fn) {
for(var i=0; i < list.length; i++)
if(eval_fn && eval_fn(list[i]) || elm == list[i])
return i;
return -1;
},
createDOM: function(name, attrs) {
var i=0, attr;
elm = document.createElement(name);
if(AJS.isDict(attrs[i])) {
for(k in attrs[0]) {
attr = attrs[0][k];
if(k == "style")
elm.style.cssText = attr;
else if(k == "class" || k == 'className')
elm.className = attr;
else {
elm.setAttribute(k, attr);
}
}
i++;
}
if(attrs[0] == null)
i = 1;
AJS.map(attrs, function(n) {
if(n) {
if(AJS.isString(n) || AJS.isNumber(n))
n = AJS.TN(n);
elm.appendChild(n);
}
}, i);
return elm;
},
nodeName: function(elm) {
return elm.nodeName.toLowerCase();
},
isIe: function() {
return (navigator.userAgent.toLowerCase().indexOf("msie") != -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1);
},
addEventListener: function(elm, type, fn, /*optional*/listen_once, cancle_bubble) {
if(!cancle_bubble)
cancle_bubble = false;
var elms = AJS.$A(elm);
AJS.map(elms, function(elmz) {
if(listen_once)
fn = AJS._listenOnce(elmz, type, fn);
if(AJS.isIn(type, ['submit', 'load', 'scroll', 'resize'])) {
var old = elm['on' + type];
elm['on' + type] = function() {
if(old) {
fn(arguments);
return old(arguments);
}
else
return fn(arguments);
};
return;
}
if (elmz.attachEvent) {
elmz.attachEvent("on" + type, fn);
}
else if(elmz.addEventListener)
elmz.addEventListener(type, fn, cancle_bubble);
AJS.listeners = AJS.$A(AJS.listeners);
AJS.listeners.push([elmz, type, fn]);
});
},
callLater: function(fn, interval) {
var fn_no_send = function() {
fn();
};
window.setTimeout(fn_no_send, interval);
},
swapDOM: function(dest, src) {
dest = AJS.getElement(dest);
var parent = dest.parentNode;
if (src) {
src = AJS.getElement(src);
parent.replaceChild(src, dest);
} else {
parent.removeChild(dest);
}
return src;
},
_sendXMLHttpRequest: function(req, data) {
var d = new AJSDeferred(req);
var onreadystatechange = function () {
if (req.readyState == 4) {
var status = '';
try {
status = req.status;
}
catch(e) {};
if(status == 200 || status == 304 || req.responseText == null) {
d.callback();
}
else if(status == 500) {
alert(req.responseText);
d.errback();
}
else {
d.errback();
}
}
}
req.onreadystatechange = onreadystatechange;
return d;
},
getLast: function(list) {
if(list.length > 0)
return list[list.length-1];
else
return null;
},
map: function(list, fn,/*optional*/ start_index, end_index) {
var i = 0, l = list.length;
if(start_index)
i = start_index;
if(end_index)
l = end_index;
for(i; i < l; i++)
fn.apply(null, [list[i]]);
},
getElementsByTagAndClassName: function(tag_name, class_name, /*optional*/ parent) {
var class_elements = [];
if(!AJS.isDefined(parent))
parent = document;
if(!AJS.isDefined(tag_name))
tag_name = '*';
var els = parent.getElementsByTagName(tag_name);
var els_len = els.length;
var pattern = new RegExp("(^|\\s)" + class_name + "(\\s|$)");
for (i = 0, j = 0; i < els_len; i++) {
if ( pattern.test(els[i].className) || class_name == null ) {
class_elements[j] = els[i];
j++;
}
}
return class_elements;
},
absolutePosition: function(elm) {
var posObj = {'x': elm.offsetLeft, 'y': elm.offsetTop};
if(elm.offsetParent) {
var temp_pos =	AJS.absolutePosition(elm.offsetParent);
posObj.x += temp_pos.x;
posObj.y += temp_pos.y;
}
if (AJS.isSafari() && elm.style.position == 'absolute' ) {
posObj.x -= document.body.offsetLeft;
posObj.y -= document.body.offsetTop;
}
return posObj;
},
isOpera: function() {
return (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
},
replaceChildNodes: function(elm/*, elms...*/) {
var child;
while ((child = elm.firstChild))
elm.removeChild(child);
if (arguments.length < 2)
return elm;
else
return AJS.appendChildNodes.apply(null, arguments);
return elm;
},
setLeft: function(/*elm1, elm2..., left*/) {
var args = AJS.flattenList(arguments);
var l = AJS.getLast(args);
AJS.map(args, function(elm) { elm.style.left = AJS.getCssDim(l)}, 0, args.length-1);
},
getBody: function() {
return AJS.$bytc('body')[0]
},
getWindowSize: function() {
var win_w, win_h;
if (self.innerHeight) {
win_w = self.innerWidth;
win_h = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
win_w = document.documentElement.clientWidth;
win_h = document.documentElement.clientHeight;
} else if (document.body) {
win_w = document.body.clientWidth;
win_h = document.body.clientHeight;
}
return {'w': win_w, 'h': win_h};
},
isSafari: function() {
return (navigator.userAgent.toLowerCase().indexOf("khtml") != -1);
},
showElement: function(/*elms...*/) {
var args = AJS.flattenList(arguments);
AJS.map(args, function(elm) { elm.style.display = ''});
},
removeEventListener: function(elm, type, fn, /*optional*/cancle_bubble) {
if(!cancle_bubble)
cancle_bubble = false;
if(elm.removeEventListener) {
elm.removeEventListener(type, fn, cancle_bubble);
if(AJS.isOpera())
elm.removeEventListener(type, fn, !cancle_bubble);
}
else if(elm.detachEvent)
elm.detachEvent("on" + type, fn);
},
_getRealScope: function(fn, /*optional*/ extra_args, dont_send_event, rev_extra_args) {
var scope = window;
extra_args = AJS.$A(extra_args);
if(fn._cscope)
scope = fn._cscope;
return function() {
var args = [];
var i = 0;
if(dont_send_event)
i = 1;
AJS.map(arguments, function(arg) { args.push(arg) }, i);
args = args.concat(extra_args);
if(rev_extra_args)
args = args.reverse();
return fn.apply(scope, args);
};
},
_createDomShortcuts: function() {
var elms = [
"ul", "li", "td", "tr", "th",
"tbody", "table", "input", "span", "b",
"a", "div", "img", "button", "h1",
"h2", "h3", "br", "textarea", "form",
"p", "select", "option", "iframe", "script",
"center", "dl", "dt", "dd", "small",
"pre"
];
var createDOM = AJS.createDOM;
var extends_ajs = function(elm) {
var c_dom = "return createDOM.apply(null, ['" + elm + "', arguments]);";
var c_fun_dom = 'function() { ' + c_dom + '  }';
eval("AJS." + elm.toUpperCase() + "=" + c_fun_dom);
}
AJS.map(elms, extends_ajs);
AJS.TN = function(text) { return document.createTextNode(text) };
},
isNumber: function(obj) {
return (typeof obj == 'number');
},
bind: function(fn, scope, /*optional*/ extra_args, dont_send_event, rev_extra_args) {
fn._cscope = scope;
return AJS._getRealScope(fn, extra_args, dont_send_event, rev_extra_args);
},
setTop: function(/*elm1, elm2..., top*/) {
var args = AJS.flattenList(arguments);
var t = AJS.getLast(args);
AJS.map(args, function(elm) { elm.style.top = AJS.getCssDim(t)}, 0, args.length-1);
},
getQueryArgument: function(var_name) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == var_name) {
return pair[1];
}
}
return null;
},
appendChildNodes: function(elm/*, elms...*/) {
if(arguments.length >= 2) {
AJS.map(arguments, function(n) {
if(AJS.isString(n))
n = AJS.TN(n);
if(AJS.isDefined(n))
elm.appendChild(n);
}, 1);
}
return elm;
},
isString: function(obj) {
return (typeof obj == 'string');
},
getXMLHttpRequest: function() {
var try_these = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
function () { throw "Browser does not support XMLHttpRequest"; }
];
for (var i = 0; i < try_these.length; i++) {
var func = try_these[i];
try {
return func();
} catch (e) {
}
}
},

getRequest: function(url, data, type) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
} catch (e) { }
/* if(!type)*/
type = "POST";
var req = AJS.getXMLHttpRequest();
if(url.indexOf("http://") == -1) {
if(url.indexOf('/') != 0)
url = '/' + url;
/*if(AJS.BASE_URL != '')*/
url = AJS.BASE_URL + url;
/*else
url = "http://" + window.location.host + url;*/
$url_tst = url;
}
/*echo " $url_tst ";*/
/* FEL !! req.open(type, url, true); ------------------------------------------------------------------ */
req.open(type, url, true);
if(type == "POST")
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
return AJS._sendXMLHttpRequest(req);
},

getEventElm: function(e) {
if(e && !e.type && !e.keyCode)
return e
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
},
isIn: function(elm, list) {
var i = AJS.getIndex(elm, list);
if(i != -1)
return true;
else
return false;
},
setHeight: function(/*elm1, elm2..., height*/) {
var args = AJS.flattenList(arguments);
var h = AJS.getLast(args);
AJS.map(args, function(elm) { elm.style.height = AJS.getCssDim(h)}, 0, args.length-1);
},
keys: function(obj) {
var rval = [];
for (var prop in obj) {
rval.push(prop);
}
return rval;
},
insertBefore: function(elm, reference_elm) {
reference_elm.parentNode.insertBefore(elm, reference_elm);
return elm;
},
hideElement: function(elm) {
var args = AJS.flattenList(arguments);
AJS.map(args, function(elm) { elm.style.display = 'none'});
},
createArray: function(v) {
if(AJS.isArray(v) && !AJS.isString(v))
return v;
else if(!v)
return [];
else
return [v];
},
setWidth: function(/*elm1, elm2..., width*/) {
var args = AJS.flattenList(arguments);
var w = AJS.getLast(args);
AJS.map(args, function(elm) { elm.style.width = AJS.getCssDim(w)}, 0, args.length-1);
},
insertAfter: function(elm, reference_elm) {
reference_elm.parentNode.insertBefore(elm, reference_elm.nextSibling);
return elm;
},
getCssDim: function(dim) {
if(AJS.isString(dim))
return dim;
else
return dim + "px";
},
_listenOnce: function(elm, type, fn) {
var r_fn = function() {
AJS.removeEventListener(elm, type, r_fn);
fn(arguments);
}
return r_fn;
},
flattenList: function(list) {
var r = [];
var _flatten = function(r, l) {
AJS.map(l, function(o) {
if (AJS.isArray(o))
_flatten(r, o);
else
r.push(o);
});
}
_flatten(r, list);
return r;
}
}
AJS.$ = AJS.getElement;
AJS.$$ = AJS.getElements;
AJS.$f = AJS.getFormElement;
AJS.$b = AJS.bind;
AJS.$A = AJS.createArray;
AJS.DI = AJS.documentInsert;
AJS.ACN = AJS.appendChildNodes;
AJS.RCN = AJS.replaceChildNodes;
AJS.AEV = AJS.addEventListener;
AJS.REV = AJS.removeEventListener;
AJS.$bytc = AJS.getElementsByTagAndClassName;
AJS.addEventListener(window, 'unload', AJS._unloadListeners);
AJS._createDomShortcuts()
AJSDeferred = function(req) {
this.callbacks = [];
this.errbacks = [];
this.req = req;
};
AJSDeferred.prototype = {
excCallbackSeq: function(req, list) {
var data = req.responseText;
while (list.length > 0) {
var fn = list.pop();
var new_data = fn(data, req);
if(new_data)
data = new_data;
}
},
callback: function () {
this.excCallbackSeq(this.req, this.callbacks);
},
errback: function() {
if(this.errbacks.length == 0)
alert("Error encountered:\n" + this.req.responseText);
this.excCallbackSeq(this.req, this.errbacks);
},
addErrback: function(fn) {
this.errbacks.unshift(fn);
},
addCallback: function(fn) {
this.callbacks.unshift(fn);
},
addCallbacks: function(fn1, fn2) {
this.addCallback(fn1);
this.addErrback(fn2);
},
sendReq: function(data) {
if(AJS.isObject(data)) {
var post_data = [];
for(k in data) {
post_data.push(k + "=" + AJS.urlencode(data[k]));
}
post_data = post_data.join("&");
this.req.send(post_data);
}
else if(AJS.isDefined(data))
this.req.send(data);
else {
this.req.send("");
}
}
};var GOOGIE_CUR_LANG = null;
var GOOGIE_DEFAULT_LANG = "sv";
function GoogieSpell(img_dir, server_url) {
var cookie_value;
var lang;
cookie_value = getCookie('language');
if(cookie_value != null)
GOOGIE_CUR_LANG = cookie_value;
else
GOOGIE_CUR_LANG = GOOGIE_DEFAULT_LANG;
this.img_dir = img_dir;
this.server_url = server_url;
this.org_lang_to_word = {"da": "Dansk", "de": "Deutsch", "en": "English",
"es": "Espa&#241;ol", "fr": "Fran&#231;ais", "it": "Italiano", 
"nl": "Nederlands", "pl": "Polski", "pt": "Portugu&#234;s",
"fi": "Suomi", "sv": "Svenska"};
this.lang_to_word = this.org_lang_to_word;
this.langlist_codes = AJS.keys(this.lang_to_word);
this.show_change_lang_pic = true;
this.change_lang_pic_placement = "left";
this.report_state_change = true;
this.ta_scroll_top = 0;
this.el_scroll_top = 0;
this.lang_chck_spell = "Stavningskontroll";
this.lang_revert = "Revert to";
this.lang_close = "Tillbaka";
this.lang_rsm_edt = "Tillbaka till redigering";
this.lang_no_error_found = "Inga stavfel hittade";
this.lang_no_suggestions = "Inga forslag";
this.show_spell_img = true;
this.decoration = true;
this.use_close_btn = true;
this.edit_layer_dbl_click = true;
this.report_ta_not_found = true;
this.custom_ajax_error = null;
this.custom_no_spelling_error = null;
this.custom_menu_builder = []; //Should take an eval function and a build menu function
this.custom_item_evaulator = null; //Should take an eval function and a build menu function
this.extra_menu_items = [];
this.custom_spellcheck_starter = null;
this.main_controller = true;
this.lang_state_observer = null;
this.spelling_state_observer = null;
this.show_menu_observer = null;
this.all_errors_fixed_observer = null;
this.use_focus = false;
this.focus_link_t = null;
this.focus_link_b = null;
this.cnt_errors = 0;
this.cnt_errors_fixed = 0;
var fn = function(e) {
var elm = AJS.getEventElm(e);
if(elm.googie_action_btn != "1" && this.isLangWindowShown())
this.hideLangWindow();
if(elm.googie_action_btn != "1" && this.isErrorWindowShown())
this.hideErrorWindow();
};
AJS.AEV(document, "click", AJS.$b(fn, this));
}
GoogieSpell.prototype.decorateTextarea = function(id) {
if(typeof(id) == "string")
this.text_area = AJS.$(id);
else
this.text_area = id;
var r_width, r_height;
if(this.text_area != null) {
if(!AJS.isDefined(this.spell_container) && this.decoration) {
var table = AJS.TABLE();
var tbody = AJS.TBODY();
var tr = AJS.TR();
if(AJS.isDefined(this.force_width))
r_width = this.force_width;
else
r_width = this.text_area.offsetWidth + "px";
if(AJS.isDefined(this.force_height))
r_height = this.force_height;
else
r_height = "";
var spell_container = AJS.TD();
this.spell_container = spell_container;
tr.appendChild(spell_container);
tbody.appendChild(tr);
table.appendChild(tbody);
AJS.insertBefore(table, this.text_area);
AJS.setHeight(table, spell_container, r_height);
AJS.setWidth(table, spell_container, r_width);
spell_container.style.textAlign = "right";
}
this.checkSpellingState();
}
else 
if(this.report_ta_not_found)
alert("Text area not found");
}
GoogieSpell.prototype.setSpellContainer = function(elm) {
this.spell_container = AJS.$(elm);
}
GoogieSpell.prototype.setLanguages = function(lang_dict) {
this.lang_to_word = lang_dict;
this.langlist_codes = AJS.keys(lang_dict);
}
GoogieSpell.prototype.setForceWidthHeight = function(width, height) {
this.force_width = width;
this.force_height = height;
}
GoogieSpell.prototype.setDecoration = function(bool) {
this.decoration = bool;
}
GoogieSpell.prototype.dontUseCloseButtons = function() {
this.use_close_btn = false;
}
GoogieSpell.prototype.appendNewMenuItem = function(name, call_back_fn, checker) {
this.extra_menu_items.push([name, call_back_fn, checker]);
}
GoogieSpell.prototype.appendCustomMenuBuilder = function(eval, builder) {
this.custom_menu_builder.push([eval, builder]);
}
GoogieSpell.prototype.setFocus = function() {
try {
this.focus_link_b.focus();
this.focus_link_t.focus();
return true;
}
catch(e) {
return false;
}
}
GoogieSpell.prototype.setStateChanged = function(current_state) {
this.state = current_state;
if(this.spelling_state_observer != null && this.report_state_change)
this.spelling_state_observer(current_state, this);
}
GoogieSpell.prototype.setReportStateChange = function(bool) {
this.report_state_change = bool;
}
GoogieSpell.prototype.getGoogleUrl = function() {
return this.server_url + GOOGIE_CUR_LANG;
}
GoogieSpell.escapeSepcial = function(val) {
return val.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
GoogieSpell.createXMLReq = function (text) {
return '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' + text + '</text></spellrequest>';
}
GoogieSpell.prototype.spellCheck = function(ignore) {
var me = this;
this.cnt_errors_fixed = 0;
this.cnt_errors = 0;
this.setStateChanged("checking_spell");
if(this.main_controller)
this.appendIndicator(this.spell_span);
this.error_links = [];
this.ta_scroll_top = this.text_area.scrollTop;
try { this.hideLangWindow(); }
catch(e) {}
this.createEditLayer(this.text_area.offsetWidth, this.text_area.offsetHeight);
this.createErrorWindow();
AJS.getBody().appendChild(this.error_window);
try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } 
catch (e) { }
if(this.main_controller)
this.spell_span.onclick = null;
this.orginal_text = this.text_area.value;
if(this.text_area.value == '' || ignore) {
if(!me.custom_no_spelling_error)
me.flashNoSpellingErrorState();
else
me.custom_no_spelling_error(me);
me.removeIndicator();
return ;
}
var d = AJS.getRequest(this.getGoogleUrl());
var reqdone = function(res_txt) {
var r_text = res_txt;
me.results = me.parseResult(r_text);
if(r_text.match(/<c.*>/) != null) {
me.showErrorsInIframe();
me.resumeEditingState();
}
else {
if(!me.custom_no_spelling_error)
me.flashNoSpellingErrorState();
else
me.custom_no_spelling_error(me);
}
me.removeIndicator();
};
d.addCallback(reqdone);
reqdone = null;
var reqfailed = function(res_txt, req) {
if(me.custom_ajax_error)
me.custom_ajax_error(req);
else
alert("An error was encountered on the server. Please try again later.");
if(me.main_controller) {
AJS.removeElement(me.spell_span);
me.removeIndicator();
}
me.checkSpellingState();
};
d.addErrback(reqfailed);
reqfailed = null;
var req_text = GoogieSpell.escapeSepcial(this.orginal_text);
d.sendReq(GoogieSpell.createXMLReq(req_text));
}
GoogieSpell.prototype.parseResult = function(r_text) {
var re_split_attr_c = /\w+="(\d+|true)"/g;
var re_split_text = /\t/g;
var matched_c = r_text.match(/<c[^>]*>[^<]*<\/c>/g);
var results = new Array();
if(matched_c == null)
return results;
for(var i=0; i < matched_c.length; i++) {
var item = new Array();
this.errorFound();
item['attrs'] = new Array();
var split_c = matched_c[i].match(re_split_attr_c);
for(var j=0; j < split_c.length; j++) {
var c_attr = split_c[j].split(/=/);
var val = c_attr[1].replace(/"/g, '');
if(val != "true")
item['attrs'][c_attr[0]] = parseInt(val);
else {
item['attrs'][c_attr[0]] = val;
}
}
item['suggestions'] = new Array();
var only_text = matched_c[i].replace(/<[^>]*>/g, "");
var split_t = only_text.split(re_split_text);
for(var k=0; k < split_t.length; k++) {
if(split_t[k] != "")
item['suggestions'].push(split_t[k]);
}
results.push(item);
}
return results;
}
GoogieSpell.prototype.errorFixed = function() { 
this.cnt_errors_fixed++; 
if(this.all_errors_fixed_observer)
if(this.cnt_errors_fixed == this.cnt_errors) {
this.hideErrorWindow();
this.all_errors_fixed_observer();
}
}
GoogieSpell.prototype.errorFound = function() { this.cnt_errors++; }
GoogieSpell.prototype.createErrorWindow = function() {
this.error_window = AJS.DIV();
this.error_window.className = "googie_window";
this.error_window.googie_action_btn = "1";
}
GoogieSpell.prototype.isErrorWindowShown = function() {
return this.error_window != null && this.error_window.style.visibility == "visible";
}
GoogieSpell.prototype.hideErrorWindow = function() {
try {
this.error_window.style.visibility = "hidden";
if(this.error_window_iframe)
this.error_window_iframe.style.visibility = "hidden";
}
catch(e) {}
}
GoogieSpell.prototype.updateOrginalText = function(offset, old_value, new_value, id) {
var part_1 = this.orginal_text.substring(0, offset);
var part_2 = this.orginal_text.substring(offset+old_value.length);
this.orginal_text = part_1 + new_value + part_2;
this.text_area.value = this.orginal_text;
var add_2_offset = new_value.length - old_value.length;
for(var j=0; j < this.results.length; j++) {
if(j != id && j > id){
this.results[j]['attrs']['o'] += add_2_offset;
}
}
}
GoogieSpell.prototype.saveOldValue = function(elm, old_value) {
elm.is_changed = true;
elm.old_value = old_value;
}
GoogieSpell.prototype.createListSeparator = function() {
var e_col = AJS.TD(" ");
e_col.googie_action_btn = "1";
e_col.style.cursor = "default";
e_col.style.fontSize = "3px";
e_col.style.borderTop = "1px solid #ccc";
e_col.style.paddingTop = "3px";
return AJS.TR(e_col);
}
GoogieSpell.prototype.correctError = function(id, elm, l_elm, /*optional*/ rm_pre_space) {
var old_value = elm.innerHTML;
var new_value = l_elm.innerHTML;
var offset = this.results[id]['attrs']['o'];
if(rm_pre_space) {
var pre_length = elm.previousSibling.innerHTML;
elm.previousSibling.innerHTML = pre_length.slice(0, pre_length.length-1);
old_value = " " + old_value;
offset--;
}
this.hideErrorWindow();
this.updateOrginalText(offset, old_value, new_value, id);
elm.innerHTML = new_value;
elm.style.color = "green";
elm.is_corrected = true;
this.results[id]['attrs']['l'] = new_value.length;
if(!AJS.isDefined(elm.old_value))
this.saveOldValue(elm, old_value);
this.errorFixed();
}
GoogieSpell.prototype.showErrorWindow = function(elm, id) {
if(this.show_menu_observer)
this.show_menu_observer(this);
var me = this;
var abs_pos = AJS.absolutePosition(elm);
abs_pos.y -= this.edit_layer.scrollTop;
this.error_window.style.visibility = "visible";
AJS.setTop(this.error_window, (abs_pos.y+20));
AJS.setLeft(this.error_window, (abs_pos.x));
this.error_window.innerHTML = "";
var table = AJS.TABLE({'class': 'googie_list'});
table.googie_action_btn = "1";
var list = AJS.TBODY();
var changed = false;
if(this.custom_menu_builder != []) {
for(var k=0; k<this.custom_menu_builder.length; k++) {
var eb = this.custom_menu_builder[k];
if(eb[0]((this.results[id]))){
changed = eb[1](this, list, elm);
break;
}
}
}
if(!changed) {
var suggestions = this.results[id]['suggestions'];
var offset = this.results[id]['attrs']['o'];
var len = this.results[id]['attrs']['l'];
if(suggestions.length == 0) {
var row = AJS.TR();
var item = AJS.TD({'style': 'cursor: default;'});
var dummy = AJS.SPAN();
dummy.innerHTML = this.lang_no_suggestions;
AJS.ACN(item, AJS.TN(dummy.innerHTML));
item.googie_action_btn = "1";
row.appendChild(item);
list.appendChild(row);
}
for(i=0; i < suggestions.length; i++) {
var row = AJS.TR();
var item = AJS.TD();
var dummy = AJS.SPAN();
dummy.innerHTML = suggestions[i];
item.appendChild(AJS.TN(dummy.innerHTML));
var fn = function(e) {
var l_elm = AJS.getEventElm(e);
this.correctError(id, elm, l_elm);
};
AJS.AEV(item, "click", AJS.$b(fn, this));
item.onmouseover = GoogieSpell.item_onmouseover;
item.onmouseout = GoogieSpell.item_onmouseout;
row.appendChild(item);
list.appendChild(row);
}
if(elm.is_changed && elm.innerHTML != elm.old_value) {
var old_value = elm.old_value;
var revert_row = AJS.TR();
var revert = AJS.TD();
revert.onmouseover = GoogieSpell.item_onmouseover;
revert.onmouseout = GoogieSpell.item_onmouseout;
var rev_span = AJS.SPAN({'class': 'googie_list_revert'});
rev_span.innerHTML = this.lang_revert + " " + old_value;
revert.appendChild(rev_span);
var fn = function(e) { 
this.updateOrginalText(offset, elm.innerHTML, old_value, id);
elm.is_corrected = true;
elm.style.color = "#b91414";
elm.innerHTML = old_value;
this.hideErrorWindow();
};
AJS.AEV(revert, "click", AJS.$b(fn, this));
revert_row.appendChild(revert);
list.appendChild(revert_row);
}
var edit_row = AJS.TR();
var edit = AJS.TD({'style': 'cursor: default'});
var edit_input = AJS.INPUT({'style': 'width: 120px; margin:0; padding:0', 'value': elm.innerHTML});
edit_input.googie_action_btn = "1";
var onsub = function () {
if(edit_input.value != "") {
if(!AJS.isDefined(elm.old_value))
this.saveOldValue(elm, elm.innerHTML);
this.updateOrginalText(offset, elm.innerHTML, edit_input.value, id);
elm.style.color = "green"
elm.is_corrected = true;
elm.innerHTML = edit_input.value;
this.hideErrorWindow();
}
return false;
};
onsub = AJS.$b(onsub, this);
var imgdir = "http://hotpot.se/spell/";
var ok_pic = AJS.IMG({'src': imgdir + "ok.gif", 'style': 'width: 32px; height: 16px; margin-left: 2px; margin-right: 2px; cursor: pointer;'});
var edit_form = AJS.FORM({'style': 'margin: 0; padding: 0; cursor: default;'}, edit_input, ok_pic);
edit_form.googie_action_btn = "1";
edit.googie_action_btn = "1";
AJS.AEV(edit_form, "submit", onsub);
AJS.AEV(ok_pic, "click", onsub);
edit.appendChild(edit_form);
edit_row.appendChild(edit);
list.appendChild(edit_row);
if(this.extra_menu_items.length > 0)
AJS.ACN(list, this.createListSeparator());
var loop = function(i) {
if(i < me.extra_menu_items.length) {
var e_elm = me.extra_menu_items[i];
if(!e_elm[2] || e_elm[2](elm, me)) {
var e_row = AJS.TR();
var e_col = AJS.TD(e_elm[0]);
e_col.onmouseover = GoogieSpell.item_onmouseover;
e_col.onmouseout = GoogieSpell.item_onmouseout;
var fn = function() {
return e_elm[1](elm, me);
};
AJS.AEV(e_col, "click", fn);
AJS.ACN(e_row, e_col);
AJS.ACN(list, e_row);
}
loop(i+1);
}
}
loop(0);
loop = null;
if(this.use_close_btn) {
AJS.ACN(list, this.createCloseButton(this.hideErrorWindow));
}
}
table.appendChild(list);
this.error_window.appendChild(table);
if(AJS.isIe() && !this.error_window_iframe) {
var iframe = AJS.IFRAME({'style': 'position: absolute; z-index: 0;'});
AJS.ACN(AJS.getBody(), iframe);
this.error_window_iframe = iframe;
}
if(AJS.isIe()) {
var iframe = this.error_window_iframe;
AJS.setTop(iframe, this.error_window.offsetTop);
AJS.setLeft(iframe, this.error_window.offsetLeft);
AJS.setWidth(iframe, this.error_window.offsetWidth);
AJS.setHeight(iframe, this.error_window.offsetHeight);
iframe.style.visibility = "visible";
}
var link = this.createFocusLink('link');
list.appendChild(AJS.TR(AJS.TD({'style': 'text-align: right; font-size: 1px; height: 1px; margin: 0; padding: 0;'}, link)));
link.focus();
}
GoogieSpell.prototype.createEditLayer = function(width, height) {
this.edit_layer = AJS.DIV({'class': 'googie_edit_layer'});
this.edit_layer.className = this.text_area.className;
this.edit_layer.style.border = "1px solid #999";
this.edit_layer.style.backgroundColor = "#f7f7f7";
this.edit_layer.style.padding = "3px";
this.edit_layer.style.margin = "0px";
AJS.setWidth(this.edit_layer, (width-8));
if(AJS.nodeName(this.text_area) != "input" || this.text_area.value == "") {
this.edit_layer.style.overflow = "auto";
AJS.setHeight(this.edit_layer, (height-6));
}
else {
this.edit_layer.style.overflow = "hidden";
}
if(this.edit_layer_dbl_click) {
var me = this;
var fn = function(e) {
if(AJS.getEventElm(e).className != "googie_link" && !me.isErrorWindowShown()) {
me.resumeEditing();
var fn1 = function() {
me.text_area.focus();
fn1 = null;
};
AJS.callLater(fn1, 10);
}
return false;
};
this.edit_layer.ondblclick = fn;
fn = null;
}
}
GoogieSpell.prototype.resumeEditing = function() {
this.setStateChanged("spell_check");
this.switch_lan_pic.style.display = "inline";
this.el_scroll_top = this.edit_layer.scrollTop;
this.hideErrorWindow();
try {
this.edit_layer.parentNode.removeChild(this.edit_layer);
if(this.use_focus) {
AJS.removeElement(this.focus_link_t);
AJS.removeElement(this.focus_link_b);
}
}
catch(e) {
}
AJS.showElement(this.text_area);
if(this.main_controller)
this.spell_span.className = "googie_no_style";
this.text_area.scrollTop = this.el_scroll_top;
elm.onmouseout = null;
this.checkSpellingState(false);
}
GoogieSpell.prototype.createErrorLink = function(text, id) {
var elm = AJS.SPAN({'class': 'googie_link'});
var me = this;
var d = function (e) {
me.showErrorWindow(elm, id);
d = null;
return false;
};
AJS.AEV(elm, "click", d);
elm.googie_action_btn = "1";
elm.g_id = id;
elm.is_corrected = false;
elm.oncontextmenu = d;
elm.innerHTML = text;
return elm;
}
GoogieSpell.createPart = function(txt_part) {
if(txt_part == " ")
return AJS.TN(" ");
var result = AJS.SPAN();
var is_first = true;
var is_safari = (navigator.userAgent.toLowerCase().indexOf("safari") != -1);
var part = AJS.SPAN();
txt_part = GoogieSpell.escapeSepcial(txt_part);
txt_part = txt_part.replace(/\n/g, "<br>");
txt_part = txt_part.replace(/  /g, " &nbsp;");
txt_part = txt_part.replace(/^ /g, "&nbsp;");
txt_part = txt_part.replace(/ $/g, "&nbsp;");
part.innerHTML = txt_part;
return part;
}
GoogieSpell.prototype.showErrorsInIframe = function() {
var output = AJS.DIV();
output.style.textAlign = "left";
var pointer = 0;
var results = this.results;
if(results.length > 0) {
for(var i=0; i < results.length; i++) {
var offset = results[i]['attrs']['o'];
var len = results[i]['attrs']['l'];
var part_1_text = this.orginal_text.substring(pointer, offset);
var part_1 = GoogieSpell.createPart(part_1_text);
output.appendChild(part_1);
pointer += offset - pointer;
var err_link = this.createErrorLink(this.orginal_text.substr(offset, len), i);
this.error_links.push(err_link);
output.appendChild(err_link);
pointer += len;
}
var part_2_text = this.orginal_text.substr(pointer, this.orginal_text.length);
var part_2 = GoogieSpell.createPart(part_2_text);
output.appendChild(part_2);
}
else
output.innerHTML = this.orginal_text;
var me = this;
if(this.custom_item_evaulator)
AJS.map(this.error_links, function(elm){me.custom_item_evaulator(me, elm)});
AJS.ACN(this.edit_layer, output);
this.text_area_bottom = this.text_area.offsetTop + this.text_area.offsetHeight;
AJS.hideElement(this.text_area);
AJS.insertBefore(this.edit_layer, this.text_area);
if(this.use_focus) {
this.focus_link_t = this.createFocusLink('focus_t');
this.focus_link_b = this.createFocusLink('focus_b');
AJS.insertBefore(this.focus_link_t, this.edit_layer);
AJS.insertAfter(this.focus_link_b, this.edit_layer);
}
this.edit_layer.scrollTop = this.ta_scroll_top;
}
GoogieSpell.prototype.createLangWindow = function() {
this.language_window = AJS.DIV({'class': 'googie_window'});
AJS.setWidth(this.language_window, 100);
this.language_window.googie_action_btn = "1";
var table = AJS.TABLE({'class': 'googie_list'});
AJS.setWidth(table, "100%");
var list = AJS.TBODY();
this.lang_elms = new Array();
for(i=0; i < this.langlist_codes.length; i++) {
var row = AJS.TR();
var item = AJS.TD();
item.googieId = this.langlist_codes[i];
this.lang_elms.push(item);
var lang_span = AJS.SPAN();
lang_span.innerHTML = this.lang_to_word[this.langlist_codes[i]];
item.appendChild(AJS.TN(lang_span.innerHTML));
var fn = function(e) {
var elm = AJS.getEventElm(e);
this.deHighlightCurSel();
this.setCurrentLanguage(elm.googieId);
if(this.lang_state_observer != null) {
this.lang_state_observer();
}
this.highlightCurSel();
this.hideLangWindow();
};
AJS.AEV(item, "click", AJS.$b(fn, this));
item.onmouseover = function(e) { 
var i_it = AJS.getEventElm(e);
if(i_it.className != "googie_list_selected")
i_it.className = "googie_list_onhover";
};
item.onmouseout = function(e) { 
var i_it = AJS.getEventElm(e);
if(i_it.className != "googie_list_selected")
i_it.className = "googie_list_onout"; 
};
row.appendChild(item);
list.appendChild(row);
}
if(this.use_close_btn) {
list.appendChild(this.createCloseButton(this.hideLangWindow));
}
this.highlightCurSel();
table.appendChild(list);
this.language_window.appendChild(table);
}
GoogieSpell.prototype.setCurrentLanguage = function(lan_code) {
GOOGIE_CUR_LANG = lan_code;
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
setCookie('language', lan_code, now);
}
GoogieSpell.prototype.isLangWindowShown = function() {
return this.language_window != null && this.language_window.style.visibility == "visible";
}
GoogieSpell.prototype.hideLangWindow = function() {
try {
this.language_window.style.visibility = "hidden";
this.switch_lan_pic.className = "googie_lang_3d_on";
}
catch(e) {}
}
GoogieSpell.prototype.deHighlightCurSel = function() {
this.lang_cur_elm.className = "googie_list_onout";
}
GoogieSpell.prototype.highlightCurSel = function() {
if(GOOGIE_CUR_LANG == null)
GOOGIE_CUR_LANG = GOOGIE_DEFAULT_LANG;
for(var i=0; i < this.lang_elms.length; i++) {
if(this.lang_elms[i].googieId == GOOGIE_CUR_LANG) {
this.lang_elms[i].className = "googie_list_selected";
this.lang_cur_elm = this.lang_elms[i];
}
else {
this.lang_elms[i].className = "googie_list_onout";
}
}
}
GoogieSpell.prototype.showLangWindow = function(elm, ofst_top, ofst_left) {
if(this.show_menu_observer)
this.show_menu_observer(this);
if(!AJS.isDefined(ofst_top))
ofst_top = 20;
if(!AJS.isDefined(ofst_left))
ofst_left = 100;
this.createLangWindow();
AJS.getBody().appendChild(this.language_window);
var abs_pos = AJS.absolutePosition(elm);
AJS.showElement(this.language_window);
AJS.setTop(this.language_window, (abs_pos.y+ofst_top));
AJS.setLeft(this.language_window, (abs_pos.x+ofst_left-this.language_window.offsetWidth));
this.highlightCurSel();
this.language_window.style.visibility = "visible";
}
GoogieSpell.prototype.createChangeLangPic = function() {
var img = AJS.IMG({'src': this.img_dir + 'change_lang.gif', 'alt': "Ändra språk"});
img.googie_action_btn = "1";
var switch_lan = AJS.SPAN({'class': 'googie_lang_3d_on', 'style': 'padding-left: 6px;'}, img);
var fn = function(e) {
var elm = AJS.getEventElm(e);
if(AJS.nodeName(elm) == 'img')
elm = elm.parentNode;
if(elm.className == "googie_lang_3d_click") {
elm.className = "googie_lang_3d_on";
this.hideLangWindow();
}
else {
elm.className = "googie_lang_3d_click";
this.showLangWindow(switch_lan);
}
}
AJS.AEV(switch_lan, "click", AJS.$b(fn, this));
return switch_lan;
}
GoogieSpell.prototype.createSpellDiv = function() {
var chk_spell = AJS.SPAN({'class': 'googie_check_spelling_link'});
chk_spell.innerHTML = this.lang_chck_spell;
var spell_img = null;
if(this.show_spell_img)
var imgdir = "http://hotpot.se/spell/"; 
spell_img = AJS.IMG({'src': imgdir + "spellc.gif"});
return AJS.SPAN(spell_img, " ", chk_spell);
}
GoogieSpell.prototype.flashNoSpellingErrorState = function(on_finish) {
var no_spell_errors;
if(on_finish) {
var fn = function() {
on_finish();
this.checkSpellingState();
};
no_spell_errors = fn;
}
else
no_spell_errors = this.checkSpellingState;
this.setStateChanged("no_error_found");
if(this.main_controller) {
AJS.hideElement(this.switch_lan_pic);
var dummy = AJS.IMG({'src': this.img_dir + "blank.gif", 'style': 'height: 16px; width: 1px;'});
var rsm = AJS.SPAN();
rsm.innerHTML = this.lang_no_error_found;
AJS.RCN(this.spell_span, AJS.SPAN(dummy, rsm));
this.spell_span.className = "googie_check_spelling_ok";
this.spell_span.style.textDecoration = "none";
this.spell_span.style.cursor = "default";
AJS.callLater(AJS.$b(no_spell_errors, this), 1200, [false]);
}
}
GoogieSpell.prototype.resumeEditingState = function() {
this.setStateChanged("resume_editing");
if(this.main_controller) {
AJS.hideElement(this.switch_lan_pic);
var dummy = AJS.IMG({'src': this.img_dir + "blank.gif", 'style': 'height: 16px; width: 1px;'});
var rsm = AJS.SPAN();
rsm.innerHTML = this.lang_rsm_edt;
AJS.RCN(this.spell_span, AJS.SPAN(dummy, rsm));
var fn = function(e) {
this.resumeEditing();
}
AJS.AEV(this.spell_span, "click", AJS.$b(fn, this), true);
this.spell_span.className = "googie_resume_editing";
}
try { this.edit_layer.scrollTop = this.ta_scroll_top; }
catch(e) { }
}
GoogieSpell.prototype.checkSpellingState = function(fire) {
if(!AJS.isDefined(fire) || fire)
this.setStateChanged("spell_check");
if(this.show_change_lang_pic)
this.switch_lan_pic = this.createChangeLangPic();
else
this.switch_lan_pic = AJS.SPAN();
var span_chck = this.createSpellDiv();
var fn = function() {
this.spellCheck();
};
if(this.custom_spellcheck_starter)
span_chck.onclick = this.custom_spellcheck_starter;
else {
AJS.AEV(span_chck, "click", AJS.$b(fn, this), true);
}
this.spell_span = span_chck;
if(this.main_controller) {
if(this.change_lang_pic_placement == "left")
AJS.RCN(this.spell_container, span_chck, " ", this.switch_lan_pic);
else
AJS.RCN(this.spell_container, this.switch_lan_pic, " ", span_chck);
}
}
GoogieSpell.item_onmouseover = function(e) {
var elm = AJS.getEventElm(e);
if(elm.className != "googie_list_revert" && elm.className != "googie_list_close")
elm.className = "googie_list_onhover";
else
elm.parentNode.className = "googie_list_onhover";
}
GoogieSpell.item_onmouseout = function(e) {
var elm = AJS.getEventElm(e);
if(elm.className != "googie_list_revert" && elm.className != "googie_list_close")
elm.className = "googie_list_onout";
else
elm.parentNode.className = "googie_list_onout";
}
GoogieSpell.prototype.createCloseButton = function(c_fn) {
return this.createButton(this.lang_close, 'googie_list_close', AJS.$b(c_fn, this));
}
GoogieSpell.prototype.createButton = function(name, css_class, c_fn) {
var btn_row = AJS.TR();
var btn = AJS.TD();
btn.onmouseover = GoogieSpell.item_onmouseover;
btn.onmouseout = GoogieSpell.item_onmouseout;
var spn_btn;
if(css_class != "") {
spn_btn = AJS.SPAN({'class': css_class});
spn_btn.innerHTML = name;
}
else {
spn_btn = AJS.TN(name);
}
btn.appendChild(spn_btn);
AJS.AEV(btn, "click", c_fn);
btn_row.appendChild(btn);
return btn_row;
}
GoogieSpell.prototype.removeIndicator = function(elm) {
try { AJS.removeElement(this.indicator); }
catch(e) {}
}
GoogieSpell.prototype.appendIndicator = function(elm) {
var imgdir = "http://hotpot.se/spell/"; 
var img = AJS.IMG({'src': imgdir + 'indicator.gif', 'style': 'margin-right: 5px;'});
AJS.setWidth(img, 16);
AJS.setHeight(img, 16);
this.indicator = img;
img.style.textDecoration = "none";
try {
AJS.insertBefore(img, elm);
}
catch(e) {}
}
GoogieSpell.prototype.createFocusLink = function(name) {
return AJS.A({'href': 'javascript:;', name: name});
}
/*
var GB_CURRENT = null;
var GB_ONLY_ONE = null;
GB_IMG_DIR = null;
function GreyBox() {
this.type = "page";
this.overlay_click_close = true;
if(GB_IMG_DIR)
this.img_dir = GB_IMG_DIR;
else
this.img_dir = "greybox/";
this.overlay_color = "dark";
this.center_window = false;
this.g_window = null;
this.g_container = null;
this.iframe = null;
this.overlay = null;
this.timeout = null;
this.defaultSize();
this.showCloseImage(true);
*/
this.url = "";
/*
this.caption = "";
this.callback_fn = [];
this.reload_on_close = false;
}
GreyBox.prototype.setDimension = function(width, height) {
this.height = height;
this.width = width;
}
GreyBox.prototype.setFullScreen = function(bool) {
this.full_screen = bool;
}
GreyBox.prototype.setType = function(type) {
this.type = type;
}
GreyBox.prototype.setCenterWindow = function(bool) {
this.center_window = bool;
}
GreyBox.prototype.setImageDir = function(dir) {
this.img_dir = dir;
}
GreyBox.prototype.showCloseImage = function(bool) {
this.show_close_img = bool;
}
GreyBox.prototype.setOverlayCloseClick = function(bool) {
this.overlay_click_close = bool;
}
GreyBox.prototype.setOverlayColor = function(color) {
this.overlay_color = color;
}
GreyBox.prototype.setCallback = function(fn) {
if(fn)
this.callback_fn.push(fn);
}
GreyBox.prototype.show = function(caption, url) {
GB_CURRENT = this;
this.url = url;
this.caption = caption;
AJS.map(AJS.$bytc("div", "GB_dummy"), function(elm) { AJS.removeElement(elm) });
AJS.map(AJS.$bytc("div", "GB_loader"), function(elm) { AJS.removeElement(elm) });
if(AJS.isIe())
AJS.map(AJS.$bytc("select"), function(elm) {elm.style.visibility = "hidden"});
AJS.map(AJS.$bytc("object"), function(elm) {elm.style.visibility = "hidden"});
this.initOverlayIfNeeded();
this.setOverlayDimension();
AJS.showElement(this.overlay);
this.setFullScreenOption();
this.initIfNeeded();
AJS.hideElement(this.g_window);
AJS.ACN(this.g_container, this.iframe);
if(caption == "")
caption = "&nbsp;";
this.div_caption.innerHTML = caption;
AJS.showElement(this.g_window)
this.setVerticalPosition();
this.setWidthNHeight();
this.setTopNLeft();
GB_CURRENT.startLoading();
return false;
}
GreyBox.prototype.hide = function() {
AJS.hideElement(this.g_window, this.overlay);
try{ AJS.removeElement(this.iframe); }
catch(e) {}
this.iframe = null;
if(this.type == "image") {
this.width = 200;
this.height = 200;
}
if(AJS.isIe()) 
AJS.map(AJS.$bytc("select"), function(elm) {elm.style.visibility = "visible"});
AJS.map(AJS.$bytc("object"), function(elm) {elm.style.visibility = "visible"});
var c_bs = GB_CURRENT.callback_fn;
if(c_bs != []) {
AJS.map(c_bs, function(fn) { 
fn();
});
}
GB_CURRENT = null;
if(this.reload_on_close)
window.location.reload();
}
GB_initOneIfNeeded = function() {
if(!GB_ONLY_ONE) {
GB_ONLY_ONE = new GreyBox();
}
}
GB_show = function(caption, url, /* optional / height, width, callback_fn) {
GB_initOneIfNeeded();
GB_ONLY_ONE.defaultSize();
GB_ONLY_ONE.setFullScreen(false);
GB_ONLY_ONE.setType("page");
GB_ONLY_ONE.setCallback(callback_fn);
GB_ONLY_ONE.setDimension(width, height);
GB_ONLY_ONE.show(caption, url);
return false;
}
GB_showFullScreen = function(caption, url, /* optional / callback_fn) {
GB_initOneIfNeeded();
GB_ONLY_ONE.defaultSize();
GB_ONLY_ONE.setType("page");
GB_ONLY_ONE.setCallback(callback_fn);
GB_ONLY_ONE.setFullScreen(true);
GB_ONLY_ONE.show(caption, url);
return false;
}
GB_showImage = function(caption, url) {
GB_initOneIfNeeded();
GB_ONLY_ONE.defaultSize();
GB_ONLY_ONE.setFullScreen(false);
GB_ONLY_ONE.setType("image");
GB_ONLY_ONE.show(caption, url);
return false;
}
GB_hide = function() {
GB_CURRENT.hide();
}
GreyBox.preloadGreyBoxImages = function(img_dir) {
var pics = [];
if(!img_dir)
img_dir = GB_IMG_DIR;
var fn = function(path) { 
var pic = new Image();
pic.src = GB_IMG_DIR + path;
pics.push(pic);
};
*/
/*
AJS.map(['indicator.gif', 'blank.gif', 'close.gif', 'header_bg.gif', 'overlay_light.png', 'overlay_dark.png'], AJS.$b(fn, this));
}
*/
/*
GreyBox.prototype.getOverlayImage = function() {
return "overlay_" + this.overlay_color + ".png";
};
GreyBox.prototype.initOverlayIfNeeded = function() {
this.overlay = AJS.DIV({'id': 'GB_overlay'});
if(AJS.isIe()) {
this.overlay.style.backgroundColor = "#000000";
this.overlay.style.backgroundColor = "transparent";
this.overlay.style.backgroundImage = "url("+ this.img_dir +"blank.gif)";
this.overlay.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.img_dir + this.getOverlayImage() + "',sizingMethod='scale')";
}
else 
this.overlay.style.backgroundImage = "url("+ this.img_dir + this.getOverlayImage() +")";
if(this.overlay_click_close)
AJS.AEV(this.overlay, "click", GB_hide);
AJS.getBody().insertBefore(this.overlay, AJS.getBody().firstChild);
};
GreyBox.prototype.initIfNeeded = function() {
this.init();
this.setWidthNHeight = AJS.$b(this.setWidthNHeight, this);
this.setTopNLeft = AJS.$b(this.setTopNLeft, this);
this.setFullScreenOption = AJS.$b(this.setFullScreenOption, this);
this.setOverlayDimension = AJS.$b(this.setOverlayDimension, this);
GreyBox.addOnWinResize(this.setWidthNHeight, this.setTopNLeft, this.setFullScreenOption, this.setOverlayDimension);
this.g_container.style.marginBottom = "-3px";
var fn = function() { 
this.setOverlayDimension();
this.setVerticalPosition(); 
this.setTopNLeft();
this.setWidthNHeight(); 
};
AJS.AEV(window, "scroll", AJS.$b(fn, this));
if(!this.iframe) {
var new_frame;
var d = {'name': 'GB_frame', 'class': 'GB_frame', 'frameBorder': 0};
new_frame = AJS.IFRAME(d);
this.iframe = new_frame;
AJS.hideElement(this.iframe);
}
}
GreyBox.prototype.init = function() {
this.g_window = AJS.DIV({'id': 'GB_window'});
var table = AJS.TABLE({'class': 'GB_t_frame', 'frameborder': 0});
var tbody = AJS.TBODY();
AJS.ACN(table, tbody);
var td_middle_m = AJS.TD({'class': 'GB_content'});
this.td_middle_m = td_middle_m;
AJS.ACN(tbody, AJS.TR(td_middle_m));
var header = AJS.TABLE({'class': 'GB_header'});
this.header = header;
var caption = AJS.TD({'class': 'GB_caption'});
this.div_caption = caption;
header.style.backgroundImage = "url("+ this.img_dir +"header_bg.gif)";
tbody_header = AJS.TBODY();
var close = AJS.TD({'class': 'GB_close'});
if(this.show_close_img) {
var img_close = AJS.IMG({'src': this.img_dir + 'close.gif'});
AJS.ACN(close, img_close, "Close");
AJS.AEV(close, "click", GB_hide);
}
AJS.ACN(tbody_header, AJS.TR(caption, close));
AJS.ACN(header, tbody_header);
AJS.ACN(td_middle_m, header);
this.g_container = AJS.DIV({'class': 'GB_container'});
AJS.ACN(td_middle_m, this.g_container);
AJS.ACN(this.g_window, table);
AJS.getBody().insertBefore(this.g_window, this.overlay.nextSibling);
}
GreyBox.prototype.startLoading = function() {
this.iframe.src = this.img_dir + 'loader_frame.html';
AJS.showElement(this.iframe);
}
GreyBox.prototype.setIframeWidthNHeight = function() {
try{
AJS.setWidth(this.iframe, this.width);
AJS.setHeight(this.iframe, this.height);
}
catch(e) {
}
}
/*GreyBox.prototype.setOverlayDimension = function() {
var page_size = AJS.getWindowSize();
if((navigator.userAgent.toLowerCase().indexOf("firefox") != -1))
AJS.setWidth(this.overlay, "100%");
else
AJS.setWidth(this.overlay, page_size.w);
var max_height = Math.max(AJS.getScrollTop()+page_size.h, AJS.getScrollTop()+this.height);
if(max_height < AJS.getScrollTop())
AJS.setHeight(this.overlay, max_height);
else
AJS.setHeight(this.overlay, AJS.getScrollTop()+page_size.h);
}
GreyBox.prototype.setWidthNHeight = function() {
AJS.setWidth(this.g_window, this.width);
AJS.setHeight(this.g_window, this.height);
AJS.setWidth(this.g_container, this.width);
AJS.setHeight(this.g_container, this.height);
this.setIframeWidthNHeight();
AJS.setWidth(this.td_middle_m, this.width+10);
}
GreyBox.prototype.setTopNLeft = function() {
var page_size = AJS.getWindowSize();
AJS.setLeft(this.g_window, ((page_size.w - this.width)/2)-13);
if(this.center_window) {
var fl = ((page_size.h - this.height) /2) - 15 + AJS.getScrollTop();
AJS.setTop(this.g_window, fl);
}
else {
if(this.g_window.offsetHeight < page_size.h)
AJS.setTop(this.g_window, AJS.getScrollTop());
}
}
GreyBox.prototype.setVerticalPosition = function() {
var page_size = AJS.getWindowSize();
var st = AJS.getScrollTop();
if(this.g_window.offsetWidth <= page_size.h || st <= this.g_window.offsetTop) {
AJS.setTop(this.g_window, st);
}
}
GreyBox.prototype.setFullScreenOption = function() {
if(this.full_screen) {
var page_size = AJS.getWindowSize();
overlay_h = page_size.h;
this.width = Math.round(this.overlay.offsetWidth - (this.overlay.offsetWidth/100)*10);
this.height = Math.round(overlay_h - (overlay_h/100)*10);
}
}
GreyBox.prototype.defaultSize = function() {
this.width = 300;
this.height = 300;
}
GreyBox.addOnWinResize = function(funcs) {
funcs = AJS.$A(funcs);
AJS.map(funcs, function(fn) { AJS.AEV(window, "resize", fn); });
}
*/
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}

