var ie6 = false
if((bName.indexOf("Internet Explorer") > -1) && (parseInt(bVer) >= 6)){
	ie6 = true
}

var ns6 = false
if((bName.indexOf("Netscape") > -1) && (parseFloat(bVer) >= 6.2)){
	ns6 = true
}

currIDb=null; xoff=0; yoff=0;
currRS=null; rsxoff=0; rsyoff=0;
oldac=null; newac=null; zdx=1; mx=0; my=0;

var w3c = (ie6||ns6) ? true: false;

function hidebox(id){
	if(w3c){
		document.getElementById(id+'_b').style.display='none';
		document.getElementById(id+'_s').style.display='none';
	}
}

function showbox(id){
	if(w3c){
		var bx=document.getElementById(id+'_b').style;
		var sh=document.getElementById(id+'_s').style;
		bx.display='block';
		sh.display='block';
		sh.zIndex=++zdx;
		bx.zIndex=++zdx;
	}
}

function ns6bugfix(){
	self.resizeBy(0,1);
	self.resizeBy(0,-1);
}

function trackmouse(evt){
	mx=(ie6)?event.clientX+document.body.scrollLeft:evt.pageX;
	my=(ie6)?event.clientY+document.body.scrollTop:evt.pageY;
	if(!ns6)movepopup();
	if((currIDb!=null)||(currRS!=null))return false;
}

function movepopup(){
	if((currIDb!=null)&&w3c){
		var x=mx+xoff;
		var y=my+yoff;
		currIDb.style.left=x+'px';
		currIDs.style.left=x+3+'px';
		currIDb.style.top=y+'px';
		currIDs.style.top=y+3+'px';
	}
	if((currRS!=null)&&w3c){
		var rx=mx+rsxoff;
		var ry=my+rsyoff;
		var c=currRS;
		c.style.left=Math.max(rx,((ie6)?88:92))+'px';
		c.style.top=Math.max(ry,((ie6)?68:72))+'px';
		c.IDS[0].style.width=Math.max(rx+((ie6)?12:8),100)+'px';
		c.IDS[0].style.height=Math.max(ry+((ie6)?12:8),80)+'px';
		c.IDS[1].style.width=Math.max(rx+((ie6)?4:3),((ns6)?95:92))+'px';
		c.IDS[4].style.left=parseInt(c.IDS[1].style.width)-48+'px';
		c.IDS[3].style.width=Math.max(rx+12,((ie6)?100:104))+'px';
		c.IDS[3].style.height=Math.max(ry+((ie6)?12:13),((ie6)?80:86))+'px';
		c.IDS[2].style.width=Math.max(rx-((ie6)?-5:5),((ie6)?92:87))+'px';
		c.IDS[2].style.height=Math.max(ry-((ie6)?24:28),44)+'px';
		c.IDS[10]=parseInt(c.IDS[0].style.height);
	}
}

function startRS(evt){
	var ex=(ie6)?event.clientX+document.body.scrollLeft:evt.pageX;
	var ey=(ie6)?event.clientY+document.body.scrollTop:evt.pageY;
	rsxoff=parseInt(this.style.left)-ex;
	rsyoff=parseInt(this.style.top)-ey;
	currRS=this;
	if(ns6)this.IDS[2].style.overflow='hidden';
	return false;
}

function changez(){
	if(oldac!=null)oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
	if(ns6)this.IDS[2].style.overflow='auto';
	oldac=this;
	this.IDS[1].style.backgroundColor=this.activecolor;
	this.IDS[3].style.zIndex=++zdx;
	this.style.zIndex=++zdx;
}

function stopdrag(){
	currIDb=null;
	this.IDS[11].style.display="none";
	if(ns6)ns6bugfix();
}

function grab_id(evt){
	var ex=(ie6)?event.clientX+document.body.scrollLeft:evt.pageX;
	var ey=(ie6)?event.clientY+document.body.scrollTop:evt.pageY;
	xoff=parseInt(this.IDS[0].style.left)-ex;
	yoff=parseInt(this.IDS[0].style.top)-ey;
	currIDb=this.IDS[0];
	currIDs=this.IDS[3];
	this.IDS[11].style.display="block";
	return false;
}

function subBox(x,y,w,h,bgc,id){
	var v=document.createElement('div');
	v.setAttribute('id',id);
	v.style.position='absolute';
	v.style.left=x+'px';
	v.style.top=y+'px';
	v.style.width=w+'px';
	v.style.height=h+'px';
	if(bgc!='')v.style.backgroundColor=bgc;
	v.style.visibility='visible';
	v.style.padding='0px 0px 0px 0px';
	return v;
}

