/* ------------------------------------------------------------------------------------------------ */
/* All intellectual property rights relating to this code are owned by EURO RSCG DSW Partners, LLC. */
/* ------------------------------------------------------------------------------------------------ */

var is_ie6 =
document.all &&
(navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1);


if(is_ie6)
{
	var v_css  = document.createElement('link');
	v_css.rel = 'stylesheet'
	v_css.type = 'text/css';
	v_css.href = "/css/ie6.css";
	document.getElementsByTagName('head')[0].appendChild(v_css);

}

var ns = (document.layers) ? 1 : 0;
var ie = (document.all) ? 1 : 0;

if (ns||ie) {
	var build;
	var currMenu = null;
	var currLayer = null;
	var menuTimer = setInterval('null',1000);
	var hideTimer = setTimeout('null',1000);
var nsFix=0; var popTimer = setTimeout('null',1);
}

function drop_menu(layer) { if (!navPics.rollovers) return; if (layer==currMenu) { /*endNav();*/ return;} endNav();
	currMenu = layer; currLayer = getLayer(layer+'_nav'); if (currLayer==null) return; var n = (layer=='quickpick')? 20:10;
	currLayer.min=currLayer.getHeight()*-1; currLayer.style.top = currLayer.min+n;
	if (currMenu=='quickpick') {layervis(1,'qpfade1','qpfade2');}
	if ((currMenu=='projectors')||(currMenu=='language')) { swapOn(navPics,currMenu); }
	document.onmousemove=dragFix; document.onmouseup=uplink; if (ns) nsFix=1;
	getLayer(layer+'_clip').style.visibility=visible; currLayer.style.visibility=visible; clearInterval(menuTimer); menuTimer = setInterval('openmenu()',50); }

function openmenu() { var y = currLayer.getTop(); y+=25; if (y>0) y=0; currLayer.style.top=y; if (y==0) {clearInterval(menuTimer); document.onmousedown=closeNav;} }
function layervis(n) { var j, vis = (n==1)? visible:hidden; for (j=1; j<arguments.length; j++) { getLayer(arguments[j]).style.visibility=vis; } }

function dragFix() {return false;}
function powerup() {swapOff(navPics,'brightideas'); document.onmousemove=null; document.onmouseup=null;}
function uplink() {document.onmousemove=null; document.onmouseup=null;}

currIdea=0;
function nsBITable(n) { var stuff= '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="161"><TR><TD WIDTH="160" BGCOLOR="ffffff">' + '<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="5" WIDTH="160"><TR><TD BGCOLOR="#006600" BACKGROUND="/pix/brightideas/bg.jpg" VALIGN="top"><FONT FACE="ARIAL,HELVETICA" SIZE="1" COLOR="#FFFFFF" STYLE="font-size:9pt">'+brightIdeasArray[n]+'</FONT></TD></TR></TABLE>' + '</TD><TD WIDTH="1" BGCOLOR="#000000"><IMG SRC="/pix/spacer.gif" WIDTH="1" HEIGHT="1"></TD>' + '</TR><TR><TD COLSPAN="2" BGCOLOR="#000000"><IMG SRC="/pix/spacer.gif" WIDTH="1" HEIGHT="1"></TD></TR></TABLE>'; return(stuff); }

function swapBrightIdea() { var layer = getLayer('bIdeaArea');
if (ie) layer.innerHTML=brightIdeasArray[currIdea]; if (ns) { layer.document.write(nsBITable(currIdea)); layer.document.close(); }
currIdea++; if (currIdea==brightIdeasArray.length) currIdea = 0;
}

document.skip=false;
function closeNav() { if (!document.skip) endNav(); else document.skip=false; }
function skipClose() { if (document.onmousedown!=null) document.skip=true; }

function initNav() { loadImages(); navReady=true; }
//function clicked(who) { if (who=='brightideas') { showTip(1); } else { if (who=='howtobuy') { swapOn(bn,'howtobuy'); drop_menu(who); } else { drop_menu(who); } } }
function clicked(who) { if (who=='brightideas') { showTip(1); } else { if (who=='howtobuy') { swapOn(bn,'howtobuy'); drop_menu(who); }  if (who=='buy') { swapOn(bn,'buy'); drop_menu(who); } else { drop_menu(who);}}}

