var MaxMenuItems = 100;
function ShowMenu(MenuNo) {
if (document.getElementById("Submenu" + MenuNo)) {
document.getElementById("Submenu" + MenuNo).style.visibility = "visible";
}
}
function HideMenu(MenuNo) {
if (document.getElementById("Submenu" + MenuNo)) {
document.getElementById("Submenu" + MenuNo).style.visibility = "hidden";
}
}
// ExceptNo - multiple params like 1,3,8
function HideMenuAll(ExceptNo) {
var i;
var arr;
var found;
ExceptNo = ExceptNo + ',';
arr = ExceptNo.split(",");
for(i = 1; i <= MaxMenuItems; i++) {
found = 0;
for (x in arr) {
if (arr[x] == i) {
found = 1;
}
}
if ((found == 0) && (document.getElementById("Submenu" + i))) {
document.getElementById("Submenu" + i).style.visibility = "hidden";
}
}
}
// IMAGE BUTTONS
function SwitchImg()
{
var rem, keep=0, store, obj, switcher=new Array, history=document.Data;
for (rem=0; rem < (SwitchImg.arguments.length-2); rem+=3) {
store = SwitchImg.arguments[(navigator.appName == 'Netscape')?rem:rem+1];
if ((store.indexOf('document.layers[')==0 && document.layers==null) ||
(store.indexOf('document.all[')==0 && document.all==null))
store = 'document'+store.substring(store.lastIndexOf('.'),store.length);
obj = eval(store);
if (obj != null) {
switcher[keep++] = obj;
switcher[keep++] = (history==null || history[keep-1]!=obj)?obj.src:history[keep];
obj.src = SwitchImg.arguments[rem+2];
} }
document.Data = switcher;
}
function RestoreImg()
{
if (document.Data != null)
for (var rem=0; rem<(document.Data.length-1); rem+=2)
document.Data[rem].src=document.Data[rem+1];
}
// TreeCollapse, TreeExpand
function TreeExpandToogle(ID) {
var ExpandButton = document.getElementById("tree_expand"+ID);
var ExpandArea = document.getElementById("tree"+ID);
if (ExpandArea) {
if (ExpandArea.style.display == "") {
if (ExpandButton)
ExpandButton.innerHTML = "
";
ExpandArea.style.display = "none";
} else {
if (ExpandButton)
ExpandButton.innerHTML = "
";
ExpandArea.style.display = "";
}
}
}
// Popup window
function PopupNewWindow(url, width, height, params) {
if (params == "")
params = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no';
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
params = params + ',width=' + width + ',height=' + height + ',screenX=' + left + ',screenY=' + top;
window.open(url, '' ,params);
}
//
var AjaxIsRunning = false;
// ------------------------------------------
// freemap ajax helper functions
// ------------------------------------------
// Options:
// TargetId - elementid
// Callback
// CallbackFailed
// PostParams = name=111&help=abc
// PostForm
// BeforeHTML
// AfterHTML
// FailedHTML
// NoProgress - true
function Ajax(URL, Options) {
var request = null;
AjaxIsRunning = true;
if (!Options['BeforeHTML']) Options['BeforeHTML'] = "";
if (!Options['AfterHTML']) Options['AfterHTML'] = "";
if (!Options['FailedHTML']) Options['FailedHTML'] = "";
if (!Options['TargetId']) Options['TargetId'] = "";
if (!Options['NoProgress']) Options['NoProgress'] = false;
//
if (Options['TargetId'] != "") {
if (typeof ThemeOpenArea == 'function') {
Options['TargetId'] = ThemeOpenArea(Options['TargetId'], URL, Options);
}
}
//
if (Options['PostForm']) {
var f = document.getElementById(Options['PostForm']);
var Params = "";
for( var i = 0; i < f.elements.length; i++ ) {
if (f.elements[i].type == "checkbox") {
if (f.elements[i].checked) {
Params += ((Params == "") ? "":"&") + f.elements[i].name + '=' + encodeURI(f.elements[i].value);
}
} else {
Params += ((Params == "") ? "":"&") + f.elements[i].name + '=' + encodeURI(f.elements[i].value);
}
}
if (!Options['PostParams']) {
Options['PostParams'] = "";
}
Options['PostParams'] = ((Options['PostParams'] == "") ? "":"&") + Params;
}
if (Options['PostParams'])
Method = "POST";
else
Method = "GET";
//
try {
request = new XMLHttpRequest();
} catch(e) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {
}
}
var Text = "";
if (request != null) {
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
Text = request.responseText;
if (Options['Callback']) {
Text = Options['Callback'](Text);
}
if (Options['TargetId'] != "") {
document.getElementById(Options['TargetId']).innerHTML = Options['BeforeHTML'] + Text + Options['AfterHTML'];
runScripts( document.getElementById(Options['TargetId']));
}
} else {
if (Options['CallbackFailed']) {
Text = Options['CallbackFailed'];
}
if (Options['TargetId'] != "") {
document.getElementById(Options['TargetId']).innerHTML = Options['FailedHTML'];
} else {
alert("Problem retrieving XML data");
}
}
AjaxIsRunning = false;
}
}
}
if ((Options['TargetId'] != "") && (!Options['NoProgress'])) {
document.getElementById(Options['TargetId']).innerHTML = "
";
}
request.open(Method, URL + '&Ajax=' + Options['TargetId'], true);
if (Options['PostParams']) {
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", Options['PostParams'].length);
request.setRequestHeader("Connection", "close");
request.send(Options['PostParams']);
} else {
request.send(null);
}
}
function runScripts(e) {
if (e.nodeType != 1) return; //if it's not an element node, return
if (e.tagName.toLowerCase() == 'script') {
eval(e.text); //run the script
} else {
var n = e.firstChild;
while ( n ) {
if ( n.nodeType == 1 ) {
runScripts( n ); //if it's an element node, recurse
}
n = n.nextSibling;
}
}
}
// first line contains DIV name ..
function RefreshContent(input) {
lines = input.split("#");
element = document.getElementById(lines[1]);
if (element) {
lines.splice(0, 2);
element.innerHTML = lines.join("#");
}
return "";
}// GalleryShow - display gallery window, set position..
function GalleryShowWindow() {
var Control = document.getElementById("gallery");
if (Control) {
Control.style.display = "block";
Control.style.position = "absolute";
window.scrollTo(0,0);
// alert(pageYOffset);
}
}
// GalleryHid - hide gallery window
function GalleryHideWindow() {
var Control = document.getElementById("gallery");
if (Control) {
Control.style.display = "none";
}
}
// display gallery image
function GalleryShowFromURL(ImageURL) {
GalleryShowWindow();
Ajax('?Proc=gallery&ImageURL='+ImageURL+'', { TargetId: 'gallery' });
}
function GalleryShowByGalleryID(GalleryID, AttachmentType) {
GalleryShowWindow();
Ajax('?Proc=gallery&GalleryID=' + GalleryID + '&AttachmentType=' + AttachmentType, { TargetId: 'gallery' });
}
function GalleryShowForAttachmentID(AttachmentID, AttachmentType) {
GalleryShowWindow();
Ajax('?Proc=gallery&AttachmentID=' + AttachmentID + '&AttachmentType=' + AttachmentType, { TargetId: 'gallery' });
}
function PreloadGalleryImage(URL) {
var GS = document.getElementById('gallery');
var GSP = document.getElementById('gallery_picture_frame');
var GSN = document.getElementById('gallery_navigator');
var Pic = document.getElementById("gallery_picture");
var GalleryImage = new Image();
var ScreenWidth = 0;
var ScreenHeight = 0;
// height
var theHeight = 0;
if (window.innerHeight) {
theHeight=window.innerHeight;
} else
if (document.documentElement && document.documentElement.clientHeight) {
theHeight=document.documentElement.clientHeight;
} else
if (document.body) {
theHeight=document.body.clientHeight;
}
ScreenHeight = theHeight;
// width
var theWidth = 0;
if (window.innerWidth) {
theWidth=window.innerWidth;
} else
if (document.documentElement && document.documentElement.clientWidth) {
theWidth=document.documentElement.clientWidth;
} else
if (document.body) {
theWidth=document.body.clientWidth;
}
ScreenWidth = theWidth;
function GalleryResize(NewWidth, NewHeight) {
if (NewWidth == 0) {
NewWidth = 400;
}
if (NewHeight == 0) {
NewHeight = 400;
}
var toolbar;
if (GSN == null) {
toolbar = 0;
} else {
toolbar = 24;
GSN.style.display = "block";
GSN.style.position = "absolute";
GSN.style.left = "16px";
GSN.style.top = "16px";
GSN.style.width = NewWidth + "px";
GSN.style.height = "24px";
}
GSP.style.display = "block";
GSP.style.position = "absolute";
GSP.style.left = "16px";
GSP.style.top = (16+toolbar)+"px";
GSP.style.width = NewWidth + "px";
GSP.style.height = NewHeight + "px";
GS.style.left = ((ScreenWidth-NewWidth-32) / 2) + "px";
GS.style.top = ((ScreenHeight-NewHeight-32-toolbar) / 2) + "px";
GS.style.width = (NewWidth+32) + "px";
GS.style.height = (NewHeight+32+toolbar) + "px";
}
function ImageLoaded() {
// RESIZE WINDOW
var NewWidth = GalleryImage.width;
var NewHeight = GalleryImage.height;
var Prop = 0;
if (NewWidth == 0)
NewWidth = 400;
if (NewHeight == 0)
NewHeight = 400;
if ((NewWidth > ScreenWidth - 64) || (NewHeight > ScreenHeight - 88)) {
if ((NewWidth / (ScreenWidth - 64)) <= (NewHeight / (ScreenHeight - 88))) {
Prop = (NewHeight / (ScreenHeight - 88));
if (Prop > 0) {
NewWidth = NewWidth / Prop;
NewHeight = NewHeight / Prop;
}
} else {
Prop = (NewWidth / (ScreenWidth - 64));
if (Prop > 0) {
NewWidth = NewWidth / Prop;
NewHeight = NewHeight / Prop;
}
}
}
// alert('G6');
Pic.src = GalleryImage.src;
GalleryResize(NewWidth, NewHeight);
Pic.width = NewWidth;
Pic.height = NewHeight;
}
GalleryImage.onload = ImageLoaded;
GalleryImage.src = URL;
}