/*Prototype JavaScript framework,version 1.5.1.1
 *(c) 2005-2007 Sam Stephenson
 *
 *Prototype is freely distributable under the terms of an MIT-style license.
 *For details,see the Prototype web site:http://www.prototypejs.org/
 *
/*--------------------------------------------------------------------------*/

var Prototype ={
Version:'1.5.1.1',

Browser:{
IE:!!(window.attachEvent && !window.opera),
Opera:!!window.opera,
WebKit:navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko:navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
},

BrowserFeatures:{
XPath:!!document.evaluate,
ElementExtensions:!!window.HTMLElement,
SpecificElementExtensions:
(document.createElement('div').__proto__ !==
 document.createElement('form').__proto__)
},

ScriptFragment:'<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,

emptyFunction:function(){ },
K:function(x){ return x }
}

var Class ={
create:function(){
return function(){
this.initialize.apply(this,arguments);
}
}
}

var Abstract = new Object();

Object.extend = function(destination,source){
for (var property in source){
destination[property] = source[property];
}
return destination;
}

Object.extend(Object,{
inspect:function(object){
try{
if (object === undefined) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect():object.toString();
} catch (e){
if (e instanceof RangeError) return '...';
throw e;
}
},

toJSON:function(object){
var type = typeof object;
switch(type){
case 'undefined':
case 'function':
case 'unknown':return;
case 'boolean':return object.toString();
}
if (object === null) return 'null';
if (object.toJSON) return object.toJSON();
if (object.ownerDocument === document) return;
var results = [];
for (var property in object){
var value = Object.toJSON(object[property]);
if (value !== undefined)
results.push(property.toJSON() + ':' + value);
}
return '{' + results.join(',') + '}';
},

keys:function(object){
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},

values:function(object){
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},

clone:function(object){
return Object.extend({},object);
}
});

Function.prototype.bind = function(){
var __method = this,args = $A(arguments),object = args.shift();
return function(){
return __method.apply(object,args.concat($A(arguments)));
}
}

Function.prototype.bindAsEventListener = function(object){
var __method = this,args = $A(arguments),object = args.shift();
return function(event){
return __method.apply(object,[event || window.event].concat(args));
}
}

Object.extend(Number.prototype,{
toColorPart:function(){
return this.toPaddedString(2,16);
},

succ:function(){
return this + 1;
},

times:function(iterator){
$R(0,this,true).each(iterator);
return this;
},

toPaddedString:function(length,radix){
var string = this.toString(radix || 10);
return '0'.times(length - string.length) + string;
},

toJSON:function(){
return isFinite(this) ? this.toString():'null';
}
});

Date.prototype.toJSON = function(){
return '"' + this.getFullYear() + '-' +
(this.getMonth() + 1).toPaddedString(2) + '-' +
this.getDate().toPaddedString(2) + 'T' +
this.getHours().toPaddedString(2) + ':' +
this.getMinutes().toPaddedString(2) + ':' +
this.getSeconds().toPaddedString(2) + '"';
};

var Try ={
these:function(){
var returnValue;

for (var i = 0,length = arguments.length;i < length;i++){
var lambda = arguments[i];
try{
returnValue = lambda();
break;
} catch (e){}
}

return returnValue;
}
}

/*--------------------------------------------------------------------------*/

var PeriodicalExecuter = Class.create();
PeriodicalExecuter.prototype ={
initialize:function(callback,frequency){
this.callback = callback;
this.frequency = frequency;
this.currentlyExecuting = false;

this.registerCallback();
},

registerCallback:function(){
this.timer = setInterval(this.onTimerEvent.bind(this),this.frequency * 1000);
},

stop:function(){
if (!this.timer) return;
clearInterval(this.timer);
this.timer = null;
},

onTimerEvent:function(){
if (!this.currentlyExecuting){
try{
this.currentlyExecuting = true;
this.callback(this);
} finally{
this.currentlyExecuting = false;
}
}
}
}
Object.extend(String,{
interpret:function(value){
return value == null ? '':String(value);
},
specialChar:{
'\b':'\\b',
'\t':'\\t',
'\n':'\\n',
'\f':'\\f',
'\r':'\\r',
'\\':'\\\\'
}
});

Object.extend(String.prototype,{
gsub:function(pattern,replacement){
var result = '',source = this,match;
replacement = arguments.callee.prepareReplacement(replacement);

while (source.length > 0){
if (match = source.match(pattern)){
result += source.slice(0,match.index);
result += String.interpret(replacement(match));
source= source.slice(match.index + match[0].length);
} else{
result += source,source = '';
}
}
return result;
},

sub:function(pattern,replacement,count){
replacement = this.gsub.prepareReplacement(replacement);
count = count === undefined ? 1:count;

return this.gsub(pattern,function(match){
if (--count < 0) return match[0];
return replacement(match);
});
},

scan:function(pattern,iterator){
this.gsub(pattern,iterator);
return this;
},

truncate:function(length,truncation){
length = length || 30;
truncation = truncation === undefined ? '...':truncation;
return this.length > length ?
this.slice(0,length - truncation.length) + truncation:this;
},

strip:function(){
return this.replace(/^\s+/,'').replace(/\s+$/,'');
},

stripTags:function(){
return this.replace(/<\/?[^>]+>/gi,'');
},

stripScripts:function(){
return this.replace(new RegExp(Prototype.ScriptFragment,'img'),'');
},

extractScripts:function(){
var matchAll = new RegExp(Prototype.ScriptFragment,'img');
var matchOne = new RegExp(Prototype.ScriptFragment,'im');
return (this.match(matchAll) || []).map(function(scriptTag){
return (scriptTag.match(matchOne) || ['',''])[1];
});
},

evalScripts:function(){
return this.extractScripts().map(function(script){ return eval(script) });
},

escapeHTML:function(){
var self = arguments.callee;
self.text.data = this;
return self.div.innerHTML;
},

unescapeHTML:function(){
var div = document.createElement('div');
div.innerHTML = this.stripTags();
return div.childNodes[0] ? (div.childNodes.length > 1 ?
$A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }):
div.childNodes[0].nodeValue):'';
},

toQueryParams:function(separator){
var match = this.strip().match(/([^?#]*)(#.*)?$/);
if (!match) return{};

return match[1].split(separator || '&').inject({},function(hash,pair){
if ((pair = pair.split('='))[0]){
var key = decodeURIComponent(pair.shift());
var value = pair.length > 1 ? pair.join('='):pair[0];
if (value != undefined) value = decodeURIComponent(value);

if (key in hash){
if (hash[key].constructor != Array) hash[key] = [hash[key]];
hash[key].push(value);
}
else hash[key] = value;
}
return hash;
});
},

toArray:function(){
return this.split('');
},

succ:function(){
return this.slice(0,this.length - 1) +
String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
},

times:function(count){
var result = '';
for (var i = 0;i < count;i++) result += this;
return result;
},

camelize:function(){
var parts = this.split('-'),len = parts.length;
if (len == 1) return parts[0];

var camelized = this.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
:parts[0];

for (var i = 1;i < len;i++)
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);

return camelized;
},

capitalize:function(){
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
},

underscore:function(){
return this.gsub(/::/,'/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
},

dasherize:function(){
return this.gsub(/_/,'-');
},

inspect:function(useDoubleQuotes){
var escapedString = this.gsub(/[\x00-\x1f\\]/,function(match){
var character = String.specialChar[match[0]];
return character ? character:'\\u00' + match[0].charCodeAt().toPaddedString(2,16);
});
if (useDoubleQuotes) return '"' + escapedString.replace(/"/g,'\\"') + '"';
return "'" + escapedString.replace(/'/g,'\\\'') + "'";
},

toJSON:function(){
return this.inspect(true);
},

unfilterJSON:function(filter){
return this.sub(filter || Prototype.JSONFilter,'#{1}');
},

isJSON:function(){
var str = this.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'');
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},

evalJSON:function(sanitize){
var json = this.unfilterJSON();
try{
if (!sanitize || json.isJSON()) return eval('(' + json + ')');
} catch (e){ }
throw new SyntaxError('Badly formed JSON string:' + this.inspect());
},

include:function(pattern){
return this.indexOf(pattern) > -1;
},

startsWith:function(pattern){
return this.indexOf(pattern) === 0;
},

endsWith:function(pattern){
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
},

empty:function(){
return this == '';
},

blank:function(){
return /^\s*$/.test(this);
}
});

if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype,{
escapeHTML:function(){
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
},
unescapeHTML:function(){
return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
}
});

String.prototype.gsub.prepareReplacement = function(replacement){
if (typeof replacement == 'function') return replacement;
var template = new Template(replacement);
return function(match){ return template.evaluate(match) };
}

String.prototype.parseQuery = String.prototype.toQueryParams;

Object.extend(String.prototype.escapeHTML,{
div:document.createElement('div'),
text:document.createTextNode('')
});

with (String.prototype.escapeHTML) div.appendChild(text);

var Template = Class.create();
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype ={
initialize:function(template,pattern){
this.template = template.toString();
this.pattern= pattern || Template.Pattern;
},

evaluate:function(object){
return this.template.gsub(this.pattern,function(match){
var before = match[1];
if (before == '\\') return match[2];
return before + String.interpret(object[match[3]]);
});
}
}

var $break ={},$continue = new Error('"throw $continue" is deprecated,use "return" instead');

var Enumerable ={
each:function(iterator){
var index = 0;
try{
this._each(function(value){
iterator(value,index++);
});
} catch (e){
if (e != $break) throw e;
}
return this;
},

eachSlice:function(number,iterator){
var index = -number,slices = [],array = this.toArray();
while ((index += number) < array.length)
slices.push(array.slice(index,index+number));
return slices.map(iterator);
},

all:function(iterator){
var result = true;
this.each(function(value,index){
result = result && !!(iterator || Prototype.K)(value,index);
if (!result) throw $break;
});
return result;
},

any:function(iterator){
var result = false;
this.each(function(value,index){
if (result = !!(iterator || Prototype.K)(value,index))
throw $break;
});
return result;
},

collect:function(iterator){
var results = [];
this.each(function(value,index){
results.push((iterator || Prototype.K)(value,index));
});
return results;
},

detect:function(iterator){
var result;
this.each(function(value,index){
if (iterator(value,index)){
result = value;
throw $break;
}
});
return result;
},

findAll:function(iterator){
var results = [];
this.each(function(value,index){
if (iterator(value,index))
results.push(value);
});
return results;
},

grep:function(pattern,iterator){
var results = [];
this.each(function(value,index){
var stringValue = value.toString();
if (stringValue.match(pattern))
results.push((iterator || Prototype.K)(value,index));
})
return results;
},

include:function(object){
var found = false;
this.each(function(value){
if (value == object){
found = true;
throw $break;
}
});
return found;
},

inGroupsOf:function(number,fillWith){
fillWith = fillWith === undefined ? null:fillWith;
return this.eachSlice(number,function(slice){
while(slice.length < number) slice.push(fillWith);
return slice;
});
},

inject:function(memo,iterator){
this.each(function(value,index){
memo = iterator(memo,value,index);
});
return memo;
},

invoke:function(method){
var args = $A(arguments).slice(1);
return this.map(function(value){
return value[method].apply(value,args);
});
},

max:function(iterator){
var result;
this.each(function(value,index){
value = (iterator || Prototype.K)(value,index);
if (result == undefined || value >= result)
result = value;
});
return result;
},

min:function(iterator){
var result;
this.each(function(value,index){
value = (iterator || Prototype.K)(value,index);
if (result == undefined || value < result)
result = value;
});
return result;
},

partition:function(iterator){
var trues = [],falses = [];
this.each(function(value,index){
((iterator || Prototype.K)(value,index) ?
trues:falses).push(value);
});
return [trues,falses];
},

pluck:function(property){
var results = [];
this.each(function(value,index){
results.push(value[property]);
});
return results;
},

reject:function(iterator){
var results = [];
this.each(function(value,index){
if (!iterator(value,index))
results.push(value);
});
return results;
},

sortBy:function(iterator){
return this.map(function(value,index){
return{value:value,criteria:iterator(value,index)};
}).sort(function(left,right){
var a = left.criteria,b = right.criteria;
return a < b ? -1:a > b ? 1:0;
}).pluck('value');
},

toArray:function(){
return this.map();
},

zip:function(){
var iterator = Prototype.K,args = $A(arguments);
if (typeof args.last() == 'function')
iterator = args.pop();

var collections = [this].concat(args).map($A);
return this.map(function(value,index){
return iterator(collections.pluck(index));
});
},

size:function(){
return this.toArray().length;
},

inspect:function(){
return '#<Enumerable:' + this.toArray().inspect() + '>';
}
}

Object.extend(Enumerable,{
map:Enumerable.collect,
find:Enumerable.detect,
select:Enumerable.findAll,
member:Enumerable.include,
entries:Enumerable.toArray
});
var $A = Array.from = function(iterable){
if (!iterable) return [];
if (iterable.toArray){
return iterable.toArray();
} else{
var results = [];
for (var i = 0,length = iterable.length;i < length;i++)
results.push(iterable[i]);
return results;
}
}

if (Prototype.Browser.WebKit){
$A = Array.from = function(iterable){
if (!iterable) return [];
if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&
iterable.toArray){
return iterable.toArray();
} else{
var results = [];
for (var i = 0,length = iterable.length;i < length;i++)
results.push(iterable[i]);
return results;
}
}
}

Object.extend(Array.prototype,Enumerable);

if (!Array.prototype._reverse)
Array.prototype._reverse = Array.prototype.reverse;

Object.extend(Array.prototype,{
_each:function(iterator){
for (var i = 0,length = this.length;i < length;i++)
iterator(this[i]);
},

clear:function(){
this.length = 0;
return this;
},

first:function(){
return this[0];
},

last:function(){
return this[this.length - 1];
},

compact:function(){
return this.select(function(value){
return value != null;
});
},

flatten:function(){
return this.inject([],function(array,value){
return array.concat(value && value.constructor == Array ?
value.flatten():[value]);
});
},

without:function(){
var values = $A(arguments);
return this.select(function(value){
return !values.include(value);
});
},

indexOf:function(object){
for (var i = 0,length = this.length;i < length;i++)
if (this[i] == object) return i;
return -1;
},

reverse:function(inline){
return (inline !== false ? this:this.toArray())._reverse();
},

reduce:function(){
return this.length > 1 ? this:this[0];
},

uniq:function(sorted){
return this.inject([],function(array,value,index){
if (0 == index || (sorted ? array.last() != value:!array.include(value)))
array.push(value);
return array;
});
},

clone:function(){
return [].concat(this);
},

size:function(){
return this.length;
},

inspect:function(){
return '[' + this.map(Object.inspect).join(',') + ']';
},

toJSON:function(){
var results = [];
this.each(function(object){
var value = Object.toJSON(object);
if (value !== undefined) results.push(value);
});
return '[' + results.join(',') + ']';
}
});

Array.prototype.toArray = Array.prototype.clone;

function $w(string){
string = string.strip();
return string ? string.split(/\s+/):[];
}

if (Prototype.Browser.Opera){
Array.prototype.concat = function(){
var array = [];
for (var i = 0,length = this.length;i < length;i++) array.push(this[i]);
for (var i = 0,length = arguments.length;i < length;i++){
if (arguments[i].constructor == Array){
for (var j = 0,arrayLength = arguments[i].length;j < arrayLength;j++)
array.push(arguments[i][j]);
} else{
array.push(arguments[i]);
}
}
return array;
}
}
var Hash = function(object){
if (object instanceof Hash) this.merge(object);
else Object.extend(this,object ||{});
};

Object.extend(Hash,{
toQueryString:function(obj){
var parts = [];
parts.add = arguments.callee.addPair;

this.prototype._each.call(obj,function(pair){
if (!pair.key) return;
var value = pair.value;

if (value && typeof value == 'object'){
if (value.constructor == Array) value.each(function(value){
parts.add(pair.key,value);
});
return;
}
parts.add(pair.key,value);
});

return parts.join('&');
},

toJSON:function(object){
var results = [];
this.prototype._each.call(object,function(pair){
var value = Object.toJSON(pair.value);
if (value !== undefined) results.push(pair.key.toJSON() + ':' + value);
});
return '{' + results.join(',') + '}';
}
});

Hash.toQueryString.addPair = function(key,value,prefix){
key = encodeURIComponent(key);
if (value === undefined) this.push(key);
else this.push(key + '=' + (value == null ? '':encodeURIComponent(value)));
}

Object.extend(Hash.prototype,Enumerable);
Object.extend(Hash.prototype,{
_each:function(iterator){
for (var key in this){
var value = this[key];
if (value && value == Hash.prototype[key]) continue;

var pair = [key,value];
pair.key = key;
pair.value = value;
iterator(pair);
}
},

keys:function(){
return this.pluck('key');
},

values:function(){
return this.pluck('value');
},

merge:function(hash){
return $H(hash).inject(this,function(mergedHash,pair){
mergedHash[pair.key] = pair.value;
return mergedHash;
});
},

remove:function(){
var result;
for(var i = 0,length = arguments.length;i < length;i++){
var value = this[arguments[i]];
if (value !== undefined){
if (result === undefined) result = value;
else{
if (result.constructor != Array) result = [result];
result.push(value)
}
}
delete this[arguments[i]];
}
return result;
},

toQueryString:function(){
return Hash.toQueryString(this);
},

inspect:function(){
return '#<Hash:{' + this.map(function(pair){
return pair.map(Object.inspect).join(':');
}).join(',') + '}>';
},

toJSON:function(){
return Hash.toJSON(this);
}
});

function $H(object){
if (object instanceof Hash) return object;
return new Hash(object);
};

// Safari iterates over shadowed properties
if (function(){
var i = 0,Test = function(value){ this.key = value };
Test.prototype.key = 'foo';
for (var property in new Test('bar')) i++;
return i > 1;
}()) Hash.prototype._each = function(iterator){
var cache = [];
for (var key in this){
var value = this[key];
if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;
cache.push(key);
var pair = [key,value];
pair.key = key;
pair.value = value;
iterator(pair);
}
};
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype,Enumerable);
Object.extend(ObjectRange.prototype,{
initialize:function(start,end,exclusive){
this.start = start;
this.end = end;
this.exclusive = exclusive;
},

_each:function(iterator){
var value = this.start;
while (this.include(value)){
iterator(value);
value = value.succ();
}
},

include:function(value){
if (value < this.start)
return false;
if (this.exclusive)
return value < this.end;
return value <= this.end;
}
});

var $R = function(start,end,exclusive){
return new ObjectRange(start,end,exclusive);
}

var Ajax ={
getTransport:function(){
return Try.these(
function(){return new XMLHttpRequest()},
function(){return new ActiveXObject('Msxml2.XMLHTTP')},
function(){return new ActiveXObject('Microsoft.XMLHTTP')}
) || false;
},

activeRequestCount:0
}

Ajax.Responders ={
responders:[],

_each:function(iterator){
this.responders._each(iterator);
},

register:function(responder){
if (!this.include(responder))
this.responders.push(responder);
},

unregister:function(responder){
this.responders = this.responders.without(responder);
},

dispatch:function(callback,request,transport,json){
this.each(function(responder){
if (typeof responder[callback] == 'function'){
try{
responder[callback].apply(responder,[request,transport,json]);
} catch (e){}
}
});
}
};

Object.extend(Ajax.Responders,Enumerable);

Ajax.Responders.register({
onCreate:function(){
Ajax.activeRequestCount++;
},
onComplete:function(){
Ajax.activeRequestCount--;
}
});

Ajax.Base = function(){};
Ajax.Base.prototype ={
setOptions:function(options){
this.options ={
method:'post',
asynchronous:true,
contentType:'application/x-www-form-urlencoded',
encoding:'UTF-8',
parameters:''
}
Object.extend(this.options,options ||{});

this.options.method = this.options.method.toLowerCase();
if (typeof this.options.parameters == 'string')
this.options.parameters = this.options.parameters.toQueryParams();
}
}

Ajax.Request = Class.create();
Ajax.Request.Events =
['Uninitialized','Loading','Loaded','Interactive','Complete'];

Ajax.Request.prototype = Object.extend(new Ajax.Base(),{
_complete:false,

initialize:function(url,options){
this.transport = Ajax.getTransport();
this.setOptions(options);
this.request(url);
},

request:function(url){
this.url = url;
this.method = this.options.method;
var params = Object.clone(this.options.parameters);

if (!['get','post'].include(this.method)){
// simulate other verbs over post
params['_method'] = this.method;
this.method = 'post';
}

this.parameters = params;

if (params = Hash.toQueryString(params)){
// when GET,append parameters to URL
if (this.method == 'get')
this.url += (this.url.include('?') ? '&':'?') + params;
else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params += '&_=';
}

try{
if (this.options.onCreate) this.options.onCreate(this.transport);
Ajax.Responders.dispatch('onCreate',this,this.transport);

this.transport.open(this.method.toUpperCase(),this.url,
this.options.asynchronous);

if (this.options.asynchronous)
setTimeout(function(){ this.respondToReadyState(1) }.bind(this),10);

this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();

this.body = this.method == 'post' ? (this.options.postBody || params):null;
this.transport.send(this.body);

/* Force Firefox to handle ready state 4 for synchronous requests */
if (!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange();

}
catch (e){
this.dispatchException(e);
}
},

onStateChange:function(){
var readyState = this.transport.readyState;
if (readyState > 1 && !((readyState == 4) && this._complete))
this.respondToReadyState(this.transport.readyState);
},

//setRequestHeaders:function(){
// var headers ={
//'X-Requested-With':'XMLHttpRequest',
//'X-Prototype-Version':Prototype.Version,
//'Accept':'text/javascript,text/html,application/xml,text/xml,*/*'
//};
setRequestHeaders:function(){
var headers ={
'If-Modified-Since':'Thu,1 Jan 1970 00:00:00 GMT',
'X-Requested-With':'XMLHttpRequest',
'X-Prototype-Version':Prototype.Version,
'Accept':'text/javascript,text/html,application/xml,text/xml,*/*'
};
if (this.method == 'post'){
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? ';charset=' + this.options.encoding:'');

/* Force "Connection:close" for older Mozilla browsers to work
 * around a bug where XMLHttpRequest sends an incorrect
 * Content-length header. See Mozilla Bugzilla #246651.
 */
if (this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
headers['Connection'] = 'close';
}

// user-defined headers
if (typeof this.options.requestHeaders == 'object'){
var extras = this.options.requestHeaders;

if (typeof extras.push == 'function')
for (var i = 0,length = extras.length;i < length;i += 2)
headers[extras[i]] = extras[i+1];
else
$H(extras).each(function(pair){ headers[pair.key] = pair.value });
}

for (var name in headers)
this.transport.setRequestHeader(name,headers[name]);
},

success:function(){
return !this.transport.status
|| (this.transport.status >= 200 && this.transport.status < 300);
},

respondToReadyState:function(readyState){
var state = Ajax.Request.Events[readyState];
var transport = this.transport,json = this.evalJSON();

if (state == 'Complete'){
try{
this._complete = true;
(this.options['on' + this.transport.status]
 || this.options['on' + (this.success() ? 'Success':'Failure')]
 || Prototype.emptyFunction)(transport,json);
} catch (e){
this.dispatchException(e);
}

var contentType = this.getHeader('Content-type');
if (contentType && contentType.strip().
match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
this.evalResponse();
}

try{
(this.options['on' + state] || Prototype.emptyFunction)(transport,json);
Ajax.Responders.dispatch('on' + state,this,transport,json);
} catch (e){
this.dispatchException(e);
}

if (state == 'Complete'){
// avoid memory leak in MSIE:clean up
this.transport.onreadystatechange = Prototype.emptyFunction;
}
},

getHeader:function(name){
try{
return this.transport.getResponseHeader(name);
} catch (e){ return null }
},

evalJSON:function(){
try{
var json = this.getHeader('X-JSON');
return json ? json.evalJSON():null;
} catch (e){ return null }
},

evalResponse:function(){
try{
return eval((this.transport.responseText || '').unfilterJSON());
} catch (e){
this.dispatchException(e);
}
},

dispatchException:function(exception){
(this.options.onException || Prototype.emptyFunction)(this,exception);
Ajax.Responders.dispatch('onException',this,exception);
}
});

Ajax.Updater = Class.create();

Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{
initialize:function(container,url,options){
this.container ={
success:(container.success || container),
failure:(container.failure || (container.success ? null:container))
}

this.transport = Ajax.getTransport();
this.setOptions(options);

var onComplete = this.options.onComplete || Prototype.emptyFunction;
this.options.onComplete = (function(transport,param){
this.updateContent();
onComplete(transport,param);
}).bind(this);

this.request(url);
},

updateContent:function(){
var receiver = this.container[this.success() ? 'success':'failure'];
var response = this.transport.responseText;

if (!this.options.evalScripts) response = response.stripScripts();

if (receiver = $(receiver)){
if (this.options.insertion)
new this.options.insertion(receiver,response);
else
receiver.update(response);
}

if (this.success()){
if (this.onComplete)
setTimeout(this.onComplete.bind(this),10);
}
}
});

Ajax.PeriodicalUpdater = Class.create();
Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(),{
initialize:function(container,url,options){
this.setOptions(options);
this.onComplete = this.options.onComplete;

this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);

this.updater ={};
this.container = container;
this.url = url;

this.start();
},

start:function(){
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},

stop:function(){
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this,arguments);
},

updateComplete:function(request){
if (this.options.decay){
this.decay = (request.responseText == this.lastText ?
this.decay * this.options.decay:1);

this.lastText = request.responseText;
}
this.timer = setTimeout(this.onTimerEvent.bind(this),
this.decay * this.frequency * 1000);
},

onTimerEvent:function(){
this.updater = new Ajax.Updater(this.container,this.url,this.options);
}
});
function $(element){
if (arguments.length > 1){
for (var i = 0,elements = [],length = arguments.length;i < length;i++)
elements.push($(arguments[i]));
return elements;
}
if (typeof element == 'string')
element = document.getElementById(element);
return Element.extend(element);
}