function popUp(x,y,w,h,cid,text,bgcolor,textcolor,fontstyleset,title,titlecolor,titletextcolor,bordercolor,scrollcolor,shadowcolor,showonstart,isdrag,isresize,oldOK,isExt){
	if(w3c){
		var tw, th;
		w=Math.max(w,100);
		h=Math.max(h,80);
		tw=(ie6)?w:w+4;
		th=(ie6)?h:h+6;
		var shadow=new subBox(x+3,y+3,tw,th,shadowcolor,cid+'_s');
		if(ie6)shadow.style.filter="alpha(opacity=50)";
		else shadow.style.MozOpacity=.5;
		shadow.style.zIndex=++zdx;
		var tw,th;
		var outerdiv=new subBox(x,y,w,h,"#ffffff",cid+'_b');
		outerdiv.style.borderStyle="solid";
		outerdiv.style.borderWidth="1px";
		outerdiv.style.borderColor=bordercolor;
		outerdiv.style.zIndex=++zdx;
		tw=(ie6)?w-8:w-5;
		th=(ie6)?h+4:h-4;
		var titlebar=new subBox(2,2,tw,14,titlecolor,cid+'_t');
		titlebar.style.overflow="hidden";
		titlebar.style.cursor="default";
		titlebar.innerHTML='<span style="position:absolute; left:3px; top:0px; font:bold 7pt Verdana; color:'+titletextcolor+'; height:14px; overflow:hidden; clip-height:12px;">'+title+'</span><div id="'+cid+'_btt" style="position:absolute; width:48px; height:12px; left:'+(tw-48)+'px; top:0px; text-align:right; line-height: 12px"><a href="#" id="'+cid+'_cls" class="copy">close</a>&nbsp;</div>';
		tw=(ie6)?w-7:w-2;
		th=(ie6)?h-24:h-24;
		var content=new subBox(2,19,tw,th,bgcolor,cid+'_c');
		content.style.borderColor="#ffffff";
		content.style.borderWidth="1px";
		if(isExt){
			content.innerHTML='<iframe id="'+cid+'_ifrm" src="" width="' + tw + '" height="' + th + '" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">';
			content.style.overflow="hidden";
		}
		else{
			if(ie6)content.style.scrollbarBaseColor=scrollcolor;
			content.style.borderStyle="solid";
			content.style.overflow="auto";
			content.style.padding="0px 0px 0px 0px";
			content.innerHTML=text;
			content.style.font=fontstyleset;
			content.style.color=textcolor;
		}
// THE NEXT 4 LINES ARE PART OF THE "EXTERNAL FILE WORKAROUND" FOR WHICH I
// CREDIT DYNAMICDRIVE.COM. THEY CREATE A "FALSE" DIV THAT COVERS THE CONTENT
// AREA FOR DRAGGING TO EVERCOME A BUG WHEN USING AN EXTERNAL FILE.
		var extWA=new subBox(2,19,0,0,'',cid+'_extWA');
		extWA.style.display="none";
		extWA.style.width='100%';
		extWA.style.height='100%';
		outerdiv.appendChild(titlebar);
		outerdiv.appendChild(content);
		outerdiv.appendChild(extWA);
		document.body.appendChild(shadow);
		document.body.appendChild(outerdiv);
		if(isExt)document.getElementById(cid+'_ifrm').src=text + "&h=" + th;
		if(!showonstart)hidebox(cid);
		var IDS=new Array();
		IDS[0]=document.getElementById(cid+'_b');
		IDS[1]=document.getElementById(cid+'_t');
		IDS[2]=document.getElementById(cid+'_c');
		IDS[3]=document.getElementById(cid+'_s');
		IDS[4]=document.getElementById(cid+'_btt');
		//IDS[6]=document.getElementById(cid+'_min');
		//IDS[7]=document.getElementById(cid+'_max');
		IDS[8]=document.getElementById(cid+'_cls');
		IDS[9]=cid;
		IDS[10]=h;
		IDS[11]=document.getElementById(cid+'_extWA');
		this.IDb=IDS[0]; this.IDb.IDS=IDS;
		this.IDt=IDS[1]; this.IDt.IDS=IDS;
		this.IDc=IDS[2]; this.IDc.IDS=IDS;
		this.IDs=IDS[3]; this.IDs.IDS=IDS;
		this.IDbtt=IDS[4]; this.IDbtt.IDS=IDS;
		this.IDcls=IDS[8]; this.IDcls.IDS=IDS;
		this.IDb.activecolor=titlecolor;
		this.IDb.inactivecolor=scrollcolor;
		if(oldac!=null)oldac.IDS[1].style.backgroundColor=oldac.inactivecolor;
		oldac=this.IDb;
		this.IDcls.onclick=new Function("hidebox('"+cid+"');return false");
		if(isresize){
			this.IDrs.onmousedown=startRS;
			this.IDrs.onmouseup=new Function("currRS=null");
		}
		this.IDb.onmousedown = changez;
		if(isdrag){
			this.IDt.onmousedown=grab_id;
			this.IDt.onmouseup=stopdrag;
		}
	}
	else{
		if(oldOK){
			var t=(isExt)?text + '&h=' + (h-24):'';
				
			//var newwin=window.open("outerframe.asp?id=2&h=131" , "abc" , "status=no,menubar=no,width="+w+",height="+h+",resizable=no,scrollbars=no,left=" + (screen.width/2 - w/2) + ",top=" + (screen.height/2 - h/2));
			var newwin=window.open(t , "abc" , "status=no,menubar=no,width="+w+",height="+h+",resizable=no,scrollbars=no,left=" + (screen.width/2 - w/2) + ",top=" + (screen.height/2 - h/2));
			if(!isExt){
				t='<html><head><title>THE CAPE HERB &amp; SPICE COMPANY</title></head><body bgcolor="'+bgcolor+'"><font style="font:'+fontstyleset+'; color:'+textcolor+'">'+text+'</font></body></html>';
				newwin.document.write(t);
				newwin.document.close();
			}
			newwin.resizeTo(w,h)
			newwin.focus()
		}
	}
}

if(ns6)setInterval('movepopup()',40);

if(w3c){
	document.onmousemove=trackmouse;
	document.onmouseup=new Function("currRS=null");
}