// *** COMMON CROSS-BROWSER COMPATIBILITY CODE ***

var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isOp=window.opera?1:0;
var isWin=navigator.platform.indexOf('Win')!=-1?1:0;
var isDyn=isDOM||isIE||isNS4;


function getRef(id, par)
{
 par=!par?document:(par.navigator?par.document:par);
 return isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  (isNS4 ? par.layers[id] : null));
}

function getSty(id, par)
{
 var r=getRef(id, par);
 return r?(isNS4?r:r.style):null;
}


if (!window.LayerObj) var LayerObj = new Function('id', 'par',
 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
function getLyr(id, par) { return new LayerObj(id, par) }

function LyrFn(fn, fc)
{
 LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px"; ' +
  'with (this) { '+fc+' }');
}
LyrFn('x','if (!isNaN(p)) sty.left=p+px; else return parseInt(sty.left)');
LyrFn('y','if (!isNaN(p)) sty.top=p+px; else return parseInt(sty.top)');
LyrFn('w','if (p) (isNS4?sty.clip:sty).width=p+px; ' +
 'else return (isNS4?ref.document.width:ref.offsetWidth)');
LyrFn('h','if (p) (isNS4?sty.clip:sty).height=p+px; ' +
 'else return (isNS4?ref.document.height:ref.offsetHeight)');
LyrFn('vis','sty.visibility=p');
LyrFn('write','if (isNS4) with (ref.document){write(p);close()} else ref.innerHTML=p');
LyrFn('alpha','var f=ref.filters,d=(p==null); if (f) {' +
 'if (!d&&sty.filter.indexOf("alpha")==-1) sty.filter+=" alpha(opacity="+p+")"; ' +
 'else if (f.length&&f.alpha) with(f.alpha){if(d)enabled=false;else{opacity=p;enabled=true}} }' +
 'else if (isDOM) sty.MozOpacity=d?"":p+"%"');


var CSSmode=document.compatMode;
CSSmode=(CSSmode&&CSSmode.indexOf('CSS')!=-1)||isDOM&&!isIE||isOp?1:0;

if (!window.page) var page = { win: window, minW: 0, minH: 0, MS: isIE&&!isOp,
 db: CSSmode?'documentElement':'body' }

page.winW=function()
 { with (this) return Math.max(minW, MS?win.document[db].clientWidth:win.innerWidth) }
page.winH=function()
 { with (this) return Math.max(minH, MS?win.document[db].clientHeight:win.innerHeight) }

page.scrollY=function()
 { with (this) return MS?win.document[db].scrollTop:win.pageYOffset }
page.scrollX=function()
 { with (this) return MS?win.document[db].scrollLeft:win.pageXOffset }





function tipTrack(evt, always) { with (this)
{
 evt=evt?evt:window.event;

 sX = page.scrollX();
 sY = page.scrollY();
 mX = isNS4 ? evt.pageX : sX + evt.clientX;
 mY = isNS4 ? evt.pageY : sY + evt.clientY;

 if (tipStick == 1) position();
}}

function tipPosition(forcePos) { with (this)
{
 if (!actTip) return;

 var wW = page.winW()-(isIE?0:15), wH = page.winH()-(isIE?0:15);

 var t=tips[actTip], tipX=eval(t[0]), tipY=eval(t[1]), tipW=div.w(), tipH=div.h(), adjY = 1;

 if (typeof(t[0])=='number') tipX += mX;
 if (typeof(t[1])=='number') tipY += mY;

 if (tipX + tipW + 5 > sX + wW) { tipX = sX + wW - tipW - 5; adjY = 2 }
 if (tipY + tipH + 5 > sY + wH) tipY = sY + wH - (adjY*tipH) - 5;
 if (tipX < sX+ 5) tipX = sX + 5;
 if (tipY < sY + 5) tipY = sY + 5;

 if ((!showTip && (doFades ? !alpha : true)) || forcePos)
 {
 //uncomment xPos and yPos along with below for dynamic position with mouse
 xPos = tipX;
 yPos = tipY;
 }
 //uncomment xPos and yPos along with below for dynamic position with mouse
 xPos += (tipX - xPos) * tipStick;
 yPos += (tipY - yPos) * tipStick;
 
 // locked position on screen
 if (eval(t[5])==1) { xPos = 310; yPos = 74; }
 

 div.x(xPos);
 div.y(yPos);
}}

function tipShow(tipN) { with (this)
{
 if (!isDyn) return;

 if (tips[tipN].parentObj) tips[tipN].parentObj.show(tips[tipN].parentTip);

 if (!div) div = getLyr(myName + 'Layer');
 
 if (isDOM) div.sty.width = 'auto';

 if (actTip != tipN)
 {
  actTip = tipN;

  if (tipStick == 0)
  {
   if (isNS4) div.ref.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
   div.ref.onmouseover = new Function('evt', myName + '.show("' + tipN + '"); ' +
    'if (isNS4) return this.routeEvent(evt)');
   div.ref.onmouseout = new Function('evt', myName + '.hide(); ' +
   'if (isNS4) return this.routeEvent(evt)');
  }

  position(true);

  var str = template;
  for (var i=0; i<tips[tipN].length; i++) str = str.replace('%'+i+'%', tips[tipN][i]);
  div.write(str + ((document.all && !isWin) ? '<small><br></small>' : ''));
 }

 clearInterval(trackTimer);
 if (tipStick != parseInt(tipStick)) trackTimer = setInterval(myName+'.position()', 50);

 clearTimeout(fadeTimer);
 if (showDelay || isNS4)
  fadeTimer = setTimeout('with ('+myName+') { showTip = true; fade() }', showDelay + 10);
 else { showTip = true; fade() }
}}