if (Prototype.BrowserFeatures.XPath){
document._getElementsByXPath = function(expression,parentElement){
var results = [];
var query = document.evaluate(expression,$(parentElement) || document,
null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
for (var i = 0,length = query.snapshotLength;i < length;i++)
results.push(query.snapshotItem(i));
return results;
};

document.getElementsByClassName = function(className,parentElement){
var q = ".//*[contains(concat(' ',@class,' '),' " + className + " ')]";
return document._getElementsByXPath(q,parentElement);
}

} else document.getElementsByClassName = function(className,parentElement){
var children = ($(parentElement) || document.body).getElementsByTagName('*');
var elements = [],child,pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
for (var i = 0,length = children.length;i < length;i++){
child = children[i];
var elementClassName = child.className;
if (elementClassName.length == 0) continue;
if (elementClassName == className || elementClassName.match(pattern))
elements.push(Element.extend(child));
}
return elements;
};

/*--------------------------------------------------------------------------*/

if (!window.Element) var Element ={};

Element.extend = function(element){
var F = Prototype.BrowserFeatures;
if (!element || !element.tagName || element.nodeType == 3 ||
 element._extended || F.SpecificElementExtensions || element == window)
return element;

var methods ={},tagName = element.tagName,cache = Element.extend.cache,
 T = Element.Methods.ByTag;

// extend methods for all tags (Safari doesn't need this)
if (!F.ElementExtensions){
Object.extend(methods,Element.Methods),
Object.extend(methods,Element.Methods.Simulated);
}

// extend methods for specific tags
if (T[tagName]) Object.extend(methods,T[tagName]);

for (var property in methods){
var value = methods[property];
if (typeof value == 'function' && !(property in element))
element[property] = cache.findOrStore(value);
}

element._extended = Prototype.emptyFunction;
return element;
};

Element.extend.cache ={
findOrStore:function(value){
return this[value] = this[value] || function(){
return value.apply(null,[this].concat($A(arguments)));
}
}
};

Element.Methods ={
visible:function(element){
return $(element).style.display != 'none';
},

toggle:function(element){
element = $(element);
Element[Element.visible(element) ? 'hide':'show'](element);
return element;
},

hide:function(element){
$(element).style.display = 'none';
return element;
},

show:function(element){
$(element).style.display = '';
return element;
},

remove:function(element){
element = $(element);
element.parentNode.removeChild(element);
return element;
},

update:function(element,html){
html = typeof html == 'undefined' ? '':html.toString();
$(element).innerHTML = html.stripScripts();
setTimeout(function(){html.evalScripts()},10);
return element;
},

replace:function(element,html){
element = $(element);
html = typeof html == 'undefined' ? '':html.toString();
if (element.outerHTML){
element.outerHTML = html.stripScripts();
} else{
var range = element.ownerDocument.createRange();
range.selectNodeContents(element);
element.parentNode.replaceChild(
range.createContextualFragment(html.stripScripts()),element);
}
setTimeout(function(){html.evalScripts()},10);
return element;
},

inspect:function(element){
element = $(element);
var result = '<' + element.tagName.toLowerCase();
$H({'id':'id','className':'class'}).each(function(pair){
var property = pair.first(),attribute = pair.last();
var value = (element[property] || '').toString();
if (value) result += ' ' + attribute + '=' + value.inspect(true);
});
return result + '>';
},

recursivelyCollect:function(element,property){
element = $(element);
var elements = [];
while (element = element[property])
if (element.nodeType == 1)
elements.push(Element.extend(element));
return elements;
},

ancestors:function(element){
return $(element).recursivelyCollect('parentNode');
},

descendants:function(element){
return $A($(element).getElementsByTagName('*')).each(Element.extend);
},

firstDescendant:function(element){
element = $(element).firstChild;
while (element && element.nodeType != 1) element = element.nextSibling;
return $(element);
},

immediateDescendants:function(element){
if (!(element = $(element).firstChild)) return [];
while (element && element.nodeType != 1) element = element.nextSibling;
if (element) return [element].concat($(element).nextSiblings());
return [];
},

previousSiblings:function(element){
return $(element).recursivelyCollect('previousSibling');
},

nextSiblings:function(element){
return $(element).recursivelyCollect('nextSibling');
},

siblings:function(element){
element = $(element);
return element.previousSiblings().reverse().concat(element.nextSiblings());
},

match:function(element,selector){
if (typeof selector == 'string')
selector = new Selector(selector);
return selector.match($(element));
},

up:function(element,expression,index){
element = $(element);
if (arguments.length == 1) return $(element.parentNode);
var ancestors = element.ancestors();
return expression ? Selector.findElement(ancestors,expression,index):
ancestors[index || 0];
},

down:function(element,expression,index){
element = $(element);
if (arguments.length == 1) return element.firstDescendant();
var descendants = element.descendants();
return expression ? Selector.findElement(descendants,expression,index):
descendants[index || 0];
},

previous:function(element,expression,index){
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
var previousSiblings = element.previousSiblings();
return expression ? Selector.findElement(previousSiblings,expression,index):
previousSiblings[index || 0];
},

next:function(element,expression,index){
element = $(element);
if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
var nextSiblings = element.nextSiblings();
return expression ? Selector.findElement(nextSiblings,expression,index):
nextSiblings[index || 0];
},

getElementsBySelector:function(){
var args = $A(arguments),element = $(args.shift());
return Selector.findChildElements(element,args);
},

getElementsByClassName:function(element,className){
return document.getElementsByClassName(className,element);
},

readAttribute:function(element,name){
element = $(element);
if (Prototype.Browser.IE){
if (!element.attributes) return null;
var t = Element._attributeTranslations;
if (t.values[name]) return t.values[name](element,name);
if (t.names[name])name = t.names[name];
var attribute = element.attributes[name];
return attribute ? attribute.nodeValue:null;
}
return element.getAttribute(name);
},

getHeight:function(element){
return $(element).getDimensions().height;
},

getWidth:function(element){
return $(element).getDimensions().width;
},

classNames:function(element){
return new Element.ClassNames(element);
},

hasClassName:function(element,className){
if (!(element = $(element))) return;
var elementClassName = element.className;
if (elementClassName.length == 0) return false;
if (elementClassName == className ||
elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
return true;
return false;
},

addClassName:function(element,className){
if (!(element = $(element))) return;
Element.classNames(element).add(className);
return element;
},

removeClassName:function(element,className){
if (!(element = $(element))) return;
Element.classNames(element).remove(className);
return element;
},

toggleClassName:function(element,className){
if (!(element = $(element))) return;
Element.classNames(element)[element.hasClassName(className) ? 'remove':'add'](className);
return element;
},

observe:function(){
Event.observe.apply(Event,arguments);
return $A(arguments).first();
},

stopObserving:function(){
Event.stopObserving.apply(Event,arguments);
return $A(arguments).first();
},

// removes whitespace-only text node children
cleanWhitespace:function(element){
element = $(element);
var node = element.firstChild;
while (node){
var nextNode = node.nextSibling;
if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
element.removeChild(node);
node = nextNode;
}
return element;
},

empty:function(element){
return $(element).innerHTML.blank();
},

descendantOf:function(element,ancestor){
element = $(element),ancestor = $(ancestor);
while (element = element.parentNode)
if (element == ancestor) return true;
return false;
},

scrollTo:function(element){
element = $(element);
var pos = Position.cumulativeOffset(element);
window.scrollTo(pos[0],pos[1]);
return element;
},

getStyle:function(element,style){
element = $(element);
style = style == 'float' ? 'cssFloat':style.camelize();
var value = element.style[style];
if (!value){
var css = document.defaultView.getComputedStyle(element,null);
value = css ? css[style]:null;
}
if (style == 'opacity') return value ? parseFloat(value):1.0;
return value == 'auto' ? null:value;
},

getOpacity:function(element){
return $(element).getStyle('opacity');
},

setStyle:function(element,styles,camelized){
element = $(element);
var elementStyle = element.style;

for (var property in styles)
if (property == 'opacity') element.setOpacity(styles[property])
else
elementStyle[(property == 'float' || property == 'cssFloat') ?
(elementStyle.styleFloat === undefined ? 'cssFloat':'styleFloat'):
(camelized ? property:property.camelize())] = styles[property];

return element;
},

setOpacity:function(element,value){
element = $(element);
element.style.opacity = (value == 1 || value === '') ? '':
(value < 0.00001) ? 0:value;
return element;
},

getDimensions:function(element){
element = $(element);
var display = $(element).getStyle('display');
if (display != 'none' && display != null) // Safari bug
return{width:element.offsetWidth,height:element.offsetHeight};

// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return{width:originalWidth,height:originalHeight};
},

makePositioned:function(element){
element = $(element);
var pos = Element.getStyle(element,'position');
if (pos == 'static' || !pos){
element._madePositioned = true;
element.style.position = 'relative';
// Opera returns the offset relative to the positioning context,when an
// element is position relative but top and left have not been defined
if (window.opera){
element.style.top = 0;
element.style.left = 0;
}
}
return element;
},

undoPositioned:function(element){
element = $(element);
if (element._madePositioned){
element._madePositioned = undefined;
element.style.position =
element.style.top =
element.style.left =
element.style.bottom =
element.style.right = '';
}
return element;
},

makeClipping:function(element){
element = $(element);
if (element._overflow) return element;
element._overflow = element.style.overflow || 'auto';
if ((Element.getStyle(element,'overflow') || 'visible') != 'hidden')
element.style.overflow = 'hidden';
return element;
},

undoClipping:function(element){
element = $(element);
if (!element._overflow) return element;
element.style.overflow = element._overflow == 'auto' ? '':element._overflow;
element._overflow = null;
return element;
}
};

Object.extend(Element.Methods,{
childOf:Element.Methods.descendantOf,
childElements:Element.Methods.immediateDescendants
});

if (Prototype.Browser.Opera){
Element.Methods._getStyle = Element.Methods.getStyle;
Element.Methods.getStyle = function(element,style){
switch(style){
case 'left':
case 'top':
case 'right':
case 'bottom':
if (Element._getStyle(element,'position') == 'static') return null;
default:return Element._getStyle(element,style);
}
};
}
else if (Prototype.Browser.IE){
Element.Methods.getStyle = function(element,style){
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat':style.camelize();
var value = element.style[style];
if (!value && element.currentStyle) value = element.currentStyle[style];

if (style == 'opacity'){
if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
if (value[1]) return parseFloat(value[1]) / 100;
return 1.0;
}

if (value == 'auto'){
if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
return element['offset'+style.capitalize()] + 'px';
return null;
}
return value;
};

Element.Methods.setOpacity = function(element,value){
element = $(element);
var filter = element.getStyle('filter'),style = element.style;
if (value == 1 || value === ''){
style.filter = filter.replace(/alpha\([^\)]*\)/gi,'');
return element;
} else if (value < 0.00001) value = 0;
style.filter = filter.replace(/alpha\([^\)]*\)/gi,'') +
'alpha(opacity=' + (value * 100) + ')';
return element;
};

// IE is missing .innerHTML support for TABLE-related elements
Element.Methods.update = function(element,html){
element = $(element);
html = typeof html == 'undefined' ? '':html.toString();
var tagName = element.tagName.toUpperCase();
if (['THEAD','TBODY','TR','TD'].include(tagName)){
var div = document.createElement('div');
switch (tagName){
case 'THEAD':
case 'TBODY':
div.innerHTML = '<table><tbody>' +html.stripScripts() + '</tbody></table>';
depth = 2;
break;
case 'TR':
div.innerHTML = '<table><tbody><tr>' +html.stripScripts() + '</tr></tbody></table>';
depth = 3;
break;
case 'TD':
div.innerHTML = '<table><tbody><tr><td>' +html.stripScripts() + '</td></tr></tbody></table>';
depth = 4;
}
$A(element.childNodes).each(function(node){ element.removeChild(node) });
depth.times(function(){ div = div.firstChild });
$A(div.childNodes).each(function(node){ element.appendChild(node) });
} else{
element.innerHTML = html.stripScripts();
}
setTimeout(function(){ html.evalScripts() },10);
return element;
}
}
else if (Prototype.Browser.Gecko){
Element.Methods.setOpacity = function(element,value){
element = $(element);
element.style.opacity = (value == 1) ? 0.999999:
(value === '') ? '':(value < 0.00001) ? 0:value;
return element;
};
}

Element._attributeTranslations ={
names:{
colspan:"colSpan",
rowspan:"rowSpan",
valign:"vAlign",
datetime:"dateTime",
accesskey:"accessKey",
tabindex:"tabIndex",
enctype:"encType",
maxlength:"maxLength",
readonly:"readOnly",
longdesc:"longDesc"
},
values:{
_getAttr:function(element,attribute){
return element.getAttribute(attribute,2);
},
_flag:function(element,attribute){
return $(element).hasAttribute(attribute) ? attribute:null;
},
style:function(element){
return element.style.cssText.toLowerCase();
},
title:function(element){
var node = element.getAttributeNode('title');
return node.specified ? node.nodeValue:null;
}
}
};

(function(){
Object.extend(this,{
href:this._getAttr,
src:this._getAttr,
type:this._getAttr,
disabled:this._flag,
checked:this._flag,
readonly:this._flag,
multiple:this._flag
});
}).call(Element._attributeTranslations.values);

Element.Methods.Simulated ={
hasAttribute:function(element,attribute){
var t = Element._attributeTranslations,node;
attribute = t.names[attribute] || attribute;
node = $(element).getAttributeNode(attribute);
return node && node.specified;
}
};

Element.Methods.ByTag ={};

Object.extend(Element,Element.Methods);

if (!Prototype.BrowserFeatures.ElementExtensions &&
 document.createElement('div').__proto__){
window.HTMLElement ={};
window.HTMLElement.prototype = document.createElement('div').__proto__;
Prototype.BrowserFeatures.ElementExtensions = true;
}

Element.hasAttribute = function(element,attribute){
if (element.hasAttribute) return element.hasAttribute(attribute);
return Element.Methods.Simulated.hasAttribute(element,attribute);
};

Element.addMethods = function(methods){
var F = Prototype.BrowserFeatures,T = Element.Methods.ByTag;

if (!methods){
Object.extend(Form,Form.Methods);
Object.extend(Form.Element,Form.Element.Methods);
Object.extend(Element.Methods.ByTag,{
"FORM":Object.clone(Form.Methods),
"INPUT":Object.clone(Form.Element.Methods),
"SELECT":Object.clone(Form.Element.Methods),
"TEXTAREA":Object.clone(Form.Element.Methods)
});
}

if (arguments.length == 2){
var tagName = methods;
methods = arguments[1];
}

if (!tagName) Object.extend(Element.Methods,methods ||{});
else{
if (tagName.constructor == Array) tagName.each(extend);
else extend(tagName);
}

function extend(tagName){
tagName = tagName.toUpperCase();
if (!Element.Methods.ByTag[tagName])
Element.Methods.ByTag[tagName] ={};
Object.extend(Element.Methods.ByTag[tagName],methods);
}

function copy(methods,destination,onlyIfAbsent){
onlyIfAbsent = onlyIfAbsent || false;
var cache = Element.extend.cache;
for (var property in methods){
var value = methods[property];
if (!onlyIfAbsent || !(property in destination))
destination[property] = cache.findOrStore(value);
}
}

function findDOMClass(tagName){
var klass;
var trans ={
"OPTGROUP":"OptGroup","TEXTAREA":"TextArea","P":"Paragraph",
"FIELDSET":"FieldSet","UL":"UList","OL":"OList","DL":"DList",
"DIR":"Directory","H1":"Heading","H2":"Heading","H3":"Heading",
"H4":"Heading","H5":"Heading","H6":"Heading","Q":"Quote",
"INS":"Mod","DEL":"Mod","A":"Anchor","IMG":"Image","CAPTION":
"TableCaption","COL":"TableCol","COLGROUP":"TableCol","THEAD":
"TableSection","TFOOT":"TableSection","TBODY":"TableSection","TR":
"TableRow","TH":"TableCell","TD":"TableCell","FRAMESET":
"FrameSet","IFRAME":"IFrame"
};
if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName + 'Element';
if (window[klass]) return window[klass];
klass = 'HTML' + tagName.capitalize() + 'Element';
if (window[klass]) return window[klass];

window[klass] ={};
window[klass].prototype = document.createElement(tagName).__proto__;
return window[klass];
}

if (F.ElementExtensions){
copy(Element.Methods,HTMLElement.prototype);
copy(Element.Methods.Simulated,HTMLElement.prototype,true);
}

if (F.SpecificElementExtensions){
for (var tag in Element.Methods.ByTag){
var klass = findDOMClass(tag);
if (typeof klass == "undefined") continue;
copy(T[tag],klass.prototype);
}
}

Object.extend(Element,Element.Methods);
delete Element.ByTag;
};

var Toggle ={ display:Element.toggle };

/*--------------------------------------------------------------------------*/

Abstract.Insertion = function(adjacency){
this.adjacency = adjacency;
}

Abstract.Insertion.prototype ={
initialize:function(element,content){
this.element = $(element);
this.content = content.stripScripts();

if (this.adjacency && this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
} catch (e){
var tagName = this.element.tagName.toUpperCase();
if (['TBODY','TR'].include(tagName)){
this.insertContent(this.contentFromAnonymousTable());
} else{
throw e;
}
}
} else{
this.range = this.element.ownerDocument.createRange();
if (this.initializeRange) this.initializeRange();
this.insertContent([this.range.createContextualFragment(this.content)]);
}

setTimeout(function(){content.evalScripts()},10);
},

contentFromAnonymousTable:function(){
var div = document.createElement('div');
div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
return $A(div.childNodes[0].childNodes[0].childNodes);
}
}

var Insertion = new Object();

Insertion.Before = Class.create();
Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'),{
initializeRange:function(){
this.range.setStartBefore(this.element);
},

insertContent:function(fragments){
fragments.each((function(fragment){
this.element.parentNode.insertBefore(fragment,this.element);
}).bind(this));
}
});

Insertion.Top = Class.create();
Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'),{
initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},

insertContent:function(fragments){
fragments.reverse(false).each((function(fragment){
this.element.insertBefore(fragment,this.element.firstChild);
}).bind(this));
}
});

Insertion.Bottom = Class.create();
Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'),{
initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},

insertContent:function(fragments){
fragments.each((function(fragment){
this.element.appendChild(fragment);
}).bind(this));
}
});

Insertion.After = Class.create();
Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'),{
initializeRange:function(){
this.range.setStartAfter(this.element);
},

insertContent:function(fragments){
fragments.each((function(fragment){
this.element.parentNode.insertBefore(fragment,
this.element.nextSibling);
}).bind(this));
}
});

/*--------------------------------------------------------------------------*/

Element.ClassNames = Class.create();
Element.ClassNames.prototype ={
initialize:function(element){
this.element = $(element);
},

_each:function(iterator){
this.element.className.split(/\s+/).select(function(name){
return name.length > 0;
})._each(iterator);
},

set:function(className){
this.element.className = className;
},

add:function(classNameToAdd){
if (this.include(classNameToAdd)) return;
this.set($A(this).concat(classNameToAdd).join(' '));
},

remove:function(classNameToRemove){
if (!this.include(classNameToRemove)) return;
this.set($A(this).without(classNameToRemove).join(' '));
},

toString:function(){
return $A(this).join(' ');
}
};

Object.extend(Element.ClassNames.prototype,Enumerable);
/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
 * part of YUI-Ext version 0.40,distributed under the terms of an MIT-style
 * license.Please see http://www.yui-ext.com/ for more information. */

var Selector = Class.create();

Selector.prototype ={
initialize:function(expression){
this.expression = expression.strip();
this.compileMatcher();
},

compileMatcher:function(){
// Selectors with namespaced attributes can't use the XPath version
if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression))
return this.compileXPathMatcher();

var e = this.expression,ps = Selector.patterns,h = Selector.handlers,
c = Selector.criteria,le,p,m;

if (Selector._cache[e]){
this.matcher = Selector._cache[e];return;
}
this.matcher = ["this.matcher = function(root){",
"var r = root,h = Selector.handlers,c = false,n;"];

while (e && le != e && (/\S/).test(e)){
le = e;
for (var i in ps){
p = ps[i];
if (m = e.match(p)){
this.matcher.push(typeof c[i] == 'function' ? c[i](m):
new Template(c[i]).evaluate(m));
e = e.replace(m[0],'');
break;
}
}
}

this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join('\n'));
Selector._cache[this.expression] = this.matcher;
},

compileXPathMatcher:function(){
var e = this.expression,ps = Selector.patterns,
x = Selector.xpath,le,m;

if (Selector._cache[e]){
this.xpath = Selector._cache[e];return;
}

this.matcher = ['.//*'];
while (e && le != e && (/\S/).test(e)){
le = e;
for (var i in ps){
if (m = e.match(ps[i])){
this.matcher.push(typeof x[i] == 'function' ? x[i](m):
new Template(x[i]).evaluate(m));
e = e.replace(m[0],'');
break;
}
}
}

this.xpath = this.matcher.join('');
Selector._cache[this.expression] = this.xpath;
},

findElements:function(root){
root = root || document;
if (this.xpath) return document._getElementsByXPath(this.xpath,root);
return this.matcher(root);
},

match:function(element){
return this.findElements(document).include(element);
},

toString:function(){
return this.expression;
},

inspect:function(){
return "#<Selector:" + this.expression.inspect() + ">";
}
};

Object.extend(Selector,{
_cache:{},

xpath:{
descendant:"//*",
child:"/*",
adjacent:"/following-sibling::*[1]",
laterSibling:'/following-sibling::*',
tagName:function(m){
if (m[1] == '*') return '';
return "[local-name()='" + m[1].toLowerCase() +
 "' or local-name()='" + m[1].toUpperCase() + "']";
},
className:"[contains(concat(' ',@class,' '),' #{1} ')]",
id:"[@id='#{1}']",
attrPresence:"[@#{1}]",
attr:function(m){
m[3] = m[5] || m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},
pseudo:function(m){
var h = Selector.xpath.pseudos[m[1]];
if (!h) return '';
if (typeof h === 'function') return h(m);
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},
operators:{
'=':"[@#{1}='#{3}']",
'!=':"[@#{1}!='#{3}']",
'^=':"[starts-with(@#{1},'#{3}')]",
'$=':"[substring(@#{1},(string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
'*=':"[contains(@#{1},'#{3}')]",
'~=':"[contains(concat(' ',@#{1},' '),' #{3} ')]",
'|=':"[contains(concat('-',@#{1},'-'),'-#{3}-')]"
},
pseudos:{
'first-child':'[not(preceding-sibling::*)]',
'last-child':'[not(following-sibling::*)]',
'only-child':'[not(preceding-sibling::* or following-sibling::*)]',
'empty':"[count(*) = 0 and (count(text()) = 0 or translate(text(),' \t\r\n','') = '')]",
'checked':"[@checked]",
'disabled':"[@disabled]",
'enabled':"[not(@disabled)]",
'not':function(m){
var e = m[6],p = Selector.patterns,
x = Selector.xpath,le,m,v;

var exclusion = [];
while (e && le != e && (/\S/).test(e)){
le = e;
for (var i in p){
if (m = e.match(p[i])){
v = typeof x[i] == 'function' ? x[i](m):new Template(x[i]).evaluate(m);
exclusion.push("(" + v.substring(1,v.length - 1) + ")");
e = e.replace(m[0],'');
break;
}
}
}
return "[not(" + exclusion.join(" and ") + ")]";
},
'nth-child':function(m){
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m);
},
'nth-last-child':function(m){
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m);
},
'nth-of-type':function(m){
return Selector.xpath.pseudos.nth("position() ",m);
},
'nth-last-of-type':function(m){
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m);
},
'first-of-type':function(m){
m[6] = "1";return Selector.xpath.pseudos['nth-of-type'](m);
},
'last-of-type':function(m){
m[6] = "1";return Selector.xpath.pseudos['nth-last-of-type'](m);
},
'only-of-type':function(m){
var p = Selector.xpath.pseudos;return p['first-of-type'](m) + p['last-of-type'](m);
},
nth:function(fragment,m){
var mm,formula = m[6],predicate;
if (formula == 'even') formula = '2n+0';
if (formula == 'odd')formula = '2n+1';
if (mm = formula.match(/^(\d+)$/)) // digit only
return '[' + fragment + "= " + mm[1] + ']';
if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){ // an+b
if (mm[1] == "-") mm[1] = -1;
var a = mm[1] ? Number(mm[1]):1;
var b = mm[2] ? Number(mm[2]):0;
predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({
fragment:fragment,a:a,b:b });
}
}
}
},

criteria:{
tagName:'n = h.tagName(n,r,"#{1}",c);c = false;',
className:'n = h.className(n,r,"#{1}",c);c = false;',
id:'n = h.id(n,r,"#{1}",c);c = false;',
attrPresence:'n = h.attrPresence(n,r,"#{1}");c = false;',
attr:function(m){
m[3] = (m[5] || m[6]);
return new Template('n = h.attr(n,r,"#{1}","#{3}","#{2}");c = false;').evaluate(m);
},
pseudo:function(m){
if (m[6]) m[6] = m[6].replace(/"/g,'\\"');
return new Template('n = h.pseudo(n,"#{1}","#{6}",r,c);c = false;').evaluate(m);
},
descendant:'c = "descendant";',
child:'c = "child";',
adjacent:'c = "adjacent";',
laterSibling:'c = "laterSibling";'
},

patterns:{
// combinators must be listed first
// (and descendant needs to be last combinator)
laterSibling:/^\s*~\s*/,
child:/^\s*>\s*/,
adjacent:/^\s*\+\s*/,
descendant:/^\s/,

// selectors follow
tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,
id:/^#([\w\-\*]+)(\b|$)/,
className:/^\.([\w\-\*]+)(\b|$)/,
pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,
attrPresence:/^\[([\w]+)\]/,
attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/
},

handlers:{
// UTILITY FUNCTIONS
// joins two collections
concat:function(a,b){
for (var i = 0,node;node = b[i];i++)
a.push(node);
return a;
},

// marks an array of nodes for counting
mark:function(nodes){
for (var i = 0,node;node = nodes[i];i++)
node._counted = true;
return nodes;
},

unmark:function(nodes){
for (var i = 0,node;node = nodes[i];i++)
node._counted = undefined;
return nodes;
},

// mark each child node with its position (for nth calls)
// "ofType" flag indicates whether we're indexing for nth-of-type
// rather than nth-child
index:function(parentNode,reverse,ofType){
parentNode._counted = true;
if (reverse){
for (var nodes = parentNode.childNodes,i = nodes.length - 1,j = 1;i >= 0;i--){
node = nodes[i];
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
} else{
for (var i = 0,j = 1,nodes = parentNode.childNodes;node = nodes[i];i++)
if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
}
},

// filters out duplicates and extends all nodes
unique:function(nodes){
if (nodes.length == 0) return nodes;
var results = [],n;
for (var i = 0,l = nodes.length;i < l;i++)
if (!(n = nodes[i])._counted){
n._counted = true;
results.push(Element.extend(n));
}
return Selector.handlers.unmark(results);
},

// COMBINATOR FUNCTIONS
descendant:function(nodes){
var h = Selector.handlers;
for (var i = 0,results = [],node;node = nodes[i];i++)
h.concat(results,node.getElementsByTagName('*'));
return results;
},

child:function(nodes){
var h = Selector.handlers;
for (var i = 0,results = [],node;node = nodes[i];i++){
for (var j = 0,children = [],child;child = node.childNodes[j];j++)
if (child.nodeType == 1 && child.tagName != '!') results.push(child);
}
return results;
},

adjacent:function(nodes){
for (var i = 0,results = [],node;node = nodes[i];i++){
var next = this.nextElementSibling(node);
if (next) results.push(next);
}
return results;
},

laterSibling:function(nodes){
var h = Selector.handlers;
for (var i = 0,results = [],node;node = nodes[i];i++)
h.concat(results,Element.nextSiblings(node));
return results;
},

nextElementSibling:function(node){
while (node = node.nextSibling)
if (node.nodeType == 1) return node;
return null;
},

previousElementSibling:function(node){
while (node = node.previousSibling)
if (node.nodeType == 1) return node;
return null;
},

// TOKEN FUNCTIONS
tagName:function(nodes,root,tagName,combinator){
tagName = tagName.toUpperCase();
var results = [],h = Selector.handlers;
if (nodes){
if (combinator){
// fastlane for ordinary descendant combinators
if (combinator == "descendant"){
for (var i = 0,node;node = nodes[i];i++)
h.concat(results,node.getElementsByTagName(tagName));
return results;
} else nodes = this[combinator](nodes);
if (tagName == "*") return nodes;
}
for (var i = 0,node;node = nodes[i];i++)
if (node.tagName.toUpperCase() == tagName) results.push(node);
return results;
} else return root.getElementsByTagName(tagName);
},

id:function(nodes,root,id,combinator){
var targetNode = $(id),h = Selector.handlers;
if (!nodes && root == document) return targetNode ? [targetNode]:[];
if (nodes){
if (combinator){
if (combinator == 'child'){
for (var i = 0,node;node = nodes[i];i++)
if (targetNode.parentNode == node) return [targetNode];
} else if (combinator == 'descendant'){
for (var i = 0,node;node = nodes[i];i++)
if (Element.descendantOf(targetNode,node)) return [targetNode];
} else if (combinator == 'adjacent'){
for (var i = 0,node;node = nodes[i];i++)
if (Selector.handlers.previousElementSibling(targetNode) == node)
return [targetNode];
} else nodes = h[combinator](nodes);
}
for (var i = 0,node;node = nodes[i];i++)
if (node == targetNode) return [targetNode];
return [];
}
return (targetNode && Element.descendantOf(targetNode,root)) ? [targetNode]:[];
},

className:function(nodes,root,className,combinator){
if (nodes && combinator) nodes = this[combinator](nodes);
return Selector.handlers.byClassName(nodes,root,className);
},

byClassName:function(nodes,root,className){
if (!nodes) nodes = Selector.handlers.descendant([root]);
var needle = ' ' + className + ' ';
for (var i = 0,results = [],node,nodeClassName;node = nodes[i];i++){
nodeClassName = node.className;
if (nodeClassName.length == 0) continue;
if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
results.push(node);
}
return results;
},

attrPresence:function(nodes,root,attr){
var results = [];
for (var i = 0,node;node = nodes[i];i++)
if (Element.hasAttribute(node,attr)) results.push(node);
return results;
},

attr:function(nodes,root,attr,value,operator){
if (!nodes) nodes = root.getElementsByTagName("*");
var handler = Selector.operators[operator],results = [];
for (var i = 0,node;node = nodes[i];i++){
var nodeValue = Element.readAttribute(node,attr);
if (nodeValue === null) continue;
if (handler(nodeValue,value)) results.push(node);
}
return results;
},

pseudo:function(nodes,name,value,root,combinator){
if (nodes && combinator) nodes = this[combinator](nodes);
if (!nodes) nodes = root.getElementsByTagName("*");
return Selector.pseudos[name](nodes,value,root);
}
},

pseudos:{
'first-child':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++){
if (Selector.handlers.previousElementSibling(node)) continue;
results.push(node);
}
return results;
},
'last-child':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++){
if (Selector.handlers.nextElementSibling(node)) continue;
results.push(node);
}
return results;
},
'only-child':function(nodes,value,root){
var h = Selector.handlers;
for (var i = 0,results = [],node;node = nodes[i];i++)
if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
results.push(node);
return results;
},
'nth-child':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,formula,root);
},
'nth-last-child':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,formula,root,true);
},
'nth-of-type':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,formula,root,false,true);
},
'nth-last-of-type':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,formula,root,true,true);
},
'first-of-type':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,"1",root,false,true);
},
'last-of-type':function(nodes,formula,root){
return Selector.pseudos.nth(nodes,"1",root,true,true);
},
'only-of-type':function(nodes,formula,root){
var p = Selector.pseudos;
return p['last-of-type'](p['first-of-type'](nodes,formula,root),formula,root);
},

