var splashLayer,splashLayerElement,splashTimer;
var dropDowns,resumeDelay=0;

function stopAnimation(evt) {
	if (!evt) var evt=event;
	cancelAnimation(evt);
	resumeDelay=-1;
}

function cancelAnimation(evt) {
	clearTimeout(splashTimer);
	if (splashLayerElement.TCurrentFrame("/")!=-1) splashLayerElement.stopMovie();
	if (!evt) var evt=event;
	evt.cancelBubble=true;
}

function resumeAnimation() {
	if (resumeDelay>=0) splashTimer=setTimeout("setup()",resumeDelay);
}

function loadQuickQuote() {
	if (!document.getElementById("quickQuote")) return;
	document.getElementById("quickQuote").getElementsByTagName("form")[0].style.display="block"; //NOTE: Forms do not appear unless the user has javascript enabled.
	splashLayer=document.getElementById("splash");
	if (splashLayer.getElementsByTagName("iframe")[0]) dropDowns=splashLayer.parentNode.getElementsByTagName('select');

	var so=new SWFObject("/images/quickQuote.swf","splashFlash","auto","auto","7","transparent");
	so.addParam("wmode","transparent");
	so.addParam("allowScriptAccess","always");
	so.write("splash");

	for (splashLayerElement=splashLayer.firstChild;splashLayerElement.nodeType!=1;splashLayerElement=splashLayerElement.nextSibling);

	splashTimer=setTimeout("setup()",7000);
	splashLayer.parentNode.onmouseover=cancelAnimation;
	splashLayer.parentNode.onmouseout=resumeAnimation;

	var inputs=splashLayer.parentNode.getElementsByTagName('input');
	for (var temp=0;temp<inputs.length;temp++) inputs[temp].onfocus=stopAnimation;
	inputs=splashLayer.parentNode.getElementsByTagName('select');
	for (var temp=0;temp<inputs.length;temp++) inputs[temp].onfocus=stopAnimation;
}

function setSize(width,height) {
	splashLayerElement.width=width;
	splashLayerElement.height=height;
	splashLayer.width=splashLayerElement.width;
	splashLayer.style.left=(splashLayer.parentNode.offsetWidth-splashLayerElement.offsetWidth)/2+"px";
	splashLayer.style.top=splashLayer.parentNode.offsetTop-splashLayer.offsetTop+(splashLayer.parentNode.offsetHeight-splashLayerElement.offsetHeight)/2+"px";
}

function dropDownStatus(status) {
	if (dropDowns) for (var temp=0;temp<dropDowns.length;temp++) dropDowns[temp].style.visibility=status;
	splashLayer.style.zIndex=(status=="visible")?"-1":"0";
}

function setup() {
	if (splashLayer.style.visibility!="visible") splashLayer.style.visibility="visible";
	if (splashLayerElement.TCurrentFrame("/")==-1) {
      splashTimer=setTimeout("setup()",1000);
  	   return;
	}
	if (!splashLayer.width) splashLayerElement.setSize();
	splashLayerElement.startMovie();
}

if (window.addEventListener) window.addEventListener("load",loadQuickQuote,false);
else window.attachEvent("onload",loadQuickQuote);