imgObj.pre=new Array();
imgObj.property=new Array();
imgObj.obj1=new Array(); // indexed Array, not hash
imgObj.obj=new Array();i_index=0;



if (document.body && typeof document.body.clientWidth!='undefined')
 browser_width=document.body.clientWidth
if (typeof window.innerWidth!='undefined')
 browser_width=window.innerWidth

function imgObj(id_field,image_name,title,aspect,text,l_desc){
this.index=i_index;
i_index++;
this.id_field=id_field;
this.image_name=image_name;
this.title=title;
this.text=text;
this.aspect=aspect;
this.l_desc=l_desc;
this.s_desc='';
imgObj.obj[id_field]=this;
imgObj.obj1[this.index]=this;
this.test=test;
this.checkNext=getNext;
this.getNext=getNext;
this.getLast=getLast;
this.findID=findID;
this.preLoad=preLoad;
}

function findID(){

}

function preLoad(){return 0;
var index_=this.index;
++index_;
if(index_ < imgObj.obj1.length){
imgObj.pre[index_] = new Image();
imgObj.pre[index_].src=this.image_name;
}else{
imgObj.pre[0] = new Image();
imgObj.pre[0].src=this.image_name;
}
}

function getNext(){
var index_=this.index;
++index_;
if(index_ < imgObj.obj1.length){
imgObj.obj1[index_].test(1);
}else{
imgObj.obj1[0].test(1);
}
}

function getLast(){
var index_=this.index;
--index_;
if(index_ > -1){
imgObj.obj1[index_].test(1);
}else{
imgObj.obj1[((imgObj.obj1.length)-1)].test(1);
}
}

function test(check){
if(! document.getElementById){
return true;
}

var nav='<div style="margin-top: 11px" class="pop_nav"><a href="javascript:opener.imgObj.obj['+this.id_field+'].getLast()">&lt; previous</a> &#149; <a href="javascript:opener.imgObj.obj['+this.id_field+'].getNext()">next &gt;</a></div>';

var def_width=775;
if(browser_width<900){def_width=350};
var aspect=this.aspect;

if(! aspect){aspect = 1;}

var height=def_width+5;
var width=def_width+190;
if(aspect >= 1){width=parseInt((def_width/aspect)+200);
html=htmlAll;
}
if(aspect < 1){height=parseInt((def_width*aspect)+5);
width=def_width+200;
html=htmlAll;
}

html=htmlAll;

if(! this.title){this.title = 'Gallery Popup';}

if(browser_width>900){
this.image_name=this.image_name.replace(/350a-/g,'700a-');}
var title=this.title
html = html.replace(/\^title\^/g ,this.title);
html = html.replace(/\^id_field\^/g ,this.id_field);
html = html.replace(/\^image_name\^/g ,this.image_name);
html = html.replace(/\^s_desc\^/g ,this.s_desc);
html = html.replace(/\^image_author\^/g ,this.image_author);
html = html.replace(/\^text\^/g ,this.text);
html = html.replace(/\^nav\^/g ,nav);

// var body_ref=document.getElementsByTagName('body')[0];
// if(! check){imgObj.property['saved_html']=body_ref.innerHTML;};
// body_ref.innerHTML=html;

var id_field=this.id_field;

makeWindow(html,width,height,id_field);

this.preLoad()
return false;
}

var winArray=new Array();
function makeWindow(contents,width,height,id_field){
// width=800;
// height=470;

// if(winArray[id_field]){if(winArray[id_field].closed){winArray[id_field].close()}}
winArray[id_field] = window.open("","","width="+width+",height="+height);
winArray[id_field].document.open();
winArray[id_field].document.write(contents);
winArray[id_field].document.close();
winArray[id_field].focus();
closeWindows(id_field);
winArray[id_field].moveTo(0,0);
}

function closeWindows(id_field){
for (var x in winArray){
if(x != id_field){
if(winArray[x]){if(! winArray[x].closed){winArray[x].close()}}}
}
}

function restore(){
document.getElementsByTagName('body')[0].innerHTML=imgObj.property['saved_html'];
return false;
}