// handles the an+b logic
getIndices:function(a,b,total){
if (a == 0) return b > 0 ? [b]:[];
return $R(1,total).inject([],function(memo,i){
if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
return memo;
});
},

// handles nth(-last)-child,nth(-last)-of-type,and (first|last)-of-type
nth:function(nodes,formula,root,reverse,ofType){
if (nodes.length == 0) return [];
if (formula == 'even') formula = '2n+0';
if (formula == 'odd')formula = '2n+1';
var h = Selector.handlers,results = [],indexed = [],m;
h.mark(nodes);
for (var i = 0,node;node = nodes[i];i++){
if (!node.parentNode._counted){
h.index(node.parentNode,reverse,ofType);
indexed.push(node.parentNode);
}
}
if (formula.match(/^\d+$/)){ // just a number
formula = Number(formula);
for (var i = 0,node;node = nodes[i];i++)
if (node.nodeIndex == formula) results.push(node);
} else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){ // an+b
if (m[1] == "-") m[1] = -1;
var a = m[1] ? Number(m[1]):1;
var b = m[2] ? Number(m[2]):0;
var indices = Selector.pseudos.getIndices(a,b,nodes.length);
for (var i = 0,node,l = indices.length;node = nodes[i];i++){
for (var j = 0;j < l;j++)
if (node.nodeIndex == indices[j]) results.push(node);
}
}
h.unmark(nodes);
h.unmark(indexed);
return results;
},

'empty':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++){
// IE treats comments as element nodes
if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
results.push(node);
}
return results;
},

'not':function(nodes,selector,root){
var h = Selector.handlers,selectorType,m;
var exclusions = new Selector(selector).findElements(root);
h.mark(exclusions);
for (var i = 0,results = [],node;node = nodes[i];i++)
if (!node._counted) results.push(node);
h.unmark(exclusions);
return results;
},

'enabled':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++)
if (!node.disabled) results.push(node);
return results;
},

'disabled':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++)
if (node.disabled) results.push(node);
return results;
},

'checked':function(nodes,value,root){
for (var i = 0,results = [],node;node = nodes[i];i++)
if (node.checked) results.push(node);
return results;
}
},

operators:{
'=':function(nv,v){ return nv == v},
'!=':function(nv,v){ return nv != v},
'^=':function(nv,v){ return nv.startsWith(v)},
'$=':function(nv,v){ return nv.endsWith(v)},
'*=':function(nv,v){ return nv.include(v)},
'~=':function(nv,v){ return (' ' + nv + ' ').include(' ' + v + ' ')},
'|=':function(nv,v){ return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-')}
},

matchElements:function(elements,expression){
var matches = new Selector(expression).findElements(),h = Selector.handlers;
h.mark(matches);
for (var i = 0,results = [],element;element = elements[i];i++)
if (element._counted) results.push(element);
h.unmark(matches);
return results;
},

findElement:function(elements,expression,index){
if (typeof expression == 'number'){
index = expression;expression = false;
}
return Selector.matchElements(elements,expression || '*')[index || 0];
},

findChildElements:function(element,expressions){
var exprs = expressions.join(','),expressions = [];
exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){
expressions.push(m[1].strip());
});
var results = [],h = Selector.handlers;
for (var i = 0,l = expressions.length,selector;i < l;i++){
selector = new Selector(expressions[i].strip());
h.concat(results,selector.findElements(element));
}
return (l > 1) ? h.unique(results):results;
}
});

function $$(){
return Selector.findChildElements(document,$A(arguments));
}
var Form ={
reset:function(form){
$(form).reset();
return form;
},

serializeElements:function(elements,getHash){
var data = elements.inject({},function(result,element){
if (!element.disabled && element.name){
var key = element.name,value = $(element).getValue();
if (value != null){
 if (key in result){
if (result[key].constructor != Array) result[key] = [result[key]];
result[key].push(value);
}
else result[key] = value;
}
}
return result;
});

return getHash ? data:Hash.toQueryString(data);
}
};

Form.Methods ={
serialize:function(form,getHash){
return Form.serializeElements(Form.getElements(form),getHash);
},

getElements:function(form){
return $A($(form).getElementsByTagName('*')).inject([],
function(elements,child){
if (Form.Element.Serializers[child.tagName.toLowerCase()])
elements.push(Element.extend(child));
return elements;
}
);
},

getInputs:function(form,typeName,name){
form = $(form);
var inputs = form.getElementsByTagName('input');

if (!typeName && !name) return $A(inputs).map(Element.extend);

for (var i = 0,matchingInputs = [],length = inputs.length;i < length;i++){
var input = inputs[i];
if ((typeName && input.type != typeName) || (name && input.name != name))
continue;
matchingInputs.push(Element.extend(input));
}

return matchingInputs;
},

disable:function(form){
form = $(form);
Form.getElements(form).invoke('disable');
return form;
},

enable:function(form){
form = $(form);
Form.getElements(form).invoke('enable');
return form;
},

findFirstElement:function(form){
return $(form).getElements().find(function(element){
return element.type != 'hidden' && !element.disabled &&
['input','select','textarea'].include(element.tagName.toLowerCase());
});
},

focusFirstElement:function(form){
form = $(form);
form.findFirstElement().activate();
return form;
},

request:function(form,options){
form = $(form),options = Object.clone(options ||{});

var params = options.parameters;
options.parameters = form.serialize(true);

if (params){
if (typeof params == 'string') params = params.toQueryParams();
Object.extend(options.parameters,params);
}

if (form.hasAttribute('method') && !options.method)
options.method = form.method;

return new Ajax.Request(form.readAttribute('action'),options);
}
}

/*--------------------------------------------------------------------------*/

Form.Element ={
focus:function(element){
$(element).focus();
return element;
},

select:function(element){
$(element).select();
return element;
}
}

Form.Element.Methods ={
serialize:function(element){
element = $(element);
if (!element.disabled && element.name){
var value = element.getValue();
if (value != undefined){
var pair ={};
pair[element.name] = value;
return Hash.toQueryString(pair);
}
}
return '';
},

getValue:function(element){
element = $(element);
var method = element.tagName.toLowerCase();
return Form.Element.Serializers[method](element);
},

clear:function(element){
$(element).value = '';
return element;
},

present:function(element){
return $(element).value != '';
},

activate:function(element){
element = $(element);
try{
element.focus();
if (element.select && (element.tagName.toLowerCase() != 'input' ||
!['button','reset','submit'].include(element.type)))
element.select();
} catch (e){}
return element;
},

disable:function(element){
element = $(element);
element.blur();
element.disabled = true;
return element;
},

enable:function(element){
element = $(element);
element.disabled = false;
return element;
}
}

/*--------------------------------------------------------------------------*/

var Field = Form.Element;
var $F = Form.Element.Methods.getValue;

/*--------------------------------------------------------------------------*/

Form.Element.Serializers ={
input:function(element){
switch (element.type.toLowerCase()){
case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element);
default:
return Form.Element.Serializers.textarea(element);
}
},

inputSelector:function(element){
return element.checked ? element.value:null;
},

textarea:function(element){
return element.value;
},

select:function(element){
return this[element.type == 'select-one' ?
'selectOne':'selectMany'](element);
},

selectOne:function(element){
var index = element.selectedIndex;
return index >= 0 ? this.optionValue(element.options[index]):null;
},

selectMany:function(element){
var values,length = element.length;
if (!length) return null;

for (var i = 0,values = [];i < length;i++){
var opt = element.options[i];
if (opt.selected) values.push(this.optionValue(opt));
}
return values;
},

optionValue:function(opt){
// extend element because hasAttribute may not be native
return Element.extend(opt).hasAttribute('value') ? opt.value:opt.text;
}
}

/*--------------------------------------------------------------------------*/

Abstract.TimedObserver = function(){}
Abstract.TimedObserver.prototype ={
initialize:function(element,frequency,callback){
this.frequency = frequency;
this.element = $(element);
this.callback= callback;

this.lastValue = this.getValue();
this.registerCallback();
},

registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency * 1000);
},

onTimerEvent:function(){
var value = this.getValue();
var changed = ('string' == typeof this.lastValue && 'string' == typeof value
? this.lastValue != value:String(this.lastValue) != String(value));
if (changed){
this.callback(this.element,value);
this.lastValue = value;
}
}
}

Form.Element.Observer = Class.create();
Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(),{
getValue:function(){
return Form.Element.getValue(this.element);
}
});

Form.Observer = Class.create();
Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(),{
getValue:function(){
return Form.serialize(this.element);
}
});

/*--------------------------------------------------------------------------*/

Abstract.EventObserver = function(){}
Abstract.EventObserver.prototype ={
initialize:function(element,callback){
this.element= $(element);
this.callback = callback;

this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},

onElementEvent:function(){
var value = this.getValue();
if (this.lastValue != value){
this.callback(this.element,value);
this.lastValue = value;
}
},

registerFormCallbacks:function(){
Form.getElements(this.element).each(this.registerCallback.bind(this));
},

registerCallback:function(element){
if (element.type){
switch (element.type.toLowerCase()){
case 'checkbox':
case 'radio':
Event.observe(element,'click',this.onElementEvent.bind(this));
break;
default:
Event.observe(element,'change',this.onElementEvent.bind(this));
break;
}
}
}
}

Form.Element.EventObserver = Class.create();
Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(),{
getValue:function(){
return Form.Element.getValue(this.element);
}
});

Form.EventObserver = Class.create();
Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(),{
getValue:function(){
return Form.serialize(this.element);
}
});
if (!window.Event){
var Event = new Object();
}

Object.extend(Event,{
KEY_BACKSPACE:8,
KEY_TAB:9,
KEY_RETURN:13,
KEY_ESC:27,
KEY_LEFT:37,
KEY_UP:38,
KEY_RIGHT:39,
KEY_DOWN:40,
KEY_DELETE:46,
KEY_HOME:36,
KEY_END:35,
KEY_PAGEUP:33,
KEY_PAGEDOWN:34,

element:function(event){
return $(event.target || event.srcElement);
},

isLeftClick:function(event){
return (((event.which) && (event.which == 1)) ||
((event.button) && (event.button == 1)));
},

pointerX:function(event){
return event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft));
},

pointerY:function(event){
return event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop));
},

stop:function(event){
if (event.preventDefault){
event.preventDefault();
event.stopPropagation();
} else{
event.returnValue = false;
event.cancelBubble = true;
}
},

// find the first node with the given tagName,starting from the
// node the event was triggered on;traverses the DOM upwards
findElement:function(event,tagName){
var element = Event.element(event);
while (element.parentNode && (!element.tagName ||
(element.tagName.toUpperCase() != tagName.toUpperCase())))
element = element.parentNode;
return element;
},

observers:false,

_observeAndCache:function(element,name,observer,useCapture){
if (!this.observers) this.observers = [];
if (element.addEventListener){
this.observers.push([element,name,observer,useCapture]);
element.addEventListener(name,observer,useCapture);
} else if (element.attachEvent){
this.observers.push([element,name,observer,useCapture]);
element.attachEvent('on' + name,observer);
}
},

unloadCache:function(){
if (!Event.observers) return;
for (var i = 0,length = Event.observers.length;i < length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0] = null;
}
Event.observers = false;
},

observe:function(element,name,observer,useCapture){
element = $(element);
useCapture = useCapture || false;

if (name == 'keypress' &&
(Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';

Event._observeAndCache(element,name,observer,useCapture);
},

stopObserving:function(element,name,observer,useCapture){
element = $(element);
useCapture = useCapture || false;

if (name == 'keypress' &&
(Prototype.Browser.WebKit || element.attachEvent))
name = 'keydown';

if (element.removeEventListener){
element.removeEventListener(name,observer,useCapture);
} else if (element.detachEvent){
try{
element.detachEvent('on' + name,observer);
} catch (e){}
}
}
});

/* prevent memory leaks in IE */
if (Prototype.Browser.IE)
Event.observe(window,'unload',Event.unloadCache,false);
var Position ={
// set to true if needed,warning:firefox performance problems
// NOT neeeded for page scrolling,only if draggable contained in
// scrollable elements
includeScrollOffsets:false,

// must be called before calling withinIncludingScrolloffset,every time the
// page is scrolled
prepare:function(){
this.deltaX =window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY =window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
},

realOffset:function(element){
var valueT = 0,valueL = 0;
do{
valueT += element.scrollTop|| 0;
valueL += element.scrollLeft || 0;
element = element.parentNode;
} while (element);
return [valueL,valueT];
},

cumulativeOffset:function(element){
var valueT = 0,valueL = 0;
do{
valueT += element.offsetTop|| 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return [valueL,valueT];
},

positionedOffset:function(element){
var valueT = 0,valueL = 0;
do{
valueT += element.offsetTop|| 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if (element){
if(element.tagName=='BODY') break;
var p = Element.getStyle(element,'position');
if (p == 'relative' || p == 'absolute') break;
}
} while (element);
return [valueL,valueT];
},

offsetParent:function(element){
if (element.offsetParent) return element.offsetParent;
if (element == document.body) return element;

while ((element = element.parentNode) && element != document.body)
if (Element.getStyle(element,'position') != 'static')
return element;

return document.body;
},

// caches x/y coordinate pair to use with overlap
within:function(element,x,y){
if (this.includeScrollOffsets)
return this.withinIncludingScrolloffsets(element,x,y);
this.xcomp = x;
this.ycomp = y;
this.offset = this.cumulativeOffset(element);

return (y >= this.offset[1] &&
y <this.offset[1] + element.offsetHeight &&
x >= this.offset[0] &&
x <this.offset[0] + element.offsetWidth);
},

withinIncludingScrolloffsets:function(element,x,y){
var offsetcache = this.realOffset(element);

this.xcomp = x + offsetcache[0] - this.deltaX;
this.ycomp = y + offsetcache[1] - this.deltaY;
this.offset = this.cumulativeOffset(element);

return (this.ycomp >= this.offset[1] &&
this.ycomp <this.offset[1] + element.offsetHeight &&
this.xcomp >= this.offset[0] &&
this.xcomp <this.offset[0] + element.offsetWidth);
},

// within must be called directly before
overlap:function(mode,element){
if (!mode) return 0;
if (mode == 'vertical')
return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
element.offsetHeight;
if (mode == 'horizontal')
return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
element.offsetWidth;
},

page:function(forElement){
var valueT = 0,valueL = 0;

var element = forElement;
do{
valueT += element.offsetTop|| 0;
valueL += element.offsetLeft || 0;

// Safari fix
if (element.offsetParent == document.body)
if (Element.getStyle(element,'position')=='absolute') break;

} while (element = element.offsetParent);

element = forElement;
do{
if (!window.opera || element.tagName=='BODY'){
valueT -= element.scrollTop|| 0;
valueL -= element.scrollLeft || 0;
}
} while (element = element.parentNode);

return [valueL,valueT];
},

clone:function(source,target){
var options = Object.extend({
setLeft:true,
setTop:true,
setWidth:true,
setHeight:true,
offsetTop:0,
offsetLeft:0
},arguments[2] ||{})

// find page position of source
source = $(source);
var p = Position.page(source);

// find coordinate system to use
target = $(target);
var delta = [0,0];
var parent = null;
// delta [0,0] will do fine with position:fixed elements,
// position:absolute needs offsetParent deltas
if (Element.getStyle(target,'position') == 'absolute'){
parent = Position.offsetParent(target);
delta = Position.page(parent);
}

// correct by body offsets (fixes Safari)
if (parent == document.body){
delta[0] -= document.body.offsetLeft;
delta[1] -= document.body.offsetTop;
}

// set position
if(options.setLeft) target.style.left= (p[0] - delta[0] + options.offsetLeft) + 'px';
if(options.setTop)target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
if(options.setWidth)target.style.width = source.offsetWidth + 'px';
if(options.setHeight) target.style.height = source.offsetHeight + 'px';
},

absolutize:function(element){
element = $(element);
if (element.style.position == 'absolute') return;
Position.prepare();

var offsets = Position.positionedOffset(element);
var top = offsets[1];
var left= offsets[0];
var width = element.clientWidth;
var height= element.clientHeight;

element._originalLeft = left - parseFloat(element.style.left|| 0);
element._originalTop= top- parseFloat(element.style.top || 0);
element._originalWidth= element.style.width;
element._originalHeight = element.style.height;

element.style.position = 'absolute';
element.style.top= top + 'px';
element.style.left = left + 'px';
element.style.width= width + 'px';
element.style.height = height + 'px';
},

relativize:function(element){
element = $(element);
if (element.style.position == 'relative') return;
Position.prepare();

element.style.position = 'relative';
var top= parseFloat(element.style.top|| 0) - (element._originalTop || 0);
var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);

element.style.top= top + 'px';
element.style.left = left + 'px';
element.style.height = element._originalHeight;
element.style.width= element._originalWidth;
}
}

// Safari returns margins on body which is incorrect if the child is absolutely
// positioned.For performance reasons,redefine Position.cumulativeOffset for
// KHTML/WebKit only.
if (Prototype.Browser.WebKit){
Position.cumulativeOffset = function(element){
var valueT = 0,valueL = 0;
do{
valueT += element.offsetTop|| 0;
valueL += element.offsetLeft || 0;
if (element.offsetParent == document.body)
if (Element.getStyle(element,'position') == 'absolute') break;

element = element.offsetParent;
} while (element);

return [valueL,valueT];
}
}

Element.addMethods();

