function openWindow(wurl, wname, wwidth, wheight, wleft, wtop, wetc) {
	wetc = (wetc) ? wetc : '';
	
	newWindow = window.open( wurl , wname , "width=" + wwidth + ",height=" + wheight + wetc );
	
	if ( ( !wleft && !wtop ) || (wleft < 0 && wtop < 0 ) ) {
		posY = 0;
		posX = 0;
		if (window.innerHeight)
		{
			posY = window.pageYOffset;
			posX = window.pageXOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			posY = document.documentElement.scrollTop;
			posX = document.documentElement.scrollLeft;
		}
		else if (document.body)
		{
			posY = document.body.scrollTop;
			posX = document.body.scrollLeft;
		}
		
		wtop = posY + screen.height / 2 - wheight / 2;
		wleft = posX + screen.width / 2 - wwidth / 2;
	}
	
	newWindow.moveTo( wleft , wtop );
}

function cellMouseOver(obj) {
	obj.style.backgroundColor = '#ACBBE8';
	obj.style.cursor = 'hand';
	obj.style.cursor = 'pointer';
}

function cellMouseOut(obj) {
	obj.style.backgroundColor = '#ffffff';
	obj.style.cursor = 'default';
}

function positionLayer( lid ) {
	posY = 0;
	if (window.innerHeight)
	{
		posY = window.pageYOffset;
		posX = window.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		posY = document.documentElement.scrollTop;
		posX = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{
		posY = document.body.scrollTop;
		posX = document.body.scrollLeft;
	}
	
	posY = posY + screen.height / 2 - 300;
	posX = posX + screen.width / 2 - 500 / 2;
	
	document.getElementById( lid ).style.top = posY + "px";
	document.getElementById( lid ).style.left = posX + "px";
}

function toggleTabs(set, tab) {
	document.getElementById('box' + set + 'Server').style.display = 'none';
	document.getElementById('box' + set + 'Computer').style.display = 'none'; 
	
	if ( document.getElementById('box' + set + 'Interlink' ) )
		document.getElementById('box' + set + 'Interlink').style.display = 'none'; 
		
	
	document.getElementById('tab' + set + 'Server').className = 'tabInactive'; 
	document.getElementById('tab' + set + 'Computer').className = 'tabInactive'; 
// 	document.getElementById('tabServer' + set + 'Computer').className = 'tabInactive';
// 	document.getElementById('tabComputer' + set + 'Computer').className = 'tabInactive';
	
	if ( document.getElementById('tab' + set + 'Interlink' ) )
	{
		document.getElementById('tab' + set + 'Interlink').className = 'tabInactive';
// 		document.getElementById('tabServer' + set + 'Interlink').className = 'tabInactive';
// 		document.getElementById('tabInterlink' + set + 'Interlink').className = 'tabInactive';
// 		document.getElementById('tabInterlink' + set + 'Server').className = 'tabInactive';
// 		document.getElementById('tabInterlink' + set + 'Computer').className = 'tabInactive';
	}
	
	document.getElementById('box' + set + tab).style.display = 'block';
	document.getElementById('tab' + set + tab).className = 'tabActive'; 
	
}


/*Harvest all fields*/
var fields = new Array();
window.onload = function()
{
    // an array of form elements
    var f = document.getElementsByTagName("form");

    for(var i=0; i<f.length; i++)
    {
        // all elements within this form
        var fe = f[ i];
        
        // iterate through each element
        for(var j=0; j<fe.length; j++)
        {
//             // if we find an input or select
//             if(fe.elements[j].type == "select-one" || fe.elements[j].type == "text")
//             {
                // add it to our fields array
                fields[fields.length] = fe.elements[j];

//                 // if it's a select we add the onchange
//                 if(fe.elements[j].type == "select-one")
//                 {
//                     fe.elements[j].onchange = next;
//                 }
//             }
        }
    }
}

/* Toggles the display from none to block */
function toggleDisplay( elemId ) {
	var obj = document.getElementById( elemId ).style;
	
	if (obj.display == "none") obj.display = "block";
	else obj.display = "none";
		
}

function captureEventAttributes(e) {
	if ( !e ) var e=window.event;
	if ( !e ) {
		window.alert('Could not capture event.');
		return false;
	}
	
	if ( e.target ) var obj = e.target;
	else if ( e.srcElement ) var obj = e.srcElement;
	else {
		window.alert('Could not capture target.');
		return false;
	}
	
	return obj;
}

function nextFieldOnMax(e) {
	obj = e;
// 	obj = captureEventAttributes(e);
	if ( !obj ) return;
	
	if ( obj.value.length >= obj.maxLength ) {
		nextInput(e);
// 		var arr = trigger.id.split("_");
// 		var next = document.getElementById(arr[0]+"_"+ (++arr[1]));
// 		
// 		if ( next ) {
// 			next.focus( );
// 		}
	}
}

function nextInput(e)
{
	obj = e;
// 	obj = captureEventAttributes(e);
// 	window.alert('here..' +obj.id+'/ '+obj.name);
	
    // walk through the array to find the next field
    for(var i=0; i<fields.length; i++)
    {
// 		window.alert('here: '+fields[i].id+'/ '+fields.name);
        // we've found the select box we're on
        var trigger = false;
        if (fields[i] == obj && fields[i] != undefined && fields[i] != '') {
	        trigger = true;
// 	        window.alert('obj: '+fields[i]);
        }
//         else if (fields[i].id == obj.id && fields[i].id != undefined && fields[i].id != '') {
// 	        trigger = true;
// 	        window.alert('obj.id: '+fields[i].id);
//         }
//         else if (fields[i].name == obj.name &&fields[i].name != undefined && fields[i].name != '') {
// 	        trigger = true;
// 	        window.alert('obj.name: '+fields[i].name);
//         }
        
        if (trigger)
        {
            // check if there is a next field
            if(fields[i+1] != undefined)
            {
                // set the focus and stop looking
                fields[i+1].focus();
            }
               return;
        }
    }
}