function showTip(n) { if ((!document.bi)||(!navPics.rollovers)) return;  clearTimeout(popTimer);
	if (n==1) { swapOn(navPics,'brightideas'); document.onmousemove=dragFix; document.onmouseup=powerup; skipClose(); }
	if (currMenu!='brightideas') { swapBrightIdea(); endNav(); currMenu = 'brightideas'; currLayer = getLayer('brightideas'); if (currLayer==null) return; currLayer.cb=0; if (ie) { currLayer.style.clip = "rect(0 200 0 0)"; } if (ns) { currLayer.clip.bottom = 0; } currLayer.style.visibility=visible; clearInterval(menuTimer); menuTimer = setInterval('revealTip()',10); }
	 else { if (n==1) swapBrightIdea(); } if (ns) nsFix=1; }

function revealTip() { y = currLayer.cb+20;
if (ie) { currLayer.style.clip = "rect(0 200 "+y+" 0)"; }
if (ns) { currLayer.clip.bottom = y; }
currLayer.cb = y;  /*if (y>=currLayer.getHeight())*/ if (y>=500) {clearInterval(menuTimer); document.onmousedown=closeNav;} }

function endNav() { if (currLayer==null) return; currLayer.style.visibility = hidden; if (currMenu!='brightideas') getLayer(currMenu+'_clip').style.visibility=hidden;
	if (currMenu=='quickpick') {layervis(0,'qpfade1','qpfade2');}
	if ((currMenu=='projectors')||(currMenu=='language')||(currMenu=='xbrightideas')) { swapOff(navPics,currMenu); }
	if (currMenu=='howtobuy') { swapOff(bn,'howtobuy'); }
	if (currMenu=='buy') { swapOff(bn,'buy'); }	
	if (getLayer(currMenu+'_bullet')!=null) putBullet(currMenu,'off');
	clearTimeout(hideTimer); clearInterval(menuTimer); document.skip=false; document.onmousedown=null;  currLayer = null; currMenu = null; }

function navEnter(who,n) { if (n!=1) { setDropDelay(who); } if (who!=currMenu) return; clearTimeout(hideTimer); if (ns) { if (nsFix==1) nsFix=2; else nsFix=1; } }
function navExit(who,n)  { if (n!=1) { clearTimeout(popTimer); } if (who!=currMenu) return; if (ns) { if (nsFix==2) {nsFix=10; return;}  nsFix=0; } clearTimeout(hideTimer); hideTimer = setTimeout('endNav()',1000); }
function setDropDelay(who) { clearTimeout(popTimer); if (who=='brightideas') { popTimer=setTimeout('showTip(0)',1000); } /* else { popTimer=setTimeout("drop_menu('"+who+"')",1000); } */ }

function putBullet(menu,pos) { var layer = getLayer(menu+'_bullet'); if (pos=='on') { layer.style.visibility=visible; return; }  if (pos=='off') { layer.style.visibility=hidden; return; } layer.style.top=pos; layer.style.visibility=visible;}
function navMenu (name,l,t,w,h,content,bx) { var stuff;
	if (ie) { stuff = '<DIV ID="'+name+'_clip" STYLE="position:absolute; overflow:none; left:'+l+'px; top:'+t+'px; width:'+w+'px; height:'+h+'px; clip:rect(0,'+w+','+h+',0); visibility:hidden; z-index:100">'; }
	if (ns) { stuff = '<LAYER NAME="'+name+'_clip" left="'+l+'" top="'+t+'" width="'+w+'" height="'+h+'" visibility="hide" z-index="100">'; }
	stuff+= layerTag(name+'_nav',1,hidden,0,0,w,0,'ONMOUSEDOWN="skipClose();"; ONMOUSEOVER="navEnter(\''+name+'\',1);" ONMOUSEOUT="navExit(\''+name+'\',1);"');
	stuff+= content;
	stuff+= newLayer(name+'_bullet','<IMG SRC="/pix/hd/nav/navbullet.gif" WIDTH="8" HEIGHT="8">',1,hidden,bx,0,8,8,'ONMOUSEOVER="putBullet(\''+name+'\',\'on\')" ONMOUSEOUT="putBullet(\''+name+'\',\'off\')"');
	stuff+= endTag;
	stuff+= endTag;

	return (stuff);
}



//************** DHTML FUNCTIONS ***************//

// Global Variables
var dragLayer = null; /* layer that is currently being dragged */
var offsetY = 0; var offsetX = 0; /* used to calculate dragged layer position */
var inDrag=0; /* flag set true when a layer is being dragged */
var dragOK=false;

// Equalizing Variables
var hidden = (ie)? 'hidden':'hide';
var visible = (ie)? 'visible':'show';

