sfHover = function() {
	if(document.getElementById("nav")){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			if(sfEls[i].className=="topMenu"||sfEls[i].className=="topMenuOver"){
				sfEls[i].onmouseover=function() {
					this.className+=" tmsfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className="topMenu tmsfhover\\b";
				}
			}else if(sfEls[i].className=="topMenuAlone"){
				sfEls[i].onmouseover=function() {
					this.className+=" tmasfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" tmasfhover\\b"), "");
				}
			}else if(sfEls[i].className=="subMenuWithSub"){
				sfEls[i].onmouseover=function() {
					this.className+=" sfhoverWithSub";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhoverWithSub\\b"), "");
				}
			}else if(sfEls[i].className=="subMenu2"){
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover2";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover2\\b"), "");
				}
			}else{
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
}
var br="";
if(navigator.userAgent.indexOf('Safari')>-1){br="<br>";}

function fixSafari(){
	if(navigator.userAgent.indexOf('Safari')>-1){
		document.styleSheets[1].cssRules[9].style.top="84px";
		document.styleSheets[1].cssRules[18].style.marginTop="-65px";
		document.styleSheets[1].cssRules[18].style.marginLeft="135px";
	}
	//preload images
	//var image=new Image('/images/navBackOver.jpg');
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//return [curleft,curtop];
	return curleft;
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function todoExpand(divNum, open){
	if((document.getElementById('toDo'+divNum).style.display=='none'&&open==undefined)||open){
		document.getElementById('toDoArrow'+divNum).src='/images/toDoArrowDown.jpg';
		document.getElementById('toDo'+divNum).style.display='block';
	}else{
		document.getElementById('toDoArrow'+divNum).src='/images/toDoArrowLeft.jpg';
		document.getElementById('toDo'+divNum).style.display='none';
	}
}
function todoExpandAll(){
	divNum=1;
	while(document.getElementById('toDo'+divNum)){
		todoExpand(divNum, true);
		divNum++
	}
	document.getElementById('expand_link').innerHTML='<a href="#" onclick="todoCloseAll();return false;">Collapse All</a>';
}
function todoCloseAll(){
	divNum=1;
	while(document.getElementById('toDo'+divNum)){
		todoExpand(divNum, false);
		divNum++
	}
	document.getElementById('expand_link').innerHTML='<a href="#" onclick="todoExpandAll();return false;">Expand All</a>';
}

function get_key(e){
	return e.keyCode;
}
function expand_selection(selection){
	//drop downs on main page
    if(document.getElementById('img100')!=null)
        document.getElementById('img100').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand1')!=null)
        document.getElementById('divExpand1').style.display='none';
	if(document.getElementById('img200')!=null)
        document.getElementById('img200').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand2')!=null)
        document.getElementById('divExpand2').style.display='none';
	if(document.getElementById('img300')!=null)
        document.getElementById('img300').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand3')!=null)
        document.getElementById('divExpand3').style.display='none';
	if(document.getElementById('img400')!=null)
        document.getElementById('img400').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand4')!=null)
        document.getElementById('divExpand4').style.display='none';
	if(document.getElementById('img500')!=null)
        document.getElementById('img500').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand5')!=null)
        document.getElementById('divExpand5').style.display='none';
	if(document.getElementById('img600')!=null)
        document.getElementById('img600').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand6')!=null)
        document.getElementById('divExpand6').style.display='none';
	if(document.getElementById('img700')!=null)
        document.getElementById('img700').src='/images/frontPageArrowDown.jpg';
	if(document.getElementById('divExpand7')!=null)
        document.getElementById('divExpand7').style.display='none';
        
	if(document.getElementById('img800')){
		document.getElementById('img800').src='/images/frontPageArrowDown.jpg';
		if(document.getElementById('divExpand8')!=null)
            document.getElementById('divExpand8').style.display='none';
	}
	
	if(document.getElementById('divExpand'+selection).style.display=='block'){
		document.getElementById('img'+selection+'00').src='/images/frontPageArrowDown.jpg';
		document.getElementById('divExpand'+selection).style.display='none';
	}else{
		document.getElementById('img'+selection+'00').src='/images/frontPageArrowUp.jpg';
		document.getElementById('divExpand'+selection).style.display='block';
	}
}

function ajaxPageList(pref){
	var xmlHttpReq = false;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
			xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	url="/includes/limitPage.php";
	qStr="branch="+document.getElementById(pref+'page_branch').value+"&layout="+document.getElementById(pref+'page_layout').value+"&pref="+pref;
	xmlHttpReq.open('POST', url+"?"+qStr, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			var response=xmlHttpReq.responseText;
			if(response!=""){
				document.getElementById(pref+'pageList').innerHTML=response;
			}
		}
	}
	xmlHttpReq.send('?'+qStr);
}

