//
//	COPYRIGHT NOTICE:
// 	Copyright 2002 - 2006 Barry Saxifrage. Stonebreaker Designs. All Rights Reserved.
//	By using this code you agree to indemnify Barry Saxifrage and Stonebreaker Designs 
//	from any liability that might arise from its use. Selling this code or distributing 
//	this code without prior written consent is expressly forbidden. Copyright notice  
//	must remain with this code. For more information: www.stonebreakerdesigns.com	
//
//

//================================
//
//  DOM 
//

function getDOM(objID,fStyle) {
	var isID = 0;
	var isAll = 0;
	if (document.getElementById) {isID  = 1; }
	if (document.all) 			 {isAll = 1; }
	if (fStyle == 1) {
		if (isID) 		{return (document.getElementById(objID).style);}
		else if (isAll) {return (document.all[objID].style);}
		else 			{return null; }
	}
	else {
		if (isID) 		{return (document.getElementById(objID));}
		else if (isAll) {return (document.all[objID]);}
		else 			{return null; }
	}
}
		
//================================
//
//	POPUP MENUS
//

	function getMenuHead(strMenuId, strText, rgbColor) {
		var str = '';
		var strStyle = ''
		if (isNotEmpty(rgbColor)) { strStyle = ' style="color:#'+rgbColor+';" '; }
		// stop ie wrap
		str += '<div class="m_header"><a href="javascript:showMenu(\''+strMenuId+'\')" onMouseOver="showMenu(\''+strMenuId+'\')" onMouseOut="menu_t = 1; delayHide()" class="m_h_text" '+strStyle+'>'+strText+'<img src="'+gWWWPath+'bits/menu-down.gif" width="10" height="6" alt="" border="0"></a></div>';

		return str;
	}
	function getMenuCommand(strText, strJsCommand) {
		var str = '';
		str += '<a href="javascript:'+strJsCommand+'" class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';

		return str;
	}
	function getMenuCommandSide(strText, strJsCommand, strMSStyle) {
		var str = '';
		str += '<a href="javascript:'+strJsCommand+'" class="ms_c_text" '+strMSStyle+'>'+strText+'</a><br>';

		return str;
	}
	function getMenuCommandExtra(strText, strCommand, isInternal, fOwnWindow) {
		var str = '';
		if (isInternal == 1) {
			str += '<a href="javascript:showPage(\''+strCommand+'\')" class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';
		} else {
			if (fOwnWindow == 1) {
				str += '<a ';
				str += getWebsiteHref(strCommand);
				str += ' class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';		
			} else {
				str += '<a ';
				str += getWebsiteHrefPlus(strCommand,1);
				str += ' class="m_c_text" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;" >'+strText+'</a>';					
			}	
		}
		return str;
	}
	function getMenuCommandSideExtra(strText, strCommand, isInternal, fOwnWindow, strMSStyle) {
		var str = '';
		if (isInternal == 1) {
			str += '<a href="javascript:showPage(\''+strCommand+'\')" class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';
		} else {
			if (fOwnWindow == 1) {
				str += '<a ';
				str += getWebsiteHref(strCommand);
				str += ' class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';		
			} else {
				str += '<a ';
				str += getWebsiteHrefPlus(strCommand,1);
				str += ' class="ms_c_text"  '+strMSStyle+'>'+strText+'</a>';					
			}	
		}
		str += '<br>';
		return str;
	}
	function getMenuSection(strText) {
		var str = '';
		str += '<div class="m_section" onMouseOut="menu_t = 1; delayHide()" onMouseOver="menu_t = 2;">'+strText+'</div>';

		return str;
	}
	function getMenuSectionSide(strText, strMSStyle) {
		var str = '';
		if (strText != '') { str += '<div class="ms_section" '+strMSStyle+'>'+strText+'</div>'; }

		return str;
	}
	
	// global menu variables
	var domMenu_cur = null;
	var domMenu_old = null;
	var menu_t = 0;
	var menu_lDelay = 3;
	var menu_lCount = 0;
	var menu_pause = 100;
	
	function showMenu(menuName){
		menu_t = 2;
		if (domMenu_old) {
			domMenu_old.display = 'none'; 
			domMenu_old.zIndex = '0'; 
			menu_t = 2; 
			menu_lCount = 0;
		}
		domMenu_cur = getDOM(menuName,1);
		if (domMenu_old != domMenu_cur) {	
			domMenu_cur.display = 'block';
			domMenu_cur.zIndex = 1000;
			domMenu_old = domMenu_cur;
		}
		else { domMenu_old = null; }
	}
	
	function delayHide() {
	    if ((domMenu_old) && (menu_t == 0)) {
	        domMenu_old.display = 'none'; 
	        domMenu_old.zIndex = '0';
	        domMenu_old = null;
	        menu_lCount = 0; 
	        return false;
	    }
	    if (menu_t == 2) { menu_lCount = 0; return false; }
	    if (menu_t == 1) { 
	        menu_lCount = menu_lCount + 1;
	        if (menu_lDelay <= menu_lCount) { menu_t = 0; }
	        setTimeout('delayHide()',menu_pause);
	    }
	}
		

	