function tipHide() { with (this)
{
 // We've got to be a DHTML-capable browser that has a tip currently active.
 if (!isDyn || !actTip) return;

 if (isNS4 && tipStick==0 && xPos<=mX && mX<=xPos+div.w() && yPos<=mY && mY<=yPos+div.h())
  return;

 if (tips[actTip].parentObj) tips[actTip].parentObj.hide();

 clearTimeout(fadeTimer);
 fadeTimer = setTimeout('with (' + myName + ') { showTip=false; fade() }', hideDelay);
}}


function tipFade() { with (this)
{
 clearTimeout(fadeTimer);

 if (showTip)
 {
  div.vis('visible');
  if (doFades)
  {
   alpha += fadeSpeed;
   if (alpha > maxAlpha) alpha = maxAlpha;
   div.alpha(alpha);
   // Call this function again shortly, fading tip in further.
   if (alpha < maxAlpha) fadeTimer = setTimeout(myName + '.fade()', 50);
  }
 }

 else
 {
  // Similar to before but counting down and hiding at the end.
  if (doFades && alpha > minAlpha)
  {
   alpha -= fadeSpeed;
   if (alpha < minAlpha) alpha = minAlpha;
   div.alpha(alpha);
   fadeTimer = setTimeout(myName + '.fade()', 50);
   return;
  }
  div.vis('hidden');
  actTip = '';
  clearInterval(trackTimer);
 }
}}



function TipObj(myName)
{
 // Holds the properties the functions above use.
 this.myName = myName;
 this.tips = new Array();
 this.template = '';
 this.actTip = '';
 this.showTip = false;
 this.tipStick = 1;
 this.showDelay = 50;
 this.hideDelay = 250;
 this.xPos = this.yPos = this.sX = this.sY = this.mX = this.mY = 0;

 this.track = tipTrack;
 this.position = tipPosition;
 this.show = tipShow;
 this.hide = tipHide;
 this.fade = tipFade;
 
 this.div = null;
 this.trackTimer = this.fadeTimer = 0;
 this.alpha = 0;
 this.doFades = true;
 this.minAlpha = 0;
 this.maxAlpha = 100;
 this.fadeSpeed = 10;
}

var docTips = new TipObj('docTips');
with (docTips)
{
//start gallery images here
 //deco
 tips.gdec00 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-standard.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec01 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-purple.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec02 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-blue.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec03 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-holographic.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec04 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-postcard.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec05 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-letter.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec06 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-midsize.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec07 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-cathat.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec08 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-holobear.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gdec09 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/d-redcandy.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 //bubble
 tips.gbub00 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-bubbledisc.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub01 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-port397.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub02 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-dvdcd397.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub03 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-bluecd.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub04 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-cdbubfan.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub05 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-foldfan.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub06 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-bubfold.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub07 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/b-multiscat.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub08 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/v-decocard.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 tips.gbub09 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/v-flagbbad.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 //clear
  tips.gclear00 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/x-clear.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear01 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/x-folder.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear02 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/x-midsize.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear03 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/x-midsilver.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear04 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-dissimilar.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear05 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-disfolder.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear06 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/x-clearad.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear07 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-disfolder.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear08 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-disfolder.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gclear09 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-disfolder.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
 //custom
  tips.gcust00 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-oxy.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust01 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-notch.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust02 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-print.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust03 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-peelzipper.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust04 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/c-size.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust05 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/o-bluetrans.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust06 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/o-goldpen.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust07 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/o-mearllace.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust08 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/o-orange.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');
  tips.gcust09 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', '<img src="img/o-silverlace.jpg" alt="gallery image" name="gallery" width="397" height="275" border="0" id="gallery">');

vidcontent = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="321" height="239" id="macvideo" align="middle">' +
             '<param name="allowScriptAccess" value="sameDomain" />' +
			 '<param name="movie" value="macvideo.swf" />' +
			 '<param name="quality" value="high" />' +
			 '<param name="bgcolor" value="#6b655e" />' +
			 '<embed src="macvideo.swf" quality="high" bgcolor="#6b655e" width="321" height="239" name="macvideo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
			 '</object><BR>' +
			 '<a href="javascript:void(0)" onClick="docTips.hide()">close(X)</a></div>';
//lock
  tips.locks00 = new Array(5,5,200, '<div align=center><b> Macpac Gallery &copy;2007</b></div>', vidcontent, 1 );

 tips.formulae = new Array('page.scrollX() + page.winW() - 110', -20, 100,
  'This tip is always on the right edge...');
 tips.format = new Array(5, 5, 150, 'That means <i>italics</i>...<br /><hr />...etc');

 template = '<table bgcolor="#FFFFFF" cellpadding="1" cellspacing="0" width="%2%" border="0">' +
  '<tr><td><table bgcolor="#E2E2E2" cellpadding="1" cellspacing="0" width="100%" border="0">' +
  '<tr><td class="tgry">%3%</td></tr>' +
  '<tr><td class="tipClass">%4%</td></tr></table></td></tr></table>';

 fadeSpeed = 15;
 

}

if (isNS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = function(evt)
{


 docTips.track(evt);


 if (isNS4) return document.routeEvent(evt);
}

var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
function ns4BugCheck()
{
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload()
}

window.onresize = function()
{
 ns4BugCheck();
}


