<!-- Begin
var mouseOffset = null;
var mousePos;
var Name = new String("");
var PicId = new String;
var PicList = new String;
var ChkLst = new Array();
var ItemList = new Array();
var zGallery = 0;
function moveY(id,target,adjust,evt){
    var ev = (window.event) ? window.event : evt;
	var x=0;
	var y=0;
	mousePos = mouseCoords(ev);
    if(document.getElementById(id)){
        if(document.getElementById(target)){
            var o = document.getElementById(id);
            var t = document.getElementById(target);
	        mousePos = mouseCoords(ev);
            mouseOffset = getMouseOffset(o, ev);
            x=mousePos.x - mouseOffset.x;
            y=mousePos.y - mouseOffset.y;
            t.style.top = y + adjust + "px";
        }
    }
    return true;
}
function newDiv(root,divId) {
    var c = document.getElementById(root);
    var div = document.createElement('div');
    div.setAttribute('id',divId);
    document.getElementById(root).appendChild(div);
    return div;
}
function getMouseOffset(target, ev){
    ev = (window.event) ? window.event : ev;
	var docPos = getPosition(target);
	var mousePos = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}
function getPosition(e){
	var left = 0;
	var top  = 0;	
	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e = e.offsetParent;
	}	
	left += e.offsetLeft;
	top  += e.offsetTop;	
	return {x:left, y:top};
}
function mouseCoords(ev){
    if(ev.pageX || ev.pageY){
	    return {x:ev.pageX, y:ev.pageY};
    }
    return {
	    x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
	    y:ev.clientY + document.body.scrollTop  - document.body.clientTop
    };
}
function inArray(a,i){
	var x = -1;
	for(j=0; j<a.length; j++){
		if(a[j]==i){x=j;}
	}
	return x;
}
if(typeof Item == "undefined") var Item = new Object();
	function Item(id,t,l,h){
		this.id=id;
		this.caption=t;
		this.display=display;
		this.div=newDiv("Pics",id);
		this.div.link=l;
		this.div.style.textAlign="center";
		this.div.style.verticalAlign="top";
		this.div.style.cursor="pointer";
		var bg=(h==true)?"silver":"#990000";
		this.div.bg=bg;
		this.div.style.border="solid 3px "+bg;
		this.div.style.backgroundColor=this.div.bg;
		this.div.title=t;
		this.div.setAttribute("class","Gallery");
		this.div.style.position="absolute";
		this.div.innerHTML=this.display();
		this.div.onmouseover=mouseOverItem;
		this.div.onmouseout=mouseOutItem;
		this.div.onclick=onClickItem;
	}
	function display(){
		var iH = new String;
		iH = "<img id='img"+this.id+"' src='/ddimages/small/"+this.id+".jpg' onLoad='new GalleryImg(this,"+this.id+");' onerror='this.parent.style.display=\"none\"'/>";
    	if(document.getElementById(PicId)){
    	    iH+="<br/><a class='button_1' href='#' onclick='deletePic("+this.id+");return false;'><span>X</span></a>";
    	    iH+="<a class='button_1' href='ItemEdit.aspx?IID="+this.id+"'><span>edit</span></a>";
    	    iH+="<input id='cbx"+this.id+"' value='"+this.id+"' type='checkbox' onclick='checkList(this)' />";
    	}
		return iH;
    }
    function mouseOverItem(ev){
        this.style.border="solid 3px #FF0000";
        this.style.background="#FF0000";
        zGallery++;
        this.style.zIndex=zGallery;
    }
    function mouseOutItem(ev){
        this.style.border="solid 3px "+this.bg;
        this.style.background=this.bg;
    }
    function onClickItem(ev){
        if(!document.getElementById("pictureViewer"))newViewer();
    	var v=document.getElementById("pictureViewer");
    	moveY(this.id,v.id,-50,ev);
    	var iH="";
    	v.style.display="block";
		var lnk = new String;
		if (this.link>0){lnk="<a class='button_1' href='default.aspx?IID="+this.link+"'><span>*** go here ***</span></a>";}
    	iH+="<img src='/ddimages/large/"+this.id+".jpg' title='close'><p>"+this.title+lnk+"</p>";
	    iH+="";
    	if(Name != ""){
	        iH+="<a class='button_1' href='#' onclick='myPic("+this.id+");return false;'><span>my pic</span></a>";
	    }
    	if(document.getElementById(PicId)){
    	    iH+="<a class='button_1' href='#' onclick='deletePic("+this.id+");return false;'><span>X</span></a>";
    	    iH+="<a class='button_1' href='ItemEditor.aspx?IID="+this.id+"'><span>edit</span></a>";
    	}
    	v.innerHTML="<span style='float:left;'>"+iH+"</span>";
    }