//******* Drag Functions ********//


	/* makes a layer draggable (sSpec requred, others optional)*/
	/* sSpec: name of slave layer that is dragged - an optional "|" divides two layers (horizontal|vertical) */
	/* mSpec: name of master layer that you click on to drag - if null slave controls itself */
	/* dragZ: z-index at which layer is to be dragged (.dz) */
	/* dropFunc: optional mouseup function (for drag and drop capabilities) (.mu) */
	/* cons='x': Constrains horizontally. d1,d2= min/max constraints (.cx) */
	/* cons='y': Constrains vertically. d1,d2= min/max constraints (.cy) */
	/* cons='f': Constrains to first direction moved. d1,d2= x constraints, d3,d4= x constraints (.cf) */
	/* cons='b': Constrains to box. d1,d2= x constraints, d3,d4= x constraints (.cb) */
function makeDraggable(sSpec,mSpec,dragZ,dropFunc,cons,d1,d2,d3,d4) {

	if (sSpec.indexOf('|')!=-1) { var sSpec2= sSpec.substring(sSpec.indexOf('|')+1,sSpec.length); sSpec=sSpec.substring(0,sSpec.indexOf('|')); } /* Splits sSpec into two entries if sSpec contains | */

	if (mSpec==null) { mSpec=sSpec;	if ((ns)&&(getLayer(sSpec+'A')!=null)) sSpec=sSpec+'A'; }  /* detects second layer created by writeFloater() for Netscape (second layer fixes Netscape Inline layer drag bug) */

	var dragger = getLayer(mSpec);	dragger.slave = getLayer(sSpec); /* gets maters layer object and sets .slave to slave layer */
	equalize(dragger); equalize(dragger.slave);
	if (sSpec2!=null) { dragger.slaveY = getLayer(sSpec2); equalize(dragger.slaveY); } /* If two layers specified in sSpec, set .slaveY to second layer (slave=horizontal, slaveY=vertical) */

	if (ns) dragger.captureEvents(Event.MOUSEDOWN);

	dragger.onmousedown = beginDrag;
	if (dropFunc != null) { dragger.mu = dropFunc; } else { dragger.mu = stopDrag; } /* .mu is mouseup function (used later) */

	dragger.z = dragger.slave.style.zIndex; /* sets .z to layers current z-index */
	if (dragZ!=null) { dragger.dz=dragZ; } else { dragger.dz = dragger.z; }

	/* Set Constraints, min/max */
	if (cons=='x') {dragger.cx = 1; if (d1 != null) dragger.xmin = d1;  if (d2 != null) dragger.xmax = d2;  }
	if (cons=='y') {dragger.cy = 1; if (d1 != null) dragger.ymin = d1;  if (d2 != null) dragger.ymax = d2;  }
	if (cons=='f') {dragger.cf = 1; if (d1 != null) dragger.xmin = d1; if (d2 != null) dragger.xmax = d2; if (d3 != null) dragger.ymin = d3; if (d4 != null) dragger.ymax = d4; }
	if (cons=='b') {dragger.cb = 1;	if (d1 != null) dragger.xmin = d1; if (d2 != null) dragger.xmax = d2; if (d3 != null) dragger.ymin = d3; if (d4 != null) dragger.ymax = d4; }
}


	/* stops dragging layer */
function stopDrag() { inDrag = 0; dragLayer.slave.style.zIndex=dragLayer.z; document.onmousemove=null; document.onmouseup=null; dragLayer=null; }

	/* begins dragging a layer (called on layer mousedown) */

function beginDrag(e) { if (!dragOK) return;

	dragLayer = this; /* set dragLayer to the layer that was clicked */
	dragLayer.slave.style.zIndex = dragLayer.dz; /* sets z-index for dragging */
	if (dragLayer.id=='Ship') olds = (ie)? (event.clientY):e.pageY;
	/* calculates offset (difference of layer top,left and mouse position) */
	if (ns) { offsetY = e.pageY-dragLayer.slave.top; offsetX = e.pageX-dragLayer.slave.left; }
	if (ie) { offsetY = event.clientY + document.body.scrollTop - dragLayer.slave.style.pixelTop; offsetX = event.clientX - dragLayer.slave.style.pixelLeft;  }
	if (dragLayer.slaveY!=null) { if (ns) { offsetY = e.pageY-dragLayer.slaveY.top; } if (ie) { offsetY = event.clientY + document.body.scrollTop - dragLayer.slaveY.style.pixelTop; } }

	/* if constraining to first move, records current mouse position */
	if (dragLayer.cf) { dragLayer.cfx = (ns)? e.pageX:event.clientX; dragLayer.cfy = (ns)? e.pageY:event.clientY; }

	inDrag = 1; /* allows dragging */
	if (!dragLayer.cf) { document.onmousemove=moveDragged;} else { document.onmousemove=checkFirstMove; }
	document.onmouseup=dragLayer.mu;
  }

	/* calculate which direction layer was dragged first then sets constraints, sets layer control to moveDragged() */
