function onLoadHandler(obj) {
this.functions = [];
this.add = function(f) { this.functions[this.functions.length] = f; };
obj.obj = this;
  this.exec = function() { 
    for(var i=0; i < this.obj.functions.length;i++) {
    eval(this.obj.functions[i]+'()'); 
    }
  }    
}

var window_onload = new onLoadHandler(this);
window.onload = window_onload.exec;

var popWin = null;
var winCount = 0;
var winName = "popWin";

function openPopWin(winURL, winWidth, winHeight, winFeatures){
winName = "popWin" + winCount++;
closePopWin();
	if (openPopWin.arguments.length == 4)
		winFeatures = "," + winFeatures;
	else
		winFeatures = "";
		popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures);
	}

function closePopWin(){
	if (navigator.appName != "Microsoft Internet Explorer"
		|| parseInt(navigator.appVersion) >=4)
	if(popWin != null) if(!popWin.closed) popWin.close()
	}

function xoopsGetElementById(id) {
if(document.getElementById && document.getElementById(id)) {
	return document.getElementById(id);
	} else if (document.all && document.all[id]) {
		return document.all[id];
		} else if (document.layers && document.layers[id]) {
			return (document.layers[id]);
			} else {
				return false;
			}
}

function toggle_visibility(id, flag)  {

if (xoopsGetElementById(id)) {
	xoopsGetElementById(id).style.visibility = (flag) ? 'visible' : 'hidden';
	}
}

function showImgSelected(imgId, selectId, imgDir) {
imgDom     = xoopsGetElementById(imgId);
selectDom  = xoopsGetElementById(selectId);
imgDom.src = GLOBALS['BASE_URL']+"/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value;
}

function justReturn() {
	return;
}

function openWithSelfMain(url,name,width,height) {
var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
if(url.match('pmlite.php')) options = options.replace('scrollbars=yes','scrollbars=no');

new_window = window.open(url, name, options);
window.self.name = "okd_main";
new_window.moveTo(((screen.availWidth/2)-(width/2)),((screen.availHeight/2)-(height/2)))
new_window.focus();
}


function setElementColor(id, color) {
	xoopsGetElementById(id).style.color = "#" + color;
}


function setElementFont(id, font) {
	xoopsGetElementById(id).style.fontFamily = font;
}


function setElementSize(id, size) {
	xoopsGetElementById(id).style.fontSize = size;
}


function changeDisplay(id) {
var elestyle = xoopsGetElementById(id).style;

if (elestyle.display == "") {
	elestyle.display = "none";
	} else {
		elestyle.display = "block";
	}
}

function toggleDisplay(id) {
var elestyle = xoopsGetElementById(id).style;

if (elestyle.display == "block" || elestyle.display == "") {
	elestyle.display = 'none';
	} else {
		elestyle.display = "block";
	}
}

function setVisible(id) {
	xoopsGetElementById(id).style.visibility = "visible";
}


function setHidden(id) {
	xoopsGetElementById(id).style.visibility = "hidden";
}


function makeBold(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.fontWeight != "bold") {
	eleStyle.fontWeight = "bold";
	} else {
		eleStyle.fontWeight = "normal";
	}
}


function makeItalic(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.fontStyle != "italic") {
	eleStyle.fontStyle = "italic";
	} else {
		eleStyle.fontStyle = "normal";
	}
}


function makeUnderline(id) {
var eleStyle = xoopsGetElementById(id).style;

if (eleStyle.textDecoration != "underline") {
	eleStyle.textDecoration = "underline";
	} else {
		eleStyle.textDecoration = "none";
	}
}


function appendSelectOption(selectMenuId, optionName, optionValue) {
var selectMenu = xoopsGetElementById(selectMenuId);
var newoption  = new Option(optionName, optionValue);

selectMenu.options[selectMenu.length] = newoption;
selectMenu.options[selectMenu.length].selected = true;
}


function disableElement(target) {
var targetDom = xoopsGetElementById(target);

if (targetDom.disabled != true) {
	targetDom.disabled = true;
	} else {
		targetDom.disabled = false;
	}
}


function xoopsCheckAll(formname, switchid) {
var ele = document.forms[formname].elements;
var switch_cbox = xoopsGetElementById(switchid);

for (var i=0; i<ele.length; i++) {
	var e = ele[i];
	if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
		e.checked = switch_cbox.checked;
	}
}
}

function setRequired() {
var args = (arguments) ? arguments : setRequired.arguments;
  for (var i=0; i<args.length; i++) {
  var id    = args[i];
  var field = xoopsGetElementById(id);
    if (field.value == "") {
    alert(GLOBALS['_PLZCOMPLETE'] + args[i]);
    field.focus();
    return false;
    }
  }
}

function getLink(name){
var str = '<a href="mailto:'+name+'@okinawa-diet.com">'+name+'@okinawa-diet.com</a>';
document.write(str);
}