if(typeof GalleryImg == "undefined") var GalleryImg = new Object();
	function GalleryImg(id,n){
		this.id=id;
		this.id.n=n;
	}
	function deletePic(p){
    	if(document.getElementById(PicId)){
	        document.getElementById(PicId).value=p;
	        __doPostBack("Delete",p);
	    }
    }
	function myPic(p){
    	if(Name != ""){
	        __doPostBack("MyPic",p);
	    }
    }
	function checkList(id){
	    if(id.checked==true){
	        ChkLst.push(id.value);
	    }else{
	        ChkLst.splice(inArray(ChkLst,id.value),1);
	    }
	    var cl="0";
	    for(i=0;i<ChkLst.length;i++){cl+=","+ChkLst[i];}
        document.getElementById(PicList).value=cl;
	}
if(typeof List == "undefined") var List = new Object();
	function List(name){
		this.name=name;
		this.position=0;
		this.items=new Array();
		this.addItem=addItem;
		this.moveItem=moveItem;
		this.thisItem=thisItem;
		this.percent=100;
		this.getItem=getItem;
	}
	function moveItem(i){
		this.position += i;
		if(this.position>=this.items.length){this.position=0;}
		if(this.position<0){this.position=this.items.length-1;}
		var ni = this.position+i;
		if(ni<0){ni=this.items.length-ni;}
		if(ni>=this.items.length){ni=ni-this.items.length;}
		if(this.items[ni]){
			var nSrc = this.items[ni].id;
			MM_preloadImages("/ddimages/small/"+nSrc+".jpg");	
		}
		return this.items[this.position];
	}
	function thisItem(){
		return this.items[this.position];
	}
	function addItem(i){
		this.items.push(i);
	}
	function listIndex(n){
		var l = -1;
		for(i=0; i<ItemList.length; i++){
  			if(ItemList[i].name==n){l = i}
		}
		return l;
	}
	function getItem(n){
		var l = -1;
		for(i=0; i<this.items.length; i++){
  			if(this.items[i].id==n){l = i;}
		}
		return this.items[l];
	}
	function fillAllItemViews(){
	    if(document.getElementById("Pics")){
		    for(i=0; i<ItemList.length; i++){
		        var w=70;
		        var h=100;
	            var x=650;
		        var y=100;
		        var col=0;
		        var top=0;
		        var left=0;
		        var edit;
		        document.getElementById(PicList)?edit=true:edit=false;
		        if(edit)h=140;
		        zGallery=ItemList[i].items.length;
			    for(j=0; j<ItemList[i].items.length; j++){
			        if(ItemList[i].items[j].div){
			            var div=ItemList[i].items[j].div;
                        div.setAttribute("class","Gallery");
                        div.style.zIndex=j;
                        if(edit==true){
                            left=(x+(w*(col-1)*1.5));
                            top=y+50;
                        }else{
                            left=(x+(w*(col-1))+(Math.floor(Math.random()*((w/2)*(col-1)))));
                            top=y+(Math.floor(Math.random()*(h/2)));
                        }
                        div.style.left=left+"px";
                        div.style.top=top+"px";
			            if((j+1)/3==Math.floor((j+1)/3)){y+=h;};
			            col+=1;
			            if(col==3){col=0;}
			        }
			    }
	            var Pics_h=0;
	            Pics_h = ((ItemList[i].items.length*33)+100);
	            document.getElementById("Pics").style.height=Pics_h+"px";
		    }
	    }
	}
