

// Declare variables
//	document.write('In headfoot.js');

    var dq = String.fromCharCode(34);
    var strSeperator = " / ";

// -----------------------------------------------------------------------------
// Purpose: These four routines handle preloading and swapping images.
// Input:   N/A
// Output:  N/A
// Changed: 
// -----------------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// -----------------------------------------------------------------------------
// Purpose: Displays a popup window
// Input:   N/A
// Output:  N/A
// Author:  Mark Pilger
// Changed: 
// -----------------------------------------------------------------------------
function popupWindow(strPage, strWindow, strHeight, strWidth) {
  h = "height = " + strHeight + ", ";
  w = "width = " + strWidth + ", ";
//  parms = h + w + "directories=no, location=yes, menu=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
  parms = h + w + "directories=no, location=no, menu=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
  win=window.open(strPage, strWindow, parms);
}

// -----------------------------------------------------------------------------
// Purpose: Displays a new window
// Input:   N/A
// Output:  N/A
// Changed: 
// -----------------------------------------------------------------------------
function newWindow(strPage, strWindow, strHeight, strWidth) {
  h = "height = " + strHeight + ", ";
  w = "width = " + strWidth + ", ";
  parms = h + w + "directories=no, location=yes, menu=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes";
//  parms = h + w + "directories=no, location=no, menu=no, resizable=no, scrollbars=yes, status=no, toolbar=no";
  win=window.open(strPage, strWindow, parms);
}


/* Dropdowns */



function setClass(obj, cl){
	if (obj != null)
		if (obj.className!=cl) obj.className = cl;
}

function setClassById(objid, cl){
	if (!cl) cl = '';
	document.getElementById(objid).className = cl;
}

function changeDisplayById(objId){
	for (c = 0; c < changeDisplayById.arguments.length; c++){
		obj = document.getElementById(changeDisplayById.arguments[c]);
		if (obj.style.display == 'none') obj.style.display = '';
		else obj.style.display = 'none';
	}
}

function gotoURL(url, newWnd){
	if (!url) url = "/";
	if (newWnd) {
		window.open(url);
		return;
	}
	if (window.event){
		var src = window.event.srcElement;
		if((src.tagName != 'A') && ((src.tagName != 'IMG') || (src.parentElement.tagName != 'A'))){
			if (window.event.shiftKey) window.open(url);
			else document.location = url;
		}
	} else document.location = url;
}

/*
function popupURL(url){
	window.open(url);
}
*/
function popupURL(url){
	window.open(url,'','resizable=yes, scrollbars=yes,width=600,height=500');
}

function OpenPopup(url, params ,w ,h){
	var width = (w ? w : 366);
	var height = (h ? h : 250);
	return showModalDialog(url, params, 'dialogWidth:' + width + 'px; dialogHeight:' + height + 'px; resizable:no; status:no;help:no');
}


function OpenStandartPopup(url, n, w, h){
	var width = (w ? w : 366);
	var height = (h ? h : 250);
	var name = (n ? n : '');
	var handler = window.open(url,n,'resizable=yes, scrollbars=yes,width=' + width + ',height=' + height + '');
	handler.focus();
	return handler;
}


function getLeftPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return res;
}

