var domovey=1
var timeOuts = new Array();
function clearAllTimeouts() {
	for (key in timeOuts) {
		clearTimeout(timeOuts[key]);
	}
}
var showport = function (id) {
	$('port').innerHTML = '';
	new Ajax.Updater('port', 'ajax.asp', {
		parameters: {
			act: 'fillport',
			id: id
		},
		insertion: Insertion.Top,
		evalScripts: true
	});
	$('pageholder').fade({
		duration:0.5,
		from: 1,
		to: 0.3,
		queue: {
			position: 'end',
			scope: 'portqueue'
		}
	});
	$('portholder').appear({
		duration:0.5,
		queue: {
			position: 'end',
			scope: 'portqueue'
		}
	});
	Effect.ScrollTo('pageholder',{queue:{position:'end',scope:'portqueue'}});
	Event.observe($('pageholder'), 'click', hideport);
};
var hideport = function () {
	Event.stopObserving($('pageholder'), 'click', hideport)
	$('portholder').fade({
		duration:0.5,
		queue: {
			position: 'end',
			scope: 'portqueue'
		}
	});
	$('pageholder').appear({
		duration:0.5,
		queue: {
			position: 'end',
			scope: 'portqueue'
		}
	});
}
var navup = function (id, x) {
	clearTimeout(timeOuts['navtime_' + x]);
	timeOuts['navtime_' + x] = setTimeout("donavup('" + id + "','" + x + "')", 200);
}
var donavup = function (id, x) {
	new Effect.Move($('nav_' + id), {
		x: -x,
		y: -10,
		mode: 'absolute',
		transition: Effect.Transitions.spring
	});
}
var navdn = function (id, x) {
	clearTimeout(timeOuts['navtime_' + x]);
	timeOuts['navtime_' + x] = setTimeout("donavdn('" + id + "','" + x + "')", 200);
}
var donavdn = function (id, x) {
	new Effect.Move($('nav_' + id), {
		x: -x,
		y: 0,
		mode: 'absolute',
		transition: Effect.Transitions.spring
	});
}
var botnavup = function (id, x) {
	clearTimeout(timeOuts['botnavtime_' + x]);
	timeOuts['botnavtime_' + x] = setTimeout("dobotnavup('" + id + "','" + x + "')", 200);
}
var dobotnavup = function (id, x) {
	new Effect.Move($('botnav_' + id), {
		x: -x,
		y: 0,
		mode: 'absolute',
		transition: Effect.Transitions.spring
	});
}
var botnavdn = function (id, x) {
	clearTimeout(timeOuts['botnavtime_' + x]);
	timeOuts['botnavtime_' + x] = setTimeout("dobotnavdn('" + id + "','" + x + "')", 200);
}
var dobotnavdn = function (id, x) {
	new Effect.Move($('botnav_' + id), {
		x: -x,
		y: 30,
		mode: 'absolute',
		transition: Effect.Transitions.spring
	});
}
var killimg = function (id, iid) {
	new Ajax.Updater('img_' + iid, 'ajax.asp', {
		parameters: {
			act: 'killimg',
			id: id,
			iid: iid
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var addport = function (id, pid) {
	if (pid != 'zzz') {
		$('vport').innerHTML = '';
		new Ajax.Updater('vport', 'ajax.asp', {
			parameters: {
				act: 'addport',
				id: id,
				pid: pid
			},
			insertion: Insertion.Top,
			evalScripts: true,
			queue: {
				position: 'end',
				scope: 'doqueue'
			}
		});
	}
}
addblink = function (id, pid) {
	$('bottomlinks').innerHTML='';
	if (pid != 'zzz') {
		new Ajax.Updater('bottomlinks', 'ajax.asp', {
			parameters: {
				act: 'addblink',
				pid: id,
				bid: pid
			},
			insertion: Insertion.Top,
			evalScripts: true,
			queue: {
				position: 'end',
				scope: 'doqueue'
			}
		});
	}
}
addfeat = function (id, pid) {
	$('bottomlinks').innerHTML='';
	if (pid != 'zzz') {
		new Ajax.Updater('bottomlinks', 'ajax.asp', {
			parameters: {
				act: 'addfeat',
				pid: id,
				fid: pid
			},
			insertion: Insertion.Top,
			evalScripts: true,
			queue: {
				position: 'end',
				scope: 'doqueue'
			}
		});
	}
}
var dostuff = function (act, fid) {
	if ($(fid)) {
		$(fid).innerHTML = '';
		new Ajax.Updater(fid, 'ajax.asp', {
			parameters: {
				act: act
			},
			insertion: Insertion.Top,
			evalScripts: true,
			queue: {
				position: 'end',
				scope: 'doqueue'
			}
		});
	}
}
var pos = function (table, list) {
	var thelist = Sortable.sequence(list);
	var fullist = ''
	for (x in thelist) {
		if (parseInt(thelist[1, x]) == thelist[1, x]) {
			fullist = fullist + thelist[1, x] + '-'
		}
	}
	new Ajax.Request('ajax.asp', {
		method: 'post',
		parameters: {
			act: 'pos',
			table: table,
			ids: fullist
		}
	});
}
var activate = function (table, id, val1, val2) {
	$('activate' + id).innerHTML = '';
	new Ajax.Updater('activate' + id, 'ajax.asp', {
		parameters: {
			act: 'activate',
			id: id,
			table: table,
			val1: val1,
			val2: val2
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var del = function (table, id, fid, title, fid2, fid3, fid4, fid5) {
	$('msg').innerHTML = '';
	new Ajax.Updater('msg', 'ajax.asp', {
		parameters: {
			act: 'del',
			id: id,
			table: table,
			fid: fid,
			title: title,
			fid2: fid2,
			fid3: fid3,
			fid4: fid4,
			fid5: fid5
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var kill = function (table, id, fid, fid2, fid3, fid4, fid5) {
	new Ajax.Updater('dname', 'ajax.asp', {
		parameters: {
			act: 'kill',
			id: id,
			table: table,
			fid: fid,
			fid2: fid2,
			fid3: fid3,
			fid4: fid4,
			fid5: fid5
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var dsave = function (table, id, fid, vid, vtype) {
	clearTimeout(timeOuts['timedsave_' + fid]);
	timeOuts['timedsave_' + fid] = setTimeout("dodsave('" + table + "','" + id + "','" + fid + "','" + vid + "','" + vtype + "')", 1000);
}
var dodsave = function (table, id, fid, vid, vtype) {
	$(vid).innerHTML = '';
	var thisda = $(fid + '_Day_ID').options[$(fid + '_Day_ID').selectedIndex].value;
	var thismo = eval($(fid + '_Month_ID').options[$(fid + '_Month_ID').selectedIndex].value) + 1;
	var thisye = $(fid + '_Year_ID').value;
	var val = thisye + '-' + thismo + '-' + thisda + ' 00:00:00';
	new Ajax.Updater(vid, 'ajax.asp', {
		parameters: {
			act: 'editsave',
			table: table,
			id: id,
			fid: fid,
			vid: vid,
			val: val
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var esave = function (table, id, fid, vid, vtype) {
	clearTimeout(timeOuts['timedsave_' + fid]);
	timeOuts['timedsave_' + fid] = setTimeout("dosave('" + table + "','" + id + "','" + fid + "','" + vid + "','" + vtype + "')", 1000);
}
var dosave = function (table, id, fid, vid, vtype) {
	$(vid).innerHTML = '';
	if ($(fid).type == 'checkbox') {
		var iname = document.getElementsByName($(fid).name);
		var val = ''
		if (iname.length > 1) {
			var cb = 0;
			val = '-';
			fid = $(fid).name
			for (cb = 0; cb < iname.length; ++cb) {
				if (iname[cb].checked) {
					val = val + iname[cb].value + '-'
				}
			}
		}
		else {
			if ($(fid).checked) {
				val = $(fid).value
			}
			else {
				val = 0
			}
		}
	}
	else if ($(fid).type == 'radio') {
		var iname = document.getElementsByName($(fid).name);
		var val = ''
		if (iname.length > 1) {
			var cb = 0;
			fid = $(fid).name
			for (cb = 0; cb < iname.length; ++cb) {
				if (iname[cb].checked) {
					val = iname[cb].value
				}
			}
		}
		else {
			if ($(fid).checked) {
				val = $(fid).value
			}
			else {
				val = 0
			}
		}
	}
	else if ($(fid).type == 'select-one') {
		var val = $(fid).options[$(fid).selectedIndex].value;
	}
	else {
		var val = $(fid).value;
	}
	new Ajax.Updater(vid, 'ajax.asp', {
		parameters: {
			act: 'editsave',
			table: table,
			id: id,
			fid: fid,
			vid: vid,
			val: val
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var fsave = function (formid, asppage, vid) {
	$(formid).target = 'upload_target';
	$(formid).action = asppage;
	$(vid).innerHTML = '<img src="/library/ajaxloader.gif" alt="please wait">'
	submitform(formid);
}
var tsave = function (table, id, fid, vid, vtype) {
	clearTimeout(timeOuts['timedsave_' + fid]);
	timeOuts['timedsave_' + fid] = setTimeout("dotsave('" + table + "','" + id + "','" + fid + "','" + vid + "','" + vtype + "')", 1000);
}
var dotsave = function (table, id, fid, vid, vtype) {
	$(vid).innerHTML = '';
	var thismi = $(fid + '_min').options[$(fid + '_min').selectedIndex].value;
	var thisho = $(fid + '_hour').options[$(fid + '_hour').selectedIndex].value;
	var thisda = $(fid + '_Day_ID').options[$(fid + '_Day_ID').selectedIndex].value;
	var thismo = eval($(fid + '_Month_ID').options[$(fid + '_Month_ID').selectedIndex].value) + 1;
	var thisye = $(fid + '_Year_ID').value;
	var val = thisye + '-' + thismo + '-' + thisda + ' ' + thisho + ':' + thismi + ':00';
	new Ajax.Updater(vid, 'ajax.asp', {
		parameters: {
			act: 'editsave',
			table: table,
			id: id,
			fid: fid,
			vid: vid,
			val: val
		},
		insertion: Insertion.Top,
		evalScripts: true,
		queue: {
			position: 'end',
			scope: 'doqueue'
		}
	});
}
var useful = function (act, id) {
	$('use').innerHTML = '';
	new Ajax.Updater('use', 'ajax.asp', {
		parameters: {
			act: act,
			id: id
		},
		insertion: Insertion.Top,
		evalScripts: true
	});
}
var fadeusebox = function () {
	$('useholder').fade();
	new Effect.Opacity('pageholder', {
		duration: 0.5,
		from: 0.3,
		to: 1
	});
}
var hidemsg = function () {
	$('msgholder').fade();
	new Effect.Opacity('pageholder', {
		duration: 0.5,
		from: 0.3,
		to: 1
	});
}
var fadepage = function () {
	$('pageholder').fade({
		from: 1,
		to: 0.3
	});
}
var fadetmsg = function () {
	$('tmsg').fade({
		duration: 2.0,
		from: 1,
		to: 0,
		delay: 4.0
	});
}
var toggleme = function (sss) {
	if ($(sss).style.display != 'none') {
		$(sss).fade();
	}
	else {
		$(sss).appear();
	}
}
var toggleshow = function (sss) {
	$(sss).appear();
}
var togglehide = function (sss) {
	$(sss).fade();
}
var searcher = function (sss, ttt) {
	var dname = 'main_content';
	var dname2 = 'titlebar';
	$(dname).innerHTML = '<img id="ajaxloader" src="/library/ajaxloader.gif" alt="loading..." />';
	$(dname2).innerHTML = '<img id="ajaxloader2" src="/library/ajaxloader.gif" alt="loading..." />';
	var act = 'searchcontent';
	var act2 = 'searchtitle';
	var title = ttt + ' "' + sss + '"'
	new Ajax.Updater(dname2, 'ajax.asp', {
		parameters: {
			act: act2,
			title: title
		},
		insertion: Insertion.Top,
		evalScripts: true
	});
	new Ajax.Updater(dname, 'ajax.asp', {
		parameters: {
			act: act,
			searcher: sss
		},
		insertion: Insertion.Top,
		evalScripts: true
	});
}
var viewnewchat = function () {
	$('dname').value = 'chatmenu';
	xmlHttp = GetXmlHttpObject();
	var url = "ajax.asp?sid=" + Math.random() + "&act=viewnewchat"
	xmlHttp.onreadystatechange = display;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
var viewchat = function () {
	$('dname').value = 'chatwindow';
	xmlHttp = GetXmlHttpObject();
	var url = "ajax.asp?sid=" + Math.random() + "&act=viewchat&cid=" + $('cid').value;
	xmlHttp.onreadystatechange = display;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
var savechat = function () {
	$('dname').value = 'chatwindow';
	xmlHttp = GetXmlHttpObject();
	var url = "ajax.asp?sid=" + Math.random() + "&act=savechat&cid=" + $('cid').value + "&ctxt=" + $('ctxt').value;
	$('ctxt').value = '';
	xmlHttp.onreadystatechange = display;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
var killck = function (sss) {
	if (CKEDITOR.instances[sss]) {
		CKEDITOR.remove(CKEDITOR.instances[sss]);
	}
}
var jump = function (sss) {
	if (sss != "null") {
		document.location.href = sss;
	}
}
var submitform = function (sss) {
	if (sss != "") {
		$(sss).submit();
	}
}
var clearme = function (sss) {
	if (sss.value == sss.defaultValue) {
		sss.value = "";
	}
}
var bookmarksite = function (title, url) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	}
	else if (window.opera && window.print) {
		var elem = document.createElement('a');
		elem.setAttribute('href', url);
		elem.setAttribute('title', title);
		elem.setAttribute('rel', 'sidebar');
		elem.click();
	}
	else if (document.all) {
		window.external.AddFavorite(url, title);
	}
}
var setco = function (sss) {
	document.cookie = 'setco=' + sss
}
var getcookie = function (sss) {
	var results = document.cookie.match('(^|;) ?' + sss + '=([^;]*)(;|$)');
	if (results) {
		return (unescape(results[2]));
	}
	else {
		return null;
	}
}
var cformat = function (sss) {
	var i = parseFloat(sss);
	if (isNaN(i)) {
		i = 0.00;
	}
	var minus = '';
	if (i < 0) {
		minus = '-';
	}
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if (s.indexOf('.') < 0) {
		s += '.00';
	}
	if (s.indexOf('.') == (s.length - 2)) {
		s += '0';
	}
	s = minus + s;
	return s;
}
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};
var dofaderoll=function(sss) {
	clearAllTimeouts();
	timeOuts['tio'+sss] = setTimeout('actfaderoll('+sss+')',0.5*1000); 
}
var actfaderoll=function(sss) {
	new Effect.Opacity(document.getElementById('m_'+sss), { duration: 0.5, from: 1, to: 0, queue:{position:'start',scope:'mqueue'}});
	var allmenus=getElementsByClassName("mo");
	for ( var i=allmenus.length-1; i>=0; --i ) {
		if ((allmenus[i].style.opacity=='0' || allmenus[i].style.filter=='alpha(opacity=0)') && allmenus[i].id!='m_'+sss) {
			new Effect.Opacity(allmenus[i].id, { duration: 0.5, from: 0, to: 1, queue:{position:'end',scope:'mqueue'}});
		}
	}
}
var multifaderoll=function(sss) {
	var allmenus=getElementsByClassName("mo");
	for ( var i=allmenus.length-1; i>=0; --i ) {
		if ((allmenus[i].style.opacity=='0' || allmenus[i].style.filter=='alpha(opacity=0)') && allmenus[i].id!='m_'+sss) {
			new Effect.Opacity(allmenus[i].id, { duration: 0.1, from: 0, to: 1, queue:{position:'end',scope:'mqueue'}});
		}
	}
	var allsss=getElementsByClassName(sss);
	for ( var i=allsss.length-1; i>=0; --i ) {
		new Effect.Opacity(allsss[i].id, { duration: 0.2, from: 1, to: 0, queue:{position:'end',scope:'mqueue'}});
	}
}
var domove=function(sss,xxx,yyy,id) {
	new Effect.Move(document.getElementById(sss,xxx,yyy), {x:xxx, y:yyy, mode:'absolute', queue:{position:'end',scope:'squeue'}});
	var allmenus=getElementsByClassName("movers");
	for ( var i=allmenus.length-1; i>=0; --i ) {
		allmenus[i].src='/library/gallery_off.gif';
	}
	document.getElementById(id).src='/library/gallery_on.gif';
	document.getElementById("sc_mini").innerHTML=eval(((xxx*-1)/960)+1);
}
var dotest=function(sss,xxx,yyy) {
	new Effect.Move(document.getElementById(sss,xxx,yyy), {x:xxx, y:yyy, mode:'absolute', queue:{position:'end',scope:'squeue'}});
}
var movey=function(updn) {
	if (domovey==1) {
		var mbhm=$('right_content').style.height.replace("px", "");
		var rmh=$('right_move').offsetHeight;
		var rmt=$('right_move').style.top.replace("px", "");
		if (rmt=='') {
			rmt=1
		}
		rmt=parseFloat(rmt);
		mbhm=parseFloat(mbhm);
		mbrmh=(rmh-mbhm)*-1;
		//console.log('dn:'+rmt+'>='+mbrmh+' up:'+rmt+'<0');
		if (updn=='dn') {
			if (rmt>=mbrmh) {
				domovey=0
				new Effect.Move('right_move', { x: 0, y: -mbhm, mode: 'relative', afterFinish:function(){domovey=1}});
			}
		} else {
			if (rmt<0) {
				domovey=0
				new Effect.Move('right_move', { x: 0, y: mbhm, mode: 'relative', afterFinish:function(){domovey=1}});
			}
		}
	}
}
emph=function(id) {
	clearAllTimeouts();
	timeOuts['tio'+id] = setTimeout('doemph(\''+id+'\')',0.3*1000);  
}
doemph=function(id) {
	$(id).morph('left:-10px;', {transition: Effect.Transitions.spring, queue: { position: 'start', scope: 'empher'}});
	var allln=getElementsByClassName("ln");
	for ( var i=allln.length-1; i>=0; --i ) {
		if (allln[i].style.left!='0px' && allln[i].style.left!='0' && allln[i].id!=id) {
			allln[i].morph('left:0px;', {transition: Effect.Transitions.spring, queue: { position: 'end', scope: 'empher'}});
		}
	}
}