function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}
	}
}
<!-- Begin
/****************************************************************
Panels Object (c) 2007 Rob Norwell
--Use this script to slide multiple objects into and out of the same place in a browser window.

1) create a "Panels" object in the head of your HTML document like this:
 <script type="text/javascript" language="JavaScript">var myPanels = new Pnls('myPanels',10,10,-250,-30,7,12,'h');</script>
2) then fill that object with a collection of object id's that already exist in your HTML body:
 <body onload="myPanels.loadPanels('div1','div2','div3');">
3) then create controls to switch panels:
 <button onclick="myPanels.backPanel('h');">next</button>
 <button onclick="myPanels.nextPanel('h');">back</button>
****************************************************************/
if(typeof Panel == "undefined") var Panel = new Object();
function Panel(id,x,y){
	this.id=id;
	this.id._x=x;//x position
	this.id._y=y;//y position
	this.id._xX=x;//target x position
	this.id._yY=y;//target y position
	this.id._m=0;//motion / momentum
	this.id.style.position="absolute";
	this.id.style.left=x+"px";
	this.id.style.top=y+"px";
}
if(typeof Pnls == "undefined") var Pnls = new Object();
function Pnls(id,sX,sY,hX,hY,sM,hM,d){
	this.id=id;
	this.lock=0;//boolean whether panel is sliding or not 1/0
	this.position=0;//the index of the current panel in the collection
	this.direction=d;//direction of slide h/v
	this.showX=sX;//x coordinate of shown panel
	this.showY=sY;//y coordinate of shown panel
	this.hideX=hX;//x coordinate of hidden panel
	this.hideY=hY;//y coordinate of hidden panel
	this.showM=sM;//speed of panel sliding into view
	this.hideM=hM;//speed of panel sliding out of view
	this.panelOut="";//id of the panel to slide out
	this.panelIn="";//id of the panel to slide in
	this.panel=new Array();//collection of all panels
	this.loadPanels=loadPanels;
	this.hidePanels=hidePanels;
	this.showPanel=showPanel;
	this.backPanel=backPanel;
	this.nextPanel=nextPanel;
}
function getIndex(a,s){
	var l = -1;
	for(i=0; i<a.length; i++){
		if(a[i].id==s){l = i;}
	}
	return l;
}
function loadPanels(){
	var pList=new Array();
	pList=loadPanels.arguments;
	do{this.panel.pop}while(this.panel.length>0);
	var i=0;
	for(i;i<pList.length;i++){
		var p=pList[i];
		if(document.getElementById(p)){
			var tP=new Panel(document.getElementById(p),this.hideX,this.hideY)
			this.panel.push(tP.id);
			this.position=this.panel.length-1;
		}
	}
	if(this.panel.length>0){this.showPanel(0,this.direction);}
}
function hidePanels(d){
	if(d!='v' && d!='h')d=this.direction;
	var l=this.panel.length;
	var x1=this.showX;
	var y1=this.hideY;
	if(d=="h"){
		var x1=this.hideX;
		var y1=this.showY;
	}
	for(i=0;i<l;i++){
		this.panel[i]._xX=x1;
		this.panel[i]._yY=y1;
		if(i==this.position){
			this.panel[i]._m=this.hideM;
			this.panelOut=this.panel[i].id;
			if(d=="h"){
				slideLeft(this);
			}else{
				slideUp(this);
			}
		}else{
			this.panel[i]._x=x1;
			this.panel[i]._y=y1;
			this.panel[i]._m=0;
			this.panel[i].style.left=x1+"px";
			this.panel[i].style.top=y1+"px";
			this.panel[i].style.visibility="hidden";
		}
	}
}
function nextPanel(d){
	var i=this.position+1;
	if(this.panel.length<=i)i=0;
	this.showPanel(i,d);
}
function backPanel(d){
	var i=this.position-1;
	if(i<0)i=this.panel.length-1;
	this.showPanel(i,d);
}
function showPanel(i,d){
	if(i!=this.position && this.lock==0){
		this.lock=1;
		this.panelOut=this.panel[this.position].id;
		this.panelIn=this.panel[i].id;
		this.hidePanels(d);
		this.position=getIndex(this.panel,this.panelIn);
		this.panel[i]._xX=this.showX;
		this.panel[i]._yY=this.showY;
		this.panel[i]._m=this.showM;
	}
}
function fillNewPanel(){
	var i=this.panelInId;
	this.panelInId=-1;
	this.position=i;
	this.panel[i]._xX=this.showX;
	this.panel[i]._yY=this.showY;
	this.panel[i]._m=this.showM;
}
function slideUp(p){
	var po=p.panelOut;
	if(document.getElementById(po)){
		with(document.getElementById(po)){
			if(_y>=_yY){
				_y-=_m;
				style.top=_y+"px";
				setTimeout("slideUp("+p.id+")",10);
			}else{
				_y=_yY;
				_m=0;
				style.top=_y+"px";
				style.visibility="hidden";
				slideDown(p);
			}
		}
	}
}
function slideDown(p){
	var pi=p.panelIn;
	if(document.getElementById(pi)){
		with(document.getElementById(pi)){
			style.visibility="visible";
			if(_y<=_yY){
				_y+=_m;
				style.top=_y+"px";
				setTimeout("slideDown("+p.id+")",10);
			}else{
				_y=_yY;
				_m=0;
				style.top=_y+"px";
				p.panelOut=id;
				p.lock=0;
				if(fpFunction!=""){
		            flashProxy.call(fpFunction,fpArgument);
		            fpFunction = "";
		            fpArgument = "";
				}
			}
		}
	}
}
function slideLeft(p){
	var po=p.panelOut;
	if(document.getElementById(po)){
		with(document.getElementById(po)){
			if(_x>=_xX){
				_x-=_m;
				style.left=_x+"px";
				setTimeout("slideLeft("+p.id+")",10);
			}else{
				_x=_xX;
				_m=0;
				style.left=_x+"px";
				style.visibility="hidden";
				slideRight(p);
			}
		}
	}
}
function slideRight(p){
	var pi=p.panelIn;
	if(document.getElementById(pi)){
		with(document.getElementById(pi)){
			style.visibility="visible";
			if(_x<=_xX){
				_x+=_m;
				style.left=_x+"px";
				setTimeout("slideRight("+p.id+")",10);
			}else{
				_x=_xX;
				_m=0;
				style.left=_x+"px";
				p.panelOut=id;
				p.lock=0;
				if(fpFunction!=""){
		            flashProxy.call(fpFunction,fpArgument);
		            fpFunction = "";
		            fpArgument = "";
				}
			}
		}
	}
}
function newViewer(){
    if(!document.getElementById('pictureViewer')){
        var o=newDiv('form1','pictureViewer');
        o.style.position='absolute';
        o.style.display='none';
        o.style.padding='20px';
        o.style.background='firebrick';
        o.style.cursor='pointer';
        o.onclick=function(){this.style.display='none';};
    }
}
//  End -->