function getAjaxResponse(myurl,divContent)
{
$(divContent).innerHTML = "<img src='/images/loading.gif'/> đang tải dữ liệu";
new Ajax.Request(myurl,
{
method:'get',
evalScripts:true,
//onFailure:function(transport)
onSuccess:function(transport)
{
var response = transport.responseText;
$(divContent).innerHTML = response;
 
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
//onSuccess:function(){ alert('Có lỗi xảy ra..')}
});
}
function getAjaxResponseNot(myurl,divContent)
{
new Ajax.Request(myurl,
{
method:'get',
evalScripts:true,
//onFailure:function(transport)
onSuccess:function(transport)
{
var response = transport.responseText;
$(divContent).innerHTML = response;
afterResponse();
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
//onSuccess:function(){ alert('Có lỗi xảy ra..')}
});
}
function getAjaxResponseNotAfterResponse(myurl,divContent,afterResponse)
{ 
new Ajax.Request(myurl,
{
method:'get',
evalScripts:true,
//onFailure:function(transport)
onSuccess:function(transport)
{
if(divContent != "")
{
var response = transport.responseText;
$(divContent).innerHTML = response;
}
setTimeout(afterResponse,1);
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
//onSuccess:function(){ alert('Có lỗi xảy ra..')}
});
}
function getAjaxResponseAfterResponse(myurl,divContent,afterResponse)
{
$(divContent).innerHTML = "<img src='/images/loading.gif'/> đang tải dữ liệu";
new Ajax.Request(myurl,
{
method:'get',
evalScripts:true,
//onFailure:function(transport)
onSuccess:function(transport)
{
var response = transport.responseText;
$(divContent).innerHTML = response;
setTimeout(afterResponse,1);
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
//onSuccess:function(){ alert('Có lỗi xảy ra..')}
});
}
function getAjaxResponseTest(myurl,divContent)
{
new Ajax.Request(myurl,
{
method:'get',
evalScripts:true,
onFailure:function(transport)
//onSuccess:function(transport)
{
var response = transport.responseText;
$(divContent).innerHTML = response;
 
},
//onFailure:function(){ alert('Có lỗi xảy ra..')}
onSuccess:function(){ alert('Có lỗi xảy ra..')}
});
}/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
Copyright (c) 2007-2008 Geoff Stearns,Michael Williams,and Bobby van der Sluis
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+"{"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";IH=AE;AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();var IH;function reSize(newWidth,newHeight){document.getElementById(IH).style.width = newWidth + 'px';document.getElementById(IH).style.height = newHeight + 'px'};

//v1.0
//Copyright 2006 Adobe Systems,Inc. All rights reserved.
function AC_AddExtension(src,ext)
{
if (src.indexOf('?') != -1)
return src.replace(/\?/,ext+'?');
else
return src + ext;
}

function AC_Generateobj(objAttrs,params,embedAttrs) 
{ 
var str = '<object ';
for (var i in objAttrs)
str += i + '="' + objAttrs[i] + '" ';
str += '>';
for (var i in params)
str += '<param name="' + i + '" value="' + params[i] + '" /> ';
str += '<embed ';
for (var i in embedAttrs)
str += i + '="' + embedAttrs[i] + '" ';
str += ' ></embed></object>';

document.write(str);
}

function AC_FL_RunContent(){
var ret = 
AC_GetArgs
(arguments,".swf","movie","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 ,"application/x-shockwave-flash"
);
AC_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs);
}

function AC_SW_RunContent(){
var ret = 
AC_GetArgs
(arguments,".dcr","src","clsid:166B1BCA-3F9C-11CF-8075-444553540000"
 ,null
);
AC_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs);
}

function AC_GetArgs(args,ext,srcParamName,classid,mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0;i < args.length;i=i+2){
var currArg = args[i].toLowerCase();

switch (currArg){
case "classid":
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
args[i+1] = AC_AddExtension(args[i+1],ext);
ret.embedAttrs["src"] = args[i+1];
ret.params[srcParamName] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblClick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
ret.objAttrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "id":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs["classid"] = classid;
if (mimeType) ret.embedAttrs["type"] = mimeType;
return ret;
}
function ShowMaNhungFLV(linkFLV)
{
showeditform();
}
function ShowMaNhungMP3(linkMp3,width1,height1)
{
showeditformMp3(linkMp3,width1,height1);
}

function showeditform()
{
showPopup('divMaNhung');
//var editform = document.getElementById('divMaNhung');
var objFilter=document.getElementById("bgFilter");
if (objFilter)
{
document.getElementById("bgFilter").style.display = 'block';
document.getElementById("bgFilter").style.zIndex = '5';
document.getElementById("bgFilter").style.height = document.getElementById('mainDivAfa').offsetHeight + 'px';
}
}

function hideeditform()
{
var _objdivMaNhung=document.getElementById('divMaNhung');
var _objbgFilter= document.getElementById("bgFilter");
if (_objdivMaNhung)
_objdivMaNhung.style.display = 'none';
if (_objbgFilter)
_objbgFilter.style.display = 'none';
}

function showPopup(controlID)
{
var control = document.getElementById(controlID);
if (control)
{
control.style.display = 'block';
control.style.zIndex = '100';
var top = (window.screen.availHeight - control.offsetHeight)/2 - 100;
var left = (document.documentElement.offsetWidth - control.offsetWidth)/2;
left += (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft:document.body.scrollLeft;
top += (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop:document.body.scrollTop;

control.style.left= left + 'px';
control.style.top=top + 'px';

return true;
}
return false;
}var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip:Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip_game"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer_game" src="/scripts/tooltip_game/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip_game"]:document.getElementById? document.getElementById("dhtmltooltip_game"):""

var pointerobj=document.all? document.all["dhtmlpointer_game"]:document.getElementById? document.getElementById("dhtmlpointer_game"):""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement:document.body
}

function ddrivetip(thetext,thewidth,thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX:event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY:event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth:window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight:window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX:winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY:winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1):-1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}
function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove=positiontip


function rate(news_id)
{
document.getElementById('a_rate_'+news_id).onclick = ''
document.getElementById('div_'+news_id).innerHTML = "<img src='/images/loading.gif'>";

new Ajax.Request("/Ajax/Comments/Rate.aspx?News_ID="+news_id,
{
method:'get',
evalScripts:true,

onSuccess:function(transport)
{
var response = transport.responseText;
document.getElementById('div_'+news_id).innerHTML = "<span style='font-size:14pt;font-family:Georgia'>" + response+"</span>";
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
});
}

function tdMouseOver(td)
{


document.getElementById('tb_'+td).style.backgroundImage = "url(/images/family/binhluan/img_binhluanon_a.jpg)";

document.getElementById('tb_'+td).style.width = "107px";
document.getElementById('tr_'+td).style.height = "53px";

document.getElementById('div_rate_'+td).style.cursor = "pointer";

document.getElementById('div_rate_'+td).style.color = "White";
document.getElementById('div_rate_'+td).style.fontSize = "28pt";
document.getElementById('div_rate_'+td).style.fontFamily = "Georgia";

if (!document.all)
document.getElementById('td_Ngan_'+td).style.width = "30px";
else
{
document.getElementById('td_Ngan_'+td).style.width = "28px";
}
}

function tdMouseOut(td)
{
document.getElementById('tb_'+td).style.backgroundImage = "url(/images/family/binhluan/img_binhluanoff_a.jpg)";

document.getElementById('div_rate_'+td).style.color = "White";
document.getElementById('div_rate_'+td).style.fontSize = "28pt";
document.getElementById('div_rate_'+td).style.fontFamily = "Georgia";

document.getElementById('tb_'+td).style.width = "81px";
document.getElementById('tr_'+td).style.height = "53px";
document.getElementById('td_Ngan_'+td).style.width = "0px";
}/******************************************************************************
Name:Highslide JS
Version:3.3.12 (Feb 29 2008)
Config:default +inline +ajax +iframe +flash
Author:Torstein Hønsi
Support:http://vikjavev.no/highslide/forum

Licence:
Highslide JS is licensed under a Creative Commons Attribution-NonCommercial 2.5
License (http://creativecommons.org/licenses/by-nc/2.5/).

You are free:
* to copy,distribute,display,and perform the work
* to make derivative works

Under the following conditions:
* Attribution. You must attribute the work in the mannerspecified bythe
author or licensor.
* Noncommercial. You may not use this work for commercial purposes.

* Foranyreuseordistribution,youmust make clear to others the license
terms of this work.
* Anyoftheseconditionscanbewaivedifyouget permission from the 
copyright holder.

Your fair use and other rights are in no way affected by the above.
******************************************************************************/
var isLoad = true;

var hs ={

// Apply your own settings here,or override them in the html file.
graphicsDir:'highslide/graphics/',
restoreCursor:'zoomout.cur',// necessary for preload
expandSteps:10,// number of steps in zoom. Each step lasts for duration/step milliseconds.
expandDuration:250,// milliseconds
restoreSteps:10,
restoreDuration:250,
marginLeft:15,
marginRight:15,
marginTop:15,
marginBottom:15,
zIndexCounter:1001,// adjust to other absolutely positioned elements

restoreTitle:'Click vào ảnh để đóng ảnh,chọn mũi tên trên bàn phím để di chuyển',
loadingText:'Đang tải dữ liệu...',
loadingTitle:'Click để đóng',
loadingOpacity:0.75,
focusTitle:'Click to bring to front',
allowMultipleInstances:true,
numberOfImagesToPreload:5,
captionSlideSpeed:1,// set to 0 to disable slide in effect
padToMinWidth:false,// pad the popup width to make room for wide caption
outlineWhileAnimating:2,// 0 = never,1 = always,2 = HTML only 
outlineStartOffset:3,// ends at 10
fullExpandTitle:'Expand to actual size',
fullExpandPosition:'bottom right',
fullExpandOpacity:1,
showCredits:true,// you can set this to false if you want
creditsText:'Family',
creditsHref:'http://family.channelvn.net',
creditsTitle:'family',
enableKeyListener:true,


// HTML extension

previousText:'Trước',
nextText:'Tiếp',
moveText:'Di chuyển',
closeText:'Đóng',
closeTitle:'Đóng',
resizeTitle:'Resize',
allowWidthReduction:false,
allowHeightReduction:true,
preserveContent:true,// Preserve changes made to the content and position of HTML popups.
objectLoadTime:'before',// Load iframes 'before' or 'after' expansion.
cacheAjax:true,// Cache ajax popups for instant display. Can be overridden for each popup.

// These settings can also be overridden inline for each image
captionId:null,
spaceForCaption:30,// leaves space below images with captions
slideshowGroup:null,// defines groups for next/previous links and keystrokes
minWidth:200,
minHeight:200,
allowSizeReduction:true,// allow the image to reduce to fit client size. If false,this overrides minWidth and minHeight
outlineType:'drop-shadow',// set null to disable outlines
wrapperClassName:'highslide-wrapper',// for enhanced css-control

// END OF YOUR SETTINGS


// declare internal properties
preloadTheseImages:[],
continuePreloading:true,
expanders:[],
overrides:[
'allowSizeReduction',
'outlineType',
'outlineWhileAnimating',
'spaceForCaption',
'captionId',
'captionText',
'captionEval',

'contentId',
'width',
'height',
'allowWidthReduction',
'allowHeightReduction',
'preserveContent',
'objectType',
'cacheAjax',
'objectWidth',
'objectHeight',
'objectLoadTime',
'swfObject',
'wrapperClassName',
'minWidth',
'minHeight',
'slideshowGroup',
'easing',
'easingClose',
'fadeInOut'
],
overlays:[],
faders:[],

pendingOutlines:{},
sleeping:[],
preloadTheseAjax:[],
cacheBindings:[],
cachedGets:{},
clones:{},
ie:(document.all && !window.opera),
safari:/Safari/.test(navigator.userAgent),
geckoMac:/Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),

$:function (id){
return document.getElementById(id);
},

push:function (arr,val){
arr[arr.length] = val;
},

createElement:function (tag,attribs,styles,parent,nopad){
var el = document.createElement(tag);
if (attribs) hs.setAttribs(el,attribs);
if (nopad) hs.setStyles(el,{padding:0,border:'none',margin:0});
if (styles) hs.setStyles(el,styles);
if (parent) parent.appendChild(el);
return el;
},

setAttribs:function (el,attribs){
for (var x in attribs) el[x] = attribs[x];
},

setStyles:function (el,styles){
for (var x in styles){
try{ 
if (hs.ie && x == 'opacity') 
el.style.filter = (styles[x] == 1) ? '':'alpha(opacity='+ (styles[x] * 100) +')';
else el.style[x] = styles[x];
}
catch (e){}
}
},

ieVersion:function (){
var arr = navigator.appVersion.split("MSIE");
return arr[1] ? parseFloat(arr[1]):null;
},

getPageSize:function (){
var iebody = document.compatMode && document.compatMode != "BackCompat" 
? document.documentElement:document.body;

var width = hs.ie ? iebody.clientWidth:
(document.documentElement.clientWidth || self.innerWidth),
height = hs.ie ? iebody.clientHeight:self.innerHeight;

return{
width:width,
height:height,
scrollLeft:hs.ie ? iebody.scrollLeft:pageXOffset,
scrollTop:hs.ie ? iebody.scrollTop:pageYOffset
}
},

position:function(el){ 
var p ={ x:el.offsetLeft,y:el.offsetTop };
while (el.offsetParent){
el = el.offsetParent;
p.x += el.offsetLeft;
p.y += el.offsetTop;
if (el != document.body && el != document.documentElement){
p.x -= el.scrollLeft;
p.y -= el.scrollTop;
}
}
return p;
},

expand:function(a,params,custom){
if (a.getParams) return params;

try{
new hs.Expander(a,params,custom);
return false;
} catch (e){ return true}
},

htmlExpand:function(a,params,custom){
if (a.getParams) return params;

for (var i = 0;i < hs.sleeping.length;i++){
if (hs.sleeping[i] && hs.sleeping[i].a == a){
hs.sleeping[i].awake();
hs.sleeping[i] = null;
return false;
}
}
try{
hs.hasHtmlexpanders = true;
new hs.Expander(a,params,custom,'html');
return false;
} catch (e){
return true;
}
},

getElementByClass:function (el,tagName,className){
var els = el.getElementsByTagName(tagName);
for (var i = 0;i < els.length;i++){
if (els[i].className == className){
return els[i];
}
}
return null;
},

getSelfRendered:function(){
var s =

'<div class="highslide-body" onclick="return hs.close(this)"></div>'

+ '<div class="highslide-header"><ul>'
+'<li class="highslide-previous"><a onclick="return hs.previous(this)" href="#">'+ hs.previousText +'</a></li>'
+'<li class="highslide-next"><a onclick="return hs.next(this)" href="#">'+ hs.nextText +'</a></li>'
+'<li class="highslide-move"><a href="#" onclick="return false">'+ hs.moveText +'</a></li>'
+'<li class="highslide-close"><a onclick="return hs.close(this)" title="'+ hs.closeTitle +'" href="#">'
+ hs.closeText +'</a></li>'
+'</ul></div>'

+'<div class="highslide-footer"><div>'
+'<span class="highslide-resize" title="'+ hs.resizeTitle +'"><span></span></span>'
+'</div></div>';
return hs.createElement('div',{ className:'highslide-html-content',innerHTML:s } );
},


getCacheBinding:function (a){
for (var i = 0;i < hs.cacheBindings.length;i++){
if (hs.cacheBindings[i][0] == a){
var c = hs.cacheBindings[i][1];
hs.cacheBindings[i][1] = c.cloneNode(1);
return c;
}
}
return null;
},

preloadAjax:function (e){
var aTags = document.getElementsByTagName('A');
var a,re;
for (var i = 0;i < aTags.length;i++){
a = aTags[i];
re = hs.isHsAnchor(a);
if (re && re[0] == 'hs.htmlExpand' && hs.getParam(a,'objectType') == 'ajax' 
&& hs.getParam(a,'cacheAjax')){
hs.push(hs.preloadTheseAjax,a);
}
}
hs.preloadAjaxElement(0);

isLoad = false;
},

preloadAjaxElement:function (i){
if (!hs.preloadTheseAjax[i]) return;
var a = hs.preloadTheseAjax[i];
var cache = hs.getNode(hs.getParam(a,'contentId'));
if (!cache) cache = hs.getSelfRendered();
var ajax = new hs.Ajax(a,cache,1);
 ajax.onError = function (){ };
 ajax.onLoad = function (){
 hs.push(hs.cacheBindings,[a,cache]);
 hs.preloadAjaxElement(i + 1);
 };
 ajax.run();
},

focusTopmost:function(){
var topZ = 0,topmostKey = -1;
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i]){
if (hs.expanders[i].wrapper.style.zIndex && hs.expanders[i].wrapper.style.zIndex > topZ){
topZ = hs.expanders[i].wrapper.style.zIndex;

topmostKey = i;
}
}
}
if (topmostKey == -1) hs.focusKey = -1;
else hs.expanders[topmostKey].focus();
},

getAdjacentAnchor:function(key,op){
var aAr = document.getElementsByTagName('A'),hsAr ={},activeI = -1,j = 0;
for (var i = 0;i < aAr.length;i++){
if (hs.isHsAnchor(aAr[i]) && ((hs.expanders[key].slideshowGroup 
== hs.getParam(aAr[i],'slideshowGroup')))){
hsAr[j] = aAr[i];
if (hs.expanders[key] && aAr[i] == hs.expanders[key].a){
activeI = j;
}
j++;
}
}
return hsAr[activeI + op] || null;
},

getParam:function (a,param){
a.getParams = a.onclick;
var p = a.getParams ? a.getParams():null;
a.getParams = null;

return (p && typeof p[param] != 'undefined') ? p[param]:
(typeof hs[param] != 'undefined' ? hs[param]:null);
},

getSrc:function (a){
var src = hs.getParam(a,'src');
if (src) return src;
return a.href;
},

getNode:function (id){
var node = hs.$(id),clone = hs.clones[id],a ={};
if (!node && !clone) return null;
if (!clone){
clone = node.cloneNode(true);
clone.id = '';
hs.clones[id] = clone;
return node;
} else{
return clone.cloneNode(true);
}
},

purge:function(d){
if (!hs.ie) return;
var a = d.attributes,i,l,n;
if (a){
l = a.length;
for (var i = 0;i < l;i += 1){
n = a[i].name;
if (typeof d[n] === 'function'){
d[n] = null;
}
}
}
a = d.childNodes;
if (a){
l = a.length;
for (var i = 0;i < l;i += 1){
hs.purge(d.childNodes[i]);
}
}
},

previousOrNext:function (el,op){
var exp = hs.last = hs.getExpander(el);
try{
var adj = hs.upcoming =hs.getAdjacentAnchor(exp.key,op);
adj.onclick();
} catch (e){}
try{ exp.close()} catch (e){}
return false;
},

previous:function (el){
return hs.previousOrNext(el,-1);
},

next:function (el){
return hs.previousOrNext(el,1);
},

keyHandler:function(e){
if (!e) e = window.event;
if (!e.target) e.target = e.srcElement;// ie
if (e.target.form) return true;// form element has focus

var op = null;
switch (e.keyCode){
case 32:// Space
case 34:// Page Down
case 39:// Arrow right
case 40:// Arrow down
op = 1;
break;
case 8:// Backspace
case 33:// Page Up
case 37:// Arrow left
case 38:// Arrow up
op = -1;
break;
case 27:// Escape
case 13:// Enter
op = 0;
}
if (op !== null){
hs.removeEventListener(document,'keydown',hs.keyHandler);
if (!hs.enableKeyListener) return true;

if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
if (op == 0){
try{ hs.getExpander().close()} catch (e){}
return false;
} else{
return hs.previousOrNext(hs.focusKey,op);
}
}
return true;
},


registerOverlay:function (overlay){
hs.push(hs.overlays,overlay);
},

getWrapperKey:function (element){
var el,re = /^highslide-wrapper-([0-9]+)$/;
// 1. look in open expanders
el = element;
while (el.parentNode){
if (el.id && re.test(el.id)) return el.id.replace(re,"$1");
el = el.parentNode;
}
// 2. look in thumbnail
el = element;
while (el.parentNode){
if (el.tagName && hs.isHsAnchor(el)){
for (var key = 0;key < hs.expanders.length;key++){
var exp = hs.expanders[key];
if (exp && exp.a == el) return key;
}
}
el = el.parentNode;
}
return null;
},

getExpander:function (el){
if (typeof el == 'undefined') return hs.expanders[hs.focusKey] || null;
if (typeof el == 'number') return hs.expanders[el] || null;
if (typeof el == 'string') el = hs.$(el);
return hs.expanders[hs.getWrapperKey(el)] || null;
},

isHsAnchor:function (a){
return (a.onclick && a.onclick.toString().replace(/\s/g,' ').match(/hs.(htmlE|e)xpand/));
},

cleanUp:function (){
for (var i = 0;i < hs.expanders.length;i++)
if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost();
},

mouseClickHandler:function(e) 
{
if (!e) e = window.event;
if (e.button > 1) return true;
if (!e.target) e.target = e.srcElement;

var el = e.target;
while (el.parentNode
&& !(/highslide-(image|move|html|resize)/.test(el.className)))
{
el = el.parentNode;
}
var exp = hs.getExpander(el);
if (exp && (exp.isClosing || !exp.isExpanded)) return true;

if (exp && e.type == 'mousedown'){
if (e.target.form) return true;
var match = el.className.match(/highslide-(image|move|resize)/);
if (match){
hs.dragArgs ={ exp:exp ,type:match[1],left:exp.x.min,width:exp.x.span,top:exp.y.min,
height:exp.y.span,clickX:e.clientX,clickY:e.clientY };

//if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move';

hs.addEventListener(document,'mousemove',hs.dragHandler);
if (e.preventDefault) e.preventDefault();// FF

if (/highslide-(image|html)-blur/.test(exp.content.className)){
exp.focus();
hs.hasFocused = true;
}
return false;
}
else if (/highslide-html/.test(el.className) && hs.focusKey != exp.key){
exp.focus();
exp.redoShowHide();
}
} else if (e.type == 'mouseup'){

hs.removeEventListener(document,'mousemove',hs.dragHandler);

if (hs.dragArgs){
if (hs.dragArgs.type == 'image')
hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;
var hasDragged = hs.dragArgs.hasDragged;

if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)){
exp.close();
} 
else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)){
hs.dragArgs.exp.redoShowHide();
}

if (hs.dragArgs.exp.releaseMask) 
hs.dragArgs.exp.releaseMask.style.display = 'none';

hs.hasFocused = false;
hs.dragArgs = null;

} else if (/highslide-image-blur/.test(el.className)){
el.style.cursor = hs.styleRestoreCursor;
}
}
return false;
},

dragHandler:function(e)
{
if (!hs.dragArgs) return true;
if (!e) e = window.event;
var a = hs.dragArgs,exp = a.exp;
if (exp.iframe){
if (!exp.releaseMask) exp.releaseMask = hs.createElement('div',null,
{ position:'absolute',width:exp.x.span+'px',height:exp.y.span+'px',
left:0,top:0,zIndex:4,background:(hs.ie ? 'white':'none'),
opacity:0.01 },
exp.wrapper,true);
if (exp.releaseMask.style.display == 'none')
exp.releaseMask.style.display = '';
}

a.dX = e.clientX - a.clickX;
a.dY = e.clientY - a.clickY;

var distance = Math.sqrt(Math.pow(a.dX,2) + Math.pow(a.dY,2));
a.hasDragged = (a.type != 'image' && distance > 0)
|| (distance > (hs.dragSensitivity || 5));

if (a.hasDragged){

if (a.type == 'resize') exp.resize(a);
else exp.move(a);
}
return false;
},

addEventListener:function (el,event,func){
try{
el.addEventListener(event,func,false);
} catch (e){
try{
el.detachEvent('on'+ event,func);
el.attachEvent('on'+ event,func);
} catch (e){
el['on'+ event] = func;
}
} 
},

removeEventListener:function (el,event,func){
try{
el.removeEventListener(event,func,false);
} catch (e){
try{
el.detachEvent('on'+ event,func);
} catch (e){
el['on'+ event] = null;
}
}
},

preloadFullImage:function (i){
if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined'){
var img = document.createElement('img');
img.onload = function(){ hs.preloadFullImage(i + 1)};
img.src = hs.preloadTheseImages[i];
}
},
preloadImages:function (number){
if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;
var a,re,j = 0;

var aTags = document.getElementsByTagName('A');
for (var i = 0;i < aTags.length;i++){
a = aTags[i];
re = hs.isHsAnchor(a);
if (re && re[0] == 'hs.expand'){
if (j < hs.numberOfImagesToPreload){
hs.preloadTheseImages[j] = hs.getSrc(a);
j++;
}
}
}

// preload outlines
new hs.Outline(hs.outlineType,function (){ hs.preloadFullImage(0)} );


// preload cursor
var cur = hs.createElement('img',{ src:hs.graphicsDir + hs.restoreCursor });
},


genContainer:function (){
if (!hs.container){
hs.container = hs.createElement('div',
null,
{ position:'absolute',left:0,top:0,width:'100%',zIndex:hs.zIndexCounter },
document.body,
true
);
hs.loading = hs.createElement('a',
{
className:'highslide-loading',
title:hs.loadingTitle,
innerHTML:hs.loadingText,
href:'javascript:void(0)'
},
{
position:'absolute',
opacity:hs.loadingOpacity,
left:'-9999px',
zIndex:1
},hs.container
);
hs.clearing = hs.createElement('div',null,
{ clear:'both',paddingTop:'1px' },null,true);

// http://www.robertpenner.com/easing/ 
Math.linearTween = function (t,b,c,d){
return c*t/d + b;
};
Math.easeInQuad = function (t,b,c,d){
return c*(t/=d)*t + b;
};
}
},

fade:function (el,o,oFinal,dur,i,dir){
if (typeof i == 'undefined'){ // new fader
if (typeof dur != 'number') dur = 250;
if (dur < 25){ // instant
hs.setStyles( el,{
opacity:oFinal,
visibility:(o < oFinal ? 'visible':'hidden')
});
return;
}
i = hs.faders.length;
dir = oFinal > o ? 1:-1;
var step = (25 / (dur - dur % 25)) * Math.abs(o - oFinal);
}
o = parseFloat(o);
el.style.visibility = (o <= 0) ? 'hidden':'visible';
if (o < 0 || (dir == 1 && o > oFinal)) return;
if (el.fading && el.fading.i != i){ // reverse
clearTimeout(hs.faders[el.fading.i]);
o = el.fading.o;
}
el.fading ={i:i,o:o,step:(step || el.fading.step)};
el.style.visibility = (o <= 0) ? 'hidden':'visible';
hs.setStyles(el,{ opacity:o });
hs.faders[i] = setTimeout(function(){
hs.fade(el,o + el.fading.step * dir,oFinal,null,i,dir);
},25);
},

close:function(el){
try{ hs.getExpander(el).close()} catch (e){}
return false;
}
};// end hs object


//-----------------------------------------------------------------------------
hs.Outline =function (outlineType,onLoad){
this.onLoad = onLoad;
this.outlineType = outlineType;
var v = hs.ieVersion(),tr;

this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 7;
if (!outlineType){
if (onLoad) onLoad();
return;
}

hs.genContainer();
this.table = hs.createElement(
'table',{ cellSpacing:0 },
{
visibility:'hidden',
position:'absolute',
borderCollapse:'collapse'
},
hs.container,
true
);
this.tbody = hs.createElement('tbody',null,null,this.table,1);

this.td = [];
for (var i = 0;i <= 8;i++){
if (i % 3 == 0) tr = hs.createElement('tr',null,{ height:'auto' },this.tbody,true);
this.td[i] = hs.createElement('td',null,null,tr,true);
var style = i != 4 ?{ lineHeight:0,fontSize:0}:{ position:'relative' };
hs.setStyles(this.td[i],style);
}
this.td[4].className = outlineType;

this.preloadGraphic();
};

hs.Outline.prototype ={
preloadGraphic:function (){
var src = hs.graphicsDir + (hs.outlinesDir || "outlines/")+ this.outlineType +".png";

var appendTo = hs.safari ? hs.container:null;
this.graphic = hs.createElement('img',null,{ position:'absolute',left:'-9999px',
top:'-9999px' },appendTo,true);// for onload trigger

var pThis = this;
this.graphic.onload = function(){ pThis.onGraphicLoad()};

this.graphic.src = src;
},

onGraphicLoad:function (){
var o = this.offset = this.graphic.width / 4,
pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],
dim ={ height:(2*o) +'px',width:(2*o) +'px' };

for (var i = 0;i <= 8;i++){
if (pos[i]){
if (this.hasAlphaImageLoader){
var w = (i == 1 || i == 7) ? '100%':this.graphic.width +'px';
var div = hs.createElement('div',null,{ width:'100%',height:'100%',position:'relative',overflow:'hidden'},this.td[i],true);
hs.createElement ('div',null,{ 
filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='"+ this.graphic.src + "')",
position:'absolute',
width:w,
height:this.graphic.height +'px',
left:(pos[i][0]*o)+'px',
top:(pos[i][1]*o)+'px'
},
div,
true);
} else{
hs.setStyles(this.td[i],{ background:'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'});
}

if (window.opera && (i == 3 || i ==5)) 
hs.createElement('div',null,dim,this.td[i],true);

hs.setStyles (this.td[i],dim);
}
}

hs.pendingOutlines[this.outlineType] = this;
if (this.onLoad) this.onLoad();
},

setPosition:function (exp,x,y,w,h,vis){
if (vis) this.table.style.visibility = (h >= 4 * this.offset) 
? 'visible':'hidden';
this.table.style.left = (x - this.offset) +'px';
this.table.style.top = (y - this.offset) +'px';
this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px';
w += 2 * (exp.offsetBorderW - this.offset);
h += + 2 * (exp.offsetBorderH - this.offset);
this.td[4].style.width = w >= 0 ? w +'px':0;
this.td[4].style.height = h >= 0 ? h +'px':0;
if (this.hasAlphaImageLoader) this.td[3].style.height 
= this.td[5].style.height = this.td[4].style.height;
},

destroy:function(hide){
if (hide) this.table.style.visibility = 'hidden';
else{
hs.purge(this.table);
try{ this.table.parentNode.removeChild(this.table)} catch (e){}
}
}
};

//-----------------------------------------------------------------------------
// The expander object
hs.Expander = function(a,params,custom,contentType){
this.a = a;
this.custom = custom;
this.contentType = contentType || 'image';
this.isHtml = (contentType == 'html');
this.isImage = !this.isHtml;

hs.continuePreloading = false;
hs.genContainer();
var key = this.key = hs.expanders.length;

// override inline parameters
for (var i = 0;i < hs.overrides.length;i++){
var name = hs.overrides[i];
this[name] = params && typeof params[name] != 'undefined' ?
params[name]:hs[name];
}

// get thumb
var el = this.thumb = ((params && params.thumbnailId) ? hs.$(params.thumbnailId):null) 
|| a.getElementsByTagName('img')[0] || a;
this.thumbsUserSetId = el.id || a.id;

// check if already open
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && hs.expanders[i].a == a){
hs.expanders[i].focus();
return false;
}
}
// cancel other
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted){
hs.expanders[i].cancelLoading();
}
}
hs.expanders[this.key] = this;
if (!hs.allowMultipleInstances){
if (hs.expanders[key-1]) hs.expanders[key-1].close();
if (typeof hs.focusKey != 'undefined' && hs.expanders[hs.focusKey])
hs.expanders[hs.focusKey].close();
}
this.overlays = [];

var pos = hs.position(el);

// store properties of thumbnail
this.thumbWidth = el.width ? el.width:el.offsetWidth;
this.thumbHeight = el.height ? el.height:el.offsetHeight;
this.thumbLeft = pos.x;
this.thumbTop = pos.y;
this.thumbOffsetBorderW = (this.thumb.offsetWidth - this.thumbWidth) / 2;
this.thumbOffsetBorderH = (this.thumb.offsetHeight - this.thumbHeight) / 2;

// instanciate the wrapper
this.wrapper = hs.createElement(
'div',
{
id:'highslide-wrapper-'+ this.key,
className:this.wrapperClassName
},
{
visibility:'hidden',
position:'absolute',
zIndex:hs.zIndexCounter++
},null,true );

this.wrapper.onmouseover = function (e){ 
try{ hs.expanders[key].wrapperMouseHandler(e)} catch (e){} 
};
this.wrapper.onmouseout = function (e){ 
try{ hs.expanders[key].wrapperMouseHandler(e)} catch (e){}
};
if (this.contentType == 'image' && this.outlineWhileAnimating == 2)
this.outlineWhileAnimating = 0;
// get the outline
if (hs.pendingOutlines[this.outlineType]){
this.connectOutline();
this[this.contentType +'Create']();
} else if (!this.outlineType){
this[this.contentType +'Create']();
} else{
this.displayLoading();
var exp = this;
new hs.Outline(this.outlineType,
function (){ 
exp.connectOutline();
exp[exp.contentType +'Create']();
} 
);
}
return true;
};

