// NOT LOADED FROM CACHE (no-cache)

function GetWidth()
{
var x = 0;
/*if( window.innerWidth )
{
x = window.innerWidth - window.scrollbarWidth;
}
else*/ if( window.clientWidth + window.scrollbarHeight )
{
x = window.clientWidth;
}
else if( document.documentElement && document.documentElement.clientWidth )
{
x = document.documentElement.clientWidth - window.scrollbarWidth;
}
else if( self.innerWidth )
{
x = self.innerWidth - window.scrollbarWidth;
}
else if ( document.body )
{
x = document.body.clientWidth - window.scrollbarWidth;
}
return x;
}
function GetHeight()
{
var y = 0;
/*if( window.innerHeight )
{
y = window.innerHeight - window.scrollbarHeight;
}
else*/ if( window.clientHeight + window.scrollbarHeight )
{
y = window.clientHeight;
}
else if( document.documentElement && document.documentElement.clientHeight )
{
y = document.documentElement.clientHeight - window.scrollbarHeight;
}
else if( self.innerHeight )
{
y = self.innerHeight - window.scrollbarHeight;
}
else if ( document.body )
{
y = document.body.clientHeight - window.scrollbarHeight;
}
return y;
}
/** get_scrollbar_sizes()
*
*This function calculates window.scrollbarWidth and window.scrollbarHeight.
*/
function get_scrollbar_sizes()
{
var i = document.createElement( "p" );
i.style.width = "200px";
i.style.height = "200px";
var o = document.createElement( "div" );
o.style.position = "absolute";
o.style.top = "0px";
o.style.left = "0px";
o.style.visibility = "hidden";
o.style.width = "150px";
o.style.height = "150px";
o.style.overflow = "hidden";
o.appendChild( i );
document.body.appendChild( o );
var w1 = i.offsetWidth;
var h1 = i.offsetHeight;
o.style.overflow = "scroll";
var w2 = i.offsetWidth;
var h2 = i.offsetHeight;
if ( w1 == w2 ) 
{
w2 = o.clientWidth;
}
if ( h1 == h2 )
{
h2 = o.clientHeight;
}
document.body.removeChild( o );
window.scrollbarWidth = w1 - w2 - 50;
window.scrollbarHeight = h1 - h2 - 50;
}// global variables that can be used by ALL the functions on this page.
var baseaddr = ".";
if( document.getElementsByTagName ) 
{
var elements = document.getElementsByTagName( 'base' );
if( elements.length ) 
{
baseaddr = elements[0].href;
}
}
var imgFalse = baseaddr + "/images/checkbox-half.png";
var imgTrue = baseaddr + "/images/checkbox-checked-half.png";
var imgRefresh = baseaddr + "/images/spinner_half.gif";
var ajaxImage;
var oldAjaxImage;
// this function runs when the page is loaded, put all your other onload stuff in here too.
function initChecks() 
{
replaceChecks();
}
function replaceChecks() 
{
radios_and_checkboxes = $( '[type="checkbox"], [type="radio"]' );
radios_and_checkboxes.each
(
function( index )
{
var element = $( this );
// create a new image
var img = document.createElement('img');
// check if the checkbox is checked
if( this.checked ) 
{
img.src = imgTrue;
} 
else 
{
img.src = imgFalse;
}
// set image ID and onclick action
img.id = 'checkImage_' + index;
// set image
img.onclick = function()
{
checkChange( img.id );
}
// set image
this.onchange = function()
{
checkChange( img.id );
}
if( this.id == undefined
|| this.id == "" )
{
this.id = "id_" + Math.floor( Math.random() * 1000000000 ); 
}
$(img).attr( "for", this.id );
element.attr( "for", img.id );
element.before( img );
element.hide();
}
);
}
//change the checkbox status and the replacement image
function checkChange( i ) 
{
var image = $( "#" + i );
ajaxImage = i;
var input = $( "#" + image.attr( "for" ) );
if( input.attr( "type" ) == "checkbox" )
{
if ( input.attr( "checked" ) ) 
{
input.attr( "checked", false );
image.attr( "src", imgFalse );
} 
else 
{
input.attr( "checked", true );
image.attr( "src", imgTrue );
}
}
else if( input.attr( "type" ) == "radio" )
{
input.attr( "checked", true );
var name = input.attr( "name" );
var radio_group = $( '[name="' + name + '"]' );
radio_group.each
(
function( index )
{
var sub_input = $( this );
var sub_image = $( "#" + sub_input.attr( "for" ) );
if ( sub_input.attr( "checked" ) ) 
{
sub_image.attr( "src", imgTrue );
} 
else 
{
sub_image.attr( "src", imgFalse );
}
}
);
}
input.trigger( 'click' );
}
$(window).ready( function() { initChecks(); } );
/**
* sprintf() for JavaScript v.0.4
*
* Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/>
* Thanks to David Baird (unit test and patch).
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
function str_repeat(i, m) { for (var o = []; m > 0; o[--m] = i); return(o.join('')); }
function sprintf () {
var i = 0, a, f = arguments[i++], o = [], m, p, c, x;
while (f) {
if (m = /^[^\x25]+/.exec(f)) o.push(m[0]);
else if (m = /^\x25{2}/.exec(f)) o.push('%');
else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) throw("Too few arguments.");
if (/[^s]/.test(m[7]) && (typeof(a) != 'number'))
throw("Expecting number but found " + typeof(a));
switch (m[7]) {
case 'b': a = a.toString(2); break;
case 'c': a = String.fromCharCode(a); break;
case 'd': a = parseInt(a); break;
case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
case 'o': a = a.toString(8); break;
case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
case 'u': a = Math.abs(a); break;
case 'x': a = a.toString(16); break;
case 'X': a = a.toString(16).toUpperCase(); break;
}
a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
x = m[5] - String(a).length;
p = m[5] ? str_repeat(c, x) : '';
o.push(m[4] ? a + p : p + a);
}
else throw ("Huh ?!");
f = f.substring(m[0].length);
}
return o.join('');
}/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 1.1 Copyright (C) Paul Johnston 1999 - 2002.
* Code also contributed by Greg Holt
* See http://pajhome.org.uk/site/legal.html for details.
*/
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF)
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xFFFF)
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt))
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function cmn(q, a, b, x, s, t)
{
return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
}
function ff(a, b, c, d, x, s, t)
{
return cmn((b & c) | ((~b) & d), a, b, x, s, t)
}
function gg(a, b, c, d, x, s, t)
{
return cmn((b & d) | (c & (~d)), a, b, x, s, t)
}
function hh(a, b, c, d, x, s, t)
{
return cmn(b ^ c ^ d, a, b, x, s, t)
}
function ii(a, b, c, d, x, s, t)
{
return cmn(c ^ (b | (~d)), a, b, x, s, t)
}
/*
* Calculate the MD5 of an array of little-endian words, producing an array
* of little-endian words.
*/
function coreMD5(x)
{
var a = 1732584193
var b = -271733879
var c = -1732584194
var d = 271733878
for(i = 0; i < x.length; i += 16)
{
var olda = a
var oldb = b
var oldc = c
var oldd = d
a = ff(a, b, c, d, x[i+ 0], 7 , -680876936)
d = ff(d, a, b, c, x[i+ 1], 12, -389564586)
c = ff(c, d, a, b, x[i+ 2], 17, 606105819)
b = ff(b, c, d, a, x[i+ 3], 22, -1044525330)
a = ff(a, b, c, d, x[i+ 4], 7 , -176418897)
d = ff(d, a, b, c, x[i+ 5], 12, 1200080426)
c = ff(c, d, a, b, x[i+ 6], 17, -1473231341)
b = ff(b, c, d, a, x[i+ 7], 22, -45705983)
a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416)
d = ff(d, a, b, c, x[i+ 9], 12, -1958414417)
c = ff(c, d, a, b, x[i+10], 17, -42063)
b = ff(b, c, d, a, x[i+11], 22, -1990404162)
a = ff(a, b, c, d, x[i+12], 7 , 1804603682)
d = ff(d, a, b, c, x[i+13], 12, -40341101)
c = ff(c, d, a, b, x[i+14], 17, -1502002290)
b = ff(b, c, d, a, x[i+15], 22, 1236535329)
a = gg(a, b, c, d, x[i+ 1], 5 , -165796510)
d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632)
c = gg(c, d, a, b, x[i+11], 14, 643717713)
b = gg(b, c, d, a, x[i+ 0], 20, -373897302)
a = gg(a, b, c, d, x[i+ 5], 5 , -701558691)
d = gg(d, a, b, c, x[i+10], 9 , 38016083)
c = gg(c, d, a, b, x[i+15], 14, -660478335)
b = gg(b, c, d, a, x[i+ 4], 20, -405537848)
a = gg(a, b, c, d, x[i+ 9], 5 , 568446438)
d = gg(d, a, b, c, x[i+14], 9 , -1019803690)
c = gg(c, d, a, b, x[i+ 3], 14, -187363961)
b = gg(b, c, d, a, x[i+ 8], 20, 1163531501)
a = gg(a, b, c, d, x[i+13], 5 , -1444681467)
d = gg(d, a, b, c, x[i+ 2], 9 , -51403784)
c = gg(c, d, a, b, x[i+ 7], 14, 1735328473)
b = gg(b, c, d, a, x[i+12], 20, -1926607734)
a = hh(a, b, c, d, x[i+ 5], 4 , -378558)
d = hh(d, a, b, c, x[i+ 8], 11, -2022574463)
c = hh(c, d, a, b, x[i+11], 16, 1839030562)
b = hh(b, c, d, a, x[i+14], 23, -35309556)
a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060)
d = hh(d, a, b, c, x[i+ 4], 11, 1272893353)
c = hh(c, d, a, b, x[i+ 7], 16, -155497632)
b = hh(b, c, d, a, x[i+10], 23, -1094730640)
a = hh(a, b, c, d, x[i+13], 4 , 681279174)
d = hh(d, a, b, c, x[i+ 0], 11, -358537222)
c = hh(c, d, a, b, x[i+ 3], 16, -722521979)
b = hh(b, c, d, a, x[i+ 6], 23, 76029189)
a = hh(a, b, c, d, x[i+ 9], 4 , -640364487)
d = hh(d, a, b, c, x[i+12], 11, -421815835)
c = hh(c, d, a, b, x[i+15], 16, 530742520)
b = hh(b, c, d, a, x[i+ 2], 23, -995338651)
a = ii(a, b, c, d, x[i+ 0], 6 , -198630844)
d = ii(d, a, b, c, x[i+ 7], 10, 1126891415)
c = ii(c, d, a, b, x[i+14], 15, -1416354905)
b = ii(b, c, d, a, x[i+ 5], 21, -57434055)
a = ii(a, b, c, d, x[i+12], 6 , 1700485571)
d = ii(d, a, b, c, x[i+ 3], 10, -1894986606)
c = ii(c, d, a, b, x[i+10], 15, -1051523)
b = ii(b, c, d, a, x[i+ 1], 21, -2054922799)
a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359)
d = ii(d, a, b, c, x[i+15], 10, -30611744)
c = ii(c, d, a, b, x[i+ 6], 15, -1560198380)
b = ii(b, c, d, a, x[i+13], 21, 1309151649)
a = ii(a, b, c, d, x[i+ 4], 6 , -145523070)
d = ii(d, a, b, c, x[i+11], 10, -1120210379)
c = ii(c, d, a, b, x[i+ 2], 15, 718787259)
b = ii(b, c, d, a, x[i+ 9], 21, -343485551)
a = safe_add(a, olda)
b = safe_add(b, oldb)
c = safe_add(c, oldc)
d = safe_add(d, oldd)
}
return [a, b, c, d]
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = "0123456789abcdef"
var str = ""
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF)
}
return str
}
/*
* Convert an array of little-endian words to a base64 encoded string.
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
var str = ""
for(var i = 0; i < binarray.length * 32; i += 6)
{
str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) |
((binarray[i>>5+1] >> (32-i%32)) & 0x3F))
}
return str
}
/*
* Convert an 8-bit character string to a sequence of 16-word blocks, stored
* as an array, and append appropriate padding for MD4/5 calculation.
* If any of the characters are >255, the high byte is silently ignored.
*/
function str2binl(str)
{
var nblk = ((str.length + 8) >> 6) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>2] |= (str.charCodeAt(i) & 0xFF) << ((i%4) * 8)
blks[i>>2] |= 0x80 << ((i%4) * 8)
blks[nblk*16-2] = str.length * 8
return blks
}
/*
* Convert a wide-character string to a sequence of 16-word blocks, stored as
* an array, and append appropriate padding for MD4/5 calculation.
*/
function strw2binl(str)
{
var nblk = ((str.length + 4) >> 5) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>1] |= str.charCodeAt(i) << ((i%2) * 16)
blks[i>>1] |= 0x80 << ((i%2) * 16)
blks[nblk*16-2] = str.length * 16
return blks
}
/*
* External interface
*/
function hexMD5 (str) { return binl2hex(coreMD5( str2binl(str))) }
function hexMD5w(str) { return binl2hex(coreMD5(strw2binl(str))) }
function b64MD5 (str) { return binl2b64(coreMD5( str2binl(str))) }
function b64MD5w(str) { return binl2b64(coreMD5(strw2binl(str))) }
/* Backward compatibility */
function calcMD5(str) { return binl2hex(coreMD5( str2binl(str))) }
// form.js 
var MIN_PASSWORD_LENGTH = 4;
function trim( s )
{
return s.replace( /^\s*(.*?)\s*$/, "$1" );
}
var focused_form_control = null;
function i_have_focus( e )
{
focused_form_control = e;
}
function urlencode( str ) 
{
str = escape( str );
str = str.replace( '+', '%2B' );
str = str.replace( '%20', '+' );
str = str.replace( '*', '%2A' );
str = str.replace( '/', '%2F' );
str = str.replace( '@', '%40' );
return str;
}
function urldecode( str ) 
{
str = str.replace( '+', ' ' );
str = unescape( str );
return str;
}
function SubmitForm( e, xtra )
{
if ( e==null )
return false;
if ( xtra!=null )
e.action = e.action + '?cmd=' + xtra;
e.submit();
}
function HashPassword( e, xtra )
{
if ( e == null )
{
alert( "HashPassword: The form object is missing." );
return false;
}
if ( document.getElementById( "password" ) == null )
{
alert( "HashPassword: The id 'password' input element is missing." );
return false;
}
if ( document.getElementById( "password_encoded" ) == null )
{
alert( "HashPassword: The id 'password_encoded' input element is missing." );
return false;
}
i = trim( e.password.value );
if ( i.length < MIN_PASSWORD_LENGTH )
{
alert( "Please provide a password that is at least " +
MIN_PASSWORD_LENGTH + " characters long." );
return false;
}
var theCookie = "" + document.cookie;
var cookieName = "PHPSESSID";
var ind = theCookie.indexOf( cookieName );
if( ind == -1 || cookieName == "" )
{
RandomServerString = null;
}
else
{
var ind1 = theCookie.indexOf( ";", ind );
if( ind1 == -1 ) 
{
ind1 = theCookie.length; 
}
RandomServerString = unescape( theCookie.substring( ind + cookieName.length + 1, ind1 ) );
}
hash = calcMD5( RandomServerString + calcMD5( i ) );
e.password_encoded.value = hash;
e.password.value = "";
return SubmitForm( e, xtra );
}
function HashPasswordWithoutKey( e, xtra )
{
if ( e == null )
{
alert( "HashPasswordWithoutKey: The form object is missing." );
return false;
}
if ( document.getElementById( "password" ) == null )
{
alert( "HashPasswordWithoutKey: The id 'password' input element is missing." );
return false;
}
if ( document.getElementById( "password_encoded" ) == null )
{
alert( "HashPasswordWithoutKey: The id 'password_encoded' input element is missing." );
return false;
}
if ( document.getElementById( "password_verify" ) == null )
{
alert( "HashPasswordWithoutKey: The id 'password_verify' input element is missing." );
return false;
}
i = trim( e.password.value );
j = trim( e.password_verify.value );
if ( i.length < MIN_PASSWORD_LENGTH )
{
alert( "Please provide a password that is at least " +
MIN_PASSWORD_LENGTH + " characters long." );
return false;
}
if ( i != j )
{
alert( "The verification password did not match. Please " +
"make sure the password and the verification password " +
"are exactly the same." );
return false;
}
hash = calcMD5( i );
e.password_encoded.value = hash;
e.password.value = "";
e.password_verify.value = "";
return SubmitForm( e, xtra );
}
function check_all_by_group( me, e )
{
if ( me == null
|| e == null )
{
alert( "One of these objects is missing: the checkbox " +
"or the group name." );
return false;
}
var elements = document.getElementsByTagName( "*" );
for( s = 0 ; s < elements.length; s++ )
{
var c = elements[s];
if( c.type == 'checkbox' )
{
var group = c.getAttribute( "group" );
if ( group == e )
c.checked = me.checked;
}
}
}
function check_all_by_name( me, e )
{
if ( me == null
|| e == null )
{
alert( "One of these objects is missing: the checkbox " +
"or the checkbox name." );
return false;
}
var elements = document.getElementsByName( e );
for( s = 0 ; s < elements.length; s++ )
{
var c = elements[s];
if( c.type == 'checkbox' )
{
c.checked = me.checked;
}
}
}
function ListSelectAll( a )
{
ListClearFirst( a );
for ( si = 0; si < a.options.length; si++ )
{
a.options[ si ].selected = true;
}
}
function ListSortCompFunc( a, b )
{
if ( a == null || b == null || a == b ) 
return 0;
aa = a.text.toLowerCase();
bb = b.text.toLowerCase();
if ( aa > bb )
return 1;
return -1;
}
function ListSort( s )
{
a = new Array();
for ( si = 0; si < s.options.length; si++ )
{
a[si] = new Option( s.options[si].text, s.options[si].value );
if ( s.options[si].selected == true )
a[si].selected = true;
}
a.sort( ListSortCompFunc );
for ( si = 0; si < s.options.length; si++ )
s.options[ si ] = a[ si ];
}
function ListClearAll( s )
{
for ( si = s.options.length - 1; si >= 0; si-- )
{
s.options[ si ] = null;
}
}
function ListClearFirst( s )
{
if ( s.options.length > 0 )
if ( s.options[ 0 ].text == '---------------------' )
s.options[ 0 ] = null;
}
function ListClear( s )
{
if ( !s )
{
alert( "The ID of the list is missing." );
}
var element = document.getElementById( s );
if ( !element )
{
alert( "I could not find the list with ID '" + s + "'." );
}
if ( element.options.length > 0 )
{
if ( element.options[ 0 ].text == '---------------------' )
{
element.options[ 0 ] = null;
}
}
}
function ListAddOptionExplicit( f, s, v, k )
{
f1 = document.forms[f];
if ( f1 == null )
{
alert( "Bad form name." );
return false;
}
s1 = f1.elements[s];
if ( s1 == null )
{
alert( "Bad element name." );
return false;
}
var o = new Option( v, k );
s1.options[ s1.options.length ] = o;
}
function ListAddOptionsExplicit( f, s, v, k )
{
f1 = document.forms[f];
if ( f1 == null )
{
alert( "Bad form name." );
return false;
}
s1 = f1.elements[s];
if ( s1 == null )
{
alert( "Bad element name." );
return false;
}
for ( si = 0; si < v.length; si++ )
{
var o = new Option( v[si], k[si] );
s1.options[ s1.options.length ] = o;
}
}
function ListAddOne( s1, s2, tosort )
{
ListClearFirst( s1 );
ListClearFirst( s2 );
for ( si = 0; si < s1.options.length; si++ )
{
if ( s1.options[si].selected == true )
{
v = s1.options[ si ].value;
t = s1.options[ si ].text;
var opt = new Option( t, v );
opt.selected = true;
s2.options[ s2.options.length ] = opt;
}
}
for ( si = s1.options.length-1; si >= 0; si-- )
{
if ( s1.options[si].selected == true )
{
s1.options[ si ] = null;
}
}
if ( tosort != null )
{
ListSort( tosort );
}
}
function ListAddAll( s1, s2, tosort )
{
ListClearFirst( s1 );
ListClearFirst( s2 );
for ( si = 0; si < s1.options.length; si++ )
{
v = s1.options[ si ].value;
t = s1.options[ si ].text;
var opt = new Option( t, v );
s2.options[ s2.options.length ] = opt;
}
for ( si = s1.options.length-1; si >= 0; si-- )
{
s1.options[ si ] = null;
}
if ( tosort != null )
ListSort( s1 ) ;
}
function ListMoveUp( s1 )
{
ListClearFirst( s1 );
for ( si = 1; si < s1.options.length; si++ )
{
if ( s1.options[si].selected == true)
{
if ( s1.options[si-1].selected != true )
{
v = s1.options[ si ].value;
t = s1.options[ si ].text;
var opt = new Option( t, v );
v = s1.options[ si-1 ].value;
t = s1.options[ si-1 ].text;
var rep = new Option( t, v );
s1.options[ si - 1 ] = opt;
s1.options[ si ] = rep;
s1.options[ si - 1 ].selected = true;
}
}
}
}
function ListMoveDown( s1 )
{
ListClearFirst( s1 );
for ( si = s1.options.length-2; si >= 0; si-- )
{
if ( s1.options[si].selected == true)
{
if ( s1.options[si+1].selected != true )
{
v = s1.options[ si ].value;
t = s1.options[ si ].text;
var opt = new Option( t, v );
v = s1.options[ si+1 ].value;
t = s1.options[ si+1 ].text;
var rep = new Option( t, v );
s1.options[ si + 1 ] = opt;
s1.options[ si ] = rep;
s1.options[ si + 1 ].selected = true;
}
}
}
}
var nopopups = 0;
function RePopulateList( f, s, t, r, v )
{ 
f1 = document.forms[f];
if ( f1 == null )
{
alert( "Bad form name." );
return false;
}
s1 = f1.elements[s];
if ( s1 == null )
{
alert( "Bad element name." );
return false;
}
if ( s1.options.length < 1 ) 
return PopulateList( f, s, t, r, v );
return true;
}
function PopulateList( f, s, t, r, v )
{ 
f1 = document.forms[f];
if ( f1 == null )
{
alert( "Bad form name." );
return false;
}
s1 = f1.elements[s];
if ( s1 == null )
{
alert( "Bad element name." );
return false;
}
ListClearAll( s1 );
nw = window.open( "http://glbt.unm.edu/alliance/getjsdata.php?f=" + f + 
"&s=" + s + "&t=" + t + "&r=" + r + "&v= " + v, 
"retdata",
"height=1,width=1,directories=no,location=no,menubar=no," +
"resizeable=no,scrollbars=no,status=no,toolbar=no,titlebar=no," +
"dependent=yes" );
if ( nw == null && nopopups == 0 )
{
alert( "If you have JavaScript popups blocked, please enable " +
"them on this site for this feature to function." );
nopopups = 1;
return false;
}
return true;
}
var xmlHttp = null;
var baseaddr = "http://latinlexicon.org/";
//var base_AJAX_address = "http://latinlexicon.org/ajax/";
var base_AJAX_address = "/ajax/";
// in milliseconds
var ajax_request_timeout_in_ms = 10000;
var ajax_request_timeout_timer = undefined;
var ajax_request_typing_delay_in_ms = 250;
var ajax_request_delay_timer = undefined;
var ajax_request_delay_timer_2 = undefined;
var ajax_request_previous_request = undefined;
var old_orthography_id = null;
try
{
xmlHttp = create_cross_browser_xmlHttp_object();
}
catch( e )
{
if( e instanceof String )
{
alert( e );
}
alert( "Can't create xmlHttp transport object." );
}
function ajax_request_timeout()
{
alert( "I can't fulfill the AJAX request because it timed out. \n\n" + 
"Wait 10 seconds and try again.");
xmlHttp.abort();
}
function create_cross_browser_xmlHttp_object()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
throw "Your browser does not support AJAX!" 
}
}
}
return xmlHttp;
}
function urlencode(str) 
{
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}
function urldecode(str) 
{
str = str.replace('+', ' ');
str = unescape(str);
return str;
}
/** 
*
*/
function CollectFormForAjax( form_id )
{
var data = new Object();
// ex: form_id = #permit_form
// @TODO EXCLUDE RADIO ELEMENTS
$( form_id + " input, " +
form_id + " button, " +
form_id + " textarea" ).each
(
function( index, element_dom )
{
// If the input is a checkbox and if it's not checked,
// then simply ignore it
if( element_dom.type == "checkbox" 
&& element_dom.checked == false )
{
return true;
}
// NOTE: There is a bug in IE 7 
// If a button/input/etc tag does not contain a value attribute, IE 7 will set its value 
// to the ENTIRE tag!In that case, we know the value is completely empty
if( element_dom.value == element_dom.innerHTML )
{
element_dom.value = "";
//return true;
}
if( typeof( element_dom.value ) == "undefined"
|| element_dom.value == ""
|| element_dom.value == null 
|| element_dom.value == "undefined" )
{
element_dom.value = "";
//return true;
}
if( typeof( element_dom.name ) == "undefined"
|| element_dom.name == "" 
|| element_dom.name == null )
{
return true;
}
// If the index doesn't exist, then make it a value
if( typeof( data[element_dom.name] ) == "undefined" )
{
data[element_dom.name] = element_dom.value;
}
else
{
// if the index is already an array, then push another value onto the array
if( data[element_dom.name] instanceof Array )
{
tmparr.push( data[element_dom.value] );
}
// otherwise create a new array and push the value onto the array
else
{
var tmparr = new Array();
tmparr.push( tmparr );
tmparr.push( data[element_dom.value] );
}
}
}
);
/*
var keys = new Array();
var newdata = new Array();
for( k in data )
{
keys.push(k);
}
keys.sort
( 
function(x, y)
{
var a = String(x).toUpperCase(); 
var b = String(y).toUpperCase(); 
val1 = a > b;
val2 = a < b;
return val1 - val2;
} 
);
debugger;
for( var i = 0; i < keys.length; i++ )
{
newdata[keys[i]] = data[keys[i]];
}
data = newdata;
*/
// ex: form_id = #permit_form
$( form_id + " select" ).each
(
function( index, element )
{
$( element ).find( "option:selected" ).each
(
function( subindex, subelement )
{
if( typeof( data[element.name] ) == "undefined" )
{
data[element.name] = subelement.value;
}
else
{
if( data[element.name] instanceof Array )
{
tmparr.push( data[subelement.value] );
}
else
{
var tmparr = new Array();
tmparr.push( tmparr );
tmparr.push( data[subelement.value] );
}
}
}
);
}
);
return data; 
}
//var baseaddr = ".";
/*
if( document.getElementsByTagName ) 
{
var elems = document.getElementsByTagName( 'base' );
if( elems.length ) 
{
baseaddr = elems[ 0 ].href;
}
}
*/
function entry_feedback( p1, p2, p3, p4 )
{
if( p1 == 4 || p1 == 5 )
{
// the user pressed cancel
if( p3 == null )
{
return;
}
p3 = p3.replace( /^\s+|\s+$/ig, "" );
if( p3 == "null" || p3 == "undefined" || p3 == "''" || p3 == "" )
{
alert( "Sorry, I can't submit a blank answer!" );
return;
}
}
p1 = urlencode( p1 );
p2 = urlencode( p2 );
p3 = urlencode( p3 );
p4 = urlencode( p4 );
//var gateway = baseaddr + "/ajax/entry_feedback.php?p1=" 
//+ p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4;
var gateway = "/ajax/entry_feedback.php?p1=" 
+ p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4;
try
{
debugger;
oldAjaxImage = document.getElementById( ajaxImage ).src;
document.getElementById( ajaxImage ).src = imgRefresh;
xmlHttp.open( "GET", gateway, true );
// This is for Google Analytics
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
xmlHttp.onreadystatechange = function()
{
if( xmlHttp.readyState == 4 )
{
//document.myForm.time.value = xmlHttp.responseText;
if( xmlHttp.status == 200 || xmlHttp.status == 302 )
{
var tmp_str = xmlHttp.responseText.replace( /^\s+|\s+$/g, '' ); 
if( tmp_str.length > 0 )
{
alert( tmp_str );
}
}
else
{
if( xmlHttp.status == 0 ) 
{
// This just means we aborted the connection
}
else
{
alert( "I encountered error " + 
xmlHttp.status + " (" + xmlHttp.statusText + ") " + 
"while trying to communicate with the AJAX gateway." );
}
}
document.getElementById( ajaxImage ).src = oldAjaxImage;
}
}
xmlHttp.send( null );
//alert( ajaxImage );
}
catch( e )
{
alert( "I could not open the AJAX gateway.\n\n" + gateway );
document.getElementById( ajaxImage ).src = oldAjaxImage;
}
}
/**
*
*
*/
function ajax_latin_and_english_lexicon_lookup_event( evt, language )
{
var lookup_input_element_id = "lookup_input_element";
var lookup_select_element_id = "lookup_select_element";
// for Internet Explorer compatibility
if( !evt )
{
evt = window.event;
}
var input_element = document.getElementById( lookup_input_element_id )
if( input_element == null )
{
alert( "input element not found" );
return false;
}
var select_element = document.getElementById( lookup_select_element_id )
if( select_element == null )
{
alert( "select element not found" );
return false;
}
switch( evt.type )
{
case "keydown":
if( evt.keyCode == "38" ) // up arrow
{
if( select_element.options.selectedIndex >= 0
&& select_element.selectedIndex > 0 )
{
select_element.selectedIndex--;
lookup_entry( select_element.options[select_element.options.selectedIndex].value );
}
}
else if( evt.keyCode == "40" ) // down arrow
{
if( select_element.options.selectedIndex >= 0
&& select_element.selectedIndex < ( select_element.options.length - 1 ) )
{
select_element.selectedIndex++;
lookup_entry( select_element.options[select_element.options.selectedIndex].value );
}
}
break;
case "keyup":
keychar = String.fromCharCode( evt.keyCode );
if( ( keychar >= 'A' && keychar <= 'Z' )// A-Z
|| ( keychar >= 'a' && keychar <= 'z' ) // a-z (probably unnecessary but just in case)
|| ( evt.keyCode == 8 ) // backspace
|| ( evt.keyCode == 46 ) )// delete
{
if( language == 'english' )
{
ajax_english_lexicon_lookup( input_element.value );
}
else
{
ajax_latin_lexicon_lookup( input_element.value );
}
}
else if( evt.keyCode == "13" ) // enter key
{
if( select_element.options.selectedIndex >= 0 )
{
lookup_entry( select_element.options[select_element.options.selectedIndex].value );
}
}
else if( evt.keyCode == "27" ) // escape key
{
input_element.focus();
input_element.value = '';
}
break;
case "keypress":
break;
case "mousedown":
break;
case "mouseup":
break;
default:
alert( evt.type );
}
}
/**
*
*
*/
function ajax_latin_lexicon_lookup( word )
{
if( ajax_request_delay_timer != undefined )
{
clearTimeout( ajax_request_delay_timer );
}
word = word.replace( /^\s+|\s+$/g, '' ); 
word = word.replace( /'/g, '' );
ajax_request_delay_timer = setTimeout( "ajax_latin_lexicon_lookup_keyboard_delay( '" + word + "' )", 
ajax_request_typing_delay_in_ms );
}
/**
*
*
*/
function ajax_latin_lexicon_lookup_keyboard_delay( word )
{
var lookup_select_element_id = "lookup_select_element";
p1 = urlencode( word );
p1 = p1.replace( /^\s+|\s+$/g, '' ); 
var el = document.getElementById( lookup_select_element_id )
if( el == null )
{
alert( "select element not found" );
return false;
}
if( p1.length == 0 )
{
el.options.length = 0;
return;
}
//var gateway = baseaddr + "/ajax/lookup.php?p1=" + p1;
var gateway = "/ajax/lookup.php?p1=" + p1;
try
{
el.disabled = true;
xmlHttp.open( "GET", gateway, true );
// This is for Google Analytics
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
xmlHttp.onreadystatechange = xmlHttp.onreadystatechange = function()
{
switch( xmlHttp.readyState )
{
/*
0 = open has not yet been called
1 = send has not yet been called but open has been called
2 = send has been called but no response from server
3 = data is in the process of being received from the server
4 = response from server has arrived
*/
case 4:
var el = document.getElementById( lookup_select_element_id )
if( el == null )
{
alert( "select element not found" );
return false;
}
el.disabled = false;
if( xmlHttp.status == 200 || xmlHttp.status == 302 )
{
var split_res = xmlHttp.responseText.split( "|" );
el.options.length = 0;
for ( si = 0; si < split_res.length - 2; si++ )
{
var pair = split_res[si+1].split( "=" );
key = pair[1];
value = pair[0];
// Select the first word in the list automatically
if( si == 0 )
{
el.options[si] = new Option( value, key, true, true );
}
else
{
el.options[si] = new Option( value, key );
}
el.options[si].setAttribute( "title", value );
}
}
else
{
if( xmlHttp.status == 0 ) 
{
// This just means we aborted the connection
}
else
{
alert( "I encountered error " + 
xmlHttp.status + " (" + xmlHttp.statusText + ") " + 
"while trying to communicate with the AJAX gateway." );
}
}
break;
default:
// ignore everything else 
}
}
xmlHttp.send( null );
}
catch( e )
{
alert( e );
alert( "I could not open the AJAX gateway.\n\n" + gateway );
return false;
}
return true;
}
/**
*
*
*/
function ajax_english_lexicon_lookup( word )
{
if( ajax_request_delay_timer != undefined )
{
clearTimeout( ajax_request_delay_timer );
}
word = word.replace( /^\s+|\s+$/g, '' ); 
word = word.replace( /'/g, '' );
ajax_request_delay_timer = setTimeout( "ajax_english_lexicon_lookup_keyboard_delay( '" + word + "' )", 
ajax_request_typing_delay_in_ms );
}
function ajax_english_lexicon_lookup_keyboard_delay( word )
{
var lookup_select_element_id = "lookup_select_element";
p1 = urlencode( word );
p1 = p1.replace(/^\s+|\s+$/g, ''); 
var el = document.getElementById( lookup_select_element_id )
if( el == null )
{
alert( "select element not found" );
return false;
}
if( p1.length == 0 )
{
var el = document.getElementById( lookup_select_element_id )
el.options.length = 0;
return;
}
//var gateway = baseaddr + "/ajax/lookup_english.php?p1=" + p1;
var gateway = "/ajax/lookup_english.php?p1=" + p1;
try
{
el.disabled = true;
xmlHttp.open( "GET", gateway, true );
// This is for Google Analytics
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
xmlHttp.onreadystatechange = function()
{
switch( xmlHttp.readyState )
{
/*
0 = open has not yet been called
1 = send has not yet been called but open has been called
2 = send has been called but no response from server
3 = data is in the process of being received from the server
4 = response from server has arrived
*/
case 4:
if( xmlHttp.status == 200 || xmlHttp.status == 302 )
{
var split_res = xmlHttp.responseText.split( "|" );
var el = document.getElementById( lookup_select_element_id )
if( el == null )
{
alert( "select element not found" );
return false;
}
el.disabled = false;
el.options.length = 0;
for ( si = 0; si < split_res.length - 2; si++ )
{
var pair = split_res[si+1].split( "=" );
key = pair[1];
value = pair[0];
if( si == 0 )
{
el.options[si] = new Option( value, key, true, true );
}
else
{
el.options[si] = new Option( value, key );
}
el.options[si].setAttribute( "title", value );
}
}
else
{
if( xmlHttp.status == 0 ) 
{
// This just means we aborted the connection
}
else
{
alert( "I encountered error " + 
xmlHttp.status + " (" + xmlHttp.statusText + ") " + 
"while trying to communicate with the AJAX gateway." );
}
}
break;
default:
// not used
}
}
xmlHttp.send( null );
}
catch( e )
{
alert( e );
alert( "I could not open the AJAX gateway.\n\n" + gateway );
return false;
}
return true;
}
function lookup_input_focus() 
{
var temp_function = function() 
{
var lookup_input_element_id = "lookup_input_element";
var input_element = document.getElementById( lookup_input_element_id )
if( input_element == null )
{
alert( "input element not found" );
return false;
}
input_element.focus();
} 
var generic_timer = setTimeout(temp_function, ajax_request_typing_delay_in_ms );
}
function lookup_entry( orthography_id )
{
if( ajax_request_delay_timer_2 != undefined )
{
clearTimeout( ajax_request_delay_timer_2 );
}
orthography_id = orthography_id.replace( /^\s+|\s+$/g, '' ); 
orthography_id = orthography_id.replace( /'/g, '' );
if( orthography_id != old_orthography_id )
{
ajax_request_delay_timer_2 = setTimeout( "lookup_entry_keyboard_delay( '" + orthography_id + "' )", 
ajax_request_typing_delay_in_ms );
old_orthography_id = orthography_id;
}
$("#error_history_dialog").dialog( "close" );
lookup_input_focus();
}
function lookup_entry_keyboard_delay( orthography_id )
{
var lookup_div_element_id = "lookup_div_element";
p1 = urlencode( orthography_id );
p1 = p1.replace(/^\s+|\s+$/g, ''); 
if( p1.length == 0 )
{
return;
}
//var gateway = baseaddr + "/ajax/lookup_entry.php?p1=" + p1.toString();
var gateway = "/ajax/lookup_entry.php?p1=" + p1.toString();
try
{
xmlHttp.open( "GET", gateway, true );
// This is for Google Analytics
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
xmlHttp.onreadystatechange = function()
{
switch( xmlHttp.readyState )
{
/*
0 = open has not yet been called
1 = send has not yet been called but open has been called
2 = send has been called but no response from server
3 = data is in the process of being received from the server
4 = response from server has arrived
*/
case 4:
if( xmlHttp.status == 200 || xmlHttp.status == 302 )
{
//alert( xmlHttp.responseText );
//alert( xmlHttp.responseXML );
var txt = xmlHttp.responseText;
//alert( split_res[1] );
var el = document.getElementById( lookup_div_element_id )
if( el == null )
{
alert( "div element not found" );
return false;
}
el.innerHTML = txt;
// check for scripts
$( el ).find( "script" ).each
(
function( index, element )
{
//alert( element.text );
try
{
eval( element.text );
}
catch( e )
{
alert( element.text );
}
}
);
initChecks();
initialize_orthography_editor();
initialize_short_definitions_editor();
}
else
{
if( xmlHttp.status == 0 ) 
{
// This just means we aborted the connection
}
else
{
alert( "I encountered error " + 
xmlHttp.status + " (" + xmlHttp.statusText + ") " + 
"while trying to communicate with the AJAX gateway." );
}
}
error_history_dialog();
break;
default:
// Not used
}
}
xmlHttp.send( null );
}
catch( e )
{
alert( e );
alert( "I could not open the AJAX gateway.\n\n" + gateway );
return false;
}
return true;
}
var saved_tags = new Array();
var saved_section_tags = new Array();
function clear_text( id )
{
var element = document.getElementById( id );
if( element == null )
{
alert( "input element not found" );
return false;
}
element.value = "";
element.focus();
}
function clear_select( id )
{
var element = document.getElementById( id );
if( element == null )
{
alert( "select element not found" );
return false;
}
element.options.length = 0;
}
function clear_search( id )
{
var element = document.getElementById( id );
if( element == null )
{
alert( "text element not found" );
return false;
}
link_search( element );
}
function link_search( text_box )
{
// only fill out the saved_tags once
if( saved_tags.length == 0 )
{
// get all the div tags in the document
var div_tags = document.getElementsByTagName( "div" );
// iterate the div tags
for ( si = 0; si < div_tags.length; si++ )
{
var tag = div_tags[si];
// find the div tags named "link_container"
if( tag.className == "link_container" )
{
// grab all the "a" tags
var sub_tags = tag.getElementsByTagName( "a" );
// get the link description
var keyword_string = sub_tags[0].innerHTML;
// grab all the "div" tags
var sub_tags = tag.getElementsByTagName( "div" );
// get the full description, convert to lower case
keyword_string += " " + sub_tags[0].innerHTML;
keyword_string = keyword_string.toLowerCase();
// set a variable inside the "div" tag
tag.keyword_string = keyword_string;
// save the "div" tag (as a pointer!)
saved_tags[saved_tags.length] = tag;
}
// find the div tags named "link_section_container"
if( tag.className == "link_section_container" )
{
// save the "div" tag (as a pointer!)
saved_section_tags[saved_section_tags.length] = tag;
}
}
}
// grab the value of the text box ("what the user typed")
var search_string = text_box.value;
search_string = search_string.toLowerCase();
// split it up into an array
var search_array = search_string.split( " " );
// make a list of tags to show (these are all pointers!)
var show_list = new Array();
// iterate through the list of saved tags to determine
// if this link matches or not
for ( si = 0; si < saved_tags.length; si++ )
{
var tag_item = saved_tags[si];
show_list[si] = 0; 
for ( ssi = 0; ssi < search_array.length; ssi++ )
{
var search_item = search_array[ssi];
if( tag_item.keyword_string.indexOf( search_item ) != -1 )
{
show_list[si]++;
}
}
if( show_list[si] == search_array.length )
{
tag_item.style.display = "block";
}
else
{
tag_item.style.display = "none";
}
}
/* ONLY SHOW LINK SECTIONS WHICH HAVE MORE THAN ONE VISIBLE LINK_CONTAINER */
// iterate the section tags
for ( si = 0; si < saved_section_tags.length; si++ )
{
var tag = saved_section_tags[si];
// grab all the "div" tags
var sub_tags = tag.getElementsByTagName( "div" );
var show_section = 0;
for ( ti = 0; ti < sub_tags.length; ti++ )
{
if( sub_tags[ti].style.display == "block" )
{
show_section++;
}
}
if( show_section > 0 )
{
tag.style.display = "block";
}
else
{
tag.style.display = "none";
}
}
}
/**
*
*/
function error_history_dialog()
{
$("#error_history_dialog").dialog
( 
{ 
minWidth: 720, 
autoOpen: false
} 
);
$("#app_status_dialog").dialog
( 
{ 
minWidth: 512, 
autoOpen: false,
buttons: 
[
{
text: "Clear",
click: app_status_dialog_close
}
]
} 
);
$("#app_status").button
(
{
icons: 
{
primary: "ui-icon-alert",
},
text: false
}
).click
( 
app_status_dialog_open
);
$(".error_history_button").button
(
{
icons: 
{
primary: "ui-icon-alert"
}
}
).click
( 
error_history_dialog_open
);
}
/**
*
*/
function error_history_dialog_open()
{
//var orthography_id = $("#orthography_id").val();
var orthography_id = $(this).attr( "orthography_id" );
$("#error_history_dialog").data( "orthography_id", orthography_id );
$("#error_history_dialog").html( "" );
$("#error_history_dialog").dialog( "open" );
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
data: 
{
fn: "error_history",// form name
c: 1, // command
o: orthography_id, // orthography_id
},
dataType: "json",
type: "POST",
success: error_history_dialog_initialize,
error: error_procedure,
url: gateway
}
)
} // _error_history_dialog_open
/** error_history_dialog_initialize()
*
*/
function error_history_dialog_initialize( data, textStatus, XMLHttpRequest ) 
{ 
$("#error_history_dialog").html( data.form ); 
$("#error_history_dialog .delete_changes").button
(
{
icons: 
{
primary: "ui-icon-cancel"
}
}
).click
(
error_history_dialog_delete
);
$("#error_history_dialog .save_changes").button
(
{
icons: 
{
primary: "ui-icon-disk"
}
}
).click
(
error_history_dialog_save
);
$("#error_table textarea").click
(
function()
{
$(this).parents("tr").find(".save_changes").show();
}
);
}// error_history_dialog_initialize
/**
*
*/
function error_history_dialog_delete()
{
var result = confirm( "Deleting is permanent. Are you sure?" );
if( result == false )
{
return;
}
//var orthography_id = $("#orthography_id").val();
var orthography_id = $("#error_history_dialog").data( "orthography_id" );
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
data: 
{
fn: "error_history",// form name
c: 3,// command = delete
o: orthography_id, // orthography_id
oe: $(this).attr( "orthography_error_id" ), // orthography_error_id
},
dataType: "json",
type: "POST",
success: function( data, textStatus, XMLHttpRequest ) 
{ 
if( data.errorNumber != 0 )
{
error_procedure( XMLHttpRequest, data.errorText, data.errorNumber );
}
else
{
error_history_dialog_initialize( data );
}
//error_history_dialog_open();
},
error: error_procedure,
url: gateway
}
);
} // error_history_dialog_delete
/**
*
*/
function error_history_dialog_save()
{
$(this).hide();
//var orthography_id = $("#orthography_id").val();
var orthography_id = $("#error_history_dialog").data( "orthography_id" );
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
data: 
{
fn: "error_history",// form name
c: 2,// command = save
o: orthography_id, // orthography_id
oe: $(this).attr( "orthography_error_id" ), // orthography_error_id
fixed_note: $(this).parents("tr").find(".fixed_note").val()
},
dataType: "json",
type: "POST",
success: function( data, textStatus, XMLHttpRequest ) 
{ 
if( data.errorNumber != 0 )
{
error_procedure( XMLHttpRequest, data.errorText, data.errorNumber );
}
else
{
error_history_dialog_initialize( data );
}
},
error: error_procedure,
url: gateway
}
);
} // error_history_dialog_save
/**
*
*/
function app_status_dialog_open()
{
$("#app_status_dialog").dialog( "open" );
}
/**
*
*/
function app_status_dialog_close()
{ 
$(this).dialog("close").html(""); 
$("#app_status").removeData( "error_list" ).hide();
}
/** wait_procedure()
*
*/
function wait_procedure( str )
{
// TODO: fill this in
}
/** error_procedure()
*
*/
function error_procedure( XMLHttpRequest, textStatus, errorThrown )
{
$(".dialog_box").dialog( "close" );
$("#app_status").show();
var error_list = $("#app_status").data( "error_list" );
if( error_list == undefined )
{
var error_list = Array();
}
error_list.push( textStatus + " (" + errorThrown + ")" );
$("#app_status").data( "error_list", error_list );
var inner = "";
for( var si = 0; si < error_list.length; si++ )
{
if( error_list[si] )
{
inner += "<tr><td>" + ( si + 1 ) + "</td><td>" + error_list[si] + "</td></tr>";
}
}
$("#app_status_dialog").html( "<table cellpadding=\"5\" cellspacing=\"0\" border=\"1\" width=\"\100%\">" + inner + "</table>" );
} // error_procedure()
/** analytics_gateway()
*
*/
function analytics_gateway( filename )
{
// This is for Google Analytics
var gateway = base_AJAX_address + filename;
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
return gateway;
} // analytics_gateway()
/**
*
*/
function latin_and_english_search( language )
{
$( "#lookup_input_element" ).keydown
(
function( evt )
{
var select_element = $( "#lookup_select_element" )[0];
if( evt.keyCode == "38" ) // up arrow
{
if( select_element.options.selectedIndex >= 0
&& select_element.selectedIndex > 0 )
{
select_element.selectedIndex--;
lookup_entry( select_element.options[select_element.options.selectedIndex].value );
}
return false;
}
else if( evt.keyCode == "40" ) // down arrow
{
if( select_element.options.selectedIndex >= 0
&& select_element.selectedIndex < ( select_element.options.length - 1 ) )
{
select_element.selectedIndex++;
lookup_entry( select_element.options[select_element.options.selectedIndex].value );
}
return false;
}
}
);
$( "#lookup_input_element" ).keyup
(
function( evt )
{
var select_element = $( "#lookup_select_element" );
var keychar = String.fromCharCode( evt.keyCode );
if( ( keychar >= 'A' && keychar <= 'Z' )// A-Z
|| ( keychar >= 'a' && keychar <= 'z' ) // a-z (probably unnecessary but just in case)
|| ( evt.keyCode == 8 ) // backspace
|| ( evt.keyCode == 46 ) )// delete
{
if( language == 'english' )
{
//ajax_english_lexicon_lookup( $( "#lookup_input_element" ).val() );
var gateway = "lookup_english_json.php";
}
else
{
var gateway = "lookup_json.php";
}
//select_element.attr( "disabled", "disabled" );
//select_element.disable();
if( ajax_request_delay_timer != undefined )
{
clearTimeout( ajax_request_delay_timer );
}
var latin_and_english_search_keyboard_delay = function() 
{
if( ajax_request_previous_request != undefined
&& ajax_request_previous_request.readyState != 4 )
{
ajax_request_previous_request.abort();
}
ajax_request_previous_request = $.ajax
(
{
url: base_AJAX_address + gateway, 
dataType: "json",
data: { "p1" : $( "#lookup_input_element" ).val() },
type: "POST",
success: function( data, message, XHR )
{
var select_element = $( "#lookup_select_element" );
var first = true;
select_element.disable();
select_element.empty();
//error_procedure( null, data.optgroup.length, null );
$(data.optgroup).each
(
function( index, element )
{
var optgroup = document.createElement( "optgroup" );
if( 'label' in element )
{
optgroup.label = element.label;
}
else
{
optgroup.label = "undefined";
}
$(element.options).each
(
function( subindex, subelement )
{
if( first )
{
var option = document.createElement( "option" );
option.value = subelement.id;
option.appendChild( document.createTextNode( subelement.form ) ); 
option.selected = true; 
first = false;
}
else
{
var option = document.createElement( "option" );
option.value = subelement.id;
option.appendChild( document.createTextNode( subelement.form ) ); 
first = false;
}
optgroup.appendChild( option );
}
)
select_element.append( optgroup );
select_element.scrollTop( 0 );
select_element.enable();
}
)
var gateway = analytics_gateway( 'lookup_json.php?p1=' + $( "#lookup_input_element" ).val() );
}
}
);
}
ajax_request_delay_timer = setTimeout
( 
latin_and_english_search_keyboard_delay,
ajax_request_typing_delay_in_ms 
);
//select_element.removeAttr( "disabled" );
//}
}
else if( evt.keyCode == "13" ) // enter key
{
if( select_element[0].options.selectedIndex >= 0 )
{
lookup_entry( select_element[0].options[select_element[0].options.selectedIndex].value );
}
}
else if( evt.keyCode == "27" ) // escape key
{
$( "#lookup_input_element" ).focus().val( '' );
}
}
);
}
function display_by_id( id ) 
{
var e = document.getElementById( id ); 
if ( e )
{
e.style.display = "block"
}
else
{
error_procedure( null, id + " does not exist.", null );
}
}
function suppress_display_by_id( id ) 
{
var e = document.getElementById( id ); 
if ( e )
{
e.style.display = "none"
}
else
{
error_procedure( null, id + " does not exist.", null );
}
}
function toggle_containers_by_part_of_speech( dialog )
{
var part_of_speech_id = dialog.find( "#part_of_speech_id" ).val();
display_by_id( "orthography_container" );
suppress_display_by_id( "nominative_container" );
suppress_display_by_id( "genitive_container" );
suppress_display_by_id( "gender_container" );
suppress_display_by_id( "mostly_plural_noun_container" );
suppress_display_by_id( "present_container" );
suppress_display_by_id( "infinitive_container" );
suppress_display_by_id( "perfect_container" );
suppress_display_by_id( "p3_container" );
suppress_display_by_id( "fap_container" );
suppress_display_by_id( "pap_container" );
suppress_display_by_id( "deponent_verb_container" );
suppress_display_by_id( "impersonal_verb_container" );
suppress_display_by_id( "defective_verb_container" );
suppress_display_by_id( "adjective_class_container" );
suppress_display_by_id( "preposition_class_container" );
suppress_display_by_id( "pronoun_class_container" );
suppress_display_by_id( "noun_class_container" );
suppress_display_by_id( "verb_class_container" );
switch( Number( part_of_speech_id ) )
{
case 2: // "adjective"
display_by_id( "nominative_container" );
display_by_id( "genitive_container" );
display_by_id( "adjective_class_container" );
break;
case 3: // "adverb"
case 8: // "conjunction"
case 12: // "cross-reference"
case 5: // "interjection"
case 11: // "participle"
// nothing to display
break;
case 1: // "noun"
display_by_id( "nominative_container" );
display_by_id( "genitive_container" );
display_by_id( "gender_container" );
display_by_id( "mostly_plural_noun_container" );
display_by_id( "noun_class_container" );
break;
case 7: // "preposition"
display_by_id( "preposition_class_container" );
break;
case 6: // "pronoun"
display_by_id( "nominative_container" );
display_by_id( "genitive_container" );
display_by_id( "pronoun_class_container" );
break;
case 4: // "verb"
display_by_id( "present_container" );
display_by_id( "infinitive_container" );
display_by_id( "perfect_container" );
display_by_id( "p3_container" );
display_by_id( "fap_container" );
display_by_id( "pap_container" );
display_by_id( "deponent_verb_container" );
display_by_id( "impersonal_verb_container" );
display_by_id( "defective_verb_container" );
display_by_id( "verb_class_container" );
break;
default: // "unknown"
alert( "Unknown part of speech." );
}
}
/**
*
*
*/
function initialize_orthography_editor()
{
// Grab the English definition elements (which are ordered lists)
$( ".flash_card_front" ).each
(
function( index, element )
{
var orthography_id = $(this).attr( "data-orthography-id" );
if( typeof( orthography_id ) == "undefined" )
{
return;
}
//error_procedure( null, orthography_id, null );
var edit_button = $( '<button">Edit Orthography</button>' ).button
(
{
icons: 
{
primary: 'ui-icon-pencil'
},
text: false
}
).click
(
function( event, ui )
{
var button = $(this);
var dialog = $( '<div>' ).dialog
(
{
width: 720,
height: 480,
modal: true,
title: 'Edit Orthography ID #' + orthography_id,
buttons: 
{
'Save': function() 
{
var form = $(this).find( "form" )[0];
if( typeof( form ) == "undefined" )
{
dialog.dialog( 'destroy' );
dialog.remove();
return false;
}
var id = "#" + form.id;
var post_data = CollectFormForAjax( id );
post_data.fn = "orthography"; // form name
post_data.c = 2;// command = SAVE
post_data.o = orthography_id;// orthography_id
wait_procedure( "Saving orthography information..." );
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
url: gateway, 
data: post_data,
success: function( data, textStatus, XHR ) 
{
if( data.errorNumber == 0 )
{
$( id + " input" ).removeClass( "ui-state-error" )
$( id + " textarea" ).removeClass( "ui-state-error" )
$( id + " select" ).removeClass( "ui-state-error" )
dialog.dialog( 'destroy' );
dialog.remove();
}
// validation error
else if( data.errorNumber == 512 )
{
$( data.errorList.reverse() ).each
(
function( index, element )
{
$( id + " input" ).removeClass( "ui-state-error" )
$( id + " textarea" ).removeClass( "ui-state-error" )
$( id + " select" ).removeClass( "ui-state-error" )
$( "#" + element.id ).addClass( "ui-state-error" ).focus();
$( "#" + element.name ).addClass( "ui-state-error" ).focus();
error_procedure( null, element.message, null );
}
);
}
// some other error
else
{
alert( "Error: " + data.errorText );
}
}
}
);
},
'Cancel': function() 
{
dialog.dialog( 'destroy' );
dialog.remove();
},
}
}
).append
( 
$('<img>').attr( { src: '/images/spinner_16x16.gif', title: 'Loading...' } ) 
);
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
url: gateway,
data: 
{
fn: 'orthography',// form name
c: 1, // command = RENDER
o: orthography_id, // orthography_id
},
success: function( data, textStatus, XHR )
{
if( data.errorNumber != 0 )
{
dialog.html( "Error: " + data.errorText );
return;
}
dialog.html( data.form );
dialog.find( "#part_of_speech_id" ).change
(
function( event_object )
{
toggle_containers_by_part_of_speech( dialog );
}
);
// orthographies
hide_extra_form_inputs( dialog, "orthography" );
// presents
hide_extra_form_inputs( dialog, "present" );
// infinitives
hide_extra_form_inputs( dialog, "infinitive" );
// perfects
hide_extra_form_inputs( dialog, "perfect" );
// p3s
hide_extra_form_inputs( dialog, "p3" );
// faps
hide_extra_form_inputs( dialog, "fap" );
// paps
hide_extra_form_inputs( dialog, "pap" );
// nominatives
hide_extra_form_inputs( dialog, "nominative" );
// genitives
hide_extra_form_inputs( dialog, "genitive" );
// show/hide all inputs based on part of speech
toggle_containers_by_part_of_speech( dialog, "part_of_speech_id" );
}
}
)
return false;
}
);
var edit_button_container = $( '<div style="float: right; height: 1px; overflow: visible; margin-left: 3px;">' );
edit_button_container.append( edit_button );
edit_button_container.insertBefore( $(this).find( ".flash_card_source" ) );
}
)
} // initialize_orthography_editor
/** 
*
*/
function hide_extra_form_inputs( dialog, input_name )
{
dialog.find( '#' + input_name + '_container input.' + input_name ).each
(
function( index, element )
{
if( $(this).is(":hidden") )
{
//error_procedure( null, this.name, null );
return true;
}
var val = $(this).val();
if( val.length == 0 
&& index != 0 )
{
$(this).hide();
}
else
{
$(this).prev().prev().show();
last = this;
}
$(this).focus
(
function( event, ui )
{
$(this).next().next().show();
}
);
}
)
}
/**
*
*/
function initialize_short_definitions_editor()
{
// Grab the English definition elements (which are ordered lists)
$( ".flash_card_english_def" ).each
(
function( index, element )
{
var lemma_id = $(this).attr( "data-lemma-id" );
if( typeof( lemma_id ) == "undefined" )
{
return;
}
//error_procedure( null, lemma_id, null );
var edit_button = $( '<button style="float:right">Edit Definitions</button>' ).button
(
{
icons: 
{
primary: 'ui-icon-pencil'
},
text: false
}
).click
(
function( event, ui )
{
var button = $(this);
var dialog = $( '<div>' ).dialog
(
{
width: 720,
height: 480,
modal: true,
title: 'Edit Lemma ID #' + lemma_id,
buttons: 
{
'Save': function() 
{
var form = $(this).find( "form" )[0];
if( typeof( form ) == "undefined" )
{
dialog.dialog( 'destroy' );
dialog.remove();
return false;
}
var id = "#" + form.id;
var post_data = CollectFormForAjax( id );
post_data.fn = "short_definitions"; // form name
post_data.c = 2;// command = SAVE
post_data.l = lemma_id;// lemma_id
wait_procedure( "Saving short definitions..." );
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
url: gateway, 
data: post_data,
success: function( data, textStatus, XHR ) 
{
if( data.errorNumber == 0 )
{
$( id + " input" ).removeClass( "ui-state-error" )
$( id + " textarea" ).removeClass( "ui-state-error" )
$( id + " select" ).removeClass( "ui-state-error" )
dialog.dialog( 'destroy' );
dialog.remove();
}
// validation error
else if( data.errorNumber == 512 )
{
$( data.errorList.reverse() ).each
(
function( index, element )
{
$( id + " input" ).removeClass( "ui-state-error" )
$( id + " textarea" ).removeClass( "ui-state-error" )
$( id + " select" ).removeClass( "ui-state-error" )
$( "#" + element.id ).addClass( "ui-state-error" ).focus();
$( "#" + element.name ).addClass( "ui-state-error" ).focus();
error_procedure( null, element.message, null );
}
);
}
// some other error
else
{
alert( "Error: " + data.errorText );
}
}
}
);
},
'Cancel': function() 
{
dialog.dialog( 'destroy' );
dialog.remove();
},
}
}
).append
( 
$('<img>').attr( { src: '/images/spinner_16x16.gif', title: 'Loading...' } ) 
);
var gateway = analytics_gateway( 'form.php' );
$.ajax
(
{
url: gateway,
data: 
{
fn: 'short_definitions',// form name
c: 1, // command = RENDER
l: lemma_id, // lemma_id
},
success: function( data, textStatus, XHR )
{
if( data.errorNumber != 0 )
{
dialog.html( "Error: " + data.errorText );
return;
}
dialog.html( data.form );
// definitions
dialog.find( '.definition_container input.definition' ).each
(
function( index, element )
{
var val = $(this).val();
if( val.length == 0 
&& index != 0 )
{
$(this).hide();
}
else
{
last = this;
}
$(this).focus
(
function( event, ui )
{
$(this).next().show();
}
);
}
)
}
}
)
return false;
}
);
edit_button.insertBefore( $(this) );
}
)
}
$(document).ready
(
function()
{
$.ajaxSetup
(
{
dataType: 'json',
type: 'POST',
error: error_procedure,
}
);
initialize_orthography_editor();
initialize_short_definitions_editor();
}
);
$(document).ready( error_history_dialog );
/*
CSS Browser Selector v0.3.2
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
function combo_dropdown( evt, combo_base_name, gateway )
{
text_element = document.getElementById( combo_base_name + "_text" )
if ( text_element == null )
{
alert( combo_base_name + "_text element not found." );
}
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
if ( !evt )
{
evt = window.event;
}
switch( evt.type )
{
case "keyup":
if ( evt.keyCode == "9" ) // tab
{
combo_dropdown_hide( combo_base_name );
return;
}
if ( evt.keyCode == "13" ) // enter
{
return false;
}
if ( evt.keyCode == "38" ) // up arrow
{
return;
}
if ( evt.keyCode == "40" ) // down arrow
{
return;
}
break;
}
combo_ajax_query( combo_base_name, gateway );
}
function combo_select_previous( combo_base_name )
{
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
if ( select_element.options.length == 0 
|| select_element.options.length == false )
{
return;
}
var index = select_element.options.selectedIndex;
index--;
if ( index < 0 )
{
index = 0;
}
select_element.options.selectedIndex = index;
}
function combo_select_next( combo_base_name )
{
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
if ( select_element.options.length == 0 
|| select_element.options.length == false )
{
return;
}
var index = select_element.options.selectedIndex;
index++;
if ( index > select_element.options.length - 1 )
{
index = select_element.options.length - 1;
}
select_element.options.selectedIndex = index;
}
function combo_dropdown_toggle( evt, combo_base_name, gateway )
{
text_element = document.getElementById( combo_base_name + "_text" )
if ( text_element == null )
{
alert( combo_base_name + "_text element not found." );
}
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
if ( select_element.style.visibility == 'visible' )
{
select_element.style.visibility = "hidden";
select_element.style.display = "none";
}
else
{
combo_dropdown( evt, combo_base_name, gateway );
}
text_element.focus();
focused_form_control = select_element;
}
function combo_dropdown_show( combo_base_name )
{
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
select_element.options.selectedIndex = 0;
select_element.style.visibility = "visible";
select_element.style.display = "block";
}
function combo_dropdown_hide( combo_base_name )
{
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
select_element.style.visibility = "hidden";
select_element.style.display = "none";
}
function combo_textbox_blur( combo_base_name )
{
func = function()
{
if ( focused_form_control.id != combo_base_name + "_select" )
{
combo_dropdown_hide( combo_base_name );
}
}
var combo_textbox_blur_timer = setTimeout( func, 
1000 );
}
function combo_ajax_query( combo_base_name, gateway )
{
if ( ajax_request_timeout_timer != undefined )
{
clearTimeout( ajax_request_timeout_timer );
}
func = function()
{
combo_ajax_query_keyboard_delay( combo_base_name, gateway );
}
ajax_request_timeout_timer = setTimeout( func, ajax_request_typing_delay_in_ms );
}
function combo_ajax_query_keyboard_delay( combo_base_name, gateway )
{
//alert( gateway );
try
{
xmlHttp.open( "GET", gateway, true );
// This is for Google Analytics
var short_gateway_arr = gateway.split( baseaddr );
var short_gateway = short_gateway_arr[short_gateway_arr.length - 1];
_gaq.push( [ '_trackPageview', short_gateway ] );
xmlHttp.onreadystatechange = function()
{
switch( xmlHttp.readyState )
{
/*
0 = open has not yet been called
1 = send has not yet been called but open has been called
2 = send has been called but no response from server
3 = data is in the process of being received from the server
4 = response from server has arrived
*/
case 4:
window.clearTimeout( ajax_request_timeout_timer );
if ( xmlHttp.status == 200 || xmlHttp.status == 302 )
{
//alert( xmlHttp.responseText );
//alert( xmlHttp.responseXML );
var txt = xmlHttp.responseText;
//alert( split_res[1] );
var el = document.getElementById( combo_base_name + "_select" )
if ( el == null )
{
alert( "select element not found" );
return false;
}
el.options.length = 0;
var split_res = xmlHttp.responseText.split( "|" );
for ( si = 0; si < split_res.length - 1; si++ )
{
key = split_res[si+1];
value = split_res[si+1];
el.options[si] = new Option( value, key );
}
el.options.selectedIndex = 0;
el.style.visibility = "visible";
el.style.display = "block";
}
else
{
if ( xmlHttp.status == 0 ) 
{
// This just means we aborted the connection
}
else
{
alert( "I encountered error " + 
xmlHttp.status + " (" + xmlHttp.statusText + ") " + 
"while trying to communicate with the AJAX gateway." );
}
}
break;
}
}
xmlHttp.send( null );
ajax_request_timeout_timer = window.setTimeout( "ajax_request_timeout()", ajax_request_timeout_in_ms );
}
catch( e )
{
alert( e );
alert( "I could not open the AJAX gateway.\n\n" + gateway );
return false;
}
return true;
}
function combo_set_text( combo_base_name )
{
text_element = document.getElementById( combo_base_name + "_text" )
if ( text_element == null )
{
alert( combo_text_text + " element not found." );
}
select_element = document.getElementById( combo_base_name + "_select" );
if ( select_element == null )
{
alert( combo_base_name + "_select element not found." );
}
if ( select_element.options.selectedIndex >= 0 )
{
text_element.value = select_element.options[select_element.options.selectedIndex].value;
}
select_element.style.visibility = "hidden";
select_element.style.display = "none";
text_element.focus();
focused_form_control = select_element;
}
function check_for_tab( evt, combo_base_name )
{
if ( !evt )
{
evt = window.event;
}
switch( evt.type )
{
case "keydown":
if ( evt.keyCode == "9" ) // tab
{
combo_dropdown_hide( combo_base_name );
return;
}
if ( evt.keyCode == "13" ) // enter
{
combo_set_text( combo_base_name );
return false;
}
if ( evt.keyCode == "38" ) // up arrow
{
combo_select_previous( combo_base_name );
}
if ( evt.keyCode == "40" ) // down arrow
{
combo_select_next( combo_base_name );
}
break;
}
}
/**Source Box Javascript
*
*Requires JQuery 1.4.2 (or later).
*/
$(document).ready( initialize_search_box );
var source_box_container_id = "source_box_container";
var source_box_control_id = "source_box_control";
var source_box_check_name = "source_box_check";
var source_box_arrow_name = "source_box_arrow";
var source_box_minimizable_row_name = "source_box_minimizable_row"
var source_box_container_element = null;
// MAKE SURE THIS IS A FULLY QUALIFIED BASE
var image_base = "http://latinlexicon.org/images/source_box/";
var preload_images = new Array();
preload_images["minimize_high"] = image_base + "top_control_minimize_high.png";
preload_images["minimize_normal"] = image_base + "top_control_minimize_normal.png";
preload_images["maximize_high"] = image_base + "top_control_maximize_high.png";
preload_images["maximize_normal"] = image_base + "top_control_maximize_normal.png";
preload_images["check_normal"] = image_base + "check_normal.png";
preload_images["check_high"] = image_base + "check_high.png";
preload_images["check_glow"] = image_base + "check_glow.png";
preload_images["check_checked_normal"] = image_base + "check_checked_normal.png";
preload_images["check_checked_high"] = image_base + "check_checked_high.png";
preload_images["check_checked_glow"] = image_base + "check_checked_glow.png";
preload_images["arrow_normal"] = image_base + "arrow_normal.png";
preload_images["arrow_high"] = image_base + "arrow_high.png";
preload_images["arrow_invisible"] = image_base + "arrow_invisible.png";
preload_images["arrow_glow"] = image_base + "arrow_glow.png";
function initialize_search_box()
{
source_box_container_element = $(source_box_container_id);
if( source_box_container_element == null )
{
alert( "'" + source_box_container_element + "' not found." );
return false;
}
if( document.images )
{
var preloaded_image = new Array();
for( var si = 0; si < preload_images.length; si++ )
{
preloaded_image[si] = new Image();
preloaded_image[si].src = preload_images[si];
}
}
// the minimize/maximize control
$("#source_box_control")
.mouseenter( mouseenter_control )
.mouseleave( mouseleave_control )
.click( click_control );
// the check box controls
$(".source_box_check")
.mouseenter( mouseenter_check )
.mouseleave( mouseleave_check )
.mousedown( mousedown_check )
.mouseup( mouseup_check )
.click( click_check );
// the arrow controls
$(".source_box_arrow")
.mouseenter( mouseenter_arrow )
.mouseleave( mouseleave_arrow )
.mousedown( mousedown_arrow )
.mouseup( mouseup_arrow )
.click( click_arrow );
show_hide_arrows();
get_source_box_states( true );
$(window).resize( function() { calculate_position_and_show( true ); } );
$(window).scroll( function() { calculate_position_and_show( true ); } );
}// initialize_search_box
function calculate_position_and_show( after )
{
var source_box_jq = $("#source_box_container");
var previous_height = source_box_jq.data( "previous_height" );
source_box_jq.css( "display", "block" );
source_box_jq.css( "position", "absolute" );
if( !previous_height )
{
previous_height = source_box_jq.outerHeight();
source_box_jq.data( "previous_height", previous_height );
}
if( !after )
{
source_box_jq.animate
(
{ 
"top" : $(window).height() - previous_height + $(window).scrollTop() - 1 + "px",
"left" : $(window).width() - source_box_jq.outerWidth() + $(window).scrollLeft() - 1 + "px"
}, 
"fast" 
);
}
else if( after )
{
source_box_jq.css( "left", $(window).width() - source_box_jq.outerWidth() + $(window).scrollLeft() - 1 + "px" );
source_box_jq.css( "top", $(window).height() - source_box_jq.outerHeight() + $(window).scrollTop() - 1 + "px" );
}
}
function mouseenter_control( e ) 
{
switch( this.src )
{
case preload_images["minimize_normal"]:
this.src = preload_images["minimize_high"];
break;
case preload_images["maximize_normal"]:
this.src = preload_images["maximize_high"];
break;
default:
throw "The domains probably don't match: " + this.src + image_base;
}
return false; // don't bubble this click 
};
function mouseleave_control( e ) 
{
switch( this.src )
{
case preload_images["minimize_high"]:
this.src = preload_images["minimize_normal"];
break;
case preload_images["maximize_high"]:
this.src = preload_images["maximize_normal"];
break;
default:
throw "The domains probably don't match: " + this.src + image_base;
}
return false; // don't bubble this click 
};
function click_control( e )
{
calculate_position_and_show( false );
$( ".source_box_minimizable_row" ).slideToggle
(
"fast", 
function () 
{
calculate_position_and_show( true );
}
)
switch( $(this).attr( "src" ) )
{
case preload_images["minimize_normal"]:
$(this).attr( "src", preload_images["maximize_normal"] );
break;
case preload_images["minimize_high"]:
$(this).attr( "src", preload_images["maximize_high"] );
break;
case preload_images["maximize_normal"]:
$(this).attr( "src", preload_images["minimize_normal"] );
break;
case preload_images["maximize_high"]:
$(this).attr( "src", preload_images["minimize_high"] );
break;
default:
throw "The domains probably don't match: " + this.src + image_base;
}
}
function mouseenter_check( e ) 
{
if( $(this).data( "checked" ) )
{
this.src = preload_images["check_checked_high"];
}
else
{
this.src = preload_images["check_high"];
}
return false; // don't bubble this click 
};
function mouseleave_check( e ) 
{
if( $(this).data( "checked" ) )
{
this.src = preload_images["check_checked_normal"];
}
else
{
this.src = preload_images["check_normal"];
}
return false; // don't bubble this click 
};
function mousedown_check( e )
{
if( $(this).data( "checked" ) )
{
this.src = preload_images["check_checked_glow"];
}
else
{
this.src = preload_images["check_glow"];
}
return false;
}
function mouseup_check( e )
{
if( $(this).data( "checked" ) )
{
this.src = preload_images["check_checked_normal"];
}
else
{
this.src = preload_images["check_normal"];
}
return false;
}
function click_check( e ) 
{
switch( this.src )
{
case preload_images["check_normal"]:
this.src = preload_images["check_checked_normal"];
checked = true;
break;
case preload_images["check_high"] :
this.src = preload_images["check_checked_high"];
checked = true;
break;
case preload_images["check_checked_normal"]:
this.src = preload_images["check_normal"];
checked = false;
break;
case preload_images["check_checked_high"]:
this.src = preload_images["check_high"] ;
checked = false;
break;
default:
throw "The domains probably don't match: " + this.src + image_base;
}
$(this).data( "checked", checked );
set_source_box_states();
return false; // don't bubble this click 
};
function mouseenter_arrow( e ) 
{
this.src = preload_images["arrow_high"];
return false; // don't bubble this click 
};
function mouseleave_arrow( e ) 
{
this.src = preload_images["arrow_normal"];
return false; // don't bubble this click 
};
function mousedown_arrow( e )
{
this.src = preload_images["arrow_glow"];
return false; // don't bubble this event
}
function mouseup_arrow( e )
{
this.src = preload_images["arrow_normal"];
return false; // don't bubble this event
}
function click_arrow( e ) 
{
// run ajax here to send and receive the reordering commands
//alert( $(this).parents( ".source_box_minimizable_row" ).prev( ".source_box_minimizable_row" ) );
$(this).parents( ".source_box_minimizable_row" ).prev( ".source_box_minimizable_row" ).insertAfter( $(this).parents( ".source_box_minimizable_row" ) );
show_hide_arrows();
set_source_box_states();
return false; // don't bubble this click 
};
function show_hide_arrows()
{
$("#invisible_arrow").remove();
$(".source_box_minimizable_row .source_box_arrow").each
(
function( index )
{
if( index == 0 )
{
$(this).css( "display", "none" );
$(this).after( $("<img id=\"invisible_arrow\">").attr( "src", preload_images["arrow_invisible"] ) );
}
else
{
$(this).css( "display", "block" );
}
}
);
}
function get_source_box_states( first )
{
var data = { "f": "1" };
$.getJSON
(
"/ajax/functions.php", 
data,
function( data )
{
if( data.s )
{
alert( "Error: no such function." );
return;
}
if( first )
{
$(".source_box_middle_row").each
( 
function( index ) 
{ 
if( data.d[index] )
{
$(this).data( "name", data.d[index].name );
$(this).data( "source_id", data.d[index].source_id );
}
} 
);
$(".source_box_middle_row_middle").each
( 
function( index ) 
{ 
if( data.d[index] )
{
$(this).html( data.d[index].name );
}
} 
);
$(".source_box_minimizable_row").each
( 
function( index ) 
{
if( data.d[index] == null )
{
$(this).remove();
}
} 
);
}
$(".source_box_check").each
( 
function( index ) 
{ 
if( data.d[index] )
{
if( data.d[index].checked == true )
{
$(this).data( "checked", true );
$(this).attr( "src", preload_images["check_checked_normal"] );
}
else
{
$(this).data( "checked", false );
$(this).attr( "src", preload_images["check_normal"] );
}
}
} 
);
calculate_position_and_show( true );
}
);
} // get_source_box_states
function set_source_box_states()
{
var d = new Array();
$(".source_box_middle_row").each
( 
function( index ) 
{ 
d[index] = 
{ 
source_id: $(this).data( "source_id" ),
order: index,
checked: $(".source_box_check",this).data( "checked" )
};
} 
);
$.ajax
(
{
url: "/ajax/functions.php", 
dataType: "json",
data: { "f": "2", "p1" : d },
type: "POST",
success: function( data )
{
//
}
}
);
} // get_source_box_states
/**
* @author Michał Bielawski <d3x@burek.it>
* @name jQuery disable()
* @license WTFPL (http://sam.zoy.org/wtfpl/)
*/
(function($) {
$.fn.extend({
disable: function() {
return this.each(function() {
$(this).attr({disabled: true});
});
},
enable: function() {
return this.each(function() {
$(this).removeAttr('disabled');
});
},
toggleDisabled: function(disable) {
switch(typeof(disable)) {
case "boolean": break;
case "number": disable = disable > 0; break;
default: disable = !this.is(':disabled');
}
return $(this)[disable ? "disable" : "enable"]();
},
toggleEnabled: function(enable) {
switch(typeof(enable)) {
case "boolean": break;
case "number": enable = enable > 0; break;
default: enable = this.is(':disabled');
}
return $(this)[enable ? "enable" : "disable"]();
}
});
})(jQuery);// JavaScript Document
