
var dragDiv = null;
var clientSize = [0,0];
var isIE=0;
function init(){
	// with(document.body) clientSize = [offsetWidth,offsetHeight-4];
	isIE = navigator.appVersion.toUpperCase().indexOf('MSIE')>-1?1:0;
}


function more(id,i,o,c,p){

	

}




function showTxt(id,imgWd,imgHt,click){ return showImg(getRef(id).innerHTML,imgWd,imgHt,click) }

function showImg(htm,imgWd,imgHt,click){
	var checkBoxImg = '/global/checkbox.gif'; var bgcolor = '; 	background-color:#FFFFFF'; var border='; border:1px solid #CCCCCC';
	var override = 1; var padding = 10; var o = getRef('imgPopup'); var c = getCss(o); var w = getRef('page'); var cc = getRef('copyCell'); var s = getRef('scrollbox');
	var bodyHt = w.offsetHeight+(document.all?-1:0); var bodyWd=cc.offsetWidth; var bodyTop=w.offsetTop+1; var bodyLeft = cc.offsetLeft+w.offsetLeft;
	var cellWd = cc.offsetWidth+(s.offsetWidth-s.scrollWidth); imgWd=imgWd?imgWd:0;
	var imgTop = (bodyHt-imgHt)/2;
	var maxHt = document.body.offsetHeight-4;
	if(imgHt>bodyHt){ bodyTop=(maxHt-imgHt)/2; imgTop=bodyTop; bodyTop=0; bodyHt=maxHt; imgTop=imgTop<0?padding:imgTop }
	if(imgWd>bodyWd){ bodyWd=imgWd }
	if(htm==3) { border=''; bgcolor='' }
	if(bodyTop==0 && override>0) { bgcolor='' }
	var lt=imgWd-cellWd; lt=lt>0?lt:0; lt=lt>bodyLeft-padding?bodyLeft-padding:lt; bodyLeft = bodyLeft-lt;
	showImg.disabled=showImg.disabled?click==2?1:htm==3?0:showImg.disabled:0;

	// Drag functions
	showImg.evt = function(e){ e=e?e:event; return [e.clientX,e.clientY] }
	showImg.canc = function(){ document.onmousemove=null }
	showImg.move = function(e){ with(this) with(c) { left=offset[2]+showImg.evt(e)[0]-offset[0]; top=offset[3]+showImg.evt(e)[1]-offset[1] }; return false }
	showImg.moveto = function(y,x){ with(this) with(c) { if(y!='undefined')top=y?y:0; if(x!='undefined')left=x?x:0 } }
	showImg.drag = function(e){
		var div = e?e.target:event.srcElement;
		if(div.id=='showImgArea'){
    			with(c) offset = [showImg.evt(e)[0], showImg.evt(e)[1], parseInt(left), parseInt(top)];
			document.onmousemove=showImg.move;
		}
	}
	document.onmousedown = showImg.drag;
	document.onmouseup = showImg.canc;

	if(htm!=3 && htm){
		if(showImg.disabled<2){
			if(htm.indexOf('<')<0) {
				htm = '<div align="center" style="width:'+bodyWd+'; height:'+bodyHt+bgcolor+'" id="showImgArea">'
				+'<img src="'+htm+'" width="'+imgWd+'" height="'+imgHt+'" border="0" onDblClick="showImg(3)" '
				+'style="cursor:move; top:'+imgTop+border+'" class="rel"" id="showImgArea">'
				if(click==2) htm+='<a href="." onClick="return showImg(3)">'
				+'<img src="'+checkBoxImg+'" width="16" height="16" border="0" class="abs"'
				+'style="margin:3; left:'+(imgWd-22+((bodyWd-imgWd)/2))+'; top:'+imgTop+'" title="Click to close"></a>';
				htm+='</div>';
			}
			o.innerHTML = htm;
			c.left=bodyLeft;
			c.top=bodyTop;
			showImg.disabled=click==2?2:0;
			c.visibility='visible';
		}
	}
	else if(showImg.disabled==0) c.visibility='hidden';
	return false;
}

function loadImg(kv) { kv=qs(); showImg(kv['img'],kv['w'],kv['h'],2) }

function checkScroller(){
	var page = getRef('page');
	var scrollbox = getRef('scrollbox');
	if(scrollbox && page){
		var diff = scrollbox.scrollHeight - page.offsetHeight;
		if(diff <= 0) scrollbox.style.borderColor='#FFFFFF';
	}
}

function goToPage(p,n){
	getCss(getRef('page'+p)).visibility='hidden';
	getCss(getRef('page'+n)).visibility='visible';
	return false;
}