hs.Expander.prototype ={

connectOutline:function(x,y){
var w = hs.pendingOutlines[this.outlineType];
this.objOutline = w;
w.table.style.zIndex = this.wrapper.style.zIndex;
hs.pendingOutlines[this.outlineType] = null;
},

displayLoading:function(){
if (this.onLoadStarted || this.loading) return;

this.originalCursor = this.a.style.cursor;
this.a.style.cursor = 'wait';

this.loading = hs.loading;
var exp = this;
this.loading.onclick = function(){
exp.cancelLoading();
};
this.loading.style.top = (this.thumbTop 
+ (this.thumbHeight - this.loading.offsetHeight) / 2) +'px';
var exp = this,left = (this.thumbLeft + this.thumbOffsetBorderW 
+ (this.thumbWidth - this.loading.offsetWidth) / 2) +'px';
setTimeout(function (){ if (exp.loading) exp.loading.style.left = left },100);
},

imageCreate:function(){
var exp = this;

var img = document.createElement('img');
this.content = img;
img.onload = function (){
if (hs.expanders[exp.key]) exp.contentLoaded();
};
if (hs.blockRightClick) img.oncontextmenu = function(){ return false};
img.className = 'highslide-image';
img.style.visibility = 'hidden';// prevent flickering in IE
img.style.display = 'block';
img.style.position = 'absolute';
img.style.maxWidth = 'none';
img.style.zIndex = 3;
img.title = hs.restoreTitle;
if (hs.safari) hs.container.appendChild(img);
if (hs.ie && hs.flushImgSize) img.src = null;
img.src = hs.getSrc(this.a);

this.displayLoading();
},

htmlCreate:function (){
this.tempContainer = hs.createElement('div',{ className:this.wrapperClassName },
{
padding:'0 '+ hs.marginRight +'px 0 '+ hs.marginLeft +'px',
visibility:'hidden'
},hs.container
);

this.content = hs.getCacheBinding(this.a);
if (!this.content) 
this.content = hs.getNode(this.contentId);
if (!this.content) 
this.content = hs.getSelfRendered();
this.innerContent = this.content;

if (this.swfObject || this.objectType == 'iframe') this.setObjContainerSize(this.innerContent);
this.tempContainer.appendChild(this.innerContent);// to get full width
hs.setStyles (this.innerContent,{ position:'relative',visibility:'hidden' });
this.innerContent.className += ' highslide-display-block';
if (this.width) this.innerContent.style.width = this.width+'px';
if (this.height) this.innerContent.style.height = this.height+'px';
if (this.innerContent.offsetWidth < this.minWidth)
this.innerContent.style.width = this.minWidth +'px';

this.content = hs.createElement(
'div',
{className:'highslide-html' },
{
position:'relative',
zIndex:3,
overflow:'hidden',
width:this.thumbWidth +'px',
height:this.thumbHeight +'px'
}
);

if (this.objectType == 'ajax' && !hs.getCacheBinding(this.a)){
var ajax = new hs.Ajax(this.a,this.innerContent);
var exp = this;
ajax.onLoad = function (){if (hs.expanders[exp.key]) exp.contentLoaded()};
ajax.onError = function (){ location.href = hs.getSrc(this.a)};
ajax.run();
}
else

if (this.objectType == 'iframe' && this.objectLoadTime == 'before'){
this.writeExtendedContent();
}
else
this.contentLoaded();
},

contentLoaded:function(){
try{
if (!this.content) return;
if (this.onLoadStarted) return;// old Gecko loop
else this.onLoadStarted = true;

 
if (this.loading){
this.loading.style.left = '-9999px';
this.loading = null;
this.a.style.cursor = this.originalCursor || '';
}
this.marginBottom = hs.marginBottom;
if (this.isImage){
this.newWidth = this.content.width;
this.newHeight = this.content.height;
this.fullExpandWidth = this.newWidth;
this.fullExpandHeight = this.newHeight;

this.content.style.width = this.thumbWidth +'px';
this.content.style.height = this.thumbHeight +'px';
this.getCaption();
} else if (this.htmlGetSize) this.htmlGetSize();


this.wrapper.appendChild(this.content);
this.content.style.position = 'relative';// Saf
if (this.caption) this.wrapper.appendChild(this.caption);
this.wrapper.style.left = this.thumbLeft +'px';
this.wrapper.style.top = this.thumbTop +'px';
hs.container.appendChild(this.wrapper);

// correct for borders
this.offsetBorderW = (this.content.offsetWidth - this.thumbWidth) / 2;
this.offsetBorderH = (this.content.offsetHeight - this.thumbHeight) / 2;
var modMarginRight = hs.marginRight + 2 * this.offsetBorderW;
this.marginBottom += 2 * this.offsetBorderH;

var ratio = this.newWidth / this.newHeight;
var minWidth = this.allowSizeReduction 
? this.minWidth:this.newWidth;
var minHeight = this.allowSizeReduction 
? this.minHeight:this.newHeight;

var justify ={ x:'auto',y:'auto' };

var page = hs.getPageSize();
// justify
this.x ={ 
min:parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW,
span:this.newWidth,
minSpan:(this.newWidth < minWidth && !hs.padToMinWidth) 
? this.newWidth:minWidth,
marginMin:hs.marginLeft,
marginMax:modMarginRight,
scroll:page.scrollLeft,
clientSpan:page.width,
thumbSpan:this.thumbWidth
};
var oldRight = this.x.min + parseInt(this.thumbWidth);
this.x = this.justify(this.x);
this.y ={ 
min:parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH,
span:this.newHeight,
minSpan:this.newHeight < minHeight ? this.newHeight:minHeight,
marginMin:hs.marginTop,
marginMax:this.marginBottom,
scroll:page.scrollTop,
clientSpan:page.height,
thumbSpan:this.thumbHeight
};
var oldBottom = this.y.min + parseInt(this.thumbHeight);
this.y = this.justify(this.y);
if (this.isHtml) this.htmlSizeOperations();

if (this.isImage)
this.correctRatio(ratio);


var x = this.x;
var y = this.y;

this.show();
} catch (e){
window.location.href = hs.getSrc(this.a);
}
},


setObjContainerSize:function(parent,auto){
var c = hs.getElementByClass(parent,'DIV','highslide-body');

if (this.objectType == 'iframe'){
if (this.objectWidth) c.style.width = this.objectWidth +'px';
if (this.objectHeight) c.style.height = this.objectHeight +'px';
}
if (this.swfObject){
c.style.width = this.swfObject.attributes.width +'px';
c.style.height = this.swfObject.attributes.height +'px';
}
},

writeExtendedContent:function (loadTime){
if (this.hasExtendedContent) return;
var exp = this;
this.body = hs.getElementByClass(this.innerContent,'DIV','highslide-body');
if (this.objectType == 'iframe'){
this.displayLoading();
this.ruler = hs.clearing.cloneNode(1);
this.body.appendChild(this.ruler);
this.newWidth = this.innerContent.offsetWidth;
if (!this.objectWidth) this.objectWidth = this.ruler.offsetWidth;
var hDiff = this.innerContent.offsetHeight - this.body.offsetHeight;
var h = this.objectHeight || (hs.getPageSize()).height - hDiff - hs.marginTop - hs.marginBottom;
var onload = (hs.ie && this.objectLoadTime == 'before') ? 
'onload="if(hs.expanders['+ this.key +'])hs.expanders['+ this.key +'].contentLoaded();"':'';
var tag = hs.ie ? '<iframe name="hsIframe'+ this.key+ '" '+ onload +'/>':'iframe';
this.iframe = hs.createElement(tag,
{ name:'hsIframe'+ this.key,frameBorder:0,allowTransparency:true },
{ width:this.objectWidth +'px',height:h +'px' },
this.body);
if (this.objectLoadTime == 'before'){
if (!hs.ie) this.iframe.onload = function (){ if (hs.expanders[exp.key]) exp.contentLoaded()};
}
if (hs.safari) this.iframe.src = null;
this.iframe.src = hs.getSrc(this.a);

if (this.objectLoadTime == 'after') this.correctIframeSize();

} else if (this.swfObject){
this.body.id = this.body.id || 'hs-flash-id-' + this.key;
this.swfObject.write(this.body.id);
}
this.hasExtendedContent = true;
},
htmlGetSize:function(){
if (this.iframe && !this.objectHeight){ // loadtime before
try{
var doc = this.iframe.contentDocument || this.iframe.contentWindow.document;
var clearing = doc.createElement('div');
clearing.style.clear = 'both';
doc.body.appendChild(clearing);
var h = clearing.offsetTop;
if (hs.ie) h += parseInt(doc.body.currentStyle.marginTop) 
+ parseInt(doc.body.currentStyle.marginBottom) - 1;
this.iframe.style.height = this.body.style.height = h +'px';
} catch (e){ // other domain
this.iframe.style.height = '300px';
}
}
this.innerContent.appendChild(hs.clearing);
if (!this.newWidth) this.newWidth = this.innerContent.offsetWidth;
this.newHeight = this.innerContent.offsetHeight;
this.innerContent.removeChild(hs.clearing);
if (hs.ie && this.newHeight > parseInt(this.innerContent.currentStyle.height)){ // ie css bug
this.newHeight = parseInt(this.innerContent.currentStyle.height);
}
},

correctIframeSize:function (){
var wDiff = this.innerContent.offsetWidth - this.ruler.offsetWidth;
if (wDiff < 0) wDiff = 0;

var hDiff = this.innerContent.offsetHeight - this.body.offsetHeight;

hs.setStyles(this.iframe,{ width:(this.x.span - wDiff) +'px',
height:(this.y.span - hDiff) +'px' });
hs.setStyles(this.body,{ width:this.iframe.style.width,
height:this.iframe.style.height });

this.scrollingContent = this.iframe;
this.scrollerDiv = this.scrollingContent;
},
htmlSizeOperations:function (){

this.setObjContainerSize(this.innerContent);


if (this.swfObject && this.objectLoadTime == 'before') this.writeExtendedContent();


// handle minimum size
if (this.x.span < this.newWidth && !this.allowWidthReduction) this.x.span = this.newWidth;
if (this.y.span < this.newHeight && !this.allowHeightReduction) this.y.span = this.newHeight;
this.scrollerDiv = this.innerContent;
this.mediumContent = hs.createElement('div',null,
{ 
width:this.x.span +'px',
position:'relative',
left:(this.x.min - this.thumbLeft) +'px',
top:(this.y.min - this.thumbTop) +'px'
},this.content,true);

this.mediumContent.appendChild(this.innerContent);
hs.container.removeChild(this.tempContainer);
hs.setStyles(this.innerContent,{ border:'none',width:'auto',height:'auto' });

var node = hs.getElementByClass(this.innerContent,'DIV','highslide-body');
if (node && !this.swfObject && this.objectType != 'iframe'){
var cNode = node;// wrap to get true size
node = hs.createElement(cNode.nodeName,null,{overflow:'hidden'},null,true);
cNode.parentNode.insertBefore(node,cNode);
node.appendChild(hs.clearing);// IE6
node.appendChild(cNode);

var wDiff = this.innerContent.offsetWidth - node.offsetWidth;
var hDiff = this.innerContent.offsetHeight - node.offsetHeight;
node.removeChild(hs.clearing);

var kdeBugCorr = hs.safari || navigator.vendor == 'KDE' ? 1:0;// KDE repainting bug
hs.setStyles(node,{ 
width:(this.x.span - wDiff - kdeBugCorr) +'px',
height:(this.y.span - hDiff) +'px',
overflow:'auto',
position:'relative' 
} 
);
if (kdeBugCorr && cNode.offsetHeight > node.offsetHeight){
node.style.width = (parseInt(node.style.width) + kdeBugCorr) + 'px';
}
this.scrollingContent = node;
this.scrollerDiv = this.scrollingContent;

}
if (this.iframe && this.objectLoadTime == 'before') this.correctIframeSize();
if (!this.scrollingContent && this.y.span < this.mediumContent.offsetHeight) this.scrollerDiv = this.content;

if (this.scrollerDiv == this.content && !this.allowWidthReduction && this.objectType != 'iframe'){
this.x.span += 17;// room for scrollbars
}
if (this.scrollerDiv && this.scrollerDiv.offsetHeight > this.scrollerDiv.parentNode.offsetHeight){
setTimeout("try{ hs.expanders["+ this.key +"].scrollerDiv.style.overflow = 'auto'} catch(e){}",
 hs.expandDuration);
}
},

justify:function (p){

var tgt,dim = p == this.x ? 'x':'y';


var hasMovedMin = false;

var allowReduce = true;

// calculate p.min
p.min = Math.round(p.min - ((p.span - p.thumbSpan) / 2));// auto

if (p.min < p.scroll + p.marginMin){
p.min = p.scroll + p.marginMin;
hasMovedMin = true;
}


if (p.span < p.minSpan){
p.span = p.minSpan;
allowReduce = false;
}

// calculate right/newWidth
if (p.min + p.span > p.scroll + p.clientSpan - p.marginMax){
if (hasMovedMin && allowReduce){

p.span = p.clientSpan - p.marginMin - p.marginMax;// can't expand more

} else if (p.span < p.clientSpan - p.marginMin - p.marginMax){ // move newTop up
p.min = p.scroll + p.clientSpan - p.span - p.marginMin - p.marginMax;
} else{ // image larger than client
p.min = p.scroll + p.marginMin;

if (allowReduce) p.span = p.clientSpan - p.marginMin - p.marginMax;

}

}

if (p.span < p.minSpan){
p.span = p.minSpan;
allowReduce = false;
}



if (p.min < p.marginMin){
tmpMin = p.min;
p.min = p.marginMin;

if (allowReduce) p.span = p.span - (p.min - tmpMin);

}
return p;
},

correctRatio:function(ratio){
var x = this.x;
var y = this.y;
var changed = false;
if (x.span / y.span > ratio){ // width greater
var tmpWidth = x.span;
x.span = y.span * ratio;
if (x.span < x.minSpan){ // below minWidth
if (hs.padToMinWidth) x.imgSpan = x.span;
x.span = x.minSpan;
if (!x.imgSpan)
y.span = x.span / ratio;
}
changed = true;

} else if (x.span / y.span < ratio){ // height greater
var tmpHeight = y.span;
y.span = x.span / ratio;
changed = true;
}

if (changed){
x.min = parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW;
x.minSpan = x.span;
this.x = this.justify(x);

y.min = parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH;
y.minSpan = y.span;
this.y = this.justify(y);
}
},

show:function (){

// Selectbox bug
var imgPos ={x:this.x.min - 20,y:this.y.min - 20,w:this.x.span + 40,
h:this.y.span + 40
 + this.spaceForCaption};
hs.hideSelects = (hs.ie && hs.ieVersion() < 7);
if (hs.hideSelects) this.showHideElements('SELECT','hidden',imgPos);
// Iframes bug
hs.hideIframes = ((window.opera && navigator.appVersion < 9) || navigator.vendor == 'KDE' 
|| (hs.ie && hs.ieVersion() < 5.5));
if (hs.hideIframes) this.showHideElements('IFRAME','hidden',imgPos);
// Scrollbars bug
if (hs.geckoMac) this.showHideElements('*','hidden',imgPos);


if (this.x.imgSpan) this.content.style.margin = '0 auto';

// Apply size change
this.changeSize(
1,
{ 
x:this.thumbLeft + this.thumbOffsetBorderW - this.offsetBorderW,
y:this.thumbTop + this.thumbOffsetBorderH - this.offsetBorderH,
w:this.thumbWidth,
h:this.thumbHeight,
imgW:this.thumbWidth,
o:hs.outlineStartOffset
},
{
x:this.x.min,
y:this.y.min,
w:this.x.span,
h:this.y.span,
imgW:this.x.imgSpan,
o:this.objOutline ? this.objOutline.offset:0
},
hs.expandDuration,
hs.expandSteps
);
},

changeSize:function(up,from,to,dur,steps){

if (up && this.objOutline && !this.outlineWhileAnimating) 
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

else if (!up && this.objOutline){
if (this.outlineWhileAnimating) this.objOutline.setPosition(this,from.x,from.y,from.w,from.h);
else this.objOutline.destroy(
(this.isHtml && this.preserveContent));
}

if (!up){ // remove children
var n = this.wrapper.childNodes.length;
for (var i = n - 1;i >= 0 ;i--){
var child = this.wrapper.childNodes[i];
if (child != this.content){
hs.purge(child);
this.wrapper.removeChild(child);
}
}
}

if (this.fadeInOut){
from.op = up ? 0:1;
to.op = up;
}
var t,
exp = this,
easing = Math[this.easing] || Math.easeInQuad;
if (!up) easing = Math[this.easingClose] || easing;

for (var i = 1;i <= steps;i++){
t = Math.round(i * (dur / steps));

(function(){
var pI = i,size ={};

for (var x in from) 
size[x] = easing(t,from[x],to[x] - from[x],dur);

setTimeout ( function(){
if (up && pI == 1){
exp.content.style.visibility = 'visible';
exp.a.className += ' highslide-active-anchor';
}
exp.setSize(size);
},t);
})();
}

if (up){ 

setTimeout(function(){
if (exp.objOutline) exp.objOutline.table.style.visibility = "visible";
},t);
setTimeout(function(){
if (exp.caption) exp.writeCaption();
exp.afterExpand();
},t + 50);
}
else setTimeout(function(){ exp.afterClose()},t);

},

setSize:function (to){
try{
if (this.isHtml){
hs.setStyles(this.content,{ width:to.w +'px',height:to.h +'px' });
hs.setStyles(this.mediumContent,{ left:(this.x.min - to.x) +'px',
top:(this.y.min - to.y) +'px' });
this.innerContent.style.visibility = 'visible';
} else{
this.wrapper.style.width = (to.w + 2*this.offsetBorderW) +'px';
this.content.style.width =
((to.imgW && !isNaN(to.imgW)) ? to.imgW:to.w) +'px';
if (hs.safari) this.content.style.maxWidth = this.content.style.width;
this.content.style.height = to.h +'px';
}

if (to.op) hs.setStyles(this.wrapper,{ opacity:to.op });


if (this.objOutline && this.outlineWhileAnimating){
var o = this.objOutline.offset - to.o;
this.objOutline.setPosition(this,to.x + o,to.y + o,to.w - 2 * o,to.h - 2 * o,1);
}

hs.setStyles ( this.wrapper,
{
'visibility':'visible',
'left':to.x +'px',
'top':to.y +'px'
}
);

} catch (e){ window.location.href = hs.getSrc(this.a)}
},

afterExpand:function(){
this.isExpanded = true;
this.focus();

if (this.isHtml && this.objectLoadTime == 'after') this.writeExtendedContent();

if (this.isHtml){
if (this.iframe){
try{
var exp = this,
doc = this.iframe.contentDocument || this.iframe.contentWindow.document;
hs.addEventListener(doc,'mousedown',function (){
if (hs.focusKey != exp.key) exp.focus();
});
} catch(e){}
if (hs.ie && typeof this.isClosing != 'boolean') // first open 
this.iframe.style.width = (this.objectWidth - 1) +'px';// hasLayout
}
}

this.createOverlays();
if (hs.showCredits) this.writeCredits();
if (this.isImage && this.fullExpandWidth > this.x.span) this.createFullExpand();
if (!this.caption) this.prepareNextOutline();
},


prepareNextOutline:function(){
var key = this.key;
var outlineType = this.outlineType;
new hs.Outline(outlineType,
function (){ try{ hs.expanders[key].preloadNext()} catch (e){} });
},


preloadNext:function(){
var next = hs.getAdjacentAnchor(this.key,1);
if (next.onclick.toString().match(/hs\.expand/)) 
var img = hs.createElement('img',{ src:hs.getSrc(next) });
},

cancelLoading:function(){
hs.expanders[this.key] = null;
this.a.style.cursor = this.originalCursor;
if (this.loading) hs.loading.style.left = '-9999px';
},

writeCredits:function (){
var credits = hs.createElement('a',
{
href:hs.creditsHref,
className:'highslide-credits',
innerHTML:hs.creditsText,
title:hs.creditsTitle
}
);
this.createOverlay({ overlayId:credits,position:'top left'});
},

getCaption:function(){
if (!this.captionId && this.thumbsUserSetId)
this.captionId = 'caption-for-'+ this.thumbsUserSetId;
if (this.captionId) this.caption = hs.getNode(this.captionId);
if (!this.caption && !this.captionText && this.captionEval) try{
this.captionText = eval(this.captionEval);
} catch (e){}
if (!this.caption && this.captionText) this.caption = hs.createElement('div',
{ className:'highslide-caption',innerHTML:this.captionText } );

if (!this.caption){
var next = this.a.nextSibling;
while (next && !hs.isHsAnchor(next)){
if (/highslide-caption/.test(next.className || null)){
this.caption = next.cloneNode(1);
break;
}
next = next.nextSibling;
}
}
if (this.caption){
this.marginBottom += this.spaceForCaption;
}

},

writeCaption:function(){
try{
hs.setStyles(this.wrapper,{ width:this.wrapper.offsetWidth +'px',
height:this.wrapper.offsetHeight +'px' } );
hs.setStyles(this.caption,{ visibility:'hidden',marginTop:hs.safari ? 0:'-'+ this.y.span +'px'});
this.caption.className += ' highslide-display-block';

var height,exp = this;
if (hs.ie && (hs.ieVersion() < 6 || document.compatMode == 'BackCompat')){
height = this.caption.offsetHeight;
} else{
var temp = hs.createElement('div',{innerHTML:this.caption.innerHTML},
null,null,true);// to get height
this.caption.innerHTML = '';
this.caption.appendChild(temp);
height = this.caption.childNodes[0].offsetHeight;
this.caption.innerHTML = this.caption.childNodes[0].innerHTML;
}
hs.setStyles(this.caption,{ overflow:'hidden',height:0,zIndex:2,marginTop:0 });
this.wrapper.style.height = 'auto';

if (hs.captionSlideSpeed){
var step = (Math.round(height/50) || 1) * hs.captionSlideSpeed;
} else{
this.placeCaption(height,1);
return;
}
for (var h = height % step,t = 0;h <= height;h += step,t += 10){
(function(){
var pH = h,end = (h == height) ? 1:0;
setTimeout( function(){
exp.placeCaption(pH,end);
},t);
})();
}
} catch (e){}
},

placeCaption:function(height,end){
if (!this.caption) return;
this.caption.style.height = height +'px';
this.caption.style.visibility = 'visible';
this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;


var o = this.objOutline;
if (o){
o.td[4].style.height = (this.wrapper.offsetHeight - 2 * this.objOutline.offset) +'px';
if (o.hasAlphaImageLoader) o.td[3].style.height = o.td[5].style.height = o.td[4].style.height;
}
if (end) this.prepareNextOutline();
},


showHideElements:function (tagName,visibility,imgPos){
var els = document.getElementsByTagName(tagName);
var prop = tagName == '*' ? 'overflow':'visibility';
for (var i = 0;i < els.length;i++){
if (prop == 'visibility' || (document.defaultView.getComputedStyle(
els[i],"").getPropertyValue('overflow') == 'auto'
|| els[i].getAttribute('hidden-by') != null)){
var hiddenBy = els[i].getAttribute('hidden-by');
if (visibility == 'visible' && hiddenBy){
hiddenBy = hiddenBy.replace('['+ this.key +']','');
els[i].setAttribute('hidden-by',hiddenBy);
if (!hiddenBy) els[i].style[prop] = els[i].origProp;
} else if (visibility == 'hidden'){ // hide if behind
var elPos = hs.position(els[i]);
elPos.w = els[i].offsetWidth;
elPos.h = els[i].offsetHeight;


var clearsX = (elPos.x + elPos.w < imgPos.x || elPos.x > imgPos.x + imgPos.w);
var clearsY = (elPos.y + elPos.h < imgPos.y || elPos.y > imgPos.y + imgPos.h);
var wrapperKey = hs.getWrapperKey(els[i]);
if (!clearsX && !clearsY && wrapperKey != this.key){ // element falls behind image
if (!hiddenBy){
els[i].setAttribute('hidden-by','['+ this.key +']');
els[i].origProp = els[i].style[prop];
els[i].style[prop] = 'hidden';
} else if (!hiddenBy.match('['+ this.key +']')){
els[i].setAttribute('hidden-by',hiddenBy + '['+ this.key +']');
}
} else if (hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey){ // on move
els[i].setAttribute('hidden-by','');
els[i].style[prop] = els[i].origProp || '';
} else if (hiddenBy && hiddenBy.match('['+ this.key +']')){
els[i].setAttribute('hidden-by',hiddenBy.replace('['+ this.key +']',''));
}

}
}
}
},

focus:function(){
this.wrapper.style.zIndex = hs.zIndexCounter++;
// blur others
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && i == hs.focusKey){
var blurExp = hs.expanders[i];
blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';

if (blurExp.caption){
blurExp.caption.className += ' highslide-caption-blur';
}

if (blurExp.isImage){
blurExp.content.style.cursor = hs.ie ? 'hand':'pointer';
blurExp.content.title = hs.focusTitle;
}
}
}

// focus this
if (this.objOutline) this.objOutline.table.style.zIndex 
= this.wrapper.style.zIndex;

this.content.className = 'highslide-'+ this.contentType;

if (this.caption){
this.caption.className = this.caption.className.replace(' highslide-caption-blur','');
}

if (this.isImage){
this.content.title = hs.restoreTitle;

hs.styleRestoreCursor = window.opera ? 'pointer':'url('+ hs.graphicsDir + hs.restoreCursor +'),pointer';
if (hs.ie && hs.ieVersion() < 6) hs.styleRestoreCursor = 'hand';
this.content.style.cursor = hs.styleRestoreCursor;
}
hs.focusKey = this.key;
hs.addEventListener(document,'keydown',hs.keyHandler);
},

move:function (e){
this.x.min = e.left + e.dX;
this.y.min = e.top + e.dY;

if (e.type == 'image') this.content.style.cursor = 'move';
hs.setStyles(this.wrapper,{ left:this.x.min +'px',top:this.y.min +'px' });

if (this.objOutline)
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

},

resize:function (e){
this.x.span = e.width + e.dX;
this.y.span = e.height + e.dY;

if (this.x.span < this.minWidth) this.x.span = this.minWidth;
if (this.y.span < this.minHeight) this.y.span = this.minHeight;

var d = this.scrollerDiv;
if (typeof this.wDiff == 'undefined'){
this.wDiff = this.innerContent.offsetWidth - d.offsetWidth;
this.hDiff = this.innerContent.offsetHeight - d.offsetHeight;
}
hs.setStyles(d,{ width:(this.x.span - this.wDiff) +'px',
height:(this.y.span - this.hDiff) +'px' });

var size ={ width:this.x.span +'px',height:this.y.span +'px' };
hs.setStyles(this.content,size);
if (this.releaseMask) hs.setStyles(this.releaseMask,size);

this.mediumContent.style.width = 'auto';
hs.setStyles(this.body,{ width:'auto',height:'auto' });


for (var i = 0;i < this.overlays.length;i++) 
this.positionOverlay(this.overlays[i]);
if (this.objOutline)
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

},

close:function(){
if (this.isClosing || !this.isExpanded) return;
this.isClosing = true;

hs.removeEventListener(document,'keydown',hs.keyHandler);

try{
if (this.isHtml) this.htmlPrepareClose();

this.content.style.cursor = 'default';

this.changeSize(
0,
{
x:this.x.min,
y:this.y.min,
w:this.x.span,
h:parseInt(this.content.style.height),
imgW:this.x.imgSpan,
o:this.objOutline ? this.objOutline.offset:0
},
{
x:this.thumbLeft - this.offsetBorderW + this.thumbOffsetBorderW,
y:this.thumbTop - this.offsetBorderH + this.thumbOffsetBorderH,
w:this.thumbWidth,
h:this.thumbHeight,
imgW:this.thumbWidth,
o:hs.outlineStartOffset
},
hs.restoreDuration,
hs.restoreSteps
);

} catch (e){ this.afterClose()} 
},

htmlPrepareClose:function(){
if (hs.geckoMac){ // bad redraws
if (!hs.mask) hs.mask = hs.createElement('div',null,
{ position:'absolute' },hs.container);
hs.setStyles(hs.mask,{ width:this.x.span +'px',height:this.y.span +'px',
left:this.x.min +'px',top:this.y.min +'px',display:'block' });
}
if (this.swfObject) try{ hs.$(this.swfObject.getAttribute('id')).StopPlay()} catch (e){}

if (this.objectLoadTime == 'after' && !this.preserveContent) this.destroyObject();
if (this.scrollerDiv && this.scrollerDiv != this.scrollingContent) 
this.scrollerDiv.style.overflow = 'hidden';
},

destroyObject:function (){
if (hs.ie && this.iframe)
try{ this.iframe.contentWindow.document.body.innerHTML = ''} catch (e){}
this.body.innerHTML = '';
},

sleep:function(){
if (this.objOutline) this.objOutline.table.className = 'highslide-display-none';
this.releaseMask = null;
this.wrapper.className += ' highslide-display-none';
hs.push(hs.sleeping,this);
},

awake:function(){
hs.expanders[this.key] = this;

if (!hs.allowMultipleInstances &&hs.focusKey != this.key){
try{ hs.expanders[hs.focusKey].close()} catch (e){}
}

this.wrapper.className = this.wrapper.className.replace(/highslide-display-none/,'');
var z = hs.zIndexCounter++;
this.wrapper.style.zIndex = z;
this.isClosing = false;

var o = this.objOutline || 0;
if (o){
if (!this.outlineWhileAnimating) o.table.style.visibility = 'hidden';
o.table.className = null;
o.table.style.zIndex = z;
}
this.show();
},

