﻿function moveTip(e){
    if(moveme){
        if(e) {
            if( typeof( e.pageX ) == 'number' ) {
                docX = e.pageX;
                docY = e.pageY;
            } else {
                docX = e.clientX;
                docY = e.clientY;
            }
        } else {
            e = window.event;
            docX = e.clientX;
            docY = e.clientY;
            if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
                docX += document.documentElement.scrollLeft;
                docY += document.documentElement.scrollTop;
            } else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
                docX += document.body.scrollLeft;
                docY += document.body.scrollTop;
            }
        }
        overFlow = (docX+elem.offsetWidth+10 > document.body.clientWidth) ? docX+elem.offsetWidth-document.body.clientWidth+10 : 0; //extra ten for the width of scrollbars if present
        docX = docX-offX+10-overFlow;
        docY = docY-offY+10;
        elem.style.left = docX+'px';
        elem.style.top = docY+'px';
        elem.style.visibility = 'visible';
    }
}
function tip(clicked) {
    document.onmousemove = moveTip;
	//find the answer content
	elem = clicked.nextSibling;
	while(elem.innerHTML == null){
		elem = elem.nextSibling;
	}
	//toggle it
	if(elem.className=='tipon'){
		elem.className='tipoff';
		elem.style.left = '0px';
		elem.style.top = '0px';
		moveme=false;
		elem.style.visibility = 'hidden';
	}else{
	    elem.style.visibility = 'hidden'; //prevent flicker in IE
		elem.className='tipon';
		myPos = findPos(elem);
		offX = myPos[0];
		offY = myPos[1];
		moveme = true;
	} 
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	    do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }
}

subLoc = "";
myLoc = document.URL;
myLoc_array = myLoc.split("/");
myServer_array = myLoc_array[2].split(".");
if(myServer_array[0].substring(myServer_array[0].length-3, myServer_array[0].length)=="imp"){
	subLoc = "imp";
}else {
	subLoc = "";
}


function validsearch() {
    mysearch = document.getElementById("search_txt").value.toLowerCase();
    if (mysearch != "enter search" && mysearch.length > 2) {
		if (myServer_array[0]=="paychexinsurancedev"){
			document.location = "http://paychexinsurancedev.paychex.com:8765/query.html?qt=+" + mysearch.toLowerCase() + "&charset=utf-8";
			document.forms[0].action = "http://paychexinsurancedev.paychex.com:8765/query.html?qt=+" + mysearch.toLowerCase() + "&charset=utf-8";
		}else{
            document.location = "http://search"+subLoc+".paychexinsurance.com/query.html?qt=+" + mysearch + "&charset=utf-8";
			document.forms[0].action = "http://search"+subLoc+".paychexinsurance.com/query.html?qt=+" + mysearch + "&charset=utf-8";
        }
    } else {
        alert("Please enter a search term.");
        return false;
    }
}
function keySubmit(e){
    if(e.keyCode==13){   
        validsearch();
    }
}

var htmls = new Array();
function creatediv() {
	htmls = document.getElementsByTagName("html");
	htmls[0].style.overflow = "hidden";
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', 'flashcontent'); 
	document.body.appendChild(newdiv);
	swfobject.embedSWF("/inc/flash/carriermap/carrierMap.swf", "flashcontent", "300", "120", "9.0.0",false,{},{wmode:"transparent",allowscriptaccess:"always",menu:"false",loop:"false",base:"."},{});
} 

function removeElement() {
	cmap_array = cmap_array[0].split("?");
	document.location = cmap_array[0];
	/*var htmls = document.getElementsByTagName("html");
	htmls[0].style.overflow = "auto";
	var d = document.getElementById('flashcontent');
	document.body.removeChild(d);*/
}

var cmap_array = myLoc.split("tool=cmap");
if(cmap_array.length > 1){
	window.onload = function(){ creatediv(); }
}

function expandStages(clicked,whatBox){
	selectName = clicked.parentNode.className; //selected item name
	var foundSelect = false;


	//finds UL nav
	stagesUl = clicked.parentNode.parentNode;
	for(i=0;i<stagesUl.childNodes.length;i++){
		if(stagesUl.childNodes[i].innerHTML != null){ //removes false positives (whitespace) for childNodes 
			stagesUl.childNodes[i].childNodes[0].className = (stagesUl.childNodes[i].childNodes[0]==clicked) ? "select": "visited"; //sets A links to previosly viewed except for the clicked link
			if(foundSelect){ stagesUl.childNodes[i].childNodes[0].className = ""; } //if selected link has been encountered, set A links to default
			if(stagesUl.childNodes[i].childNodes[0].className=="select"){ foundSelect=true;} //found the selected link, only set once
		}
	}

	//find the content area
	if(whatBox==null){
		elem = stagesUl.nextSibling
		while(elem.innerHTML == null){
			elem = elem.nextSibling;
		}
	}else{
		elem = document.getElementById(whatBox);
	}
	//set content area display
	for(i=0;i<elem.childNodes.length;i++){
		if(elem.childNodes[i].innerHTML != null){ //removes false positives (whitespace) for childNodes 
			elem.childNodes[i].className = (elem.childNodes[i].id == selectName + "_content") ? "on" : "off";  //sets all UL A links to default
		}
	}
}