// a few style workarounds for FireFox
function getBodyCss(){
	document.body.scroll='auto';
	if(document.body.style.scrollbarFaceColor!=undefined){
		document.write ('<style type="text/css">'
		+'div {'
		+'scrollbar-face-color:#FFFFFF;'
		+'scrollbar-arrow-color:#948B70;'
		+'scrollbar-highlight-color:#FFFFFF;'
		+'scrollbar-shadow-color:#DDDDDD;'
		+'scrollbar-3dlight-color:#DDDDDD;'
		+'scrollbar-darkshadow-color:#FFFFFF;'
		+'scrollbar-track-color:#FFFFFF;'
		+'}'
		+'</style>');
	}
}

/*
DRAGGABLEDIV() - Advanced CSS control for hiding and showing a draggable div layer.
USAGE:
To make a non-draggable layer:
dragDiv = new dragDialog('dlgDiv1', 'dlgHdr1', 'dlgTitle1', 'dlgChk1', 'dlgBody1');
To make a draggable layer:
dragDiv = new dragDialog('dlgDiv1', 'dlgHdr1', 'dlgTitle1', 'dlgChk1', 'dlgBody1', 1);
To make a draggable & scrollable layer:
dragDiv = new dragDialog('dlgDiv1', 'dlgHdr1', 'dlgTitle1', 'dlgChk1', 'dlgBody1', 1, 1);

STYLES:
.dlgDiv, .dlgHdr, .dlgChk, .dlgBody { position:absolute; overflow:hidden }
.dlgDiv { visibility:hidden; border:2px outset #DCCC8C }
.dlgHdr { width:100%; padding:2 1 2 8; height:40; cursor:move; font-weight:bold; background-color:#C7AA47; color:#FCFAF4 }
.dlgChk { position:relative; cursor:pointer; float:right; top:-1; left:-9 }
.dlgBody { height:100%; width:100%; top:18; background-color:#EBE1B9; color:#444444 }


TYPICAL POPUP DIV HTML - the id's here must match the object declaration.
<div class="abs">
	<div class="dlgDiv" id="dlgDiv1" style="width:784; height:400; top:-152; left:0">
		<div class="dlgHdr" id="dlgHdr1">
			<img src="/global/img/checkoff.gif" width="16" height="16" border="0" class="dlgChk" id="dlgChk1">
			<span class="dlgTitle" id="dlgTitle1"></span>
		</div>
		<div class="dlgBody" id="dlgBody1"></div>
	</div>
</div>
*/

function dragDialog(divId, divHdrId, divTitleId, divChkBoxId, divBodyId, draggable, scrollable){
	with(this){
		this.obj = function(id){ with(document)return getElementById?getElementById(id):all?all[id]:null }
		this.o = obj(divId);
		if(!o) return;
		this.div = null;
		this.offset = [];
		this.hide = null;
		this.chk = obj(divChkBoxId);
		this.bdy = obj(divBodyId);
		this.hdr = obj(divHdrId);
		this.titl = obj(divTitleId);
		this.sty = function(o){ return o.style?o.style:o }
		this.w = function(o){ return parseInt(sty(o).width?sty(o).width:o.offsetWidth) }
		this.h = function(o){ return parseInt(sty(o).height?sty(o).height:o.offsetHeight) }
		this.evt = function(e){ e=e?e:event; return [e.clientX,e.clientY] }
		this.canc = function(){ document.onmousemove=null }
		this.hide = function(){ with(this) sty(o).visibility='hidden'; return false }
		this.show = function(){ with(this) sty(o).visibility='visible'; return false }
		this.isIE = navigator.appVersion.toUpperCase().indexOf('MSIE')>-1;
		this.boxpad = this.isIE?4:0;
		this.size = function(wd,ht){ with(this) { if(wd)sty(o).width=wd+16+boxpad; if(ht)sty(o).height=ht+18+boxpad }; return false }
		this.move = function(e){ with(this) with(sty(o)) { left=offset[2]+evt(e)[0]-offset[0]; top=offset[3]+evt(e)[1]-offset[1] }; return false }
		this.moveto = function(y,x){ with(this) with(sty(o)) { if(y!='undefined')top=y?y:0; if(x!='undefined')left=x?x:0 } }
		this.write = function(ttl,htm){ with(this) { titl.innerHTML = ttl; bdy.innerHTML = htm }; return false }
		this.drag = function(e){
			div = e?e.target:event.srcElement;
			if(div.id==hdr.id || div.id==titl.id){
    				with(sty(o)) offset = [evt(e)[0], evt(e)[1], parseInt(left), parseInt(top)];
				document.onmousemove=move;
			}
		}
		sty(bdy).overflow = scrollable?'scroll':'';
		if(chk){
			if(this.isIE)sty(chk).left=2
			chk.onmouseup = this.hide;
		}
		if(draggable){
			document.onmousedown = this.drag;
			document.onmouseup = this.canc;
		}
	}
}


function getRef(id){ with(document)return getElementById?getElementById(id):all?all[id]:null }
function getCss(o){ return o.style?o.style:o }



/* SHOWDIV() - POPUPDIVOLD() - Simple CSS control for hiding and showing a div layer. */
function showDiv(divId, onState){
	with(document) var css=getElementById?getElementById(divId).style:all?all[divId].style:layers?layers[divId]:null;
	if(!css) return; // Bail out gracefully now if the style object does not exist.
	else css.visibility = onState?'visible':'hidden';
}