createOverlay:function (o){
var el = o.overlayId;
if (typeof el == 'string') el = hs.getNode(el);
if (!el || typeof el == 'string') return;


var overlay = hs.createElement(
'div',
null,
{
'left':0,
'top':0,
'position':'absolute',
'zIndex':3,
'visibility':'hidden'
},
this.wrapper,
true
);
if (o.opacity) hs.setStyles(el,{ opacity:o.opacity });
el.style.styleFloat = 'none';
el.className += ' highslide-display-block';
overlay.appendChild(el);

overlay.hsPos = o.position;
this.positionOverlay(overlay);

if (o.hideOnMouseOut) overlay.setAttribute('hideOnMouseOut',true);
if (!o.opacity) o.opacity = 1;
overlay.setAttribute('opacity',o.opacity);
hs.fade(overlay,0,o.opacity);

hs.push(this.overlays,overlay);
},

positionOverlay:function(overlay){
var left = this.offsetBorderW;
var dLeft = this.x.span - overlay.offsetWidth;
var top = this.offsetBorderH;
var dTop = parseInt(this.content.style.height) - overlay.offsetHeight;

var p = overlay.hsPos || 'center center';
if (/^bottom/.test(p)) top += dTop;
if (/^center/.test(p)) top += dTop / 2;
if (/right$/.test(p)) left += dLeft;
if (/center$/.test(p)) left += dLeft / 2;
overlay.style.left = left +'px';
overlay.style.top = top +'px';
},

createOverlays:function(){
for (var i = 0;i < hs.overlays.length;i++){
var o = hs.overlays[i],tId = o.thumbnailId,sg = o.slideshowGroup;
if ((!tId && !sg) || tId == this.thumbsUserSetId
|| sg === this.slideshowGroup){
if (this.isImage || (this.isHtml && o.useOnHtml))
this.createOverlay(o);
}
}
},


createFullExpand:function (){
var a = hs.createElement(
'a',
{
href:'javascript:hs.expanders['+ this.key +'].doFullExpand();',
title:hs.fullExpandTitle,
className:'highslide-full-expand'
}
);

this.fullExpandLabel = a;
this.createOverlay({ overlayId:a,position:hs.fullExpandPosition,
hideOnMouseOut:true,opacity:hs.fullExpandOpacity });
},

doFullExpand:function (){
try{
hs.purge(this.fullExpandLabel);
this.fullExpandLabel.parentNode.removeChild(this.fullExpandLabel);
this.focus();

this.x.min = parseInt(this.wrapper.style.left) - (this.fullExpandWidth - this.content.width) / 2;
if (this.x.min < hs.marginLeft) this.x.min = hs.marginLeft;
this.wrapper.style.left = this.x.min +'px';

hs.setStyles(this.content,{ width:this.fullExpandWidth +'px',
height:this.fullExpandHeight +'px'});

this.x.span = this.fullExpandWidth;
this.wrapper.style.width = (this.x.span + 2*this.offsetBorderW) +'px';

this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;

if (this.objOutline)
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

for (var i = 0;i < this.overlays.length;i++)
this.positionOverlay(this.overlays[i]);

this.redoShowHide();



} catch (e){
window.location.href = this.content.src;
}
},


// on end move and resize
redoShowHide:function(){
var imgPos ={
x:parseInt(this.wrapper.style.left) - 20,
y:parseInt(this.wrapper.style.top) - 20,
w:this.content.offsetWidth + 40,
h:this.content.offsetHeight + 40 
+ this.spaceForCaption
};
if (hs.hideSelects) this.showHideElements('SELECT','hidden',imgPos);
if (hs.hideIframes) this.showHideElements('IFRAME','hidden',imgPos);
if (hs.geckoMac) this.showHideElements('*','hidden',imgPos);

},

wrapperMouseHandler:function (e){
if (!e) e = window.event;
var over = /mouseover/i.test(e.type);
if (!e.target) e.target = e.srcElement;// ie
if (hs.ie) e.relatedTarget = 
over ? e.fromElement:e.toElement;// ie
if (hs.getExpander(e.relatedTarget) == this || hs.dragArgs) return;
for (var i = 0;i < this.overlays.length;i++){
var o = this.overlays[i];
if (o.getAttribute('hideOnMouseOut')){
var from = over ? 0:o.getAttribute('opacity'),
to = over ? o.getAttribute('opacity'):0;
hs.fade(o,from,to);
}
}
},

afterClose:function (){
this.a.className = this.a.className.replace('highslide-active-anchor','');

if (hs.hideSelects) this.showHideElements('SELECT','visible');
if (hs.hideIframes) this.showHideElements('IFRAME','visible');
if (hs.geckoMac) this.showHideElements('*','visible');

if (this.isHtml && this.preserveContent) this.sleep();
else{
if (this.objOutline && this.outlineWhileAnimating) this.objOutline.destroy();
hs.purge(this.wrapper);
if (hs.ie && hs.ieVersion() < 5.5) this.wrapper.innerHTML = '';// crash
else this.wrapper.parentNode.removeChild(this.wrapper);
}
if (hs.mask) hs.mask.style.display = 'none';
hs.expanders[this.key] = null;
hs.cleanUp();
}
};


// hs.Ajax object prototype
hs.Ajax = function (a,content,pre){
this.a = a;
this.content = content;
this.pre = pre;// preloading
};

hs.Ajax.prototype ={
run:function (){
this.src = hs.getSrc(this.a);
if (this.src.match('#')){
var arr = this.src.split('#');
this.src = arr[0];
this.id = arr[1];
}
if (hs.cachedGets[this.src]){
this.cachedGet = hs.cachedGets[this.src];
if (this.id) this.getElementContent();
else this.loadHTML();
return;
}
try{ this.xmlHttp = new XMLHttpRequest()}
catch (e){
try{ this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")}
catch (e){
try{ this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")}
catch (e){ this.onError()}
}
}
var pThis = this;
this.xmlHttp.onreadystatechange = function(){
if(pThis.xmlHttp.readyState == 4){
if (pThis.id) pThis.getElementContent();
else pThis.loadHTML();
}
};

this.xmlHttp.open("GET",this.src,true);
this.xmlHttp.send(null);
},

getElementContent:function(){
hs.genContainer();
var attribs = window.opera ?{ src:this.src }:null;// Opera needs local src
this.iframe = hs.createElement('iframe',attribs,
{ position:'absolute',left:'-9999px' },hs.container);

try{
this.loadHTML();
} catch (e){ // Opera security
var pThis = this;
setTimeout(function(){pThis.loadHTML()},1);
}
},

loadHTML:function(){
var s = this.cachedGet || this.xmlHttp.responseText;
if (this.pre) hs.cachedGets[this.src] = s;
if (!hs.ie || hs.ieVersion() >= 5.5){
s = s.replace(/\s/g,' ');
s = s.replace(new RegExp('<link[^>]*>','gi'),'');
s = s.replace(new RegExp('<script[^>]*>.*?</script>','gi'),'');
if (this.iframe){
var doc = this.iframe.contentDocument || this.iframe.contentWindow.document;
doc.open();
doc.write(s);
doc.close();
try{ s = doc.getElementById(this.id).innerHTML} catch (e){
try{ s = this.iframe.document.getElementById(this.id).innerHTML} catch (e){} // opera
}
hs.container.removeChild(this.iframe);
} else{
s = s.replace(new RegExp('^.*?<body[^>]*>(.*?)</body>.*?$','i'),'$1');
}

}
hs.getElementByClass(this.content,'DIV','highslide-body').innerHTML = s;
this.onLoad();
}
};
// history
var HsExpander = hs.Expander;

// set handlers
hs.addEventListener(document,'mousedown',hs.mouseClickHandler);
hs.addEventListener(document,'mouseup',hs.mouseClickHandler);
hs.addEventListener(window,'load',hs.preloadImages);
//hs.addEventListener(window,'load',hs.preloadAjax);function ShowMaNhungFLV(linkFLV)
{
showeditform();
}
function ShowMaNhungMP3(linkMp3,width1,height1)
{
showeditformMp3(linkMp3,width1,height1);
}

function showeditform()
{
showPopup('divMaNhung');
//var editform = document.getElementById('divMaNhung');
var objFilter=document.getElementById("bgFilter");
if (objFilter)
{
document.getElementById("bgFilter").style.display = 'block';
document.getElementById("bgFilter").style.zIndex = '5';
document.getElementById("bgFilter").style.height = document.getElementById('mainDivAfa').offsetHeight + 'px';
}
}

function hideeditform()
{
var _objdivMaNhung=document.getElementById('divMaNhung');
var _objbgFilter= document.getElementById("bgFilter");
if (_objdivMaNhung)
_objdivMaNhung.style.display = 'none';
if (_objbgFilter)
_objbgFilter.style.display = 'none';
}

function showPopup(controlID)
{
var control = document.getElementById(controlID);
if (control)
{
control.style.display = 'block';
control.style.zIndex = '100';
var top = (window.screen.availHeight - control.offsetHeight)/2 - 100;
var left = (document.documentElement.offsetWidth - control.offsetWidth)/2;
left += (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft:document.body.scrollLeft;
top += (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop:document.body.scrollTop;

control.style.left= left + 'px';
control.style.top=top + 'px';

return true;
}
return false;
}/******************************************************************************
Name:Highslide JS
Version:3.3.12 (Feb 29 2008)
Config:default
Author:Torstein Hønsi
Support:http://vikjavev.no/highslide/forum

Licence:
Highslide JS is licensed under a Creative Commons Attribution-NonCommercial 2.5
License (http://creativecommons.org/licenses/by-nc/2.5/).

You are free:
* to copy,distribute,display,and perform the work
* to make derivative works

Under the following conditions:
* Attribution. You must attribute the work in the mannerspecified bythe
author or licensor.
* Noncommercial. You may not use this work for commercial purposes.

* Foranyreuseordistribution,youmust make clear to others the license
terms of this work.
* Anyoftheseconditionscanbewaivedifyouget permission from the 
copyright holder.

Your fair use and other rights are in no way affected by the above.
******************************************************************************/

var hs ={

// Apply your own settings here,or override them in the html file.
graphicsDir:'highslide/graphics/',
restoreCursor:'zoomout.cur',// necessary for preload
expandSteps:10,// number of steps in zoom. Each step lasts for duration/step milliseconds.
expandDuration:250,// milliseconds
restoreSteps:10,
restoreDuration:250,
marginLeft:15,
marginRight:15,
marginTop:15,
marginBottom:15,
zIndexCounter:1001,// adjust to other absolutely positioned elements

restoreTitle:'Kích vào ảnh để đóng,chọn phím di chuyển để xem ảnh tiếp theo',
loadingText:'Đang tải ảnh...',
loadingTitle:'Đóng',
loadingOpacity:0.75,
focusTitle:'Chọn để hiển thị rõ hơn',
allowMultipleInstances:true,
numberOfImagesToPreload:5,
captionSlideSpeed:1,// set to 0 to disable slide in effect
padToMinWidth:false,// pad the popup width to make room for wide caption
outlineWhileAnimating:2,// 0 = never,1 = always,2 = HTML only 
outlineStartOffset:3,// ends at 10
fullExpandTitle:'Expand to actual size',
fullExpandPosition:'bottom right',
fullExpandOpacity:1,
showCredits:true,// you can set this to false if you want
creditsText:'Family',
creditsHref:'http://family.channelvn.net',
creditsTitle:'family',
enableKeyListener:true,


// These settings can also be overridden inline for each image
captionId:null,
spaceForCaption:30,// leaves space below images with captions
slideshowGroup:null,// defines groups for next/previous links and keystrokes
minWidth:200,
minHeight:200,
allowSizeReduction:true,// allow the image to reduce to fit client size. If false,this overrides minWidth and minHeight
outlineType:'drop-shadow',// set null to disable outlines
wrapperClassName:'highslide-wrapper',// for enhanced css-control

// END OF YOUR SETTINGS


// declare internal properties
preloadTheseImages:[],
continuePreloading:true,
expanders:[],
overrides:[
'allowSizeReduction',
'outlineType',
'outlineWhileAnimating',
'spaceForCaption',
'captionId',
'captionText',
'captionEval',

'wrapperClassName',
'minWidth',
'minHeight',
'slideshowGroup',
'easing',
'easingClose',
'fadeInOut'
],
overlays:[],
faders:[],

pendingOutlines:{},
clones:{},
ie:(document.all && !window.opera),
safari:/Safari/.test(navigator.userAgent),
geckoMac:/Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),

$:function (id){
return document.getElementById(id);
},

push:function (arr,val){
arr[arr.length] = val;
},

createElement:function (tag,attribs,styles,parent,nopad){
var el = document.createElement(tag);
if (attribs) hs.setAttribs(el,attribs);
if (nopad) hs.setStyles(el,{padding:0,border:'none',margin:0});
if (styles) hs.setStyles(el,styles);
if (parent) parent.appendChild(el);
return el;
},

setAttribs:function (el,attribs){
for (var x in attribs) el[x] = attribs[x];
},

setStyles:function (el,styles){
for (var x in styles){
try{ 
if (hs.ie && x == 'opacity') 
el.style.filter = (styles[x] == 1) ? '':'alpha(opacity='+ (styles[x] * 100) +')';
else el.style[x] = styles[x];
}
catch (e){}
}
},

ieVersion:function (){
var arr = navigator.appVersion.split("MSIE");
return arr[1] ? parseFloat(arr[1]):null;
},

getPageSize:function (){
var iebody = document.compatMode && document.compatMode != "BackCompat" 
? document.documentElement:document.body;

var width = hs.ie ? iebody.clientWidth:
(document.documentElement.clientWidth || self.innerWidth),
height = hs.ie ? iebody.clientHeight:self.innerHeight;

return{
width:width,
height:height,
scrollLeft:hs.ie ? iebody.scrollLeft:pageXOffset,
scrollTop:hs.ie ? iebody.scrollTop:pageYOffset
}
},

position:function(el){ 
var p ={ x:el.offsetLeft,y:el.offsetTop };
while (el.offsetParent){
el = el.offsetParent;
p.x += el.offsetLeft;
p.y += el.offsetTop;
if (el != document.body && el != document.documentElement){
p.x -= el.scrollLeft;
p.y -= el.scrollTop;
}
}
return p;
},

expand:function(a,params,custom){
if (a.getParams) return params;

try{
new hs.Expander(a,params,custom);
return false;
} catch (e){ return true}
},

focusTopmost:function(){
var topZ = 0,topmostKey = -1;
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i]){
if (hs.expanders[i].wrapper.style.zIndex && hs.expanders[i].wrapper.style.zIndex > topZ){
topZ = hs.expanders[i].wrapper.style.zIndex;

topmostKey = i;
}
}
}
if (topmostKey == -1) hs.focusKey = -1;
else hs.expanders[topmostKey].focus();
},

getAdjacentAnchor:function(key,op){
var aAr = document.getElementsByTagName('A'),hsAr ={},activeI = -1,j = 0;
for (var i = 0;i < aAr.length;i++){
if (hs.isHsAnchor(aAr[i]) && ((hs.expanders[key].slideshowGroup 
== hs.getParam(aAr[i],'slideshowGroup')))){
hsAr[j] = aAr[i];
if (hs.expanders[key] && aAr[i] == hs.expanders[key].a){
activeI = j;
}
j++;
}
}
return hsAr[activeI + op] || null;
},

getParam:function (a,param){
a.getParams = a.onclick;
var p = a.getParams ? a.getParams():null;
a.getParams = null;

return (p && typeof p[param] != 'undefined') ? p[param]:
(typeof hs[param] != 'undefined' ? hs[param]:null);
},

getSrc:function (a){
var src = hs.getParam(a,'src');
if (src) return src;
return a.href;
},

getNode:function (id){
var node = hs.$(id),clone = hs.clones[id],a ={};
if (!node && !clone) return null;
if (!clone){
clone = node.cloneNode(true);
clone.id = '';
hs.clones[id] = clone;
return node;
} else{
return clone.cloneNode(true);
}
},

purge:function(d){
if (!hs.ie) return;
var a = d.attributes,i,l,n;
if (a){
l = a.length;
for (var i = 0;i < l;i += 1){
n = a[i].name;
if (typeof d[n] === 'function'){
d[n] = null;
}
}
}
a = d.childNodes;
if (a){
l = a.length;
for (var i = 0;i < l;i += 1){
hs.purge(d.childNodes[i]);
}
}
},

previousOrNext:function (el,op){
var exp = hs.last = hs.getExpander(el);
try{
var adj = hs.upcoming =hs.getAdjacentAnchor(exp.key,op);
adj.onclick();
} catch (e){}
try{ exp.close()} catch (e){}
return false;
},

previous:function (el){
return hs.previousOrNext(el,-1);
},

next:function (el){
return hs.previousOrNext(el,1);
},

keyHandler:function(e){
if (!e) e = window.event;
if (!e.target) e.target = e.srcElement;// ie
if (e.target.form) return true;// form element has focus

var op = null;
switch (e.keyCode){
case 32:// Space
case 34:// Page Down
case 39:// Arrow right
case 40:// Arrow down
op = 1;
break;
case 8:// Backspace
case 33:// Page Up
case 37:// Arrow left
case 38:// Arrow up
op = -1;
break;
case 27:// Escape
case 13:// Enter
op = 0;
}
if (op !== null){
hs.removeEventListener(document,'keydown',hs.keyHandler);
if (!hs.enableKeyListener) return true;

if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
if (op == 0){
try{ hs.getExpander().close()} catch (e){}
return false;
} else{
return hs.previousOrNext(hs.focusKey,op);
}
}
return true;
},


registerOverlay:function (overlay){
hs.push(hs.overlays,overlay);
},

getWrapperKey:function (element){
var el,re = /^highslide-wrapper-([0-9]+)$/;
// 1. look in open expanders
el = element;
while (el.parentNode){
if (el.id && re.test(el.id)) return el.id.replace(re,"$1");
el = el.parentNode;
}
// 2. look in thumbnail
el = element;
while (el.parentNode){
if (el.tagName && hs.isHsAnchor(el)){
for (var key = 0;key < hs.expanders.length;key++){
var exp = hs.expanders[key];
if (exp && exp.a == el) return key;
}
}
el = el.parentNode;
}
return null;
},

getExpander:function (el){
if (typeof el == 'undefined') return hs.expanders[hs.focusKey] || null;
if (typeof el == 'number') return hs.expanders[el] || null;
if (typeof el == 'string') el = hs.$(el);
return hs.expanders[hs.getWrapperKey(el)] || null;
},

isHsAnchor:function (a){
return (a.onclick && a.onclick.toString().replace(/\s/g,' ').match(/hs.(htmlE|e)xpand/));
},

cleanUp:function (){
for (var i = 0;i < hs.expanders.length;i++)
if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost();
},

mouseClickHandler:function(e) 
{
if (!e) e = window.event;
if (e.button > 1) return true;
if (!e.target) e.target = e.srcElement;

var el = e.target;
while (el.parentNode
&& !(/highslide-(image|move|html|resize)/.test(el.className)))
{
el = el.parentNode;
}
var exp = hs.getExpander(el);
if (exp && (exp.isClosing || !exp.isExpanded)) return true;

if (exp && e.type == 'mousedown'){
if (e.target.form) return true;
var match = el.className.match(/highslide-(image|move|resize)/);
if (match){
hs.dragArgs ={ exp:exp ,type:match[1],left:exp.x.min,width:exp.x.span,top:exp.y.min,
height:exp.y.span,clickX:e.clientX,clickY:e.clientY };

//if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move';

hs.addEventListener(document,'mousemove',hs.dragHandler);
if (e.preventDefault) e.preventDefault();// FF

if (/highslide-(image|html)-blur/.test(exp.content.className)){
exp.focus();
hs.hasFocused = true;
}
return false;
}
} else if (e.type == 'mouseup'){

hs.removeEventListener(document,'mousemove',hs.dragHandler);

if (hs.dragArgs){
if (hs.dragArgs.type == 'image')
hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;
var hasDragged = hs.dragArgs.hasDragged;

if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)){
exp.close();
} 
else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)){
hs.dragArgs.exp.redoShowHide();
}

hs.hasFocused = false;
hs.dragArgs = null;

} else if (/highslide-image-blur/.test(el.className)){
el.style.cursor = hs.styleRestoreCursor;
}
}
return false;
},

dragHandler:function(e)
{
if (!hs.dragArgs) return true;
if (!e) e = window.event;
var a = hs.dragArgs,exp = a.exp;

a.dX = e.clientX - a.clickX;
a.dY = e.clientY - a.clickY;

var distance = Math.sqrt(Math.pow(a.dX,2) + Math.pow(a.dY,2));
a.hasDragged = (a.type != 'image' && distance > 0)
|| (distance > (hs.dragSensitivity || 5));

if (a.hasDragged){
 exp.move(a);
}
return false;
},

addEventListener:function (el,event,func){
try{
el.addEventListener(event,func,false);
} catch (e){
try{
el.detachEvent('on'+ event,func);
el.attachEvent('on'+ event,func);
} catch (e){
el['on'+ event] = func;
}
} 
},

removeEventListener:function (el,event,func){
try{
el.removeEventListener(event,func,false);
} catch (e){
try{
el.detachEvent('on'+ event,func);
} catch (e){
el['on'+ event] = null;
}
}
},

preloadFullImage:function (i){
if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined'){
var img = document.createElement('img');
img.onload = function(){ hs.preloadFullImage(i + 1)};
img.src = hs.preloadTheseImages[i];
}
},
preloadImages:function (number){
if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;
var a,re,j = 0;

var aTags = document.getElementsByTagName('A');
for (var i = 0;i < aTags.length;i++){
a = aTags[i];
re = hs.isHsAnchor(a);
if (re && re[0] == 'hs.expand'){
if (j < hs.numberOfImagesToPreload){
hs.preloadTheseImages[j] = hs.getSrc(a);
j++;
}
}
}

// preload outlines
new hs.Outline(hs.outlineType,function (){ hs.preloadFullImage(0)} );


// preload cursor
var cur = hs.createElement('img',{ src:hs.graphicsDir + hs.restoreCursor });
},


genContainer:function (){
if (!hs.container){
hs.container = hs.createElement('div',
null,
{ position:'absolute',left:0,top:0,width:'100%',zIndex:hs.zIndexCounter },
document.body,
true
);
hs.loading = hs.createElement('a',
{
className:'highslide-loading',
title:hs.loadingTitle,
innerHTML:hs.loadingText,
href:'javascript:void(0)'
},
{
position:'absolute',
opacity:hs.loadingOpacity,
left:'-9999px',
zIndex:1
},hs.container
);

// http://www.robertpenner.com/easing/ 
Math.linearTween = function (t,b,c,d){
return c*t/d + b;
};
Math.easeInQuad = function (t,b,c,d){
return c*(t/=d)*t + b;
};
}
},

fade:function (el,o,oFinal,dur,i,dir){
if (typeof i == 'undefined'){ // new fader
if (typeof dur != 'number') dur = 250;
if (dur < 25){ // instant
hs.setStyles( el,{
opacity:oFinal,
visibility:(o < oFinal ? 'visible':'hidden')
});
return;
}
i = hs.faders.length;
dir = oFinal > o ? 1:-1;
var step = (25 / (dur - dur % 25)) * Math.abs(o - oFinal);
}
o = parseFloat(o);
el.style.visibility = (o <= 0) ? 'hidden':'visible';
if (o < 0 || (dir == 1 && o > oFinal)) return;
if (el.fading && el.fading.i != i){ // reverse
clearTimeout(hs.faders[el.fading.i]);
o = el.fading.o;
}
el.fading ={i:i,o:o,step:(step || el.fading.step)};
el.style.visibility = (o <= 0) ? 'hidden':'visible';
hs.setStyles(el,{ opacity:o });
hs.faders[i] = setTimeout(function(){
hs.fade(el,o + el.fading.step * dir,oFinal,null,i,dir);
},25);
},

close:function(el){
try{ hs.getExpander(el).close()} catch (e){}
return false;
}
};// end hs object


//-----------------------------------------------------------------------------
hs.Outline =function (outlineType,onLoad){
this.onLoad = onLoad;
this.outlineType = outlineType;
var v = hs.ieVersion(),tr;

this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 7;
if (!outlineType){
if (onLoad) onLoad();
return;
}

hs.genContainer();
this.table = hs.createElement(
'table',{ cellSpacing:0 },
{
visibility:'hidden',
position:'absolute',
borderCollapse:'collapse'
},
hs.container,
true
);
this.tbody = hs.createElement('tbody',null,null,this.table,1);

this.td = [];
for (var i = 0;i <= 8;i++){
if (i % 3 == 0) tr = hs.createElement('tr',null,{ height:'auto' },this.tbody,true);
this.td[i] = hs.createElement('td',null,null,tr,true);
var style = i != 4 ?{ lineHeight:0,fontSize:0}:{ position:'relative' };
hs.setStyles(this.td[i],style);
}
this.td[4].className = outlineType;

this.preloadGraphic();
};

hs.Outline.prototype ={
preloadGraphic:function (){
var src = hs.graphicsDir + (hs.outlinesDir || "outlines/")+ this.outlineType +".png";

var appendTo = hs.safari ? hs.container:null;
this.graphic = hs.createElement('img',null,{ position:'absolute',left:'-9999px',
top:'-9999px' },appendTo,true);// for onload trigger

var pThis = this;
this.graphic.onload = function(){ pThis.onGraphicLoad()};

this.graphic.src = src;
},

onGraphicLoad:function (){
var o = this.offset = this.graphic.width / 4,
pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],
dim ={ height:(2*o) +'px',width:(2*o) +'px' };

for (var i = 0;i <= 8;i++){
if (pos[i]){
if (this.hasAlphaImageLoader){
var w = (i == 1 || i == 7) ? '100%':this.graphic.width +'px';
var div = hs.createElement('div',null,{ width:'100%',height:'100%',position:'relative',overflow:'hidden'},this.td[i],true);
hs.createElement ('div',null,{ 
filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src='"+ this.graphic.src + "')",
position:'absolute',
width:w,
height:this.graphic.height +'px',
left:(pos[i][0]*o)+'px',
top:(pos[i][1]*o)+'px'
},
div,
true);
} else{
hs.setStyles(this.td[i],{ background:'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'});
}

if (window.opera && (i == 3 || i ==5)) 
hs.createElement('div',null,dim,this.td[i],true);

hs.setStyles (this.td[i],dim);
}
}

hs.pendingOutlines[this.outlineType] = this;
if (this.onLoad) this.onLoad();
},

setPosition:function (exp,x,y,w,h,vis){
if (vis) this.table.style.visibility = (h >= 4 * this.offset) 
? 'visible':'hidden';
this.table.style.left = (x - this.offset) +'px';
this.table.style.top = (y - this.offset) +'px';
this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px';
w += 2 * (exp.offsetBorderW - this.offset);
h += + 2 * (exp.offsetBorderH - this.offset);
this.td[4].style.width = w >= 0 ? w +'px':0;
this.td[4].style.height = h >= 0 ? h +'px':0;
if (this.hasAlphaImageLoader) this.td[3].style.height 
= this.td[5].style.height = this.td[4].style.height;
},

destroy:function(hide){
if (hide) this.table.style.visibility = 'hidden';
else{
hs.purge(this.table);
try{ this.table.parentNode.removeChild(this.table)} catch (e){}
}
}
};

