/*
	Gauntlet Coach Insurance Javascript Functions
	Created by Matt Reeves 10th August 2007
	for Kariba Creative Media
*/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

// This script will emulate the css :hover effect on the menu elements in IE

// The variables
var cssid = "primary-nav"; // CSS ID for the menuwrapper
var menuadd = "h";  // Character to be added to the specific classes upon hovering. So for example, if this is set to "h", class "menuparent" will become "menuparenth" when hovered over.
var menuh = "menuh"; // Classname for hovering over all other menu items

if (window.attachEvent) window.attachEvent("onload", cssHover);

function cssHover() {
	var sfEls = document.getElementById(cssid).getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {

		sfEls[i].onmouseover=function() {
			if (this.className != "") {
				this.className = this.className + menuadd;
			}
			else {	
				this.className = menuh;
			}
		}

		sfEls[i].onmouseout=function() {
			if (this.className == menuh) {
				this.className = "";
			}
			else {
				this.className = this.className.replace(new RegExp(menuadd + "$"), "");
			}
		}
	}
}

function enable_form_pages(page, total)
{
	for (var index = 1; index <= total; ++index) 
	{
		//alert('Hiding Page ' + index);
		if (index == page)
		{
			$('form_page_' + index).show();
		}
		else
		{
			if ($('form_page_' + index))
			{
				$('form_page_' + index).hide();
			}
		}
	}
	
}

function init_form_pages(form_name, pages)
{
	addLoadEvent(function() {
		if ($(form_name))
		{
			// If Form Name DIV exists, do JS functions to hide other pages	
			for (var index = 2; index <= pages; ++index) 
			{
				var div_name = 'form_page_' + index;				
				if ($(div_name))
				{
					$(div_name).hide();
				}
			}
		}
	});
}

addLoadEvent(function() {
	if (Prototype.Browser.IE)
	{
		$('request_a_quote_img').pngHack();
	}
});