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_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];}
}

var hide  = true;

function showhide(p1,p2) {
	if (p1 == "Computer") thetext="<p id='title'>Number of Computers</p><p>Fonts are licensed for a specific number of computers at a fixed number of locations. From this site, you can buy licenses for up to 50 computers at a single location.</p><p>For larger licenses, or for further information, please see the <a href='../ask/topics.php?topicID=10'>Licensing &amp; Usage</a> FAQ.</p>";
	if (p1 == "Grade") thetext="<p id='title'>Grades</p><p>&#8216;Grades&#8217; are different variations of a font designed to counter the effects of different kinds of challenging media, such as newsprint or reflective signs. You can buy each grade individually, or get all four grades together in the specially-priced &#8220;Complete&#8221; package.</p><p><a href='../ask/recentTopic.php?rtID=89'>This chart</a> has more information about choosing the right grade for your project.</p>";
	if (p1 == "Platform") thetext="<p id='title'>Platform</p><p>Font software is produced for both Macintosh and Windows operating systems. If you&#8217;re licensing fonts for two or more computers, you can choose to download both versions.</p><p>For more information about font formats, please see our <a href='../ask/topics.php?topicID=12'>Specifications</a> FAQ.</p>";
	if (p1 == "Language") thetext="<p id='title'>Character Sets</p><p>This font is available in different character sets, each of which accommodates a different collection of languages. A complete list of languages appears in the <a href='../ask/faq.php?faqID=12#Faq_12'>Language Specification</a> in our FAQ.</p><p>Please note: different language editions of the same font <em>cannot be operated on the same computer simultaneously.</em> Those needing more than one character set should choose this font's specially-priced <strong>Multiscript Edition</strong>, which integrates all available character sets into a single set of fonts.</p>";
	if (p1 == "Publication") thetext="<p id='title'>Publication or Division</p><p>If you're purchasing a font license for use in a newspaper, magazine, or other publication, enter the publication's title here.</p>";
	if (p1 == "Company") thetext="<p id='title'>Company</p><p>Font licenses may only be purchased for individuals within your company: they may not be purchased for resale. Licenses are non-transferrable, and licenses will not be issued on behalf of other organizations.</p><p>Distributors, please read our <a href='../ask/topics.php?topicID=11#Faq_94'>resale policy</a>.</p>";
	if (p1 == "EmailAddress") thetext="<p id='title'>E-Mail Address</p><p>To ensure that you don't lose any past orders (which are linked to your e-mail address), please contact our sales office at <a href='mailto:moved@typography.com?subject=Change of e-mail address'>moved@typography.com</a> if your e-mail address has changed.</p>";
	if (p1 == "CVV2") thetext="<p id='title'>CVV2 Security Code</p><p><span class='card-illustration'><img src='../images/account/checkout/card_cvv.png' width='87' height='56'></span>This is the three-digit code on the back of your Mastercard or Visa, or the four-digit code on the front of your Amex card.</p>";
	var obj = document.getElementById(p2);
	var x = document.getElementById('dhtmltooltip');
	var fullhtml = "<p id='popclose'><a href=\"javascript:showhide(\'\',\'"+p2+"\');\"><img src='../images/general/close.gif' height='12' width='12' border='0' alt='close' /></a></p>"+thetext+"<p id='popbot'>&nbsp;</p>";
	x.innerHTML=fullhtml;
	hide = !hide;
	x.style.visibility = (hide) ? 'hidden' : 'visible';
	setLyr(obj,'dhtmltooltip');
}

function setLyr(obj,lyr) {
	var coors = findPos(obj);
	var x = document.getElementById(lyr);
	x.style.top = (coors[1]-100) + 'px';
	x.style.left = (coors[0]-250) + 'px';
}

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];
}

var openingBM;
var obmFinalY;
var obmFinalHeight;
var obmCurrentHeight;
var obmCurrentY;
var obmInt;
function shBM(p1,p2) {

	if (1==2) {
// rowland's stuff
		var obj = document.getElementById(p1);
		var x = document.getElementById(p2);
		hide = !hide;
		x.style.visibility = (hide) ? 'hidden' : 'visible';
		var coors = findPos(obj);
		x.style.top = (coors[1]-79) + 'px';
		x.style.left = coors[0] + 'px';
	}
	else {
// scotts stuff
		clearInterval(obmInt);
		var obj = document.getElementById(p1);
		var x = document.getElementById(p2);
		hide = !hide;
// check the height 
		var coors = findPos(obj);
		if (x.style.visibility == 'visible') {
			// lert("closing?S?!?");
			obmFinalHeight = 1;
			obmFinalY = coors[1] - 79 + obmFinalHeight;
			obmCurrentHeight = 110;
			obmCurrentY = coors[1] - 79;
			x.style.visibility = 'visible';
			obmInt =  setInterval("animateOBM(-1,'"+p2+"')",10);
		}
		else {
			x.style.height = "10px";
			obmCurrentHeight = 1;
			x.style.overflow = "scroll";
			obmFinalHeight = x.scrollHeight + 8;
			obmFinalY = coors[1]-79;
			obmCurrentY = coors[1] - 79 + obmFinalHeight;
			x.style.top = obmCurrentY + 'px';
			x.style.left = coors[0] + 'px';
			x.style.overflow = "hidden";
			x.style.visibility = 'visible';
			obmInt =  setInterval("animateOBM(1,'"+p2+"')",10);
		}
// end of scotts stuff
	}
}
function animateOBM(direction,divID) {
	var obmDiv = document.getElementById(divID);
	var speed = Math.abs((obmFinalHeight - obmCurrentHeight) * .2);	
	obmCurrentHeight += direction * speed;
	obmCurrentY -= direction * speed;
	var diff = Math.abs(obmFinalHeight - obmCurrentHeight);
	if (diff < 1) {
		// lert("clearing int! "+obmCurrentHeight+" "+obmFinalHeight+"  "+diff);
		clearInterval(obmInt);
		obmDiv.style.height = obmFinalHeight+"px";	
		obmDiv.style.top = obmFinalY+"px";	
		if (obmFinalHeight == 1) obmDiv.style.visibility = "hidden";
	}
	else {
		obmDiv.style.height = obmCurrentHeight+"px";	
		obmDiv.style.top = obmCurrentY+"px";	
	}
}

function shBM2( whichLayer ) {
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
