
var cell_status=new Array();var image_list=new Array();var image_type=new Array();var image_text=new Array();var image_title=new Array();var image_subtitle=new Array();var mouseX=0;var mouseY=0;var cell_step_row=-1;var cell_step_col=-1;var cell_total=-1;var lastresponse="";var wth_txt="";var hht_txt="";var wth=1;var hht=1;var main_div_name='screen';var default_dirs=false;var group_fade=0;var PHOTO_NOT_HIGHLIGHTED=0;var PHOTO_HIGHLIGHTED=2;var PHOTO_IS_COLOR=7;function print_message(message)
{var status=document.getElementById('status');if(status){status.innerHTML=message;}}
function get_int_from_string(str)
{return parseInt(str.substr(0,str.length-2));}
function alpha(value)
{return parseFloat(parseInt(value)/100.0);}
function getopacity(id){var object=document.getElementById(id);if(object){var obj_style=object.style;if(typeof obj_style.opacity=="string")
{return parseFloat(obj_style.opacity);}
else
{return eval(obj_style.filter);}}}
function setopacity(opacity,id){var object=document.getElementById(id);if(object){objstyle=object.style;objstyle.opacity=(opacity);objstyle.MozOpacity=(opacity);objstyle.KhtmlOpacity=(opacity);objstyle.filter="alpha(opacity="+opacity*100+")";}
else
print_message("Error can't find "+id);}
function requestEval(url)
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{alert("Sorry you cannot run AJAX Applications.");return;}
xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{eval(xmlHttp.responseText);}}
xmlHttp.open("GET",url,false);xmlHttp.send(null);eval(xmlHttp.responseText);return xmlHttp.responseText;}
function showPage(pageToFetch,whereToPut)
{xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{alert("Sorry you cannot run AJAX Applications.");return;}
var url=pageToFetch;localWhereToPut=whereToPut;xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,false);xmlHttp.send(null);var aa=lastresponse;return xmlHttp.responseText;}
function stateChanged()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{lastresponse=xmlHttp.responseText;localWhereToPut="";}}
function CheckBrowser()
{var objXMLHttp=null;try{objXMLHttp=new XMLHttpRequest();objXMLHttp.overrideMimeType('text/xml; charset=iso-8859-1');return'NONIE';}catch(e){try{objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser broke!");return'FALSE';}}}
return'IE';}
function GetXmlHttpObject()
{var objXMLHttp=null;try{objXMLHttp=new XMLHttpRequest();objXMLHttp.overrideMimeType('text/xml; charset=iso-8859-1');}catch(e){try{objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser broke!");return false;}}}
return objXMLHttp}
function fadeout_photoinfo()
{var photoinfo=document.getElementById('photoinfo');var brightness=getopacity('photoinfo');brightness-=info_step_fade;setopacity(brightness,'photoinfo');if(brightness>=0.0)
setTimeout("fadeout_photoinfo()",info_fadeout_speed);}
function hide_null()
{alert(' Error');}
function hide_photoinfo()
{var photoinfo=document.getElementById('photoinfo');var photohead=document.getElementById('photohead');photoinfo.style.display='none';photohead.style.display='none';if(usefadeoutinfo==true){brightness=1.0;setTimeout("fadeout_photoinfo()",fadeout_speed);}
else
{brightness=0.0;setTimeout("fadeout_photoinfo()",fadeout_speed);}}
function check_photoinfo_pos(xoff,yoff,xp,yp,photoinfo)
{var photohead=document.getElementById('photohead');var photoinfo=document.getElementById('photoinfo');wth_txt=photoinfo.style.width;hht_txt=photoinfo.style.height;wth=1+parseInt(wth_txt.substr(0,wth_txt.length-2));hht=1+parseInt(hht_txt.substr(0,hht_txt.length-2));right=parseInt(xp+6*cell_width+5*cell_space);bottom=parseInt(yp+2*cell_height+cell_space);if((bottom>canvas_height)||(right>canvas_width))
{nrx=parseInt((right-canvas_width-canvas_left)/cell_width);nry=parseInt((bottom-canvas_height-canvas_top)/cell_height);if(nrx>0)
{photoinfo.style.left=xp-((nrx-2)*(cell_width+cell_space))+'px';photohead.style.left=xp-((nrx)*(cell_width+cell_space))+'px';}
if(nry>0)
{photoinfo.style.top=yp-(nry*(cell_height+cell_space))+'px';photohead.style.top=yp-(nry*(cell_height+cell_space))+'px';}}}
function fadein_photoinfo(name,speed)
{var obj=document.getElementById(name);var ert=getopacity(name);ert=ert+info_step_fade;setopacity(ert,name);if(ert<1.0&&cell_status[name]!=0)
setTimeout("fadein_photoinfo('"+name+"', "+speed+")",speed);else
{setopacity(1.0,name);}}
function get_position(name)
{var getVars=new Array();var object=document.getElementById(name);if(object){left_pos_txt=object.style.left;top_pos_txt=object.style.top;xp=parseInt(left_pos_txt.substr(0,left_pos_txt.length-2));yp=parseInt(top_pos_txt.substr(0,top_pos_txt.length-2));getVars[0]=' '+xp;getVars[1]=' '+yp;}
return getVars;}
function zoom_cell(no,mx,my)
{var objname='color_img_'+no;var cellobj=document.getElementById(objname);var photohead=document.getElementById('photohead');var img=photohead.getElementsByTagName('img');img[0].src=cellobj.src;xw=get_int_from_string(photohead.style.width);yw=get_int_from_string(photohead.style.height);xw+=2;yw+=2;photohead.style.display='block';photohead.style.zIndex=900;photohead.style.width=xw+'px';photohead.style.height=yw+'px';if(xw<(mx))
setTimeout("zoom_cell("+no+","+mx+","+my+")",6);else
{photohead.style.width=mx+'px';photohead.style.height=my+'px';}}
function show_aniphotoinfo(object)
{setopacity(1.0,object.id);wth=object.id.substr(1+object.id.lastIndexOf('_'));cell_status[object.id]=2;zoom_cell(wth,2*(cell_width+2)+cell_space-4+ie_correctie,(2*cell_height)+cell_space+ie_correctie);}
function show_photoinfo()
{var canvasParent=document.getElementById('canvas');var photoinfo=document.getElementById('photoinfo');var photohead=document.getElementById('photohead');hide_photohover();setopacity(0.0,'photoinfo');var selpos=get_position(this.id);var infpos=get_position('canvas');var x=parseInt(selpos[0]);var y=parseInt(selpos[1]);var x1=parseInt(infpos[0]);var y1=parseInt(infpos[1]);var x_abs=x+x1;var y_abs=y+y1;photoinfo.style.display='block';photohead.style.width=cell_width+'px';photohead.style.height=cell_height+'px';if(show_infoani){photoinfo.style.background="#bbb";photoinfo.style.border="1px solid #fff";image_elements=this.childNodes;var l,t;var x_corr=0;l=x_abs;t=y_abs;if(l+(cell_width*2)>canvas_width){l=x1+x-cell_width-cell_space;x_corr=cell_width+cell_space;}
photohead.style.left=l+'px';photohead.style.top=t+'px';photohead.style.display='block';photohead.style.zIndex=600;l=2*cell_width+2*cell_space+x1+x;t=y1+y;if(l+photoinfo.clientWidth>canvas_width){l=x1+x-(cell_width*4)-(cell_space*4)-x_corr;}
photoinfo.style.left=l+'px';photoinfo.style.top=t+'px';wth=image_elements[1].id.substr(1+image_elements[1].id.lastIndexOf('_'));photoinfo.innerHTML=image_text[wth];photohead.onclick=function(){show_video(wth);};show_aniphotoinfo(image_elements[1]);fadein_photoinfo('photoinfo',50);return true;}
else
{photoinfo.style.left=1+parseInt(x1+x)+'px';photoinfo.style.top=parseInt(y1+y)+'px';fadein_photoinfo('photoinfo',50);}}
function show_photohover(e)
{var container=this.parentNode;var images=container.childNodes;wth=images[1].id.substr(1+images[1].id.lastIndexOf('_'));var title=image_title[wth];var subtitle=image_subtitle[wth];var photoinfo=document.getElementById('photoinfo');var canvasParent=document.getElementById('canvas');var hover=document.getElementById('photohover');hover.style.display='block';hover.innerHTML=title+" - "+subtitle;if(e&&e.pageX&&e.pageY){mouseX=e.pageX;mouseY=e.pageY;}
var x=mouseX+8;var y=mouseY+16;hover.style.left=x+'px';hover.style.top=y+'px';}
function hide_photohover()
{var hover=document.getElementById('photohover');hover.style.display='none';}
function setout_photo_color(name)
{var obj=document.getElementById(name);if(obj)
if(obj.parentNode)
cell_status[obj.parentNode.id]=2;setopacity(0.0,name);}
function fadeout_photo_color(name)
{var obj=document.getElementById(name);var ert=getopacity(name);if(ert<=0.0)return;ert=ert-step_fade;setopacity(ert,name);if(getopacity(name)>=0.0)
{setTimeout("fadeout_photo_color('"+name+"')",fadeout_speed);}
cell_status[obj.parentNode.id]=2;if(cell_status[this.id]==2){}
setopacity(0.0,name);}
function setout_photo(name)
{var obj=document.getElementById(name);setopacity(low_opacity,name);cell_status[name]=0;}
function fadeout_photo(name)
{var obj=document.getElementById(name);var ert=getopacity(name);if(cell_status[name]==7)return;if(cell_status[name]==3)
{cell_status[name]=4;}
ert=ert-step_fade;if(ert<low_opacity)
{ert=low_opacity;setopacity(ert,name);cell_status[name]=0;return;}
setopacity(ert,name);if(ert>=low_opacity&&cell_status[name]!=0)
setTimeout("fadeout_photo('"+name+"')",fadeout_speed);else
{setopacity(low_opacity,name);cell_status[name]=0;ert=low_opacity;}}
function fadein_photo_color(name)
{var obj=document.getElementById(name);var ert=getopacity(name);if(ert>1.0){setopacity(1.0,name);return;}
ert=ert+step_fade;setopacity(ert,name);if(getopacity(name)<1.0)
{setTimeout("fadein_photo_color('"+name+"')",50);}
if(cell_status[this.id]==2){}}
function hidephoto1()
{var container=this.parentNode;var images=container.childNodes;var colorid=images[0].id;var bwid=images[1].id;hide_photohover();if(cell_status[container.id]==PHOTO_IS_COLOR)
{setopacity(0.0,colorid);cell_status[container.id]=PHOTO_HIGHLIGHTED;setout_photo_color(colorid);return true;}
else
if(cell_status[container.id]==PHOTO_HIGHLIGHTED){setout_photo(bwid);return true;}
else
{fadeout_photo(bwid);cell_status[container.id]=PHOTO_NOT_HIGHLIGHTED;return true;}}
function fadein_photo(name,speed)
{var obj=document.getElementById(name);if(cell_status[name]==7)return;if(cell_status[name]==4)return;cell_status[name]=3;var ert=getopacity(name);ert=ert+step_fade;setopacity(ert,name);if(ert<1.0&&cell_status[name]!=0)
setTimeout("fadein_photo('"+name+"', "+speed+")",speed);else
if(ert>1.0)
{cell_status[name]=4;}}
function highlightphoto1()
{var container=this.parentNode;var images=container.childNodes;var colorid=images[0].id;var bwid=images[1].id;wth=images[1].id.substr(1+images[1].id.lastIndexOf('_'));if(cell_status[container.id]==PHOTO_IS_COLOR)
{return;}
else
if(cell_status[container.id]==PHOTO_HIGHLIGHTED){cell_status[container.id]=PHOTO_IS_COLOR;setopacity(0.0,colorid);setopacity(0.1,colorid);setopacity(0.2,colorid);setopacity(0.3,colorid);setopacity(0.4,colorid);setopacity(0.5,colorid);setopacity(0.6,colorid);setopacity(0.7,colorid);setopacity(0.75,colorid);setopacity(0.8,colorid);setopacity(0.85,colorid);setopacity(0.9,colorid);setopacity(0.95,colorid);setopacity(1.0,colorid);}
else
{cell_status[bwid]=PHOTO_NOT_HIGHLIGHTED;fadein_photo(bwid,fadeinspeed);}
return true;}
function highlight_group(name,filter){var canvasobj=document.getElementById('canvas');hide_photoinfo();var photos=canvasobj.childNodes;var container=photos[0];var images=container.childNodes;var aantal_photos=photos.length;var filter_matches;var tag_found;if(!filter)filter="";filter=filter.toLowerCase();filter=filter.split(" ");group_fade=0;for(var no=0;no<aantal_photos;no++)
{container=photos[no];images=container.childNodes;colorid=images[0].id;bwid=images[1].id;aa=container.style;if(aa){setopacity(low_opacity,bwid);setopacity(0.0,colorid);if(image_type[no])
taglist=image_type[no].split(",");if(filter.length>0){filter_matches=true;for(var idx=0;idx<filter.length;idx++){if(filter[idx].length==0)
continue;if(image_title[no].toLowerCase().indexOf(filter[idx])==-1&&image_subtitle[no].toLowerCase().indexOf(filter[idx])==-1){filter_matches=false;tag_found=false;if(taglist.length>0){for(var a=0;a<taglist.length;a++){if(taglist[a].toLowerCase().indexOf(filter[idx])!=-1){tag_found=true;}}}
if(!tag_found)
break;else
filter_matches=true;}}}else{filter_matches=true;}
if(name.length==0){if((filter.length==1&&filter[0].length==0)||!filter_matches){setopacity(low_opacity,bwid);cell_status[container.id]=PHOTO_NOT_HIGHLIGHTED;}else{setopacity(high_opacity,bwid);cell_status[container.id]=PHOTO_HIGHLIGHTED;}}else if(taglist.length>1){found=0;for(var a=0;a<taglist.length;a++){if(taglist[a]==name){if(filter_matches){setopacity(high_opacity,bwid);cell_status[container.id]=PHOTO_HIGHLIGHTED;found=1;break;}}}
if(found==0){setopacity(low_opacity,bwid);cell_status[container.id]=PHOTO_NOT_HIGHLIGHTED;}}else if(image_type[no]==name){if(filter_matches){setopacity(high_opacity,bwid);cell_status[container.id]=PHOTO_HIGHLIGHTED;}}else{if(cell_status[this.id]==PHOTO_HIGHLIGHTED){}else if(cell_status[this.id]==PHOTO_IS_COLOR){}else{cell_status[container.id]=PHOTO_NOT_HIGHLIGHTED;setopacity(low_opacity,bwid);}}}}}
function fill_image_cell(cell_object,xpos,ypos)
{cell_object.style.border='solid white 1px';cell_object.style.position='absolute';cell_object.style.margin='0px';cell_object.style.padding='0px';cell_object.style.left=xpos+'px';cell_object.style.top=ypos+'px';cell_object.style.left=0;cell_object.style.top=0;cell_object.style.width=cell_width+'px';cell_object.style.height=cell_height+'px';cell_object.style.zIndex=400;}
function initialize_canvas()
{var screenParent=document.getElementById(main_div_name);var canvasobj=document.getElementById('canvas');var canvas_div=canvasobj.getElementsByTagName('DIV');ie_correctie=0;cell_space=cell_space+2;cell_step_row=cell_width+(cell_space);if(cell_square==true)
cell_step_col=cell_step_row;else
cell_step_col=parseInt(canvas_height/cell_cols);cell_total=cell_rows*cell_cols;canvas_width=cell_rows*cell_width+cell_rows*cell_space;canvas_height=cell_cols*cell_height+cell_cols*cell_space;canvasobj.style.height=30+canvas_height+'px';screenParent.style.height=60+canvas_height+'px';canvasobj.style.display='none';for(var no=0,col=0;col<cell_cols;col++)
{for(var row=0;row<cell_rows;row++,no++)
{if(image_list[no]){var photoobject=document.createElement('div');con_name='container_'+no+'_div';bw_name='bw_img_'+no;color_name='color_img_'+no;var xpos=parseInt(row*cell_step_row);var ypos=parseInt(col*cell_step_col);cell_status[con_name]=0;photoobject.style.border='solid gray 0px';photoobject.style.margin='0px';photoobject.style.padding='0px';photoobject.style.position='absolute';photoobject.style.left=xpos+'px';photoobject.style.top=ypos+'px';photoobject.style.width=2+cell_width+'px';photoobject.style.height=2+cell_height+'px';if(use_bg_technique)
photoobject.setAttribute('id',bw_name);else
photoobject.setAttribute('id',con_name);if(default_dirs)
naam=bw_dir+'/'+image_list[no];else
naam=image_list[no]+bw_ext;if(use_bg_technique)
photoobject.style.background='url( '+naam+' ) 100px';photoobject.style.zIndex=200;photoobject.onclick=show_photoinfo;var bw_photo=document.createElement('img');if(default_dirs)
naam1=bw_dir+'/'+image_list[no];else
naam1=image_list[no]+bw_ext;bw_photo.src=naam1;bw_photo.setAttribute('id',bw_name);fill_image_cell(bw_photo,xpos,ypos);bw_photo.onmouseout=hide_null;bw_photo.style.zIndex=300;var color_photo=document.createElement('img');if(default_dirs)
naam1=color_dir+'/'+image_list[no];else
naam1=image_list[no]+color_ext;color_photo.src=naam1;fill_image_cell(color_photo,xpos,ypos);color_photo.style.zIndex=900;color_photo.style.cursor="pointer";color_photo.onmouseout=hidephoto1;color_photo.onmouseover=highlightphoto1;color_photo.onmousemove=show_photohover;color_photo.setAttribute('id',color_name);canvasobj.appendChild(photoobject);photoobject.appendChild(color_photo);photoobject.appendChild(bw_photo);setopacity(1.0,con_name);setopacity(low_opacity,bw_name);setopacity(0.0,color_name);}}}
canvasobj.style.display='block';}
function create_divs()
{var screenParent=document.getElementById(main_div_name);var tmp=document.createElement('div');var cnv=document.createElement('div');var hover=document.createElement('div');if(!document.getElementById('photo_info'))
{var phi=document.createElement('div');phi.setAttribute('id','photoinfo');phi.style.border='solid white 1px';phi.style.position='relative';phi.style.padding='0px';phi.style.margin='0px';phi.style.display='none';phi.style.overflow='hidden';phi.style.top='0px';phi.style.left='0px';phi.style.width='200px';phi.style.height='100px';screenParent.appendChild(phi);}
var headimg=document.createElement('img');cnv.setAttribute('id','canvas');cnv.style.border='solid white 0px';headimg.style.width='100%';headimg.style.height='100%';headimg.setAttribute('id','img');headimg.setAttribute('alt','');headimg.style.border='solid white 0px';headimg.style.width='100%';headimg.style.height='100%';tmp.setAttribute('id','photohead');tmp.style.border='solid white 1px';tmp.style.width='10px';tmp.style.height='10px';tmp.style.margin='0px';tmp.style.padding='0px';tmp.style.position='absolute';tmp.style.display='none';tmp.style.overflow='hidden';tmp.style.top='10px';tmp.style.left='10px';tmp.style.background='#aaaaaa';tmp.style.cursor='pointer';hover.setAttribute('id','photohover');hover.style.position='absolute';hover.style.padding='1px 2px';hover.style.color='#eeeeee';hover.style.background='#222222';hover.style.border='solid #999 1px';hover.style.display='none';hover.style.zIndex=950;document.body.appendChild(hover);tmp.appendChild(headimg);screenParent.appendChild(tmp);screenParent.appendChild(cnv);}
function set_css()
{}
function initCollection()
{create_divs();set_css();var screenParent=document.getElementById(main_div_name);var photoinfo=document.getElementById('photoinfo');var canvasParent=document.getElementById('canvas');eer=requestEval(callback_images);if(!canvasParent){alert(' First define a div with id=canvas');return false;}
if(!photoinfo){alert(' First define a div with id=photoinfo\nAfter the canvas div');return false;}
canvas_width=cell_rows*(cell_width+cell_space+2);canvas_height=cell_cols*(cell_height+cell_space+2)+30;canvasParent.zIndex=-400;canvasParent.style.left=canvas_left+'px';canvasParent.style.top=canvas_top+'px';canvasParent.style.width=canvas_width+'px';canvasParent.style.height=canvas_height+'px';canvasParent.style.border='solid black 0px';canvasParent.style.margin='0px';canvasParent.style.padding='0px';canvasParent.style.display='block';canvasParent.style.overflow='hidden';canvasParent.style.position='absolute';screenParent.style.position='relative';screenParent.style.margin='0px';screenParent.style.padding='0px';screenParent.style.border='solid black 0px';screenParent.zIndex=-400;screenParent.style.left=canvas_left+'px';screenParent.style.top=canvas_top+'px';screenParent.style.width=canvas_width+'px';screenParent.style.height=canvas_height+'px';screenParent.style.fontSize='12px';screenParent.style.lineheight='14px';screenParent.style.background='transparent';initialize_canvas();photoinfo.style.zIndex=300;photoinfo.style.width=(4*(cell_width)+(3*(cell_space)))+'px';photoinfo.style.height=parseInt(2*cell_height+cell_space)+'px';photoinfo.style.display='none';photoinfo.style.background='#ffffff';photoinfo.style.zIndex=300;setopacity(high_opacity,'photoinfo');highlight_group('niets');}
$().mousemove(function(e){mouseX=e.pageX;mouseY=e.pageY;});$(function(){initCollection();});