function checkFirstMove(e) { if (Math.abs(dragLayer.cfy-((ns)? e.pageY:event.clientY)) > Math.abs(dragLayer.cfx-((ns)? e.pageX:event.clientX)) ) { dragLayer.cy=1; dragLayer.cx=0; } else { dragLayer.cx=1; dragLayer.cy=0;}  document.onmousemove=moveDragged; return false; }

var olds=0; var sSpeed = 0;
function moveDragged(e) { if (!inDrag) return false; var y = 0; var x = 0;

	if (dragLayer.id=='Ship') sSpeed = (ie)? (event.clientY-olds):(e.pageY-olds);
	if (dragLayer.id=='Ship') olds = (ie)? (event.clientY):e.pageY;
 	/* calculate new layer position based on mouse position and offset */
 	if (ie) { y = event.clientY + document.body.scrollTop - offsetY; x = event.clientX - offsetX;}
	if (ns) { y = e.pageY - offsetY; x = e.pageX - offsetX;}

 	/* check constraints */
 	if ((dragLayer.cx)||(dragLayer.cb)) { if (dragLayer.xmin!=null) { if (x< dragLayer.xmin) x = dragLayer.xmin; } if (dragLayer.xmax!=null) { if (x> dragLayer.xmax) x = dragLayer.xmax; } }
	if ((dragLayer.cy)||(dragLayer.cb)) { if (dragLayer.ymin!=null) { if (y< dragLayer.ymin) y = dragLayer.ymin; } if (dragLayer.ymax!=null) { if (y> dragLayer.ymax) y = dragLayer.ymax; } }

 	/* set new layer position */
	if (!dragLayer.cx) { (dragLayer.slaveY==null)? dragLayer.slave.style.top=y : dragLayer.slaveY.style.top=y; }
	if (!dragLayer.cy) { dragLayer.slave.style.left = x;
		if (ns &&(dragLayer.id=='pulltab')) getLayer('pullout').clip.width=585+x; }

	if (dragLayer.onmove) dragLayer.onmove();

	return false;
}


//******* End Drag Functions ********//


//******* Layer Functions ********//


function getLayerLeft(layer) { if (layer==null) layer=this; if (ie) return layer.style.pixelLeft; if (ns) return layer.left; }
function getLayerTop(layer) { if (layer==null) layer=this; if (ie) return layer.style.pixelTop; if (ns) return layer.top; }
function getLayerHeight(layer) { if (layer==null) layer=this; if (ie) return layer.scrollHeight; if (ns) return layer.document.height; }

function equalizeLayers() { var k,layer; for (k=0; k<arguments.length; k++) { layer = getLayer(arguments[k]); if(layer!=null) equalize(layer); } }
function equalize(layer) { if(layer==null) return;
	layer.getLeft = getLayerLeft;
	layer.getTop = getLayerTop;
	layer.getHeight = getLayerHeight;
	if (ns) { layer.style = layer; }
	}

function setClip(who,l,t,r,b) { var layer = getLayer(who); if (layer==null) { return;} if (ie) { layer.style.clip='rect('+t+' '+r+' '+b+' '+l+')'; } if (ns) { layer.clip.left=l; layer.clip.top=t; layer.clip.right=r; layer.clip.bottom=b; } }

function getEQLayer(spec) { if (ie) {return document.all[spec].style;} if (ns) {return getLayer(spec);} }
function getLayer(spec,base) { if (ie) return document.all[spec]; var q=0; var temp=null;
	if (base==null) base=document; if (base.layers[spec]!=null) return base.layers[spec];
	for (q=0; q<base.layers.length; q++) { if(base.layers[q].document.layers.length>0) { temp = getLayer(spec,base.layers[q].document); if (temp != null) return temp; } }
	return null; }

