/*
	The Google AutoFill feature set the color for textboxes(INPUT) at the end of page loading.
	This script attaches the Listeners for property changes.
	When the google toolbar(scirpts) changes the background color property, this script reset the property.
*/

function FixGoogleToobarAutoFill()
{  
    if(window.attachEvent)
        window.attachEvent("onload",setListeners);
    else if(window.addEventListener)
        window.addEventListener("load", setListeners, false);

    function setListeners()
    {
        inputList = document.getElementsByTagName("INPUT");
        for(i=0;i<inputList.length;i++){
            if(inputList[i].attachEvent)
            {
                inputList[i].attachEvent("onpropertychange",restoreStyles);
            }
            else if(inputList[i].addEventListener)
            {
                inputList[i].addEventListener("propertychange", restoreStyles, false);
            }
          inputList[i].style.backgroundColor = "";
        }
        selectList = document.getElementsByTagName("SELECT");
        for(i=0;i<selectList.length;i++)
        {
            if(inputList[i].attachEvent)
            {
                selectList[i].attachEvent("onpropertychange",restoreStyles);
            }
            else if(inputList[i].addEventListener)
            {
                selectList[i].addEventListener("propertychange", restoreStyles, false);
            }

            selectList[i].style.backgroundColor = "";
        }
    }

    function restoreStyles(evt)
    {
        var target = 0;

        if(!evt)
            evt = event;

        if(evt.srcElement)
            target = evt.srcElement
        else if(evt.target)
            target = evt.target;

        if(target && target.style.backgroundColor != "")
          target.style.backgroundColor = "";
    }
  
}
/*
	This script tests whether the GoolgeToolbar in IE exists or not.
*/
function GoogleToolbarExists()
{
	if (navigator.appName == "Microsoft Internet Explorer") 
	{
		if (document.GoogleActivated) 
		{
			//alert("The Google Toolbar \(" + document.GoogleToolbarVersion + "\) was detected on your computer.");
			return true;
		}
		else 
		{
			//alert("The Google Toolbar was not detected on your computer.");
			return false;
		}
		/*
		The following code to be placed within HTML -HEAD tags
		//<object id="g1" classid="clsid:6CB5E471-C305-11D3-99A8-000086395495" style="display: none;"></object>
		//<object id="g2" classid="clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB" style="display: none;"></object>

		if (document.g2 && typeof(g2.Search) != "undefined") {
			alert("The Google Toolbar was detected on your computer.");
		*/
	}
}