//-----------------------------------------------------------------------------
// The expander object
hs.Expander = function(a,params,custom,contentType){
this.a = a;
this.custom = custom;
this.contentType = contentType || 'image';
this.isImage = !this.isHtml;

hs.continuePreloading = false;
hs.genContainer();
var key = this.key = hs.expanders.length;

// override inline parameters
for (var i = 0;i < hs.overrides.length;i++){
var name = hs.overrides[i];
this[name] = params && typeof params[name] != 'undefined' ?
params[name]:hs[name];
}

// get thumb
var el = this.thumb = ((params && params.thumbnailId) ? hs.$(params.thumbnailId):null) 
|| a.getElementsByTagName('img')[0] || a;
this.thumbsUserSetId = el.id || a.id;

// check if already open
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && hs.expanders[i].a == a){
hs.expanders[i].focus();
return false;
}
}
// cancel other
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted){
hs.expanders[i].cancelLoading();
}
}
hs.expanders[this.key] = this;
if (!hs.allowMultipleInstances){
if (hs.expanders[key-1]) hs.expanders[key-1].close();
if (typeof hs.focusKey != 'undefined' && hs.expanders[hs.focusKey])
hs.expanders[hs.focusKey].close();
}
this.overlays = [];

var pos = hs.position(el);

// store properties of thumbnail
this.thumbWidth = el.width ? el.width:el.offsetWidth;
this.thumbHeight = el.height ? el.height:el.offsetHeight;
this.thumbLeft = pos.x;
this.thumbTop = pos.y;
this.thumbOffsetBorderW = (this.thumb.offsetWidth - this.thumbWidth) / 2;
this.thumbOffsetBorderH = (this.thumb.offsetHeight - this.thumbHeight) / 2;

// instanciate the wrapper
this.wrapper = hs.createElement(
'div',
{
id:'highslide-wrapper-'+ this.key,
className:this.wrapperClassName
},
{
visibility:'hidden',
position:'absolute',
zIndex:hs.zIndexCounter++
},null,true );

this.wrapper.onmouseover = function (e){ 
try{ hs.expanders[key].wrapperMouseHandler(e)} catch (e){} 
};
this.wrapper.onmouseout = function (e){ 
try{ hs.expanders[key].wrapperMouseHandler(e)} catch (e){}
};
if (this.contentType == 'image' && this.outlineWhileAnimating == 2)
this.outlineWhileAnimating = 0;
// get the outline
if (hs.pendingOutlines[this.outlineType]){
this.connectOutline();
this[this.contentType +'Create']();
} else if (!this.outlineType){
this[this.contentType +'Create']();
} else{
this.displayLoading();
var exp = this;
new hs.Outline(this.outlineType,
function (){ 
exp.connectOutline();
exp[exp.contentType +'Create']();
} 
);
}
return true;
};

hs.Expander.prototype ={

connectOutline:function(x,y){
var w = hs.pendingOutlines[this.outlineType];
this.objOutline = w;
w.table.style.zIndex = this.wrapper.style.zIndex;
hs.pendingOutlines[this.outlineType] = null;
},

displayLoading:function(){
if (this.onLoadStarted || this.loading) return;

this.originalCursor = this.a.style.cursor;
this.a.style.cursor = 'wait';

this.loading = hs.loading;
var exp = this;
this.loading.onclick = function(){
exp.cancelLoading();
};
this.loading.style.top = (this.thumbTop 
+ (this.thumbHeight - this.loading.offsetHeight) / 2) +'px';
var exp = this,left = (this.thumbLeft + this.thumbOffsetBorderW 
+ (this.thumbWidth - this.loading.offsetWidth) / 2) +'px';
setTimeout(function (){ if (exp.loading) exp.loading.style.left = left },100);
},

imageCreate:function(){
var exp = this;

var img = document.createElement('img');
this.content = img;
img.onload = function (){
if (hs.expanders[exp.key]) exp.contentLoaded();
};
if (hs.blockRightClick) img.oncontextmenu = function(){ return false};
img.className = 'highslide-image';
img.style.visibility = 'hidden';// prevent flickering in IE
img.style.display = 'block';
img.style.position = 'absolute';
img.style.maxWidth = 'none';
img.style.zIndex = 3;
img.title = hs.restoreTitle;
if (hs.safari) hs.container.appendChild(img);
if (hs.ie && hs.flushImgSize) img.src = null;
img.src = hs.getSrc(this.a);

this.displayLoading();
},

contentLoaded:function(){
try{
if (!this.content) return;
if (this.onLoadStarted) return;// old Gecko loop
else this.onLoadStarted = true;

 
if (this.loading){
this.loading.style.left = '-9999px';
this.loading = null;
this.a.style.cursor = this.originalCursor || '';
}
this.marginBottom = hs.marginBottom;
this.newWidth = this.content.width;
this.newHeight = this.content.height;
this.fullExpandWidth = this.newWidth;
this.fullExpandHeight = this.newHeight;

this.content.style.width = this.thumbWidth +'px';
this.content.style.height = this.thumbHeight +'px';
this.getCaption();


this.wrapper.appendChild(this.content);
this.content.style.position = 'relative';// Saf
if (this.caption) this.wrapper.appendChild(this.caption);
this.wrapper.style.left = this.thumbLeft +'px';
this.wrapper.style.top = this.thumbTop +'px';
hs.container.appendChild(this.wrapper);

// correct for borders
this.offsetBorderW = (this.content.offsetWidth - this.thumbWidth) / 2;
this.offsetBorderH = (this.content.offsetHeight - this.thumbHeight) / 2;
var modMarginRight = hs.marginRight + 2 * this.offsetBorderW;
this.marginBottom += 2 * this.offsetBorderH;

var ratio = this.newWidth / this.newHeight;
var minWidth = this.allowSizeReduction 
? this.minWidth:this.newWidth;
var minHeight = this.allowSizeReduction 
? this.minHeight:this.newHeight;

var justify ={ x:'auto',y:'auto' };

var page = hs.getPageSize();
// justify
this.x ={ 
min:parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW,
span:this.newWidth,
minSpan:(this.newWidth < minWidth && !hs.padToMinWidth) 
? this.newWidth:minWidth,
marginMin:hs.marginLeft,
marginMax:modMarginRight,
scroll:page.scrollLeft,
clientSpan:page.width,
thumbSpan:this.thumbWidth
};
var oldRight = this.x.min + parseInt(this.thumbWidth);
this.x = this.justify(this.x);
this.y ={ 
min:parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH,
span:this.newHeight,
minSpan:this.newHeight < minHeight ? this.newHeight:minHeight,
marginMin:hs.marginTop,
marginMax:this.marginBottom,
scroll:page.scrollTop,
clientSpan:page.height,
thumbSpan:this.thumbHeight
};
var oldBottom = this.y.min + parseInt(this.thumbHeight);
this.y = this.justify(this.y);

this.correctRatio(ratio);


var x = this.x;
var y = this.y;

this.show();
} catch (e){
window.location.href = hs.getSrc(this.a);
}
},

justify:function (p){

var tgt,dim = p == this.x ? 'x':'y';


var hasMovedMin = false;

var allowReduce = true;

// calculate p.min
p.min = Math.round(p.min - ((p.span - p.thumbSpan) / 2));// auto

if (p.min < p.scroll + p.marginMin){
p.min = p.scroll + p.marginMin;
hasMovedMin = true;
}


if (p.span < p.minSpan){
p.span = p.minSpan;
allowReduce = false;
}

// calculate right/newWidth
if (p.min + p.span > p.scroll + p.clientSpan - p.marginMax){
if (hasMovedMin && allowReduce){

p.span = p.clientSpan - p.marginMin - p.marginMax;// can't expand more

} else if (p.span < p.clientSpan - p.marginMin - p.marginMax){ // move newTop up
p.min = p.scroll + p.clientSpan - p.span - p.marginMin - p.marginMax;
} else{ // image larger than client
p.min = p.scroll + p.marginMin;

if (allowReduce) p.span = p.clientSpan - p.marginMin - p.marginMax;

}

}

if (p.span < p.minSpan){
p.span = p.minSpan;
allowReduce = false;
}



if (p.min < p.marginMin){
tmpMin = p.min;
p.min = p.marginMin;

if (allowReduce) p.span = p.span - (p.min - tmpMin);

}
return p;
},

correctRatio:function(ratio){
var x = this.x;
var y = this.y;
var changed = false;
if (x.span / y.span > ratio){ // width greater
var tmpWidth = x.span;
x.span = y.span * ratio;
if (x.span < x.minSpan){ // below minWidth
if (hs.padToMinWidth) x.imgSpan = x.span;
x.span = x.minSpan;
if (!x.imgSpan)
y.span = x.span / ratio;
}
changed = true;

} else if (x.span / y.span < ratio){ // height greater
var tmpHeight = y.span;
y.span = x.span / ratio;
changed = true;
}

if (changed){
x.min = parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW;
x.minSpan = x.span;
this.x = this.justify(x);

y.min = parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH;
y.minSpan = y.span;
this.y = this.justify(y);
}
},

show:function (){

// Selectbox bug
var imgPos ={x:this.x.min - 20,y:this.y.min - 20,w:this.x.span + 40,
h:this.y.span + 40
 + this.spaceForCaption};
hs.hideSelects = (hs.ie && hs.ieVersion() < 7);
if (hs.hideSelects) this.showHideElements('SELECT','hidden',imgPos);
// Iframes bug
hs.hideIframes = ((window.opera && navigator.appVersion < 9) || navigator.vendor == 'KDE' 
|| (hs.ie && hs.ieVersion() < 5.5));
if (hs.hideIframes) this.showHideElements('IFRAME','hidden',imgPos);
// Scrollbars bug
if (hs.geckoMac) this.showHideElements('*','hidden',imgPos);


if (this.x.imgSpan) this.content.style.margin = '0 auto';

// Apply size change
this.changeSize(
1,
{ 
x:this.thumbLeft + this.thumbOffsetBorderW - this.offsetBorderW,
y:this.thumbTop + this.thumbOffsetBorderH - this.offsetBorderH,
w:this.thumbWidth,
h:this.thumbHeight,
imgW:this.thumbWidth,
o:hs.outlineStartOffset
},
{
x:this.x.min,
y:this.y.min,
w:this.x.span,
h:this.y.span,
imgW:this.x.imgSpan,
o:this.objOutline ? this.objOutline.offset:0
},
hs.expandDuration,
hs.expandSteps
);
},

changeSize:function(up,from,to,dur,steps){

if (up && this.objOutline && !this.outlineWhileAnimating) 
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

else if (!up && this.objOutline){
if (this.outlineWhileAnimating) this.objOutline.setPosition(this,from.x,from.y,from.w,from.h);
else this.objOutline.destroy();
}

if (!up){ // remove children
var n = this.wrapper.childNodes.length;
for (var i = n - 1;i >= 0 ;i--){
var child = this.wrapper.childNodes[i];
if (child != this.content){
hs.purge(child);
this.wrapper.removeChild(child);
}
}
}

if (this.fadeInOut){
from.op = up ? 0:1;
to.op = up;
}
var t,
exp = this,
easing = Math[this.easing] || Math.easeInQuad;
if (!up) easing = Math[this.easingClose] || easing;

for (var i = 1;i <= steps;i++){
t = Math.round(i * (dur / steps));

(function(){
var pI = i,size ={};

for (var x in from) 
size[x] = easing(t,from[x],to[x] - from[x],dur);

setTimeout ( function(){
if (up && pI == 1){
exp.content.style.visibility = 'visible';
exp.a.className += ' highslide-active-anchor';
}
exp.setSize(size);
},t);
})();
}

if (up){ 

setTimeout(function(){
if (exp.objOutline) exp.objOutline.table.style.visibility = "visible";
},t);
setTimeout(function(){
if (exp.caption) exp.writeCaption();
exp.afterExpand();
},t + 50);
}
else setTimeout(function(){ exp.afterClose()},t);

},

setSize:function (to){
try{
this.wrapper.style.width = (to.w + 2*this.offsetBorderW) +'px';
this.content.style.width =
((to.imgW && !isNaN(to.imgW)) ? to.imgW:to.w) +'px';
if (hs.safari) this.content.style.maxWidth = this.content.style.width;
this.content.style.height = to.h +'px';

if (to.op) hs.setStyles(this.wrapper,{ opacity:to.op });


if (this.objOutline && this.outlineWhileAnimating){
var o = this.objOutline.offset - to.o;
this.objOutline.setPosition(this,to.x + o,to.y + o,to.w - 2 * o,to.h - 2 * o,1);
}

hs.setStyles ( this.wrapper,
{
'visibility':'visible',
'left':to.x +'px',
'top':to.y +'px'
}
);

} catch (e){ window.location.href = hs.getSrc(this.a)}
},

afterExpand:function(){
this.isExpanded = true;
this.focus();

this.createOverlays();
if (hs.showCredits) this.writeCredits();
if (this.isImage && this.fullExpandWidth > this.x.span) this.createFullExpand();
if (!this.caption) this.prepareNextOutline();
},


prepareNextOutline:function(){
var key = this.key;
var outlineType = this.outlineType;
new hs.Outline(outlineType,
function (){ try{ hs.expanders[key].preloadNext()} catch (e){} });
},


preloadNext:function(){
var next = hs.getAdjacentAnchor(this.key,1);
if (next.onclick.toString().match(/hs\.expand/)) 
var img = hs.createElement('img',{ src:hs.getSrc(next) });
},

cancelLoading:function(){
hs.expanders[this.key] = null;
this.a.style.cursor = this.originalCursor;
if (this.loading) hs.loading.style.left = '-9999px';
},

writeCredits:function (){
var credits = hs.createElement('a',
{
href:hs.creditsHref,
className:'highslide-credits',
innerHTML:hs.creditsText,
title:hs.creditsTitle
}
);
this.createOverlay({ overlayId:credits,position:'top left'});
},

getCaption:function(){
if (!this.captionId && this.thumbsUserSetId)
this.captionId = 'caption-for-'+ this.thumbsUserSetId;
if (this.captionId) this.caption = hs.getNode(this.captionId);
if (!this.caption && !this.captionText && this.captionEval) try{
this.captionText = eval(this.captionEval);
} catch (e){}
if (!this.caption && this.captionText) this.caption = hs.createElement('div',
{ className:'highslide-caption',innerHTML:this.captionText } );

if (!this.caption){
var next = this.a.nextSibling;
while (next && !hs.isHsAnchor(next)){
if (/highslide-caption/.test(next.className || null)){
this.caption = next.cloneNode(1);
break;
}
next = next.nextSibling;
}
}
if (this.caption){
this.marginBottom += this.spaceForCaption;
}

},

writeCaption:function(){
try{
hs.setStyles(this.wrapper,{ width:this.wrapper.offsetWidth +'px',
height:this.wrapper.offsetHeight +'px' } );
hs.setStyles(this.caption,{ visibility:'hidden',marginTop:hs.safari ? 0:'-'+ this.y.span +'px'});
this.caption.className += ' highslide-display-block';

var height,exp = this;
if (hs.ie && (hs.ieVersion() < 6 || document.compatMode == 'BackCompat')){
height = this.caption.offsetHeight;
} else{
var temp = hs.createElement('div',{innerHTML:this.caption.innerHTML},
null,null,true);// to get height
this.caption.innerHTML = '';
this.caption.appendChild(temp);
height = this.caption.childNodes[0].offsetHeight;
this.caption.innerHTML = this.caption.childNodes[0].innerHTML;
}
hs.setStyles(this.caption,{ overflow:'hidden',height:0,zIndex:2,marginTop:0 });
this.wrapper.style.height = 'auto';

if (hs.captionSlideSpeed){
var step = (Math.round(height/50) || 1) * hs.captionSlideSpeed;
} else{
this.placeCaption(height,1);
return;
}
for (var h = height % step,t = 0;h <= height;h += step,t += 10){
(function(){
var pH = h,end = (h == height) ? 1:0;
setTimeout( function(){
exp.placeCaption(pH,end);
},t);
})();
}
} catch (e){}
},

placeCaption:function(height,end){
if (!this.caption) return;
this.caption.style.height = height +'px';
this.caption.style.visibility = 'visible';
this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;


var o = this.objOutline;
if (o){
o.td[4].style.height = (this.wrapper.offsetHeight - 2 * this.objOutline.offset) +'px';
if (o.hasAlphaImageLoader) o.td[3].style.height = o.td[5].style.height = o.td[4].style.height;
}
if (end) this.prepareNextOutline();
},


showHideElements:function (tagName,visibility,imgPos){
var els = document.getElementsByTagName(tagName);
var prop = tagName == '*' ? 'overflow':'visibility';
for (var i = 0;i < els.length;i++){
if (prop == 'visibility' || (document.defaultView.getComputedStyle(
els[i],"").getPropertyValue('overflow') == 'auto'
|| els[i].getAttribute('hidden-by') != null)){
var hiddenBy = els[i].getAttribute('hidden-by');
if (visibility == 'visible' && hiddenBy){
hiddenBy = hiddenBy.replace('['+ this.key +']','');
els[i].setAttribute('hidden-by',hiddenBy);
if (!hiddenBy) els[i].style[prop] = els[i].origProp;
} else if (visibility == 'hidden'){ // hide if behind
var elPos = hs.position(els[i]);
elPos.w = els[i].offsetWidth;
elPos.h = els[i].offsetHeight;


var clearsX = (elPos.x + elPos.w < imgPos.x || elPos.x > imgPos.x + imgPos.w);
var clearsY = (elPos.y + elPos.h < imgPos.y || elPos.y > imgPos.y + imgPos.h);
var wrapperKey = hs.getWrapperKey(els[i]);
if (!clearsX && !clearsY && wrapperKey != this.key){ // element falls behind image
if (!hiddenBy){
els[i].setAttribute('hidden-by','['+ this.key +']');
els[i].origProp = els[i].style[prop];
els[i].style[prop] = 'hidden';
} else if (!hiddenBy.match('['+ this.key +']')){
els[i].setAttribute('hidden-by',hiddenBy + '['+ this.key +']');
}
} else if (hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey){ // on move
els[i].setAttribute('hidden-by','');
els[i].style[prop] = els[i].origProp || '';
} else if (hiddenBy && hiddenBy.match('['+ this.key +']')){
els[i].setAttribute('hidden-by',hiddenBy.replace('['+ this.key +']',''));
}

}
}
}
},

focus:function(){
this.wrapper.style.zIndex = hs.zIndexCounter++;
// blur others
for (var i = 0;i < hs.expanders.length;i++){
if (hs.expanders[i] && i == hs.focusKey){
var blurExp = hs.expanders[i];
blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';

if (blurExp.caption){
blurExp.caption.className += ' highslide-caption-blur';
}

blurExp.content.style.cursor = hs.ie ? 'hand':'pointer';
blurExp.content.title = hs.focusTitle;
}
}

// focus this
if (this.objOutline) this.objOutline.table.style.zIndex 
= this.wrapper.style.zIndex;

this.content.className = 'highslide-'+ this.contentType;

if (this.caption){
this.caption.className = this.caption.className.replace(' highslide-caption-blur','');
}

this.content.title = hs.restoreTitle;

hs.styleRestoreCursor = window.opera ? 'pointer':'url('+ hs.graphicsDir + hs.restoreCursor +'),pointer';
if (hs.ie && hs.ieVersion() < 6) hs.styleRestoreCursor = 'hand';
this.content.style.cursor = hs.styleRestoreCursor;

hs.focusKey = this.key;
hs.addEventListener(document,'keydown',hs.keyHandler);
},

move:function (e){
this.x.min = e.left + e.dX;
this.y.min = e.top + e.dY;

if (e.type == 'image') this.content.style.cursor = 'move';
hs.setStyles(this.wrapper,{ left:this.x.min +'px',top:this.y.min +'px' });

if (this.objOutline)
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

},

close:function(){
if (this.isClosing || !this.isExpanded) return;
this.isClosing = true;

hs.removeEventListener(document,'keydown',hs.keyHandler);

try{

this.content.style.cursor = 'default';

this.changeSize(
0,
{
x:this.x.min,
y:this.y.min,
w:this.x.span,
h:parseInt(this.content.style.height),
imgW:this.x.imgSpan,
o:this.objOutline ? this.objOutline.offset:0
},
{
x:this.thumbLeft - this.offsetBorderW + this.thumbOffsetBorderW,
y:this.thumbTop - this.offsetBorderH + this.thumbOffsetBorderH,
w:this.thumbWidth,
h:this.thumbHeight,
imgW:this.thumbWidth,
o:hs.outlineStartOffset
},
hs.restoreDuration,
hs.restoreSteps
);

} catch (e){ this.afterClose()} 
},

createOverlay:function (o){
var el = o.overlayId;
if (typeof el == 'string') el = hs.getNode(el);
if (!el || typeof el == 'string') return;


var overlay = hs.createElement(
'div',
null,
{
'left':0,
'top':0,
'position':'absolute',
'zIndex':3,
'visibility':'hidden'
},
this.wrapper,
true
);
if (o.opacity) hs.setStyles(el,{ opacity:o.opacity });
el.style.styleFloat = 'none';
el.className += ' highslide-display-block';
overlay.appendChild(el);

overlay.hsPos = o.position;
this.positionOverlay(overlay);

if (o.hideOnMouseOut) overlay.setAttribute('hideOnMouseOut',true);
if (!o.opacity) o.opacity = 1;
overlay.setAttribute('opacity',o.opacity);
hs.fade(overlay,0,o.opacity);

hs.push(this.overlays,overlay);
},

positionOverlay:function(overlay){
var left = this.offsetBorderW;
var dLeft = this.x.span - overlay.offsetWidth;
var top = this.offsetBorderH;
var dTop = parseInt(this.content.style.height) - overlay.offsetHeight;

var p = overlay.hsPos || 'center center';
if (/^bottom/.test(p)) top += dTop;
if (/^center/.test(p)) top += dTop / 2;
if (/right$/.test(p)) left += dLeft;
if (/center$/.test(p)) left += dLeft / 2;
overlay.style.left = left +'px';
overlay.style.top = top +'px';
},

createOverlays:function(){
for (var i = 0;i < hs.overlays.length;i++){
var o = hs.overlays[i],tId = o.thumbnailId,sg = o.slideshowGroup;
if ((!tId && !sg) || tId == this.thumbsUserSetId
|| sg === this.slideshowGroup){
this.createOverlay(o);
}
}
},


createFullExpand:function (){
var a = hs.createElement(
'a',
{
href:'javascript:hs.expanders['+ this.key +'].doFullExpand();',
title:hs.fullExpandTitle,
className:'highslide-full-expand'
}
);

this.fullExpandLabel = a;
this.createOverlay({ overlayId:a,position:hs.fullExpandPosition,
hideOnMouseOut:true,opacity:hs.fullExpandOpacity });
},

doFullExpand:function (){
try{
hs.purge(this.fullExpandLabel);
this.fullExpandLabel.parentNode.removeChild(this.fullExpandLabel);
this.focus();

this.x.min = parseInt(this.wrapper.style.left) - (this.fullExpandWidth - this.content.width) / 2;
if (this.x.min < hs.marginLeft) this.x.min = hs.marginLeft;
this.wrapper.style.left = this.x.min +'px';

hs.setStyles(this.content,{ width:this.fullExpandWidth +'px',
height:this.fullExpandHeight +'px'});

this.x.span = this.fullExpandWidth;
this.wrapper.style.width = (this.x.span + 2*this.offsetBorderW) +'px';

this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;

if (this.objOutline)
this.objOutline.setPosition(this,this.x.min,this.y.min,this.x.span,this.y.span);

for (var i = 0;i < this.overlays.length;i++)
this.positionOverlay(this.overlays[i]);

this.redoShowHide();



} catch (e){
window.location.href = this.content.src;
}
},


// on end move and resize
redoShowHide:function(){
var imgPos ={
x:parseInt(this.wrapper.style.left) - 20,
y:parseInt(this.wrapper.style.top) - 20,
w:this.content.offsetWidth + 40,
h:this.content.offsetHeight + 40 
+ this.spaceForCaption
};
if (hs.hideSelects) this.showHideElements('SELECT','hidden',imgPos);
if (hs.hideIframes) this.showHideElements('IFRAME','hidden',imgPos);
if (hs.geckoMac) this.showHideElements('*','hidden',imgPos);

},

wrapperMouseHandler:function (e){
if (!e) e = window.event;
var over = /mouseover/i.test(e.type);
if (!e.target) e.target = e.srcElement;// ie
if (hs.ie) e.relatedTarget = 
over ? e.fromElement:e.toElement;// ie
if (hs.getExpander(e.relatedTarget) == this || hs.dragArgs) return;
for (var i = 0;i < this.overlays.length;i++){
var o = this.overlays[i];
if (o.getAttribute('hideOnMouseOut')){
var from = over ? 0:o.getAttribute('opacity'),
to = over ? o.getAttribute('opacity'):0;
hs.fade(o,from,to);
}
}
},

afterClose:function (){
this.a.className = this.a.className.replace('highslide-active-anchor','');

if (hs.hideSelects) this.showHideElements('SELECT','visible');
if (hs.hideIframes) this.showHideElements('IFRAME','visible');
if (hs.geckoMac) this.showHideElements('*','visible');
if (this.objOutline && this.outlineWhileAnimating) this.objOutline.destroy();
hs.purge(this.wrapper);
if (hs.ie && hs.ieVersion() < 5.5) this.wrapper.innerHTML = '';// crash
else this.wrapper.parentNode.removeChild(this.wrapper);
hs.expanders[this.key] = null;
hs.cleanUp();
}
};
// history
var HsExpander = hs.Expander;

// set handlers
hs.addEventListener(document,'mousedown',hs.mouseClickHandler);
hs.addEventListener(document,'mouseup',hs.mouseClickHandler);
hs.addEventListener(window,'load',hs.preloadImages);function navi_comment(cat_id,pageSize,pageIndex)
{
getAjaxResponse('/Ajax/Comments/CommentNew.aspx?Cat_ID='+cat_id+'&PageSize='+pageSize+'&PageIndex='+pageIndex,'comment_news');
}
function navi_comment_feek(pageSize,pageIndex)
{ 
//getAjaxResponse('/Ajax/Comments/AjaxCommentFeedBack.aspx?PageSize='+pageSize+'&PageIndex='+pageIndex,'comment_news');
AjaxRequestURL('comment_news','/Ajax/Comments/AjaxCommentFeedBack.aspx?PageSize='+pageSize+'&PageIndex='+pageIndex);
}
function LoadImages(id,src) 
{
if (id.getAttribute("loi") == null){
id.setAttribute("loi","1");
} else{
id.setAttribute("loi",eval(id.getAttribute("loi")) + 1);
}
if (eval(id.getAttribute("loi")) >= 2){
var width = src.substr(src.lastIndexOf("=") + 1,src.length - src.lastIndexOf("="));
 id.onerror = null;
 id.src = "/Images/NoImages/noimage_" + width + ".gif";
} else{
id.src = src;
}
}
/***********************************************
* Drop Down/ Overlapping Content- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay,offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft:overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft:totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj,subobjstr,opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display= "block";//(subobj.style.display!="block")? "block":"none"
var xpos=getposOffset(curobj,"left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth):0) 
var ypos=getposOffset(curobj,"top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight:0)


var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf( "firefox" ) != -1 )
{}
else
{
xpos = xpos - 130;
ypos = ypos - 170;
}
subobj.style.left=xpos+"px";
subobj.style.top=ypos+"px";
//alert(xpos+'-'+ypos);
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

/*vietuni.js - V.1.618 - R.11.11.01 @QDJTGSLLA@P*Veni*Vidi*Vici*
* by Tran Anh Tuan [tuan@physik.hu-berlin.de]
* Copyright (c) 2001,2002 AVYS e.V.. All Rights Reserved.
*
* Originally published and documented at http://www.avys.de/
* You may use this code without fee on noncommercial web sites.
* You may NOT alter the code and then call it another name and/or resell it.
* The copyright notice must remain intact on srcipts.
*/