function getTopPos(obj){
	var res = 0;
	while (obj){
		res += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return res;
}

function getRightPos(obj){
	var res = obj.offsetWidth;
	while (obj){
		res += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return res;
}


var lastMenuId = 0;
var timer;
var mSheets = new Array();
var currZ = 65500;
var mReady = false;
var mTopPos = 170;

function MenuLink(textVal, linkVal, subVal, newWnd){
	this.text = textVal;
	this.action = linkVal;
	this.submenu = subVal;
	if (newWnd)
		this.newWnd= newWnd;
	else this.newWnd = false;
}

function menuHideAll(){
	for (var c in mSheets) mSheets[c].hide();

}

function menuHideTimerSet(){
	timer = window.setTimeout(menuHideAll, 100);
}

function menuHideTimerReset(){
	if (timer) window.clearTimeout(timer);
}

function menuAddLink(textVal, linkVal, newWnd){
	this.links[this.links.length] = new MenuLink(textVal, linkVal, null, newWnd);
}

function menuAddSubmenu(textVal, linkVal, newWnd){
	this.links[this.links.length] = new MenuLink(textVal, linkVal, new MenuSheet(this), newWnd);
}

function menuShow(leftVal, topVal){
	this.block.style.left = leftVal + "px";
	this.block.style.top = topVal + "px";
	this.block.style.display = "block";
}

function menuHide(){
	this.hideCh();
	this.block.style.display = "none";
}

function menuFlip(leftVal, topVal){
	var disp = this.block.style.display;
	if (disp == "none") this.show(leftVal, topVal);
	else this.hide();
}

function menuHideCh(){
	for (var c in this.links){
		curLink = this.links[c];
		if (curLink.submenu) curLink.submenu.hide();
	}
}

function menuCreate(path){
	var res = "<div class=\"menu-sh\" onmouseout=\"menuHideTimerSet()\" onmouseover=\"menuHideTimerReset()\"><table cellpadding=\"0\" cellspacing=\"0\" class=\"tab-menu-sh\">";
	var curLink;
	var newPath;

	if (path == null) path = "mSheets[" + this.id + "]";

	for (var c in this.links){
		curLink = this.links[c];
		res += "<tr><td class=\"blk-menu-sh";
		if (curLink.submenu) res += " blk-menu-arr";
		res += "\" onmouseover=\"setClass(this, 'blk-menu-sh-act hand";
		if (curLink.submenu) res += " blk-menu-arr-act";
		res += "'); ";
		res += path + ".hideCh()";
		if (curLink.submenu){
			newPath = path + ".links[" + c + "].submenu";
			res += "; " + newPath + ".show(getLeftPos(this) + this.offsetWidth + 2, getTopPos(this))";
			curLink.submenu.create(newPath);
		}
		res += "\" onmouseout=\"setClass(this, 'blk-menu-sh";
		if (curLink.submenu) res += " blk-menu-arr";
		res += "')\" onclick=\"gotoURL('"+curLink.action+"', " + curLink.newWnd +")\" nowrap=\"nowrap\">" + curLink.text + "</td></tr>";	
	}
	res += "</table></div>";
	this.block.innerHTML =  this.links.length > 0 ? res : "";
}

function MenuSheet(parentObj){
	this.links = new Array();
	this.addLink = menuAddLink;
	this.addSubmenu = menuAddSubmenu;
	this.create = menuCreate;
	this.show = menuShow;
	this.hide = menuHide;
	this.flip = menuFlip;
	this.hideCh = menuHideCh;
	this.id = lastMenuId;
	lastMenuId++;
	this.parent = parentObj; 
	this.block = document.createElement("DIV");
	this.block.className = "blk-menu";
	this.block.style.position = "absolute";
	this.block.style.display = "none";
	this.block.style.zIndex = currZ;
	currZ++;
	document.body.appendChild(this.block);
}

function showMenu(objVal, numVal){
	if (mReady){
		menuHideAll();
		objVal.className = "hand act";
		var mTopPos = getTopPos(objVal) + 43;
		mSheets[numVal].show(getLeftPos(objVal), mTopPos);
		menuHideTimerReset();

		var divRightPos = mSheets[numVal].block.offsetLeft + mSheets[numVal].block.offsetWidth;
		var objRightPos = getRightPos(objVal.offsetParent);
		if ( divRightPos > objRightPos ){
			mSheets[numVal].show(getLeftPos(objVal) - (divRightPos - objRightPos), mTopPos);
		}
	}
}

function hideMenu(objVal, numVal){
	if (mReady){
		menuHideTimerSet();
		objVal.className = "hand";
	}
}



/* Dropdown menu realisation */

function createMenus(){
for (c = 0; c < 7; c++) mSheets[c] = new MenuSheet(); 
mSheets[1].addLink("Auto Insurance", "insurance_quoter.html");
mSheets[1].addLink("Home Insurance", "insurance_quoter.html");
mSheets[1].addLink("Life Insurance", "life_quote.html");
mSheets[1].addLink("Health Insurance", "http://www.mnhealthinsurance.com/getzipcode2.asp", true);
mSheets[1].addLink("Business Insurance", "business_Insurance.html");

mSheets[3].addLink("Auto Insurance", "insurance_quoter.html");
mSheets[3].addLink("Home Insurance", "insurance_quoter.html");
mSheets[3].addLink("Life Insurance", "life_quote.html");
mSheets[3].addLink("Health Insurance", "http://www.mnhealthinsurance.com/getzipcode2.asp", true);
mSheets[3].addLink("Business Insurance", "business_Insurance.html");

mSheets[4].addLink("AAA", "aaa.html");
mSheets[4].addLink("Travelers", "travelers.html");
mSheets[4].addLink("Integrity", "integrity.html");
mSheets[4].addLink("Progressive", "progressive.html");
mSheets[4].addLink("Acuity", "acuity.html");
mSheets[4].addLink("Wilson Mutual", "wilsonmutual.html");
mSheets[4].addLink("MetLife", "metlife.html");
mSheets[4].addLink("Harleysville", "harleysville.html");


					for (var c in mSheets) mSheets[c].create();
					mReady = true;
}

