/* This code assigns the property of vissible or hidden to the two spans "view1" and "view2" and moves
	it to the the required position.
	To get the position where the spans should be moved. The coordinates of an image named "spacer" are checked 
	offset adjusted as per browser and the position of span is set.
*/

var cD = new clientDetection();

//This functions creates a DOM of the spans defined in the html code
function getElt(id, doc){
	if(cD.nav4){
		var currentLayer;
		var currentDoc;
		if(!doc){
			currentDoc = document;
		}
		else{
			currentDoc = doc;
		}
		currentLayer = currentDoc.layers[id];
		for(var i=0;!currentLayer && i < currentDoc.layers.length;i++){
			currentLayer = getElt(id, currentDoc.layers[i].document);
		}
		return currentLayer;
	} 
	else if(cD.ie4up){
		var elt = eval('document.all.' + id);
		return(elt);
	}
	else if(cD.nav6up){
		var elt = document.getElementById(id);
		return(elt);
	}
}

// this sets the position of the spans
function moveEltTo(elt, x, y){
	if(cD.nav4)
	{
	 // to change x ans y location for netscape 4 change here.
	// x=x+1;
	elt.moveTo(x, y);
	}
	else if(cD.ie4up){
		elt.style.pixelLeft = x;
		//elt.style.pixelTop = y-1;
		elt.style.pixelTop = y;
	}
	else if(cD.nav6up){
		elt.style.left = x;
		elt.style.top = y;
	}
}

function showLayer(elt, value, oPosition)
{
    var tempelt = getElt(elt);
	moveEltTo(tempelt, oPosition.x, oPosition.y);
	if(cD.nav4)
	{
		tempelt.visibility = value;
	}
	else if(cD.ie4up)
	{
		tempelt.style.visibility = value;
	}
    else if(cD.nav6up)
	{
		tempelt.style.visibility = value;
	}
}

/*
	this function gets x and y coordinates for spacer gif placed above the spans to be displayed.
*/
function getXYcoord ( nvn ){
   	var elm = document.images[nvn];
   	if ( document.layers )
	{
		return elm;
	}
    // NS4 images contain x and y values
   	var rd = { x:0, y:0 };
   	do { rd.x += parseInt( elm.offsetLeft );
        rd.y += parseInt( elm.offsetTop );
        elm = elm.offsetParent;
   	} while ( elm );
   
   	return rd
} //end getXYcoord ( string ) -> object{x,y}

/* Define variables to be used on page */
var searchBoxPosition; // used for search box position