function ajaxStoreNum(td_id, set_after, store_value, include_allStores, appendNum){
	var xmlHttpReq = false;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
			xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	url="/includes/limitStoreNum.php";
	if(store_value==undefined&&document.getElementById('storeName')){
		qStr="store="+document.getElementById('storeName').value;
	}else{
		qStr="store="+store_value;
	}
	if(appendNum!=undefined){qStr+="&append="+appendNum;}
	if(include_allStores){
		qStr+="&allStores=1";
	}
	xmlHttpReq.open('POST', url+"?"+qStr, true);
	//xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			var response=xmlHttpReq.responseText;
			if(response!=""){
				document.getElementById(td_id).innerHTML=response;
				if(set_after!=""){
					if(appendNum!=undefined){
						document.getElementById("storeNum"+appendNum).value=set_after;
					}else{
						document.getElementById("storeNum").value=set_after;
					}
				}
			}
		}
	}
	xmlHttpReq.send(null);
}
function showNum(showIt){
	if(showIt){
		document.getElementById("qBlock").style.display="block";
	}else{
		document.getElementById("qBlock").style.display="none";
	}
}
function submitquiz(theQuiz){
	var err="";
	for(var i=1; i<=30; i++){
		if(eval("theQuiz.q"+i)){
			thisQ=eval("theQuiz.q"+i);
			answered=false;
			for (j=0; j< thisQ.length; j++){
				if(thisQ[j].checked){answered=true;}
			}
			if(!answered){
				err+="Please answer question "+i+".\n";
			}
		}
	}
	
	if(err==""){
		theQuiz.submit();
	}else{
		alert(err);
	}
}
function featureSwfLoad(swfName){
	var temp = new Array();
	temp = swfName.split('.');
	swfLoc=temp[0];
	var temp = new Array();
	temp = swfLoc.split('/');
	swfName=temp[temp.length-1];
	document.getElementById('tr3').innerHTML="<td id='td4'></td>";
	
	var so = new SWFObject(swfLoc+".swf", swfName, "540", "270", "3", "#FFF");
  so.addParam("wmode", "transparent");
  so.write("td4");
}
var quiz_finished=true;
function linkPopup(page_id){
	quiz_finished=false;
	aTags=document.getElementsByTagName('A');
	for(i=0;i<aTags.length;i++){
		if(!aTags[i].onclick&&aTags[i].target!="_blank"){  
			//link without javascript function
			aTags[i].onclick = function(){if(!quiz_finished){window.open("/includes/saveReason.php?url="+this.href+"&page="+page_id,'newwindow','width=430,height=400,scrollbars=no,toolbar=no,resizable=yes,titlebar=no,status=no');return false;}}
		}
	}
}
function finish_quiz(){
	quiz_finished=true;
}
function MM_openBrWindow(winName,features) { 
	// -------------------------------------------------------------
	// -------------------------------------------------------------
	// -------------------------------------------------------------
	/*
	Function Provided by Eileen Casey - 10-31-2007 ;-) ~ 
	This opens a window theURL, winName for window Name, and features 
	to describe the various options for that window that you so recently 
	opened. This is properiatary code, and shouldn't be used unless 
	Eileen Casey say's it's okay copyright 1996
	*/
	// --------------------------------------------------------------
	// -------------------------------------------------------------
	// -------------------------------------------------------------
      window.open("/includes/saveReason.php?url=/main/&page=674",winName,features); // This is the meat of this function theURL+this.url
        // -------------------------------------------------------------
        // -------------------------------------------------------------
        // -------------------------------------------------------------
}
