/**
  * sg_objects.js
  * Part of Souken JavaScript Library
  * Copyright 2005 Souken Group, LLC
  */

function SG_objectGet(vObject, oDocument){ //Get object
	var oObject;
	if(vObject.tagName) return vObject;
	if(!oDocument) oDocument = document;
	if(oDocument.getElementById) oObject = oDocument.getElementById(vObject);
	if(!oObject && oDocument.all) if(oDocument.all[vObject]) oObject = oDocument.all[vObject];
	return oObject;
} //SG_objectGet

function SG_objectHide(vObject){ //Hide object
	var oObject;
	oObject = SG_objectGet(vObject);
	if(!oObject) return false;
	if(oObject.style.display == 'none') return true;
	oObject.SG_display = (oObject.style.display) ? oObject.style.display : 'inline';
	oObject.style.display = 'none';
	return true;
} //SG_objectHide

function SG_objectShow(vObject){ //Show hidden object
	var oObject;
	oObject = SG_objectGet(vObject);
	if(!oObject) return false;
	if(!oObject.SG_display) return false;
	oObject.style.display = oObject.SG_display;
	return true;
} //SG_objectShow

function SG_objectToggle(vObject){ //Toggle display
	var oObject;
	oObject = SG_objectGet(vObject);
	if(!oObject) return false;
	if(oObject.style.display == 'none'){
		oObject.style.display = oObject.SG_display;
	} else {
		oObject.SG_display = oObject.style.display;
		oObject.style.display = 'none';
	}
	return true;
} //SG_objectToggle

function SG_objectBackgroundSwap(vObject, sColor){ //Swap background color
	var oObject;
	oObject = SG_objectGet(vObject);
	if(!oObject) return false;
	oObject.SG_backgroundColor = oObject.style.backgroundColor;
	oObject.style.backgroundColor = sColor;
	return true;
} //SG_objectBackgroundSwap

function SG_objectBackgroundRestore(vObject){ //Restore swapped background color
	var oObject;
	oObject = SG_objectGet(vObject);
	if(!oObject) return false;
	if(!oObject.SG_backgroundColor) return false;
	oObject.style.backgroundColor = oObject.SG_backgroundColor;
	return true;
} //SG_objectBackgroundRestore

