/*
Common JavaScript code for "Lance Lager.com" website.
Copyright 2007 Charles D. Montgomery.
All U.S. and International rights reserved.
*/
	var search = 'genalert=';
	var CookieString = document.cookie;
	var result = '';
	var i=0;
	var slcnt=0;
	var tmp=document.URL;
	for (i = 8; i < tmp.length;i++)
	{
		if (tmp.charAt(i) == "/") slcnt++;
	}
	var relPath = '';
	var Offset = 0;
	if (tmp.indexOf('cdmx') > -1)
		Offset=2;
	slcnt-=Offset;
	slcnt--;
	switch (slcnt) {
		case 1 : relPath='../'; break
		case 2 : relPath='../../'; break
		case 3 : relPath='../../../'; break
		case 4 : relPath='../../../../'; break
		case 5 : relPath='../../../../../'; 
	}

	//Setup a default referral message
	var emailText='';
	emailText='mailto:?subject=Web page of interest\&body=I found the following web page titled: ' + document.title + ' - and thought you might be interested in what it says. The page is located at: ' + document.URL;

	if (CookieString.length > 0) { 
	    offset = CookieString.indexOf(search);
	    if (offset != -1) { 
	        offset += search.length;
	        end = CookieString.indexOf(';', offset);
	        if (end == -1) {
	           end = CookieString.length };
	        result = unescape(CookieString.substring(offset, end)); 
	   } 
	}
	var showIt = 'hidden';
	if (!msgPresent)
		var msgPresent='NO';
		
	if (result=='')
	{
		if (msgPresent == 'YES')
		{
			showIt = 'visible';
		}
	}

	//figure out a 'fudged' best fit for where to put the alert box on the screen.
	var WinWidth=480;
	var WinHeight=280;
	var LeftPos = (screen.width - WinWidth) / 2;
	var TopPos = ((screen.height - WinHeight) / 2) - 100;
	if(navigator.appName.indexOf('Netscape')>-1)
	{
		ScreenPos = 'screenX:' + LeftPos + 'px; screenY:' + TopPos + 'px';
	} else if((navigator.appName.indexOf('Microsoft')>-1) || (navigator.appName.indexOf('MSIE')>-1)) {
		ScreenPos = 'left:' + LeftPos + 'px; top:' + TopPos + 'px';
	}
	//Plug in the style definition for the alert box
	document.writeln('<STYLE><!--');
	document.writeln('	.alert  {color:#000033; background-color:#cccccc; layer-background-color:#cccccc;');
	document.writeln('                position:absolute; ' + ScreenPos + '; width:480px; height:280px;');
	document.writeln('        z-index:99;  visibility:' + showIt + ';}');
	document.writeln('--></STYLE>');

	//(Inline) Set a cookie

    var futuredate = new Date();		//Get the current time and date
    var expdate = futuredate.getTime();  //Get the milliseconds since Jan 1, 1970
    expdate += 3600*1000;  //expires in 1 hour(milliseconds)
    futuredate.setTime(expdate);
    var newCookie='genalert=Set; path=/;';	//Set the new cookie values up
    newCookie += ' expires=' + futuredate.toGMTString(); //expire it in a hour or so
    window.document.cookie=newCookie; //Write the cookie

/* On page load the following is fall-through code that will always be executed
   This code binds similar event handlers to this page. This eliminates one
   setup step. Specifically, there is no need for an installer to include a
   "onload=..." statement in the <body tag.
*/
if (window.addEventListener) {
	window.addEventListener("load",adjDspFrame,false);
} else {
    window.attachEvent("onload", adjDspFrame);
}

function SetDspFrameSize(id) {
    var DspFrame = document.getElementById(id);
    if (DspFrame) {
        if (DspFrame.contentDocument && DspFrame.contentDocument.body.offsetHeight) {
            // FireFox, Mozilla, et. al. (W3C) syntax
            DspFrame.height = DspFrame.contentDocument.body.offsetHeight;    
        } else { //if (DspFrame.Document && DspFrame.Document.body.scrollHeight) {
            // MSIE syntax
            DspFrame.height = DspFrame.Document.body.scrollHeight;
        }
		/* For FF/NS class browsers (and possibly others) add some additional height
		to kill off the vertical scroll bar (shows up even if SCROLLING="NO"; go figure...)
		The next line casts the string to an integer, which may or may not be adjusted. */		
		var adj=DspFrame.height / 1; 
		if (!document.all)     /* Returns TRUE unless MSIE (inverted logic)*/
			adj+=72; 	       /* For any browser other than MSIE add 16 pixels to the height. Even
							      if it turns out that we end up overadjusting for a few browsers,
							      the likelihood that 16 pixels of space will cause a problem is
							      pretty remote. */
		DspFrame.height = adj;
		if (DspFrame.addEventListener) {
            DspFrame.addEventListener("load", adjDspFrame, false);
        } else {
			DspFrame.detachEvent("onload", adjDspFrame); //MSIE needs hand-holding...
            DspFrame.attachEvent("onload", adjDspFrame);
        }
   }
}
function adjDspFrame(evt) { //retaining the event (evt) for possible future expansion; not used
	SetDspFrameSize('DisplayFrame');
}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	var winW = (window.innerWidth) ? window.innerWidth : document.body.offsetWidth;
	var rLeft = (winW - rtpWidth) / 2;
	rTop = document.body.scrollTop + (rtpHeight * VerticalOffset);
    if(document.layers) {	   					//NN4+
		var layer = document.layers[szDivID];
    	layer.top = rTop;
		layer.left = rLeft;
		document.layers[szDivID].visibility = iState ? "show" : "hide";
    } else if(document.getElementById)	{  		//gecko(NN6) + IE 5+ 
        var layer = document.getElementById(szDivID);
		layer.style.top = rTop;
		layer.style.left = rLeft;
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    } else if(document.all)	{ 					// IE 4
		document.all[szDivID].style.posLeft = rLeft;
		document.all[szDivID].style.posTop = rTop;
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}
var min=8;
var max=24;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}
var tglFlag=0;
function ToggleBkg(cell)
{
   box=document.getElementById(cell);
   if (tglFlag == 0)
   	{
		tglFlag=1;
		box.style.backgroundColor="";
	} else {
		tglFlag=0;
		box.style.backgroundColor="";
	}
}

	//Write the DIV code we need (no adjustment necessary)	
	document.writeln('<style type="text/css">');
	document.writeln('.demo  {color:#000033; background-color:white; layer-background-color:white;');
	document.writeln('position:absolute; z-index:99;  visibility:hidden;');
	document.writeln('top:0px; left:0px; width:0px; height:0px;');
	document.writeln('</style>');
	
	document.write('<table border=0 width=100% cellspacing=0 cellpadding=0><tr><td width=100% valign=top align=left><IFRAME SRC="http://www.hirmon.com/scripts/fback/fback.cgi?ssi=false&purl=' + document.URL + '&pname=' + document.title + '"; width=' + DefaultW + ' height= ' + DefaultH + ' SCROLLING="no" FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0>We\'re sorry, but your browser does not support Inline Frames presentations.</IFRAME></td></tr><tr><td width=100% valign=top align=left><p align=center><A class=demolnk href=javascript:void(0); onclick=parent.toggleBox(\'demodiv\',0); return false;><B><font face=Arial size=2 color=blue>' + LinkUnderlineOn + CloseText + LinkUnderlineOff + '</font></b></A>' + LineBreak + '</td></tr></table>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</div>');