function layerTag(theName,z,vis,l,t,w,h,extra) { var stuff;
	if (h==null) h=0;  if (w==null) w='100%';  if (w==0) w=1;  if (t==null) t=0;  if (l==null) l=0;  if (vis==null) vis=hidden;  if (z==null) z=10; if (extra==null) extra='';   if (ie) { var px = (isNaN(w))? '':'px'; }
	if (ie) stuff = '<DIV ID="'+theName+'" STYLE="position:absolute; overflow:none; left:'+l+'px; top:'+t+'px; width:'+w+px+'; height:'+h+'px; visibility:'+vis+'; z-index:'+z+'" '+extra+'>';
	if (ns) stuff = '<LAYER NAME="'+theName+'" left="'+l+'" top="'+t+'" width="'+w+'" height="'+h+'" visibility="'+vis+'" z-index="'+z+'" '+extra+'>';
	return (stuff);}

function ilayerTag(theName,z,vis,l,t,w,h,extra,clip) { var stuff;
	if (h==null) h=0;  if (w==null) w='100%';  if (w==0) w=1;  if (t==null) t=0;  if (l==null) l=0;  if (vis==null) vis=hidden;  if (z==null) z=10;   if (ie) { var px = (isNaN(w))? '':'px'; }
	if (ie) stuff = '<DIV ID="'+theName+'" STYLE="position:relative; overflow:none; left:'+l+'px; top:'+t+'px; width:'+w+px+'; height:'+h+'px; visibility:'+vis+'; z-index:'+z+'">';
	if (ns) stuff = '<ILAYER NAME="'+theName+'" left="'+l+'" top="'+t+'" width="'+w+'" height="'+h+'" visibility="'+vis+'" z-index="'+z+'">';
	return (stuff); }

var endTag =  (ie)? '</DIV>':'</LAYER>';
var endITag =  (ie)? '</DIV>':'</ILAYER>';

function newLayer(theName,content,z,vis,l,t,w,h,extra) { return (layerTag(theName,z,vis,l,t,w,h,extra) + content + endTag); }
function newILayer(theName,content,z,vis,l,t,w,h,extra) { return (ilayerTag(theName,z,vis,l,t,w,h,extra) + content + endITag); }

function newFloater(theName,content,z,vis,l,t,w,h) { var iw=(w==null)? 1:w; var ih=(h==null)? 1:h;
	if (ie) return (newILayer(theName,content,z,vis,l,t,w,h)); var stuff='<A HREF="javascript: // Drag Me">' + content + '</A>';
	if (ns) return (ilayerTag(theName+'A',z,vis,l,t,w,h) + '<IMG SRC="/pix/spacer.gif" WIDTH="'+iw+'" HEIGHT="'+ih+'"><BR>'+ newLayer(theName,stuff,1,vis,l,t,w,h) + endITag);
	return (content); }


//******* End Layer Functions ********//

if (ns)  document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);

//************** END DHTML FUNCTIONS ***************//


//******* Rollover Functions ********//


var navPics=new Object(); document.js = true;

var cacheArray = new Array(0);

function imageGroup() { var a,i; var args=arguments; this.total = args.length; this.names= new Array(0); this.urls= new Array(0); this.i = new Object(); for (i=0; i<this.total; i++) { a = args[i].split('|'); this.names[i] = a[0]; this.urls[i] = a[1]; } this.cached = 0; this.rollovers = false; this.index = cacheArray.length; cacheArray[this.index] = this; }

function loadImages() { if (document.images) { var j; for (j=0; j<cacheArray.length; j++) { loadGroup(cacheArray[j]); }  if (document.layers) cacheImages(); } }
function loadGroup(obj) { var k; for (k=0; k<obj.total; k++) loadImg(obj,k);  }
function loadImg(obj,n) { obj.i[obj.names[n]] = new Image(); var img=obj.i[obj.names[n]]; img.group=obj.index; if (!document.layers) { img.onload = countImg; } img.src = obj.urls[n];  }

function cacheImages() { var stuff=''; var j; for (j=0; j<cacheArray.length; j++) { stuff+=cacheGroup(cacheArray[j]); } var cacher = new Layer(0); cacher.document.write(stuff); cacher.document.close(); }
function cacheGroup(obj) { var stuff=''; var k; for (k=0; k<obj.total; k++) { stuff+='<IMG SRC="'+ obj.urls[k] +'" BORDER="0" WIDTH="1" HEIGHT="1" onLoad="countImg('+obj.index+');">'; } return(stuff); }

function countImg(n) { if (n==null) n=this.group; var obj=cacheArray[n]; obj.cached++; if (obj.cached==obj.total) { obj.rollovers = true; } }

function swapOn(obj,who) {  if (obj.rollovers) { document[who + '_bttn'].src = obj.i[who+'_on'].src; } }
function swapOff(obj,who) {  if (obj.rollovers) { document[who + '_bttn'].src = obj.i[who+'_off'].src; } }

//******* End Rollover Functions ********//