function popUp(url,windowName,w,h,x,y){ return popUpAllParams(url,windowName,w,h,x,y,0,1,2) }
function popUpParams(url,nm,w,h,m,r,s){ return popUpAllParams(url,nm,w,h,-1,-1,m,r,s) } // (m)enubars, (r)esizable, (s)crollbars
function popUpAllParams(url,nm,w,h,x,y,m,r,s,st){
	nm=nm?nm:'popup'; url=url?url:this.location;
	with(window.screen){var W=availWidth-12;var H=availHeight-32}
	with(window){var X=document.all?screenLeft:screenX;var Y=document.all?screenTop:screenY}
	if(document.body)with(document.body){var cW=clientWidth;var cH=clientHeight}else{ var cW=0; var cH=0 }
	w=w?w:W; h=h?h:H; m=m==undefined?0:m; r=r==undefined?1:r; s=s==undefined?'auto':s; st=st==undefined?0:st;
	x=x==undefined||x==-1?w<W?parseInt((X+cW/2)-w/2):0:x; y=y==undefined||y==-1?h<H?parseInt((Y+cH/2)-h/2):0:y;
	eval((nm!='void'?nm+'=':'')+'window.open(\''+url+'\',\''+nm+'\',\'menubar='+m+',resizable='+r+',status='+st
	+',scrollbars='+s+',width='+w+',height='+h+',left='+x+',top='+y+'\')');
	return false;
}



/*	NO RIGHT CLICK OBJECT - USAGE: var noRightClick = new noRightClick('http://www.TitanMenStore.com'); */
function noRightClick(url){ document.onmousedown=function(e){ e=e?e.which:event.button; if(e==2||e==3){ if(url)window.open(url); return 0 }} }



/*	COOKIEOBJ()
	Sets and retrieves cookies for either simple single value cookies or key/value cookies.
	USAGE: var myCookie = new cookieObj('uservisits', 1, 'www.mydomain.com', '/ThisDirOnly');
	PARAMETERS: name is required, set hours to 0 for session cookies, domain is optional, path is optional
	METHODS: cookieObj.set(value,key), cookieObj.get(key), cookieObj.del()

	var myCookie = new cookieObj('uservisits', 1, 'mydomain.com'); 1 = expires in 1 hour, 0 = session cookie only
	myCookie.set('some value') 			sets a simple string value
	myCookie.get()					returns a simple string value
	myCookie.del()					deletes the entire cookie

	Or, if a named key is passed:
	myCookie.set(1,'visitCt')			sets a named key
	myCookie.get('visitCt')				returns a single named key value
*/

function cookieObj(name, hoursToExpire, domain, path){
	this.nm=name; this.hrs=hoursToExpire; this.dom=domain; this.path=path?path:'/'; this.u=unescape;
	this.set=function(v,k,s){with(this){s=v;if(k){h=hsh(val());h[k]=escape(v);s=str(h)};sav(s);return v}}
	this.get=function(k,s){with(this){s=val();h=hsh(s);return k?h[k]?unescape(h[k]):'':s}}
	this.del=function(){this.sav('',-1)}
	this.val=function(i,s){with(this){s=document.cookie.split(nm+'=');s=(s[1]?s[1]:'').split(';');return s[1]?s[0]:s}}
	this.str=function(h,s){s='';for(var i in h)if(i)s+=(s?'&':'')+i+'='+unescape(h[i]);return s}
	this.hsh=function(s,h){h=[];with(this)if(s){a=unescape(s).split('&');for(i=0;i< a.length;i++){s=a[i].split('=');if(s)h[s[0]]=unescape(s[1])}}return(h)}
	this.dat=function(hrs,x){x=new Date();x.setTime(x.getTime()+(isNaN(hrs)?0:hrs)*3600*1000);return x.toGMTString()}
	this.sav=function(v,h){with(this)document.cookie=nm+'='+v+(!hrs&&!h?'':'; expires='+dat(h?h:hrs))+(path?'; path='+path:'')+(dom?'; domain='+dom:'')}
}

// returns key/value hash array from query string
function qs(q,a,t,v) {
	q=document.location.search; q=q.length?q.substr(1,q.length):''; v=[]; a=q.split('&');
	for(var n=0;n<a.length;n++){ t=a[n].split('='); v[t[0]]=t[1]=='undefined'?'':t[1] }
	return v;
}

// Rollovers
function preLoad(a){a=arguments;if(document.images){var i=a.length-1;do{var x=new Image();x.src=a[i]}while(i--)}}
function imgSwap(i,s,tmp){i=i.name?i.name:i; with(document)if(images){tmp=s?images[i].src:s;images[i].src=s?s:imgSwapTmp;imgSwapTmp=tmp}}
imgSwapTmp=null;

function info(msg){ window.status=msg?msg:''; return true }

