
/*
This file created by Michael Taylor - 2007-07-01

(It requires the AttrSet.js and AttrGet.js files)

- AttrToggle() is used to toggle an attribute value between 2 supplied values for any page element that contains an ID attribute.
- It will work on dynamic IDs set by the .NET runat="server" server-side attribute.

Arguments:

	strTag (optional if the full ID is supplied):
		This is the the tag name of the element.
		It is used only if the supplied strIdPart argument doesn't match the ID of a page element.

	strIdPart (required):
		This is the ID or part of the ID of the element.
		If the full ID of a page element is supplied, the strTag argument is not used and can be set to null.
	
	strAttr (required):
		This is the attribute name to search for within the given strTag/strIdPart.
	
	strVal1 (required):
		This is the first value to set the toggle of the strAttr of the strTag/strIdPart.
		If the tag/ID is found, the strAttr will be set to this value if its value is set to strVal2.
	
	strVal2 (required):
		This is the second value to set the toggle of the strAttr of the strTag/strIdPart.
		If the tag/ID is found, the strAttr will be set to this value if its value is set to strVal1.
	
	blnDoOnce (required):
		This is a boolean value that tells the function whether to set the attribute value for 
		all elements matching the strTag/strIdPart or to stop setting the value after the first
		occurence.
	
	Examples:
		AttrToggle('div', 'Menu_Home', 'style.backgroundColor', '#660000', '#0d421f', true);
		// this will toggle the background color of this menu item between dark red and dark green.

It has been tested on and is compatible with:
	Microsoft Internet Explorer 6 and up
	Mozilla Firefox 2 and up

For inquiries or comments, visit www.genxml.com
*/

function AttrToggle(strTag, strIdPart, strAttr, strVal1, strVal2, blnDoOnce) {
	if(AttrGet(strTag, strIdPart, strAttr).indexOf(strVal1) > 0 || AttrGet(strTag, strIdPart, strAttr) == strVal1) {
		AttrSet(strTag, strIdPart, strAttr, strVal2, blnDoOnce);
	}
	else {
		AttrSet(strTag, strIdPart, strAttr, strVal1, blnDoOnce);
	}
}


