function getObjects(id){
	if(document.all)
		return document.all[id];
	else if(document.getElementById(id))
		return document.getElementById(id);
	else return null;
}
function setVisibles(id,show){
	var obj = getObject(id);
	if(typeof(show)!="undefined")obj.style.display = (show?'':'none');
	else obj.style.display = (obj.style.display!='none')?'none':'';
}

function getObject(id)
{
	if(document.getElementById(id))
		return document.getElementById(id);
	else if(document.all)
		return document.all[id];
	else if(document.layers)
	{
		var o = document.layers[id];
		o.style = document.layers[id];
		return o;
	}
	else return null;
}
function setVisible(id, show)
{
	var obj = getObject(id);
	if(typeof(show)!="undefined")obj.style.display = (show?'':'none');
	else obj.style.display = (obj.style.display!='none')?'none':'';
}

function swapImage(obj, minus, plus)
{
	var index = obj.src.lastIndexOf('/')+1;
	obj.src=obj.src.substring(0, index)+((obj.src.indexOf(minus)!=-1)?plus:minus);
}

function swapBackground(obj, over, out)
{
	var index = obj.background.lastIndexOf('/')+1;
	obj.background=obj.background.substring(0, index)+((obj.background.indexOf(over)!=-1)?out:over);
}

function changeInnerHtml(id, text)
{
	var obj = getObject(id);
	if(obj.innerHTML==text)
	{
			obj.innerHTML = obj.oldInner;
	}
	else
	{
		obj.oldInner = obj.innerHTML;
		obj.innerHTML = text;
	}
}
//=======================Tab bar==============================
function switchCell(n) {
	nc=document.getElementsByName("navcell");
	if(nc){
		t=document.getElementsByName("tb")
		for(i=0;i<nc.length;i++){
			nc.item(i).className="tab-off";
			t.item(i).className="hide-table";
		}
		nc.item(n-1).className="tab-on";
		t.item(n-1).className="tab-content show-table";
	}else if(navcell){
		for(i=0;i<navcell.length;i++){
			navcell[i].className="tab-off";
			tb[i].className="hide-table";
		}
		navcell[n-1].className="tab-on";
		tb[n-1].className="tab-content show-table";
	}
}


// Bookmark specific page
function Bookmark()		{
 		if (navigator.appName == 'Microsoft Internet Explorer') 
		window.external.AddFavorite(document.location, document.title);
}

//=========================Time==========================
function ShowTimeNow(id)
{
	var dt = new Date();
	getObject(id).innerHTML = Round2Digit(dt.getHours()) + ":" + Round2Digit(dt.getMinutes()) + ":" + Round2Digit(dt.getSeconds()) + " " + Round2Digit(dt.getDate()) + "/" + Round2Digit(dt.getMonth()+1) + "/" + dt.getFullYear();
}

function ShowTimeNowInterval(id, amount)
{
	setInterval("ShowTimeNow('" + id + "');", amount);
}
//=======================================================
function Round2Digit(n)
{
	if(n<=9&&n>=0)return "0"+n;else return n;
}

function OpenPopup(mypage,myname,w,h,pos,infocus)
{
	//var win=null;
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=auto,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	win=window.open(mypage,myname,settings);
	win.focus();
}


//Moving Item in ListBox to Another
function MoveOption(objSourceElement, objTargetElement)
{
    var aryTempSourceOptions = new Array();
    var x = 0;
    
    //looping through source element to find selected options
    for (var i = 0; i < objSourceElement.length; i++) {
        if (objSourceElement.options[i].selected) {
            //need to move this option to target element
            var intTargetLen = objTargetElement.length++;
            objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
            objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
        }
        else {
            //storing options that stay to recreate select element
            var objTempValues = new Object();
            objTempValues.text = objSourceElement.options[i].text;
            objTempValues.value = objSourceElement.options[i].value;
            aryTempSourceOptions[x] = objTempValues;
            x++;
        }
    }
    
    //resetting length of source
    objSourceElement.length = aryTempSourceOptions.length;
    //looping through temp array to recreate source select element
    for (var i = 0; i < aryTempSourceOptions.length; i++) {
        objSourceElement.options[i].text = aryTempSourceOptions[i].text;
        objSourceElement.options[i].value = aryTempSourceOptions[i].value;
        objSourceElement.options[i].selected = false;
    }
}

function kwconfirm(objMSG){
    if(confirm(objMSG)== true)  
        return true;  
    else  
        return false;    
}
function kwalert(objMSG){
    alert(objMSG);
    
}


function jumptolink(what){
    var selectedopt=what.options[what.selectedIndex]
    window.location=selectedopt.value
}
