/**
*	Miscellaneous utility scripts
*
*/

// short hand.
var d = document;
var AdoptCom = AdoptCom || {};

/**
*	Create a text node.
*/
function _T(NodeText)
{
	return d.createTextNode(NodeText);
}

/**
*	Object shortcut function
*/
function $(El)
{
	if(typeof El == "string")
	{
		El = document.getElementById(El);
	}
	return El;
}

function IsCollection(a)
{
    if(a && typeof a == "object")
	{		
		if(a.constructor == Array)
		{
			return true;
		}

		if(a.nodeType)
		{	// HTML node
			return false;
		}

		if(typeof a.length != "undefined" && typeof a[0] != "undefined")
		{
			return true;
		}		
	}

	return false;
}

function IsObject(a)
{
    return typeof a == "object" || typeof a == "function";
}

// Some people might hate this one...

if(!Array.prototype.indexOf)
{
	Array.prototype.indexOf = function(el)
	{
		for(var i = 0, j = this.length; i < j; i++)
		{
			if(el == this[i])
			{
				return i;
			}
		}
		return -1;
	};
}

function ToSource(o)
{
	if(o.toSource)
	{
		return o.toSource();
	}

	if(o.outerHTML)
	{	// Appears to be an html element
		return o.outerHTML;
	}
	
	if(typeof o === "string")
	{
		return o;
	}

	var txt,i,j;

	if(IsCollection(o))
	{
		txt = "[";
		for(i = 0, j = o.length; i < j; i++)
		{
			txt += ToSource(o[i])+", ";
		}
		txt += "]";
	}

	if(typeof o === "object")
	{
		txt = "{";
		for(i in o)
		{
			txt += i+":"+o[i];
		}
	}

	return o;
}

function printfire()
{
    if(d.createEvent)
    {
		if(window.opera)
		{
			window.opera.dump(arguments);
		}
		else
		{
			printfire.args = arguments;
			var ev = d.createEvent("Events");
			ev.initEvent("printfire", false, true);
			dispatchEvent(ev);
		}
    }	
	else
	{
		var o = $("printfire__DEBUGGER");

		if(!o)
		{
			o = d.createElement("textarea");
			o.style.width="99%";
			o.style.height="300px";
			d.body.appendChild(o);
			o.id = "printfire__DEBUGGER";
		}

		o.value += arguments[0] + "\n";
	}
}

function selectState()
{

     
onClick="ajaxCall({ url:'http://www.adoption.com/ajax_select_state.php', method:'POST'}"


}



function submit_form()
{
	
	document.local.submit();
}

function selectDifferentState()
{
	

	state = document.getElementById('select_state');
	if(state.style.display=='block')
	{
	 state.style.display = 'none';
	}
	else
	{
	state.style.display = 'block';
	
	}
}