//================================
//
//	COOKIES
//

	function getCookieVal (offset) {
	  var endstr = document.cookie.indexOf (";", offset);
	  if (endstr == -1)
	    endstr = document.cookie.length;
	  return unescape(document.cookie.substring(offset, endstr));
	}
	function GetCookie (name) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  var arg = name + "=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) {
	    var j = i + alen;
	    if (document.cookie.substring(i, j) == arg)
	      return getCookieVal (j);
	    i = document.cookie.indexOf(" ", i) + 1;
	    if (i == 0) break; 
	  }
	  return null;
	}
	function SetCookieYear (name, value, path, domain, secure) {
		var dateExp = new Date();
		dateExp.setTime(dateExp.getTime() + msecOneYear);		
		SetCookie (name,value,dateExp,path,domain,secure)
	}
	function SetCookie (name,value,expires,path,domain,secure) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  document.cookie = name + "=" + escape (value) +
	    ((expires) ? "; expires=" + expires.toGMTString() : "") +
	    ((path) ? "; path=" + path : "") +
	    ((domain) ? "; domain=" + domain : "") +
	    ((secure) ? "; secure" : "");
	}
	function DeleteCookie (name,path,domain) {
	  if (gSiteId != 1) { name = gSiteId+'_'+name; }
	  if (GetCookie(name)) {
	    document.cookie = name + "=" +
	      ((path) ? "; path=" + path : "") +
	      ((domain) ? "; domain=" + domain : "") +
	      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	  }
	}
	function acceptsCookies() {
		var fReturn = false;
		SetCookie('testAccept','35s6');
		var nVal = GetCookie('testAccept');
		fReturn = (nVal == '35s6');
		return fReturn
	}
	


//Following code is not from Stonebreaker Design

//Function for changing display attribute of an object
//Changing the values for the display property affects the layout of the surrounding content by:

//    * Adding a new line after the element with the value block.
//    * Removing a line from the element with the value inline.
//    * Hiding the data for the element with the value none. 

// Allowable values for display attribute are:
//block	Object is rendered as a block element.
//none	Object is not rendered.
//inline	Default. Object is rendered as an inline element sized by the dimensions of the content.
//inline-block	Object is rendered inline, but the contents of the object are rendered as a block element. Adjacent 
//              inline elements are rendered on the same line, space permitting.
//list-item	Microsoft Internet Explorer 6 and later. Object is rendered as a block element, and a list-item marker is 
//          added.
//table-header-group	Table header is always displayed before all other rows and row groups, and after any top
//                      captions. The header is displayed on each page spanned by a table.
//table-footer-group	Table footer is always displayed after all other rows and row groups, and before any bottom
//                      captions. The footer is displayed on each page spanned by a table.

//In contrast to the visibility property, display=none reserves no space for the object on the screen.
function swapDisplay (objID) {
	var dom = getDOM(objID,0);
	if (dom.style.display == "block") {
		(dom.style.display = "none");
		} else {
			(dom.style.display = "block");
		}
}


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.01
  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 && d.getElementById) x=d.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];}
}

function headerSetFrames (newPage) {
	document.location.href = "header" + newPage + ".htm";
	parent.navframe.document.location.href = "nav" + newPage + ".htm";
	parent.contentframe.document.location.href = "content" + newPage + ".htm";
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