// interface for HTML:
//


var supported = (document.all || document.getElementById);
var disabled = false;
var charmapid = 1;
var keymodeid = 0;
var linebreak = 0;
var theTyper = null;

reset = function(){}
initTyper = telexingVietUC;

function setTypingMode(mode){

keymodeid = mode;
if (theTyper) theTyper.keymode= initKeys();
if (!supported && !disabled){
alert("Xin loi,trinh duyet web cua ban khong cho phep dung VietTyping.\n");
disabled = true;
}
}

initCharMap = function(){ return new CVietUniCodeMap()}

initKeys = function(){
switch (keymodeid){
case 1:return new CTelexKeys();
case 2:return new CVniKeys();
case 3:return new CViqrKeys();
case 4:return new CAllKeys();
default:return new CVKOff();
}
}

function telexingVietUC(txtarea){
txtarea.vietarea= true;
txtarea.onkeyup= null;
if (!supported) return;
txtarea.onkeypress= vietTyping;
txtarea.getCurrentWord= getCurrentWord;
txtarea.replaceWord= replaceWord;
txtarea.onkeydown= onKeyDown;
txtarea.onmousedown= onMouseDown;
txtarea.getValue= function(){ return this.value}
txtarea.setValue= function(txt){ this.value = txt}
if(!theTyper) theTyper = new CVietString("");
}

function getEvt(evt,external){
if (external) return external.event.keyCode;
if (typeof(evt)=='string') return evt.charCodeAt(0);
return document.all? event.keyCode:(evt && evt.which)? evt.which:0;
}

function onKeyDown(evt){
var c= getEvt(evt,this.win);
//***********************
if(this.id == "SP1234") 
{
if ((c==10) || (c==13)){return AdvSearch()}
}
//***********************
if ((c==10) || (c==13)){ reset(1);linebreak= 1}
else if ((c<49) && (c!=16) && (c!=20)){ linebreak= 0;reset(c==32)}
return true;
}

function onMouseDown(evt){ reset(0);linebreak= 0;return true}

function vietTyping(evt){
var c= getEvt(evt,this.win);
theTyper.value= this.getCurrentWord();
var changed= ((c>32) && theTyper.typing(c));
if (changed) this.replaceWord(theTyper.value);
return !changed;
}

function getCurrentWord(){
if(!document.all) return this.value;
var caret= this.document.selection.createRange();
if (caret.text) return null;
var backward= -10;
do{
var caret2= caret.duplicate();
caret2.moveStart("character",backward);
outside= /[\x01-\x40]([^\x01-\x40]+)$/.exec(caret2.text);
if (outside) backward = -outside[1].length;
} while (outside && backward <0);
this.curword= caret2.duplicate();
return caret2.text;
}

function replaceWord(newword){
if(!document.all){ this.value= newword;return}
this.curword.text= newword;
this.curword.collapse(false);
}
// end interface


// "class":CVietString
//
function CVietString(str){
this.value= str;
this.keymode= initKeys();
this.charmap= initCharMap();
this.ctrlchar= '-';
this.changed= 0;

this.typing= typing;
this.Compose= Compose;
this.Correct= Correct;
this.findCharToChange= findCharToChange;
return this;
}

function typing(ctrl){
this.changed= 0;
this.ctrlchar= String.fromCharCode(ctrl);
if (linebreak) linebreak= 0;else this.keymode.getAction(this);
this.Correct();
return this.changed;
}

function Compose(type){
if(!this.value) return;
var info= this.findCharToChange(type);
if (!info || !info[0]) return;
var telex;
if (info[0]=='\\') telex= [1,this.ctrlchar,1];
else if (type>6) telex= this.charmap.getAEOWD(info[0],type,info[3]);
else telex= this.charmap.getDau(info[0],type);
if (!(this.changed = telex[0])) return;
this.value= this.value.replaceAt(info[1],telex[1],info[2]);
if (!telex[2]){ spellerror= 1;this.value+= this.ctrlchar}
}

function Correct(){
if (this.charmap.maxchrlen || !document.all) return 0;
var tmp= this.value;
if ('nNcC'.indexOf(this.ctrlchar)>=0) tmp+= this.ctrlchar;
var er= /[^\x01-\x7f](hn|hc|gn)$/i.exec(tmp);
if (er){
this.value= tmp.substring(0,tmp.length-2)+er[1].charAt(1)+er[1].charAt(0);
this.changed= 1;
}
else if(!this.changed) return 0;
er= /\w([^\x01-\x7f])(\w*)([^\x01-\x7f])\S*$/.exec(this.value);
if (!er) return 0;
var i= this.charmap.isVowel(er[1]);
var ri= (i-1)%24 + 1,ci= (i-ri)/24;
var i2= this.charmap.isVowel(er[3]);
if (!ci || !i2) return 0;
var ri2= (i2-1)%24 + 1,ci2= (i2-ri2)/24;
var nc= this.charmap.charAt(ri)+ er[2]+ this.charmap.charAt(ci*24+ri2);
this.value= this.value.replace(new RegExp(er[1]+er[2]+er[3],'g'),nc);
}

function findCharToChange(type){
var lastchars= this.charmap.lastCharsOf(this.value,5);
var i= 0,c=lastchars[0][0],chr=0;
if (c=='\\') return [c,this.value.length-1,1];
if (type==15) while (!(chr=this.charmap.isVD(c))){
if ((c < 'A') || (i>=4) || !(c=lastchars[++i][0])) return null;
}
else while( "cghmnptCGHMNPT".indexOf(c)>=0){
if ((c < 'A') || (i>=2) || !(c=lastchars[++i][0])) return null;
}
c= lastchars[0][0].toLowerCase();
var pc= lastchars[1][0].toLowerCase();
var ppc= lastchars[2][0].toLowerCase();
if (i==0 && type!=15){
if ( (chr=this.charmap.isVowel(lastchars[1][0]))
&& ("uyoia".indexOf(c)>=0) && !this.charmap.isUO(pc,c)
&& !((pc=='o' && c=='a') || (pc=='u' && c=='y'))
&& !((ppc=='q' && pc=='u') || (ppc=='g' && pc=='i')) ) ++i;
if (c=='a' && (type==9 || type==7)) i= 0;
}
c= lastchars[i][0];
if ((i==0 || chr==0) && type!=15) chr= this.charmap.isVowel(c);
if (!chr) return null;
var clen= lastchars[i][1],isuo=0;
if ((i>0) && (type==7 || type==8 || type==11)){
isuo=this.charmap.isUO(lastchars[i+1][0],c);
if (isuo){ chr=isuo;clen+=lastchars[++i][1];isuo=1}
}
var pos= this.value.length;
for (var j=0;j<= i;j++) pos -= lastchars[j][1];
return [chr,pos,clen,isuo];
}
// end CVietString


// character-map template
//
function CVietCharMap(){
this.vietchars = null;
this.length = 149;
this.chr_cache = new Array(20);
this.ind_cache = new Array(20);
this.cptr = 0;
this.caching= function(chr,ind){
this.chr_cache[this.cptr] = chr;
this.ind_cache[this.cptr++] = ind;
this.cptr %= 20;
}
return this;
}

CVietCharMap.prototype.charAt= function(ind){
var chrcode= this.vietchars[ind];
return chrcode ? String.fromCharCode(chrcode):null;
}

CVietCharMap.prototype.isVowel= function(chr){
var i= 0;
while ((i<20) && (chr != this.chr_cache[i])) ++i;
if (i<20) return this.ind_cache[i];

i = this.length-5;
while ((chr != this.charAt(i)) && i) --i;
this.caching(chr,i);
return i;
}

CVietCharMap.prototype.isVD= function (chr){
var ind= this.length-5;
while ((chr != this.charAt(ind)) && (ind < this.length)) ++ind;
return (ind<this.length)? ind:0;
}

CVietCharMap.prototype.isUO= function (c1,c2){
if (!c1 || !c2) return 0;
var ind1 = this.isVowel(c1);
var ci = (ind1-1)%12;
if ((ci!=9) && (ci!=10)) return 0;
var ind2 = this.isVowel(c2);
ci = (ind2-1)%12;
if ((ci!=6) && (ci!=7) && (ci!=8)) return 0;
return [ind1,ind2];
}

CVietCharMap.prototype.getDau= function (ind,type){
var accented= (ind < 25)? 0:1;
var ind_i= (ind-1) % 24 +1;
var charset= (type == 6)? 0:type;
if ((type== 6) && !accented) return [0];
var newind= charset*24 + ind_i;
if (newind == ind) newind= ind_i;
var chr= this.charAt(newind);
if (!chr) chr= this.lowerCaseOf(0,newind);
return [1,chr,newind>24 || type==6];
}

var map=[
[7,7,7,8,8,8,9,10,11,15],
[0,3,6,0,6,9,0,3,6,0],
[1,4,7,2,8,10,1,4,7,1]
];
CVietCharMap.prototype.getAEOWD= function(ind,type,isuo){
var c=0,i1=isuo? ind[0]:ind;
var vc1= (type==15)? (i1-1)%2:(i1-1)%12;
if (isuo){
var base= ind[1]-(ind[1]-1)%12;
if (type==7 || type==11) c= this.charAt(i1-vc1+9)+this.charAt(base+7);
else if (type==8) c= this.charAt(i1-vc1+10)+this.charAt(base+8);
return [c!=0,c,1];
}
var i= -1,shift= 0,del= 0;
while (shift==0 && ++i<map[0].length){
if (map[0][i]==type){
if(map[1][i]==vc1) shift= map[2][i]-vc1;
else if(map[2][i]==vc1) shift= map[1][i]-vc1;
}
}
if (shift==0){
if (type==7 && (vc1==2 || vc1==8)) shift=-1;
else if ((type==9 && vc1==2) || (type==11 && vc1==8)) shift=-1;
else if (type==8 && (vc1==1 || vc1==7)) shift=1;
del= 1;
} else del=(shift>0);
i1 += shift;
var chr= this.charAt(i1);
if (i1<145) this.caching(chr,i1);
if (!chr) chr= this.lowerCaseOf(0,i1);
return [shift!=0,chr,del];
}

CVietCharMap.prototype.lastCharsOf= function(str,num){
if (!num) return [str.charAt(str.length-1),1];
var vchars = new Array(num);
for (var i=0;i< num;i++){ vchars[i]= [str.charAt(str.length-i-1),1]}
return vchars;
}
// end CVietCharMap prototype


String.prototype.replaceAt= function(i,newchr,clen){
return this.substring(0,i)+ newchr + this.substring(i+clen);
}

// output map:class CVietUniCodeMap
//
function CVietUniCodeMap(){ var map= new CVietCharMap();
map.vietchars = new Array(
"UNICODE",
97,226,259,101,234,105,111,244,417,117,432,121,
65,194,258,69,202,73,79,212,416,85,431,89,
225,7845,7855,233,7871,237,243,7889,7899,250,7913,253,
193,7844,7854,201,7870,205,211,7888,7898,218,7912,221,
224,7847,7857,232,7873,236,242,7891,7901,249,7915,7923,
192,7846,7856,200,7872,204,210,7890,7900,217,7914,7922,
7841,7853,7863,7865,7879,7883,7885,7897,7907,7909,7921,7925,
7840,7852,7862,7864,7878,7882,7884,7896,7906,7908,7920,7924,
7843,7849,7859,7867,7875,7881,7887,7893,7903,7911,7917,7927,
7842,7848,7858,7866,7874,7880,7886,7892,7902,7910,7916,7926,
227,7851,7861,7869,7877,297,245,7895,7905,361,7919,7929,
195,7850,7860,7868,7876,296,213,7894,7904,360,7918,7928,
100,273,68,272);
return map;
}

// input methods:class C...Keys
function CVietKeys(){
this.getAction= function(typer){
var i= this.keys.indexOf(typer.ctrlchar.toLowerCase());
if(i>=0) typer.Compose(this.actions[i]);
}
return this;
}

function CVKOff(){
this.off = true;
this.getAction= function(){};
return this;
}

function CTelexKeys(){
var k= new CVietKeys();
k.keys= "sfjrxzaeowd";
k.actions= [1,2,3,4,5,6,9,10,11,8,15];
k.istelex= true;
return k;
}

function CVniKeys(){
var k= new CVietKeys();
k.keys= "0123456789";
k.actions= [6,1,2,4,5,3,7,8,8,15];
return k;
}

function CViqrKeys(){
var k= new CVietKeys();
k.keys= "\xB4/'\u2019`.?~-^(*+d";
k.actions= [1,1,1,1,2,3,4,5,6,7,8,8,8,15];
return k;
}

function CAllKeys(){
var k= new CVietKeys();
k.keys= "sfjrxzaeowd0123456789\xB4/'`.?~-^(*+d";
k.actions= [1,2,3,4,5,6,9,10,11,8,15,6,1,2,4,5,3,7,8,8,15,1,1,1,2,3,4,5,6,7,8,8,8,15];
k.istelex= true;
return k;
}

// end vietuni.js
function findDate()
{
var ngay = document.getElementById("sNgay").value;
var thang = document.getElementById("sThang").value;
var nam = document.getElementById("sNam").value;
var chuyen_muc = document.getElementById("sChuyenMuc").value;

if(chuyen_muc == "0") 
{ 
if(thang != "0" && ngay != "0")
window.location = "/tin-tuc-theo-ngay/ngay-xem_"+thang+"-"+ngay+"-"+nam+"";
else
alert("Bạn hãy chọn ngày tháng");
}
else 
{
if(ngay == "0") ngay = "";
if(thang == "0") thang = "";
window.location = "/" + chuyen_muc+"/"+ngay+""+thang+""+nam+"";
}
}

function naviComment()
{
if(document.getElementById("comment1").style.display == "none")
{
document.getElementById("comment1").style.display = "";
document.getElementById("comment2").style.display = "none";
document.getElementById("aLinkComment").innerHTML = "Xem tất cả các bình luận";
return;
}

if(document.getElementById("comment2").style.display == "none")
{
document.getElementById("comment1").style.display = "none";
document.getElementById("comment2").style.display = "";
document.getElementById("aLinkComment").innerHTML = "Xem bình luận hay";
}
}

function SendQuestionTTLD()
{
var valid = Validate(false);
if(valid)
{
var Cat_ID = document.getElementById("hdHoiDap_Cat_ID").value;
var question = encodeURIComponent(document.getElementById(document.getElementById('hdTxtQ').value).value);
getAjaxResponseNotAfterResponse("/Ajax/QA/QA_Insert.aspx?Cat_ID="+Cat_ID+"&question="+question,"","");
document.getElementById(document.getElementById('hdTxtQ').value).value = "";
alert('Bạn đã gửi câu hỏi thành công !');
}
}

function sendQuestion()
{
var valid = Validate(false);
if(valid)
{
var Cat_ID = document.getElementById("hdHoiDap_Cat_ID").value;
var question = encodeURIComponent(document.getElementById(document.getElementById('hdTxtQ').value).value);
getAjaxResponseNotAfterResponse("/Ajax/QA/QA_Insert.aspx?Cat_ID="+Cat_ID+"&question="+question,"","LoadAnswer(1)");
}
}
function sendAnswer()
{
var valid = Validate(true);
if(valid)
{
var Hoi_ID = GetControlByNameForHoiDapCat("hidId").value;
var ans = encodeURIComponent(document.getElementById(document.getElementById('hdIdReply').value).value);
getAjaxResponseNotAfterResponse("/Ajax/QA/QA_Ans.aspx?Hoi_ID="+Hoi_ID+"&ans="+ans,"","LoadAnswer(1)");
}
}

function alertContentBad(div,Hoi_Id)
{
var div = document.getElementById(div);
div.innerHTML = "Kiểm duyệt nội dung";
div.className = 'divAlertBad';
new Ajax.Request("/Ajax/QA/QA_Alert.aspx?Hoi_ID="+Hoi_Id,
{
method:'get',
evalScripts:true,
onSuccess:function(transport)
{},
onFailure:function(){ alert('Có lỗi xảy ra..')}
});

}

function changeIcon()
{
document.getElementById("hidEmoticon").value = document.getElementById("hdTxtQ").value;
}
function LoadAnswer(id)
{
new Ajax.Request("/Ajax/QA/QA_Result.aspx?Cat_ID="+document.getElementById("hdHoiDap_Cat_ID").value+"&PageIndex="+id,
{
method:'get',
evalScripts:true,
onSuccess:function(transport)
{
var response = transport.responseText;
$("divContentsAnwser").innerHTML = response;
document.getElementById(document.getElementById("hdTxtQ").value).value = '';
},
onFailure:function(){ alert('Có lỗi xảy ra..')}
});
 }

function GetControlByNameForHoiDapCat(id)
{ 
return document.getElementById(document.getElementById("hdHoiDap_ID").value + "_" + id);
}
function changeClass(ctr,id)
{
document.getElementById("hidEmoticon").value =document.getElementById("hdIdReply").value;
var hidID = GetControlByNameForHoiDapCat("hidId");
hidID.value = id;
document.getElementById(document.getElementById("hdIdReply").value).value = '';
document.getElementById(document.getElementById("hdIdReply").value).focus();
document.getElementById('count').innerHTML = '350';
return false;
}
function closeForm()
{
var DiscussReply = document.getElementById("DiscussReply");
DiscussReply.style.visibility = "hidden";
DiscussReply.style.display = "none";
}
 function Validate(bln)
{
if (bln)
{
if (!VC_RequirefieldForHoiDapCat("idReply","Bạn chưa nhập câu trả lời")) return false;
else
{
var content = GetControlByNameForHoiDapCat("idReply").value;

if(content.indexOf('script') >= 0 || content.indexOf('sex') >= 0 || content.indexOf('lauxanh.us') >= 0 || content.indexOf('imageshack') >=0)
{
document.getElementById(document.getElementById("hdIdReply").value).value = '';
document.getElementById(document.getElementById("hdIdReply").value).focus();
alert('Bạn nhập nội dung không hợp lệ,xin mời nhập lại');
return false;
}

var arr = new Array();
arr = content.split(' ');
for(var i = 0;i<arr.length;i++)
if(arr[i].length >= 30)
{
document.getElementById(document.getElementById("hdIdReply").value).value = '';
document.getElementById(document.getElementById("hdIdReply").value).focus();
alert("Nội dung của bạn không hợp lệ,xin mời nhập lại");
return false;
}
}
overlayclose('DiscussReply');
}
else
{
if (!VC_RequirefieldForHoiDapCat("txtQ","Bạn chưa nhập câu hỏi")) return false;
else
{
var content = GetControlByNameForHoiDapCat("txtQ").value;

if(content.indexOf('script') >=0 || content.indexOf('sex') >=0 || content.indexOf('lauxanh.us') >=0 || content.indexOf('imageshack') >=0)
{
document.getElementById(document.getElementById("hdTxtQ").value).value = '';
document.getElementById(document.getElementById("hdTxtQ").value).focus();
alert('Bạn nhập nội dung không hợp lệ,xin mời nhập lại');
return false;
}

var arr = new Array();
arr = content.split(' ');
for(var i = 0;i<arr.length;i++)
if(arr[i].length >= 30)
{
alert("Nội dung của bạn không hợp lệ,xin mời nhập lại");
GetControlByNameForHoiDapCat("txtQ").value = "";
GetControlByNameForHoiDapCat("txtQ").focus();
return false;
}
}
}

return true;
}

function VC_RequirefieldForHoiDapCat(id1,msg)
{ 
var id = GetControlByNameForHoiDapCat(id1);
if (id.value.length == 0) 
{
alert(msg);
id.focus();
return false;
}
return true;
}







function CountText()
{
if (document.getElementById("hdIdReply")!=null)
{
var txt = document.getElementById(document.getElementById("hdIdReply").value);
var count = txt.value.length;
if(350 - count <= 0)
{
txt.value = txt.value.substring(0,350);
document.getElementById('count').innerHTML = '0';
return;
}
document.getElementById('count').innerHTML = 350 - count + '';
setTimeout("CountText()",1000);
}
}
function rate_f(news_id)
{
document.getElementById('div_rate_f_'+news_id).onclick = ''
document.getElementById('div_rate_f_'+news_id).innerHTML = "<img src='/images/loading.gif'>";
 
new Ajax.Request("/Ajax/Comments/Rate_FeedBack.aspx?FeedBack_ID="+news_id,
{
method:'get',
evalScripts:true,

onSuccess:function(transport)
{
var response = transport.responseText;
document.getElementById('div_rate_f_'+news_id).innerHTML = response;
},
onFailure:function(){ alert('Có lỗi xảy ra..')}

});
}

function tdMouseOver_f(td)
{
document.getElementById('tb_f_'+td).style.backgroundImage = "url(/images/family/binhluan/2.gif)";
document.getElementById('td_f_'+td).style.color = "White";
document.getElementById('td_f_'+td).style.fontSize = "15pt";
document.getElementById('td_f_'+td).style.fontFamily = "Georgia";

document.getElementById('tb_f_'+td).style.width = "58px";
document.getElementById('tr_f_'+td).style.height = "39px";

document.getElementById('div_rate_f_'+td).style.cursor = "pointer";
if (!document.all)
document.getElementById('td_Ngan_f_'+td).style.width = "21px";
else
document.getElementById('td_Ngan_f_'+td).style.width = "20px";
}

function tdMouseOut_f(td)
{
document.getElementById('tb_f_'+td).style.backgroundImage = "url(/images/family/binhluan/1.gif)";
document.getElementById('td_f_'+td).style.color = "White";
document.getElementById('td_f_'+td).style.fontSize = "15pt";
document.getElementById('td_f_'+td).style.fontFamily = "Georgia";

document.getElementById('tb_f_'+td).style.width = "41px";
document.getElementById('tr_f_'+td).style.height = "39px";//td_Ngan_

document.getElementById('td_Ngan_f_'+td).style.width = "0px";
}function afterResponse()
{
var count_comment = document.getElementById(document.getElementById("hdCount").value).innerHTML;
if(count_comment == "0")
document.getElementById(document.getElementById("ifr_list_comment").value).setAttribute("height","0px");
else if (count_comment == "1")
document.getElementById(document.getElementById("ifr_list_comment").value).setAttribute("height","120px");
else if (count_comment == "2")
document.getElementById(document.getElementById("ifr_list_comment").value).setAttribute("height","240px");
else 
document.getElementById(document.getElementById("ifr_list_comment").value).setAttribute("height","360px");
}
function setUrl(FeedBack_ID)
{
window.location = "#"+FeedBack_ID;
}
function changeContent(FeedBack_ID,News_ID,Row,hidFeedBack)
{ 
if (document.getElementById(hidFeedBack)) 
document.getElementById(hidFeedBack).value = FeedBack_ID;

if(document.getElementById("span_News_Title_"+Row) == null) return;
var rootRowIndex = document.getElementById("rootRowIndex").value;
var rootFeedBack_ID = document.getElementById("rootFeedBack_ID").value;
var hidSelected = document.getElementById("hidSelected");
if (hidSelected == null){hidSelected.value="divNone_"+FeedBack_ID}
else
{
var objCu = hidSelected.value;
if (objCu)
{
if (document.getElementById(objCu)) document.getElementById(objCu).style.display="";
hidSelected.value="divNone_"+FeedBack_ID;

}
}

document.getElementById("divNone_"+FeedBack_ID).style.display ="none";
//getAjaxResponseAfterResponse('/Ajax/Tam_Su/FeedBackDetail.aspx?FeedBack_ID='+FeedBack_ID+'&News_ID='+News_ID,'divContent',"setUrl('"+FeedBack_ID+"')");
AjaxRequestURL('divContent','/Ajax/Tam_Su/FeedBackDetail.aspx?FeedBack_ID='+FeedBack_ID+'&News_ID='+News_ID);
 
if (document.getElementById("ifrForm")) document.getElementById("ifrForm").src = "/Ajax/Comments/SendCommentFeedBack.aspx?FeedBack_ID="+FeedBack_ID+"&Control="+document.getElementById("ifr_list_comment").value+"&ver="+Math.random()*1000;
//getAjaxResponseNot('/Ajax/Comments/CountCommentFeedBack.aspx?FeedBack_ID='+FeedBack_ID,document.getElementById("hdCount").value);
AjaxRequestURL(document.getElementById("hdCount").value,'/Ajax/Comments/CountCommentFeedBack.aspx?FeedBack_ID='+FeedBack_ID);
var iframe = document.getElementById(document.getElementById("ifr_list_comment").value);
iframe.src = "/Ajax/Comments/CommenFeedBack.aspx?FeedBack_ID="+FeedBack_ID+"&ver="+Math.random()*1000;
if(document.getElementById("hdCount").value!="0")
iframe.height="240px";
else
iframe.height = "0px";
var Cat_ID = document.getElementById("Cat_ID").value;
var News_ID = document.getElementById("News_ID").value;
/*changeRelation(FeedBack_ID);*/
changeTheSameAuthor(FeedBack_ID);
document.getElementById(document.getElementById("aAllBinhLuan_link").value).setAttribute("href","/home/"+News_ID+"bldt0ca"+Cat_ID+"fb"+FeedBack_ID+"/tat-ca-binh-luan.chn");
window.location = "#FeedBackZone";
}

function afterRes()
{
var url = window.location.href;
var FeedBack_ID = url.split('#')[1];
var News_ID = document.getElementById("News_ID").value;
var Row = document.getElementById("divTemp").innerHTML;
/*changeContent(FeedBack_ID,News_ID,Row,FeedBack_ID);*/
document.getElementById("divContent").style.display = "";

}
function changeRelation(FeedBack_ID)
{

getAjaxResponseNotAfterResponse('/Ajax/Tam_Su/Relation.aspx?FeedBack_ID='+FeedBack_ID,'divRelation',"afterRes()");
}
function changeTheSameAuthor(FeedBack_ID)
{
getAjaxResponseNotAfterResponse('/Ajax/Tam_Su/SameAuthor.aspx?FeedBack_ID='+FeedBack_ID,'divTheSameAuthor',"afterRes()");
}
function LoadTamSu()
{
var url = window.location.href;
if(url.indexOf('#')!=-1)
{
var FeedBack_ID = url.split('#')[1];
var News_ID = document.getElementById("News_ID").value;
getAjaxResponseNotAfterResponse('/Ajax/Tam_Su/GetFeedBackIndex.aspx?News_ID='+News_ID+'&FeedBack_ID='+FeedBack_ID,'divTemp',"afterRes()");
changeRelation(FeedBack_ID);
changeTheSameAuthor(FeedBack_ID);
}
else
{
document.getElementById("divContent").style.display = "";
var FeedBack_ID = 0;
if (document.getElementById("hidFeedBack"))
FeedBack_ID = document.getElementById("hidFeedBack").value;
changeRelation(FeedBack_ID);
changeTheSameAuthor(FeedBack_ID);
document.getElementById("divNone_"+document.getElementById("hidFeedBack").value).style.display="none";
}
}

function AddScript(divName,srcJs)
{
var Obj = document.getElementById(divName);

if (Obj)
{
alert(Obj);
var newScript = document.createElement('script');
newScript.type = "text/javascript";
newScript.src = srcJs;
//Obj.appendChild (newScript);
document.write("<s"+"cript src="+srcJs+"></s"+"cript>");
}
}