/* easy peasy Template naming pragma:
 * 
 * function_name__template_name
 * 
 */

var Templates = $H({});		


Templates.lightbox_new__body = new Template(
	'<div id="lightboxPopUp">'
	+'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="left" width="290" height="200"><TR>'
	+'<td class="dark1" valign=bottom width="100%"><DIV class="barheader">&nbsp;<FONT class="bartitle">Make a new lightbox</font></DIV></td></tr>'
	+'<tr><TD ALIGN="left" VALIGN="top" width="290" class="dark1"><DIV class="light1" style="padding: 15px;"><form action="javascript:nada();" method="get" name="send"><p>Enter a name for your new lightbox in the box below '
	+'</p><p><INPUT type="text" name="lightbox_new_name" id="lightbox_new_name" size="15" class="emailbox" value="My new LB name" onfocus="if (this.value == \'My new LB name\'){ this.value=\'\';}">'
	+'<A href="javascript:return false;" onclick="lightbox_new_send(); return false;" class=lblink style="font-size: 10pt; font-weight:bold;">Create the Lightbox</A><BR><BR>'
	+'Note:  You must enter a unique name for your new lighbox.  It will only be viewable by you unless you use the "E-mail this lightbox" function to share it with someone.<BR><BR>'
	+'If you do not need a lightbox anymore click the link below.<br><br><A HREF="" onclick="lightbox_email(\'close\'); return false;">[X] close window</A>'
	+'</div>' 
);
		
Templates.lightbox_email__body = new Template(
	'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="left" width="390" height="280"><TR>'
	+'<td class="dark1" valign=bottom width="100%"><DIV class="barheader"><FONT class="bartitle">Email your lightbox to a friend</font></DIV></td></tr>'
	+'<tr><TD ALIGN="left" VALIGN="top" width="390" class="dark1"><DIV class="light1" style="padding: 15px;"><form action="javascript:nada();" method="get" name="send"><p><B>E-mail your lightbox '
	+'"#{currentlbname}"</B> to a friend or colleague.</p><p><B>1.</B> Send To:<CODE>*</CODE></b></font><br><input type="text" name="to_email" id="to_email" size="35" class="emailbox" value="friend@domain.com" onfocus="if (this.value == \'friend@domain.com\') {this.value=\'\';}"><BR>'
	+'<BR><B>2.</B> Message:<BR><TEXTAREA NAME="mail_text" ID="mail_text" ROWS="7" COLS="45"></TEXTAREA><BR><BR><B>3.</B> <input type="checkbox" id="readonly" name="readonly" value=1> Read only<BR><FONT CLASS="xsmall">check this box to prevent recipient from changing your lightbox.</FONT></p>'
	+'<B>4.</B> <input type="checkbox" name="notify" id="notify" value="1"><font class="small">Notify me when this lightbox is viewed</font><br>'
	+'#{emaillbaddhtml}<br><p><A href="javascript: return false;" onclick="lightbox_email_send(); return false;" class=lblink style="font-size: 10pt;font-weight:bold;">Send the Lightbox</A>'
	+'<input type="hidden" name="ot" value="2"><input type="hidden" name="dsm" value="1"></center></form><br><br><p>If you have changed your mind, click the link below.<BR><BR> <A HREF="" onclick="lightbox_email(\'close\'); return false;">[X] close window</A>.<BR>'
	+'</DIV></TD></TR></TABLE>'
);
		
Templates.lightbox_rename__body = new Template(
	'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="left" width="290"><TR>'
	+'<td class="dark1" valign=bottom width="100%"><DIV class="barheader">&nbsp;<FONT class="bartitle">Rename  lightbox</font></DIV></td></tr>'
	+'<tr><TD ALIGN="left" VALIGN="top" width="290" class="dark1"><DIV class="light1" style="padding: 15px;"><form action="javascript:nada();" method="get" name="send"><p>'
	+'</p><p><INPUT type="text" name="lightbox_new_name" id="lightbox_new_name" size="15" class="lightbox_new_name" value="#{currentlbname}" onfocus=" if (this.value == \'#{currentlbname}\'){ this.value=\'\';}">'
	+'<A href="javascript: return false;" onclick="lightbox_rename_send(); return false;" class=lblink style="font-size: 10pt; font-weight:bold;">Rename</A><br/>'
	+'<A HREF="" onclick="lightbox_email(\'close\'); return false;">[X] close window</A>'
	+'</form></DIV></TD></TR></TABLE>'
);

Templates.simplemessage__body = new Template(
	'<DIV class=light1 style="text-align:center; width:400px; text-align:left; padding:10px; margin-top:200px"><FONT class="header">#{message}</DIV>'
);

Templates.simplemessage__body_lightbox = new Template(
	'<DIV class=light1 style="position:absolute; left:0px; bottom:0px; width:100%; height:30px; text-align:left; padding:10px 20px 10px 20px; margin-top:20px"><FONT class="header">#{message}</DIV>'
);

//this is the metadata layout for a popup
Templates.sp_act__metadata = new Template (
	'<span class="blah"># #{displayimageid} #{rmrftype} #{filesize} :: #{shortcaption} #{photographer} #{imagerestrictions}'
	+'<br/>'
	+'<span class="warning"> To turn live previews off, use Previews menu at top of page </span>'
);

Templates.enlarge2_act__similars = new Template (
	'<TD valign="top" align="left" width="120" height="440">'
	+'<div style="position:relative; overflow: auto; overflow-y: auto; overflow-x: hidden; height:75%">'
	+"<B>Similar Images:</B><BR>"
	+'#{simcolinfo}'
	+'</div></TD>'
);
		
Templates.enlarge2_act__body = new Template (
	'<table cellspacing="0" cellpadding="0" border="0" width="99%" style="height:99%;overflow:auto">'
		+'<TR height="99%">'
			+'<TD align="left" valign="top" width="99%" height="99%" style="overflow:auto">'
				+'<table cellspacing="4" cellpadding="0" border="0" width="920" height="470" >'
				+'<TR><TD valign="top" align="left" width="430" height="440" style="min-width: 440px">'
					+'<div style="position:relative">#{themediainsert}</div>'
				+'<br/></td>'
				+'#{similarscolumn}'
				+'<TD align="left" valign="top" width="320"><BR>'
					+'#{navbacklinks}'
					+'#{navenlargedlinks}'
					+'<br/><a href="javascript: return false;" onclick="lightbox_addto(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_lightbox.gif"  border=0 alt="" style="margin-top:5px"></a><a href="javascript: return false;" onclick="lightbox_addto(\'#{enlargetid}\'); return false;"> ADD TO CURRENT LIGHTBOX </a>'
					+'<br/><a href="javascript: return false;" onclick="license(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_price.gif" border=0 alt="" ></a><a href="javascript: return false;" onclick="license(\'#{enlargetid}\'); return false;"> CHECK USAGE RATES</a>'
					+'<br/><a href="javascript: return false;" onclick="cart_addto(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_cart.gif" border=0 alt="" ></a><a href="javascript: return false;" onclick="cart_addto(\'#{enlargetid}\'); return false;"> ADD TO SHOPPING CART</a>'
					+'<br/>#{downloadcomplink}'
					+'#{ratetierinfo}'
					+'<BR/><b>Image Number:</b> #{displayenlargetid}&nbsp;[#{rmrftype}]'
					+'<br/><b>Caption:</b> #{myshortcaption}<br/>'
					+'#{releaseinfo}'
					+'#{photographerinfo}'
					+'#{filesizeinfo}'
					+'#{restrictionsinfo}'
					+'<BR/><A class="olink" id="enalarge_keywords_text" onclick="popkeys2(\'enlarge_keywords\', this); return false;">Show keywords</A><BR>'
					+'<div id="enlarge_keywords" style="display:none; overflow-y:auto;">'
					+'#{keywordinfo}'
					+'</div>'
				+'</td></TR></table>'
	+'<BR></td></TR></table>'
);

Templates.tieredimgpricing__rfslug = new Template (
        '<h4 style="text-align: left;">Select a File Size</h4>'+
        '<table style="text-align: left;width: 95%;" cellpadding=0 cellspacing=0>#{rows}</table>'
);

Templates.tieredimgpricing__rfslug_row = new Template (
        '<tr><td align="left" nowrap="nowrap" valign="top" style="padding-bottom: 4px; padding-top: 4px;border-bottom: solid #999 1px;">#{expr}</td><td align="right" valign=top style="border-bottom: solid #999 1px;padding-bottom: 4px; padding-top: 4px;">#{currency} #{price}<BR><nobr><A href="#" class=orangelink onclick="cart_addto(\'#{enlargetid}\', { ln:\'#{enlargetid}\', lictype:\'RF\', base:\'#{base}\', Size_opname:\'#{id}\', usage:\'#{usage}\'}); return false;">Add to Cart</a></nobr></td></tr>' );

Templates.hovercopyright__text = new Template (
	'<div clsss="dark_tetra">&copy;#{currentyear} #{baseurl}  All rights reserved <a class="dark_tetra" href=/help_login.shtml#Terms_and_Conditions class=disclaimer>Terms</a> <a class="dark_tetra" href=/help_faq.shtml#Privacy_Policy class=disclaimer>Privacy policy</A> &nbsp;<A HREF=/contact.shtml class="disclaimer dark_tetra">contact</a></FONT></nobr></div>'
);

Templates.footer__body = new Template (
	'<DIV id="copyright" class="dark_tetra"><span class="disclaimer"><A class="dark_tetra" href="/aboutus_mission.shtml" onmouseover="hovercopyright();" class="disclaimer">&copy; #{currentyear} </A></span></DIV>'
);

////////////search functions only////////////

function htmlit_custom(showid){

	// build html for each image depending on viewing mode
	
	var html='';
	switchpage = false;
	if (id[showid]){
		
		var myrmrftype = rm[showid];
		myid = id[showid];
		mysimilarto=st[showid];
		if (typeof(scp) != 'undefined' && (viewmode == 'list' || viewmode == 'editing') ) {myshortcaption=unescape(scp[showid]);} else {myshortcaption = "n/a";}
		var temp = true;
		var tempshortcaption='';
		myreleased = rel[showid];

		if (typeof(relcon) != 'undefined' && relcon[showid] && mysimilarto.length < 13) {  //share control style..
			var shortrel = myreleased;
			shortrel = shortrel.substring(0,16) + (myreleased.length > 16 ? '...' : '');
			myreleased = '<div id="shortrel'+showid+'">Release: '+shortrel+'</div> <div>  <form id="releasecontrol'+showid+'" > ' + relcon[showid] + ' <input type="hidden" name="shdex" value="'+showid+'"/></form> <a href="javascript: return false;" onclick="sor('+showid+'); return false;" >Save Release</a></div>';
		} 
		else if(showrelease){
			if(! ( myreleased == "MODEL RELEASED" || myreleased == "MODEL AND PROPERTY RELEASED" || myreleased == "PROPERTY RELEASED") ){
				myreleased = "Release: " + myreleased;
			}
			if (typeof(relcon) != 'undefined' && relcon[showid] && mysimilarto.length < 13)
				myreleased ='<br/>'+myreleased;

		} else { myreleased="";}
		//shorten long captions
		if(myshortcaption.length > 90){
			for(z=0; z < 130; z++){
				var c = myshortcaption.charAt(z);
				if(temp == true){
					if((z > 90) && (c == ".")){
						temp = false;
						tempshortcaption+=c + " ...";
					} else if((z > 110) && (c == " ")){
						temp = false;
						tempshortcaption+=" ...";
					} else {
						tempshortcaption+= c;
					}
				}
        		}
        		myshortcaption = tempshortcaption;
    		}
    		var thishassimilars = "yes";
		myphotographer=pho[showid];
		myrglobaldynf = rm[showid];
		myfilesize=fs[showid];
		var myhrdlink = hrdl[showid];

		var mysharestatuses = html_share_con_opts(showid);
		var mysiteweight = html_weight_con_opts(showid);
		var mycombinedcon = html_combined_con_opts(showid);

                var thisisacoverimage_feature = '';
                if(rfcd[showid].match(myid)) //myid is in the info for the link, hence this is the cover image
                {
                        var pm = unescape(rfcd[showid]).match(/SwishSearch\?n\=1\&fn\=(.*)\&supst\=cd/);
                        if(pm != null)
                                thisisacoverimage_feature = pm[1];
                }

		adminheight=0;
		if(myhrdlink){
			myhrdlink = myhrdlink.replace(/(<br>|%3cbr%3e)/ig, '');
                        if (viewmode != 'editing')
                                adminheight=11;
		} 
		if(myfilesize < 5){myfilesize='Scan on Demand';} //else {myfilesize+=" Mb";}
		if(myid.length > 9){
			if ( o[showid] ){displayid=o[showid];} else {displayid=myid;}	
                        if(viewmode == "editing"){
                                var theight = 160 + adminheight;

                                var sharesync = unescape(shsync[showid]);
                                sharesync=sharesync.split('|');
                                //so 0 is type, 1 is if it matchess
                                var shbg = 'white';
                                if (sharesync[0] == 'shared') {
                                        shbg = '#77BB33';
                                } else if (sharesync[0].toString().match(/notshared|rejected/)) {
                                        shbg = '#DF0000';
                                }
                                var shbdr = 'white';
                                if ( parseInt(sharesync[1]) )
                                {
                                        shbdr = 'orange';
                                }
//console.log(myid+' -> '+sharesync[0]+' . '+sharesync[1]+' == '+shsync[showid]);
                                if ( mysimilarto.length < 13){

                                        html += '<span id="cellwrapper'+myid+'" valign=bottom style="float:left;background-color:'+shbdr+'; padding:0 6px; 0 6px">';

                                        html += '<div id="d'+myid+'" align=center valign=bottom style=" background-color:'+shbg+'; width:288px; height:' + theight + 'px;">';
                                        html += '<TABLE width=298 cellspacing=2 cellpadding=0 border=0><TR><TD valign=top><div style="position:relative;height:160px;"><a href="javasc' + 'ript:enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\');"><img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' +myid + '.JPG" border=0 class=pimg vspace=2 hspace=3';
                                        html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";html += '" onmouseout="hp();" id=' + myid + '>';

                                        html += '</a>';
					html += mycombinedcon + mysharestatuses;




                                        html += '</div></TD><TD valign="top"><font class=xsmall>ID:' + myid;
                                        if(typeof(suppressrmrftype) == 'undefined'){
                                                html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
                                        }
                                        html += '<DIV class=icons>';

                                        if ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) )
                                        {
                                                html+='<A href="javascript:lightbox_delete_image_enl(\'' + myid + '\');" class="lblink" TITLE="Remove this image from the lightbox">X</A>';
                                        }

                                        html += '</DIV>';

                                        myphotographer = unescape(myphotographer);
                                        if (myphotographer.length > 18)
                                                myphotographer = myphotographer.substring(0,18) + '...';

                                        if(showphotographer == 1){html +='&copy; '+currentYear+' ' + myphotographer;}
                                        html += '  <nobr>';
                                        if(showfilesize){html += myfilesize;}

                                        html += '</nobr><br/>CAPTION: ' + myshortcaption+'<div>'+myreleased+'</div></font>';

                                        html += mysiteweight;

                                        if(myhrdlink)
                                                html += '<br/><NOBR>'+myhrdlink+'</NOBR>';
                                        html += '<br/><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';

                                        html += '</TD></TR></TABLE></DIV></span></SPAN>';
                                } else {

                                        html += '<span id="cellwrapper'+myid+'" valign=bottom style="float:left;background-color:'+shbdr+'; padding:0 6px; 0 6px;">';
                                        html += '<div id="d' + myid + '" align=center valign=bottom style=" background-color:'+shbg+'; width:288px; height:' + theight + 'px;">';
                                        html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','editing', myhrdlink, myreleased);
                                        html += '</DIV></span></SPAN>';
                                }

                        }
                        else if(viewmode == "list"){
				var theight = (typeof(customlistheight) !='undefined' ? customlistheight : 172) + adminheight;
//				var theight = 172 + adminheight;
				if ( mysimilarto.length < 13){	
					
					html += '<span id="cellwrapper'+showid+'" valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:305px; height:' + theight + 'px;">';
					html += '<TABLE width=298 cellspacing=2 cellpadding=0 border0><TR><TD valign=top>';

                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" >';
                                        else
						html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;">';

					html += '<img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + myid + '.JPG" border=0 class=pimg vspace=2 hspace=3';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";html += '" onmouseout="hp();" id=' + myid + '>';
					html += '</a><BR>';
					if(myhrdlink)
						html += '<center>'+myhrdlink+'</center>';
					html += '</TD><TD valign="top"><font class=xsmall>ID:' + displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html += '<DIV class=icons>';

					if (  ! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )	
					{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="lblink" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';
					if(gsession){html += '<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}

					html += '<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature )
						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class=iconlink title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a>';

					html += '</DIV>';
					
					if(showphotographer == 1){html +='<BR>&copy; '+currentYear+' ' + myphotographer;}
					html += '  <nobr>';
					if(showfilesize){html += myfilesize;}
					html += '</nobr><br/>CAPTION: ' + myshortcaption + '<div>'+myreleased+'</div></font>';


					html += '</TD></TR></TABLE></DIV></SPAN>';
				} else {	
			
	
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:305px; height:' + theight + 'px;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','list', myhrdlink);
                                        //html += myhrdlink + '<br/>' + myreleased + mysharestatuses;

					html += '</DIV></SPAN>';
				}
				
			
			} else if (viewmode == "tiny"){
				//adminheight += 8;

				var theight = (typeof(customtinyheight) !='undefined' ? customtinyheight : 100) + adminheight;
//				var theight = 100 + adminheight;
				if ( mysimilarto.length < 13){	
					
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:95px; height:' + theight + 'px; overflow: hidden;">';

                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;"';

					if(document.page.previews.selectedIndex == 1){html +=' TITLE="ID:' + displayid;
						if(showphotographer == 1){html += '\r&copy; ' + myphotographer;}
						if(showfilesize){html += '\rSIZE: '+ myfilesize ;}
						html +=  ' \r' + 'CAPTION: ' + myshortcaption + '"';
					}
					html += '><img src=http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + myid + '.JPG border=0 class=pimg vspace=1 hspace=1 height=55';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "', '" + showid + "','"+tset+"');";
					html += '" onmouseout="hp();" id=' + myid + '>';
					
					//sp('','" + myid + "','" + myrglobaldynf + "','" + myphotographer + "','" + myid + "','" + showid + "')
					html += '</a><BR>';
					html += '<DIV class=icons>';

					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )
					{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="iconlinktiny" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlinktiny" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';
					if(gsession){html += '&nbsp;<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlinktiny" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}

					html += '&nbsp;<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlinktiny" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature)
						html += '&nbsp;<a href="javascript: return false;" onclick="javascript: enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlinktiny" title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a>';

					html += '</DIV>';
					html += '<DIV class=imidxxsmall>' + displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html +='</DIV>';
					html += myhrdlink;
					html += '</DIV></SPAN>';

				} else {				
	
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:95px; height:' + theight + 'px; overflow:hidden;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','tiny');		
					html += myhrdlink;
					html += '</DIV></SPAN>';
				}
			
			
			} else if (viewmode == "med"){
				//adminheight += 4; // tweaking adminheight...
				var theight = (typeof(custommedheight) !='undefined' ? custommedheight : 120) + adminheight;
				if ( mysimilarto.length < 13){	
				
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:140px; height:' + theight + 'px; overflow: hidden;">';

                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;"';


					if(document.page.previews.selectedIndex == 1){html += ' TITLE="ID:' + displayid;
						if(showphotographer == 1){html += '  \r&copy; ' + myphotographer;}
						if(showfilesize){html += '\rSIZE: ' + myfilesize ;}
						html += ' \r' + 'CAPTION: ' + myshortcaption + '"';
					}
					html += '><img src=http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + myid + '.JPG border=0 vspace=1 class=pimg hspace=1 height=80';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "', '" + showid + "','"+tset+"');";
					html += '" onmouseout="hp();" id=' + myid + '>';
						//sp('','" + myid + "','" + myrglobaldynf + "','" + myphotographer + "','" + myid + "','" + showid + "')
					html += '</a><BR>';
					html += '<DIV class=icons>';

					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )
					{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="lblink" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';
					if(gsession){html += '<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}

					html += '<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature)
						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a>';

					html += '</DIV>';
					html += '<DIV class=imidxxsmall>' + displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html +='</DIV>';
					html += myhrdlink;
					
					

					html += '</DIV></SPAN>';

				} else {				
	
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:140px; height:' + theight + 'px;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','med');		
					if(myhrdlink)
						html += myhrdlink;
					html += '</DIV></SPAN>';
				}
			} else if (viewmode == "ss"){			
				html = '  ';
			} else if (viewmode == "huge"){		
				var theight = (typeof(customhugeheight) !='undefined' ? customhugeheight : 230) + adminheight;
//				var theight = 230 + adminheight;
				if ( mysimilarto.length < 13){	
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:330px; height:' + theight + 'px; overflow: hidden;">';

                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" TITLE="ID:' + displayid;

					if(showphotographer == 1){html += '\r&copy; ' + myphotographer;}
					if(showfilesize){html +=   '\rSIZE: ' + myfilesize ;}
					html += ' \r' + 'CAPTION: ' + myshortcaption + '"><img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/420/60/' + myid + '.JPG" border="0" vspace="1" hspace="3" alt="loading..." height="192"></a><BR>';
					html += '<DIV class=icons>';

					if ( ! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )
					{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="lblink" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox">LIGHTBOX+</a>';
					if(gsession){html += '<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}

					html += '<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature)
						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a> ';

					html += displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font> ';
					}
                                        html += '</DIV>'+ myhrdlink;

					html += '</DIV></SPAN>';
					
				} else {
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:330px; height:' + theight + 'px; overflow: hidden;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','huge', myhrdlink);
                                        html += myhrdlink;

					html += '</DIV></SPAN>';
				}				
			} else if (viewmode == "large"){
//				var theight =199 + adminheight;
				var theight = (typeof(customlargeheight) !='undefined' ? customlargeheight : 199) + adminheight;
				if ( mysimilarto.length < 13){		
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:187px; height:' + theight + 'px; overflow:hidden;">';
                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;"'

					if(document.page.previews.selectedIndex == 1){html += ' TITLE="ID:' + displayid;
						if(showphotographer == 1){html +=  '\r&copy; ' + myphotographer;}
						if(showfilesize){html += '\rSIZE: ' + myfilesize ;}
						html += ' \r' + 'CAPTION: ' + myshortcaption + '"';
					}
					html += '><img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/170/85/' + myid + '.JPG" class=pimg border="0" vspace="0" hspace="3"';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";
					html += '" onmouseout="hp();" id=' + myid + '>';
					
					html += '</a><BR>';
					html += '<DIV class=icons>';

					
					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )						{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="iconlink" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';
					if(gsession){html += '<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}
					html += '<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature )
						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a>&nbsp;';

					html += '</div><div><font class=imid>' + displayid + '</font>';
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html +='</DIV>';

                                        html += myhrdlink;

					html += '</DIV></SPAN>';
		
			
				} else {			
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:187px; height:' + theight + 'px; overflow: hidden;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','large');
                                        html += myhrdlink;

					html += '</DIV></SPAN>';
				}
			} else {
				var theight = (typeof(customtableheight) !='undefined' ? customtableheight : 166) + adminheight;
//				var theight = 166 + adminheight;
				if ( mysimilarto.length < 13){		
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:152px; height:' + theight + 'px; overflow:hidden;">';
                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript:return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;"'


					if(document.page.previews.selectedIndex == 1){html += ' TITLE="ID:' + displayid;
						if(showphotographer == 1){html +=  '\r&copy; ' + myphotographer;}
						if(showfilesize){html += '\rSIZE: ' + myfilesize ;}
						html += ' \r' + 'CAPTION: ' + myshortcaption + '"';
					}
					html += '><img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + myid + '.JPG" class=pimg border="0" vspace="0" hspace="3"';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";
					html += '" onmouseout="hp();" id=' + myid + '>';
					
					html += '</a><BR>';
					html += '<DIV class=icons>';

					
					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )						{
						html+='<A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="iconlink" TITLE="Remove this image from the lightbox">X</A>';
					}

					html += '<a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"><img src="/graphics/icon_lightbox.gif" border="0"/></a>';
					if(gsession){html += '<a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"><img src="/graphics/icon_cart.gif" border="0"/></a>';}
					html += '<a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"><img src="/graphics/icon_price.gif" border="0"/></a>';
					if (! thisisacoverimage_feature)
						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><img src="/graphics/icon_info.gif" border="0"/></a>&nbsp;';
					html += '</div><div><font class=imid>' + displayid + '</font>';
					if(typeof(suppressrmrftype) == 'undefined'){
						html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html +='</DIV>';
                                        html += myhrdlink;


					html += '</DIV></SPAN>';
		
			
				} else {			
					html += '<span valign=bottom style="float:left;">';
					html += '<div id="d' + myid + '" align=center valign=bottom style="width:152px; height:' + theight + 'px; overflow: hidden;">';
					html += writesimilar(myid,showid,myphotographer,myshortcaption,'start','normal');
                                        html += myhrdlink;

					html += '</DIV></SPAN>';
				}

			}
		}
	} 
	return html;
};





function buildpages(startnumber,endnumber,snum){
        suspendtrap=1;

        //builds pulldown menu for page numbers depending on pixperpage and total pagenumbers
        var thehtml= '<table width=350><tr><td valign="top" width=20 >';

	thehtml+= '<NOBR><FONT class=page>';

	//pagenumbers
	var showstartnumber = parseInt(startnumber) + parseInt(snum) + 1;
	var showendnumber = parseInt(endnumber) + parseInt(snum);

        //conditional previous page
        if(Number(currentpagenum) > 0){
                thehtml+='<td width=25 align=left><div id=siconprev><A href="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\';prevpage(); return false;"></A></div>&nbsp;';
        } else if (showstartnumber <= total){
                thehtml+='<td width=25 align=left><div id=siconprev><A href="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\';prevpage(); return false;"></A></div>&nbsp;';
                //thehtml+='<FONT style=\"font-family: Arial;color:#AAAAAA;\"><FONT style="9pt;">&#8592;</FONT> </FONT>&nbsp;';
	}

	if ( showstartnumber <= total )
	{
		thehtml+='<td width=75>PAGE&nbsp;<SELECT name="pageurl" align="absmiddle"  onChange="document.currentLayer1Mode=\'searchresults\'; self.location=this.options[this.selectedIndex].value; return false;" class="smallmenu">';
	
		totalpages=(  Math.ceil((snum)/( parseInt( $F('pixperpage') ))) +  Math.ceil( (total - snum) / ( parseInt( $F('pixperpage') )  ))) ;
		if(Number(currentpagenum) > 52){psn = (Number(currentpagenum) - 50);} else { psn = 1;}
	
		if((Number(totalpages) - Number(currentpagenum)) > 50){ pen = (Number(currentpagenum) + 50);} else {pen = totalpages;}
		if(psn >1 && currentpagenum != 0){
			thehtml+='<OPTION VALUE="' + nextlink + 'snum=' + ((psn - 2) * (parseInt(gpixperpagev))) + '">&lt; ' + (Number(psn) - 1) + '</option>';
		}
	
		for(i=psn;i <= pen;i++){
			if(i == (Number(currentpagenum) + 1)){
				thehtml+='<OPTION VALUE="' + nextlink + 'snum=' + ((i-1) * (parseInt(gpixperpagev))) + '" SELECTED>' + i + '</option>';
			} else {
				thehtml+='<OPTION VALUE="' + nextlink + 'snum=' + ((i-1) * (parseInt(gpixperpagev))) + '">' + i + '</option>';
			}
		}
	
		if(pen != totalpages){
			thehtml+='<OPTION VALUE="' + nextlink + 'snum=' + ((Number(pen)) * (parseInt(gpixperpagev))) + '">&gt; ' + (Number(pen) + 1) + '</option>';
		}

	
		thehtml+='</select>';
		if(grange != "outofrange"){
			thehtml+='&nbsp;<td width=20><div id=siconnext ><A HREF="" onclick="document.currentLayer1Mode=\'searchresults\';nextpage(); return false;"></A></div>';
		}
thehtml += '<td class="dark_tetra">&nbsp;&nbsp;(' + showstartnumber + '-';
		if (showendnumber > parseInt(total)){
			thehtml +=  total + ')&nbsp;of&nbsp;' + total;
		} else {
			thehtml += showendnumber + ')&nbsp;of&nbsp;' + total;
		}
		thehtml += '</NOBR>';

		thehtml += '</td><td align="right">';

		//linkback to feature:
		if (document.thisIsFeatureView)
		{
			thehtml += '<a href="/R?'+feat_requestview+'" style="color:#c00; font-size:10px"><nobr>View images from</nobr> <br/><nobr><b>All IPN Members</b></nobr></a>';
		}

	        if (typeof(shsync) == 'object' && shsync[0] && shsync[0] != '')
		{
			var lochtml = ' Set All: <a href="javascript: return false;" onclick="return share_set_page(\'shared\'); ">Accepted</a> | <a href="javascript: return false;" onclick="return share_set_page(\'rejected\'); ">Rejected</a> | <a href="javascript: return false;" onclick="return share_set_page(\'pending\'); ">Pending</a> ';
			$('Layerpreviews').innerHTML = lochtml;
		}
	}

	thehtml += '</td></tr></table>';

	$('Layerpages').style.overflow = 'visible';
        MM_setTextOfLayer('Layerpages','',thehtml);
        //suspendtrap=0;
        //setbackpagetrap(showstartnumber,snum,viewmode);

};


/*
function buildimages(startnumber,mode,resized){
	alert("test");
	if(typeof(cartview) != 'undefined' && cartview)
		return;

	if(typeof(id) == 'undefined')
		return;
//console.log('BI: '+winH);
	$('Layer1').style.height = winH +'px';

	document.currentLayer1Mode='searchresults';
	if(!MACIE5){var tshown = Element.getOpacity('coverlayer');}
	
	if(tshown > 0.2){
		hidedisplaypanel();
	}
        suspendcheck=1;
        //calculate how many images can be held on the page depending on mode being used
        if(startnumber > 1 || resized==1){setuppagesize();}

        //  build the page
	showstartnumber_trap = parseInt(startnumber);  //save for later
        var thehtml=optimize(); // + '<FORM name=activedisplay action=#>';
        grange="legal";
        MM_setTextOfLayer('Layer1','','<CENTER> <BR><BR><BR><BR><BR><BR><BR><BR>loading ...</CENTER>');
        var cnt=startnumber;
        //figureout current range of images to show
        firstpictureonpage=startnumber;
        endnumber = parseInt(gpixperpagev) + parseInt(startnumber);

        if (viewmode != "ss"){
                //loop through images in the array and build html
				if(pagetype=='lb' && (typeof(pre_q_args) != 'undefined' && ! ( pre_q_args.match(/lb_view=1/) || pre_q_args.match(/fn=/) || pre_q_args.match(/vmo=/) ) ) )
					thehtml += '&nbsp;&nbsp;<A href="javascript: return false;" onclick="viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); self.location=\'/SwishSearch'+pre_q_args+'\'; return false;"><img src="/graphics/up_arrow.gif" border="0" /> BACK TO SEARCH RESULTS</A><BR/><BR/>';

		while(cnt < endnumber) {
			if( id[cnt] ){
                                //thehtml += htmlit(cnt);
				if ( typeof(htmlit_custom) == 'function' )  {
					thehtml += htmlit_custom(cnt);
				}
				else
				{
					 thehtml += htmlit(cnt);
				}
			} else if((snum + cnt)>=total){
                                if (grange != "outofrange"){
                                        thehtml+='<span valign=bottom style="float:left;"><div align=center valign=bottom style="width:130; height:50px; overflow: hidden;">';

                                        if(pagetype=='lb'){
						thehtml+='<BR><nobr>&nbsp;[ end of lightbox images ]&nbsp;</nobr></DIV></SPAN> ';
                                        } else {
						thehtml+='<BR><nobr>&nbsp;[ end of search results ]&nbsp;</nobr></DIV></SPAN> ';
					}
                                }

                                grange="outofrange";

                        } else {
                                grange="illegalpage";   //check to see if page numbers are out of the legal range of images
                        }
                        cnt++;
               } 

		if (snum + cnt == total)
			grange = 'outofrange';  //basically we have exactly enough images, 
						//so we want to skip adding the nextlink and the [ end of results ] cell

               //conditions below are for going ahead or behind available imagenumber ranges
                if (grange == "illegalpage"){
                        if (mode == "next"){
                                self.location= nextlink + 'snum=' + (Number(firstpictureonpage) + Number(snum)); //figure out which should be first picture on next page
                                 MM_setTextOfLayer('Layer1','','<CENTER> <BR><BR><BR><BR><BR><BR><BR><BR>loading next set of images...</CENTER>');
                        } else {

                                // two ways to go with this code
                                // method a is one screen at a time
                                //prevtogoto = snum + startnumber;

                                // method b is two screens at a time
                                prevtogoto=Number(snum) + Number(startnumber) - parseInt($F('pixperpage')); // go back two pages from start page
                                //gsetCookie("gwhichstartpage",parseInt($F('pixperpage')), '', '/', gGetCookieDom());
                                // ensure no negative numbers
                                if(prevtogoto < 0 ){ prevtogoto=0;}
                                self.location=nextlink + 'snum=' + prevtogoto;

                        }

                } else {

                        //normal page ranges - add lower right next page link
			//thehtml+='</FORM>';
                        MM_setTextOfLayer('Layer1','',thehtml);

			if (shsync[0])
				setTimeout('init_share_radios()', 1);

                        var bottomthehtml= "<table style=\"position:absolute; z-index:999; top:-16px; right:4px;margin-top:10px; border-top:solid 2px #c2c8d6\" width=100% height=17 cellpadding=0 cellspacing=0 border=0 ><TR><TD align=left width=40%>";
                        if ((typeof(snum) != 'undefined' && Number(snum) > 1) || ( typeof(startnumber) != 'undefined' && Number(startnumber) > 1)){
                                bottomthehtml+= "<div id=iconprev><A HREF=javasc" + "ript:prevpage();></A></div></nobr>";
                        } else {
                                bottomthehtml+= "&nbsp;";
                        }

                        bottomthehtml+= "</TD><TD align=\"middle\"  width=10%><center><nobr>" + footer() + "</nobr></center></TD><TD width=40% align=right>";

                        if (grange != "outofrange"){
                                bottomthehtml+= "<nobr><div id=iconnext><A HREF='' onclick='nextpage(); return false;' name=bottomnext></A></div>&nbsp;&nbsp;</nobr></DIV>";
                                //reset the page numbersw

                        } 
                        bottomthehtml+= "</TD></TR></table>";
			$('pagingrow').innerHTML =  bottomthehtml;


                        // preload next page worth of images
                        lastimage=cnt;
                      	if($('pixperpage')){
				prestart = endnumber - 1;
				preend=(lastimage + parseInt($F('pixperpage')));
//console.log(prestart+ ' -> '+preend);
                       		if(startnumber==0){
					var delay=6000 + parseInt($F('pixperpage') * 30);
                       		         self.setTimeout("preloadnextpage()",delay);
                       		} else {
					var delay=1000;//delay just a bit to make several next page load requests have time to catch up
                       		         self.setTimeout("preloadnextpage()",delay);
                        	}
			}
                }
        } else {
                //ss mode
                enlarge2(id[0],0); // new page and slideshow mode
        }

	

        currentpagenum = Math.ceil(         (      Number(snum) + Number(startnumber)         ) /      parseInt($F('pixperpage'))            );
        buildpages(startnumber,endnumber,snum);
	iconstatus();
};
*/

function dispatchBuildimages(args) {

      var MacIE5 = global.macIE5;
	var startnumber = args['snum'];
	var mode = args['buildmode'];
	var resized = args['resized'];
	viewmode = args['viewmode'];
	$('Layer1').style.height = winH +'px';
	$('Layer1').style.overflow = 'hidden';


//LS20081106 moving this to lightbox_delete_image_enl function 
//to fix issue where search results number did not match Layerspage section
//	if ( $("nav_total_images") )
//		$("nav_total_images").innerHTML = id.length;

        if($('cdheader')){
		(typeof(dsplkys) != 'undefined' ? ( ( dsplkys.substring(0,6)=='BLDVCD' || dsplkys.match(/ZRFCD$/) ) ? $('cdheader').style.display = 'block' : $('cdheader').style.display = 'none')             : $('cdheader').style.display = 'block' );
	}

	document.currentLayer1Mode='searchresults';
	createCoverLayer();
	if(!MacIE5){var tshown = Element.getOpacity('coverlayer');}
	
	if(tshown > 0.2){
		hidedisplaypanel();
	}
        suspendcheck=1;
        //calculate how many images can be held on the page depending on mode being used
        if(startnumber > 1 || resized==1){setuppagesize();}

        //  build the page
	showstartnumber_trap = parseInt(startnumber);  //save for later
        var thehtml=optimize(); // + '<FORM name=activedisplay action=#>';
        grange="legal";
        MM_setTextOfLayer('Layer1','','<CENTER> <BR><BR><BR><BR><BR><BR><BR><BR>loading ...</CENTER>');
        var cnt=startnumber;
        //figureout current range of images to show
        firstpictureonpage=startnumber;
        endnumber = parseInt(gpixperpagev) + parseInt(startnumber);

        if (viewmode != "ss"){
                //loop through images in the array and build html
				if(pagetype=='lb' && (typeof(pre_q_args) != 'undefined' && ! ( pre_q_args.match(/lb_view=1/) || pre_q_args.match(/fn=/) || pre_q_args.match(/vmo=/) ) ) )
					thehtml += '&nbsp;&nbsp;<A href="javascript: return false;" onclick="viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); self.location=\'/SwishSearch'+pre_q_args+'\'; return false;"><FONT style="font-size:9pt; font-family:Arial;">&#8593;</font> BACK TO SEARCH RESULTS</A><BR/><BR/>';

		while(cnt < endnumber) {
			if( id[cnt] ){
				if ( typeof(htmlit_custom) == 'function' )  {
					thehtml += htmlit_custom(cnt);
				} else {
					 thehtml += htmlit(cnt);
				}
			} else if((snum + cnt)>=results_total){
                                if (grange != "outofrange"){
                                        thehtml+='<span valign=bottom style="float:left;"><div align=center valign=bottom style="width:130; height:50px; overflow: hidden;">';

                                        if(pagetype=='lb'){
						thehtml+='<div id="endbox" class="endoflightboximages"><nobr>[ end of lightbox images ]</div></nobr></DIV></SPAN> ';
                                        } else {
						thehtml+='<div id="endbox" class="endofsearchresults"><nobr>[ end of search results ]</div></nobr></DIV></SPAN> ';
					}
                                }

                                grange="outofrange";

                        } else {
                                grange="illegalpage";   //check to see if page numbers are out of the legal range of images
                        }
                        cnt++;
               } 

		if (snum + cnt == results_total)
			grange = 'outofrange';  //basically we have exactly enough images, 
						//so we want to skip adding the nextlink and the [ end of results ] cell

               //conditions below are for going ahead or behind available imagenumber ranges
                if (grange == "illegalpage"){
                        if (mode == "next"){
				var next_snum = ( Number(snum) + Number(startnumber) );
        			var section = $H({ showstart:1, snum:0, viewmode:viewmode, resized:resized }).toJSON();

                                self.location= nextlink + 'snum=' + next_snum + '#nav='+section; //figure out which should be first picture on next page
                                 MM_setTextOfLayer('Layer1','','<CENTER> <BR><BR><BR><BR><BR><BR><BR><BR>loading next set of images...</CENTER>');
                        } else {

                                // two ways to go with this code
                                // method a is one screen at a time
                                //prevtogoto = snum + startnumber;

                                // method b is two screens at a time
                                prevtogoto=Number(snum) + Number(startnumber) - parseInt($F('pixperpage')); // go back two pages from start page
                                //gsetCookie("gwhichstartpage",parseInt($F('pixperpage')), '', '/', gGetCookieDom());
                                // ensure no negative numbers
                                if(prevtogoto < 0 ){ prevtogoto=0;}
        			var section = $H({ showstart:1, snum:0, viewmode:viewmode, resized:resized }).toJSON();
                                self.location=nextlink + 'snum=' + prevtogoto + '#nav='+section;

                        }

                } else {

                        //normal page ranges - add lower right next page link
			//thehtml+='</FORM>';
                        MM_setTextOfLayer('Layer1','',thehtml);

			if (shsync[0])
				setTimeout('init_share_radios()', 1);

                        var bottomthehtml= "<table id=\"footerpaging\" style=\"position:absolute; z-index:999;\" width=100% height=17 cellpadding=0 cellspacing=0 border=0><TR><TD align=left width=40%>";
                        if ((typeof(snum) != 'undefined' && Number(snum) > 1) || ( typeof(startnumber) != 'undefined' && Number(startnumber) > 1)){
                                bottomthehtml+= "<nobr><div id=\"iconprev\"><A HREF=javasc" + "ript:prevpage();></A></div></nobr>";
                        } else {
                                bottomthehtml+= "&nbsp;";
                        }

                        bottomthehtml+= "</TD><TD align=\"middle\"  width=20%><center><nobr>" + footer() + "</nobr></center></TD><TD width=40% align=right>";

                        if (grange != "outofrange"){
                                bottomthehtml+= "<nobr><div id=\"iconnext\"><A HREF='javascript: return false;' onclick='nextpage(); return false;' name=bottomnext></A>&nbsp;&nbsp;</div></nobr>";
                                //reset the page numbersw

                        } 
                        bottomthehtml+= "</TD></TR></table>";
			$('pagingrow').innerHTML =  bottomthehtml;


                        // preload next page worth of images
                        lastimage=cnt;
                      	if($('pixperpage')){
				prestart = endnumber - 1;
				preend=(lastimage + parseInt($F('pixperpage')));
                       		if(startnumber==0){
					var delay=6000 + parseInt($F('pixperpage') * 30);
                       		         self.setTimeout("preloadnextpage()",delay);
                       		} else {
					var delay=1000;//delay just a bit to make several next page load requests have time to catch up
                       		         self.setTimeout("preloadnextpage()",delay);
                        	}
			}
                }
        } else {
                //ss mode
                enlarge2(id[0],0); // new page and slideshow mode
        }


        currentpagenum = Math.ceil(         (      Number(snum) + Number(startnumber)         ) /      parseInt($F('pixperpage'))            );
       	buildpages(startnumber,endnumber,snum);
	iconstatus();
 };

 function iconstatus(){
        if(viewmode){
                //clear them
                if($('iconlist')){$('iconlist').className='sizeiconblocks';}
                if($('iconbig')){$('iconbig').className='sizeiconblocks';}
                if($('icontiny')){$('icontiny').className='sizeiconblocks';}
                if($('iconmed')){$('iconmed').className='sizeiconblocks';}
                if($('iconhuge')){$('iconhuge').className='sizeiconblocks';}
                if($('iconlarge')){$('iconlarge').className='sizeiconblocks';}
                 //set it
                if(viewmode == 'table'){
                        if($('iconbig')){$('iconbig').className='iconbigactive';}
                 } else  if(viewmode == 'list'){
                        if($('iconlist')){$('iconlist').className='iconlistactive';}
                 } else  if (viewmode == 'tiny'){
                        if($('icontiny')){$('icontiny').className='icontinyactive';}
                 } else if (viewmode == 'med'){
                        if($('iconmed')){$('iconmed').className='iconmedactive';}
                 } else if (viewmode == 'huge'){
                        if($('iconhuge')){$('iconhuge').className='iconhugeactive';}
                 } else if (viewmode == 'large'){
                        if($('iconlarge')){$('iconlarge').className='iconlargeactive';}
                 }
         }
 };

//CALLBACK ACTion for enlarge2
 function enlarge2_act(enid,encount,featuredimage,preMem) {
	featuredimage = ( featuredimage == 'undefined' ? '' : featuredimage );
	debug('featuredimage',featuredimage);
	hp();//ensure closure the preview window
        var useInPage = 0;
        if ( id[encount] == document.JSONobj.getImgDat('id') || featuredimage.length==10)
                useInPage = 1;
	debug('useInPage',useInPage);

	if (useInPage || ( document.ajaxLoaded && (enid.match( document.JSONobj.getImgDat('id') )) ) )//made it
	{
		//wipe viewmode cookie:
		if(typeof(viewmode) != 'undefined' && viewmode == 'ss')
			gsetCookie("gcurrentview",'', '', '/', gGetCookieDom());


//		if( featuredimage || preMem == 'cartview' || ( useInPage && id[encount] )
//		{
                        if($('cdheader'))
                        	$('cdheader').style.display = 'none';


			//init
			if ( (! document.thisIsFeatureView && useInPage && st[encount] && st[encount].length > 13) || overflowtype == 'hidden' )
				suspendtrap=1;
			//gSetBackpage();		
			if(firstpictureonpage)
				gsetCookie("gwhichstartpage",firstpictureonpage, '', '/', gGetCookieDom());
	
			//set metatdata variables
			var myshortcaption;
			var testshortcaption = document.JSONobj.getImgDat('short_caption');
			testshortcaption = (	testshortcaption	?  testshortcaption : "n/a");
			var testlongcaption = document.JSONobj.getImgDat('long_caption');
			testlongcaption = (	testlongcaption	?  testlongcaption : "n/a");
			if ( typeof(uselongcaption) != 'undefined' && testlongcaption != "n/a" )
			{
				if ( uselongcaption == 'useboth' )
				{
					if ( testshortcaption == "n/a" ) //then just use long
					{
						myshortcaption = testshortcaption;
					}
					else //build switcher
					{
						myshortcaption = '<span id="enlarge_short_caption">'+testshortcaption+
							' <a href="javascript: return false;" onclick="$(\'enlarge_short_caption\').style.display=\'none\'; $(\'enlarge_long_caption\').style.display=\'inline\'; return false;">more&nbsp;&gt;&gt;</a></span><span style="display:none" id="enlarge_long_caption">'+testlongcaption+'  <a href="javascript: return false;" onclick="$(\'enlarge_long_caption\').style.display=\'none\'; $(\'enlarge_short_caption\').style.display=\'inline\'; return false;">&lt;&lt;&nbsp;less</a></span>'
					}
				}
				else
				{
					myshortcaption = testlongcaption;
				}

			}
			else
			{
				myshortcaption = testshortcaption;
			}


			var myrmrftype = document.JSONobj.getImgDat('rmrftype');
			//var myratetiers = document.JSONobj.getImgDat('rfcdimgpricing'); //this is currently preformatted list from templates, could
								//be extended in ajaxhandlers to return a data obj if we need 
								//more granular data
                        var myratetiers_data = document.JSONobj.getImgDat('tieredimgpricing'); //myratetiers is a data object now.. so build..
                        var myratetiers = enlarge2_act__generateTierRows(myratetiers_data,myrmrftype,enid,encount);


			var myphotographer	= document.JSONobj.getImgDat('photographer') +
					((document.JSONobj.getImgDat('agent_name') && document.JSONobj.getImgDat('agent_name') != '') ? '&nbsp;/&nbsp;'+document.JSONobj.getImgDat('agent_name') : '' );
			var myfilesize = (	document.JSONobj.getImgDat('file_size') < 5 ?
					'Scan on Demand'
						:
					document.JSONobj.getImgDat('file_size') + ' Mb');	
			var myreleased = document.JSONobj.getImgDat('released');
			var myrestrictions = document.JSONobj.getImgDat('image_restrictions');
			var mycompallow = document.JSONobj.getImgDat('comp_allow');
                        var mydimensions = ( typeof(showdimensions) != 'undefined' ? document.JSONobj.getImgDat('dimensions') : '');
                        if (mydimensions) //comes as <XVAL>x<YVAL>
                        {
                                var dimr = mydimensions.match(/^(\d+)x(\d+)$/);
                                if (typeof(dimr) == 'object')
                                        mydimensions = '<br/><b>Original Dimensions:</b>&nbsp;'+dimr[1]+'px&nbsp;x&nbsp;'+dimr[2]+'px';
                        }
	
			var nextimage = parseInt(encount) + 1;
			var nextimageid = id[nextimage];
			var previmage = parseInt(encount) - 1;
			var previmageid = id[previmage];
			
			//this ifblock becomes template var: themediainsert
			var themediainsert = '';
			if((! document.thisIsFeatureView) && useInPage && v[encount] && (v[encount] == 'H')){
				var temph= + enid.substring(0,2) + '/' + enid.substring(0,5) + '/' + enid;
				themediainsert += '<EMBED SRC="http://tools.cgibackgrounds.com/qtvideo/' + temph + '.MOV" WIDTH=420 HEIGHT=280></EMBED>';

			} else {
				var tarid = '0000000000';
				if(featuredimage){tarid = featuredimage;} else {tarid= enid;}
				debug('tarid',tarid);
				themediainsert += '<A HREF="" onclick="currentpage(); return false;">'
					+'<img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/'+
					( (typeof(localwatermark) != 'undefined' && ! pngsupport) ? 'wm' : '420' )
					+'/60/'+tarid+'.JPG" border=1 style="display:inline; clear:none;" id="'+tarid+'">'
					+( (typeof(localwatermark) != 'undefined' && pngsupport) ?
						'<img style="z-index: 300; position:absolute; left:0px; bottom:0px;" src="'+localwatermark+'" border="0" onload="fitMeTo(\''+tarid+'\', this)"/>'
						:
						'');
				themediainsert += '</A>';
			}
			
			//similarscolumn
			var similarscolumn = '';
			if(! document.thisIsFeatureView && useInPage && st[encount] && st[encount].length > 13){
				var simlist =st[encount];
				var simarray=simlist.split(" ");
				var temparray = simarray[1].split(",");
				if(temparray.length > 1){temparray=simarray[0] + ' ' + temparray.join(' ');simarray=temparray.split(' ');}
				var simcount =simarray.length;
				if(simcount>40){simheight=(70 - simcount/2)} else {simheight=70 - simcount;}

				var simcolinfo = '';				
				for(var i=0;i< simcount;i++){
					simcolinfo += '<span valign=bottom style="float:left;">'
								+'<a href="javasc' + 'ript:enlarge2(\'' + enid + '\'' + ',' + '\'' + encount + '\',\'' + simarray[i] + '\');" TITLE="ID:' + simarray[i];
					if(showphotographer == 1)
						simcolinfo += '  \r&copy; ' + myphotographer;
						
					simcolinfo += ' click image to view similar"><img src=http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + simarray[i] + '.JPG border=0 vspace=2 hspace=2 height=' + simheight + ' align=left></a></span>';
				}
				similarscolumn = Templates.enlarge2_act__similars.evaluate({simcolinfo: simcolinfo});
			}
			
			


			//this ifblock becomes var navbacklink
			//will become navenlargedlinks
			var navenlargedlinks = '';
			var navbacklink = '';
			    if (preMem == 'cartview')
			    {
				navbacklink = '<A HREF="javascript: return false;" onclick="document.currentLayer1Mode=\'cartview\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom());currentpage(); return false;"><img src="/graphics/up_arrow.gif" border="0" />BACK TO CART</A><BR><BR>';
			    }
			    else if (document.thisIsFeatureView)
			    {
				navbacklink = '<A HREF="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); self.location = self.location; return false;"><img src="/graphics/up_arrow.gif" border="0" /> BACK TO REQUEST RESULTS</A><BR><BR>';
			    }
			    else
			    {
				navbacklink = '<A HREF="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); currentpage(); return false; "><img src="/graphics/up_arrow.gif" border="0" /> BACK TO SEARCH RESULTS</A><BR><BR>';
			    }

			if ( useInPage )
			{
			    if(preMem != 'cartview')
			    {
				if((snum + encount) > 0){ navenlargedlinks+= '                                  <A HREF="" onclick="enlarge2(\'' + previmageid + '\',\'' + previmage + '\'); return false;" TITLE="GO TO THE PREVIOUS IMAGE"><img src="/graphics/left_arrow.gif" border="" style="margin-top:10px"/>PREV IMAGE </A>&nbsp;&nbsp;';}
				if((Number(snum) + Number(encount) + 1) < Number(results_total)){ navenlargedlinks+= '                                  <A HREF="" onclick="enlarge2(\'' + nextimageid + '\',\'' + nextimage + '\'); return false;" TITLE="GO TO THE NEXT IMAGE">NEXT IMAGE <img src="/graphics/right_arrow.gif" border="" style="margin-top:10px"/></A><BR>';}
			    }
			}

			var enlargetid = '';
			if(featuredimage){ enlargetid = featuredimage;} else { 	enlargetid = enid;}
			
			//will become downloadcomplink
			var downloadcomplink = '';
			if(preMem != 'cartview')
			{
				if(gsession && gusername && mycompallow == 'Y') { 
					downloadcomplink = '<a href="Javascr' + 'ipt:displayWindow(\'/comp_view.shtml?' + gusername + '/' + cs[encount] + '/' +
					enlargetid
					+ '.JPG\',\'600\',\'640\');"><img src="/graphics/icon_comp.gif" alt="" border="0"> DOWNLOAD COMP</a><BR><BR>';
				} else {
				if(gsession) {
					downloadcomplink = '<a href="Javascr' + 'ipt:displayWindow(\'/comp_view.shtml?guest/' + cs[encount] + '/' +
					enlargetid			
					+ '.JPG\',\'600\',\'640\');"><img src="/graphics/icon_comp.gif" alt="" border="0"> DOWNLOAD COMP</a><BR><BR>';
					}
				}
			}
	
			// META DATA FOR ENLARGED TARGET IMG:
	
			//will become: ratetierinfo
			var ratetierinfo = ( myratetiers ? '<BR/><div class="enlargeratetiers">' + myratetiers + '</div>' : '' );
			
			//becomes releaseinfo
			var releaseinfo = ( showrelease ? '<b>Release:</b> ' + myreleased + '<br>' : '' );
			
			//becomes photographerinfo
			var linked_photog = myphotographer;
			if(myphotographer.indexOf('/') > 0)
				linked_photog = linked_photog.substring(0, linked_photog.indexOf('/'));
			var photographerinfo = ( (myphotographer && showphotographer) ? '<b>Photographer:</b> <A href="/SwishSearch?Keywords=' + linked_photog + '&spec_idx=ne&method=photographer">' + myphotographer + '</a><br>' : '');
	
			//becomes filesizeinfo
			var filesizeinfo = ( (! featuredimage && showfilesize) ? '<b>File Size:</b> ' + myfilesize : '');
			
			//becomes restrictionsinfo
			var restrictionsinfo = (myrestrictions ? '<BR/><span style="color:#990000">'+myrestrictions+'</span>' : '');
			
			//becomes keywordinfo
			var keywordinfo = '';
			document.JSONobj.getKeywords().each(function (kwd){
				var relink = q_args;
				//e.g. Keywords=shot%20put+haspeople+NOT+imagehasrestrictions
				if(relink.match(/Keywords=[^\+\&]+\+/))
				{
					relink = relink.replace(/Keywords=[^\+]+\+/, 'Keywords='+kwd+'+');
				}
				else if (relink.match(/Keywords=[^\+\&]+\&/))
				{
					relink = relink.replace(/Keywords=[^\+\&]+\&/, 'Keywords='+kwd+'&');
				}
				else if (relink.match(/Keywords=[^\+\&]+$/))
				{
					relink = relink.replace(/Keywords=[^\+\&]+$/, 'Keywords='+kwd);
				}
				else //might be lightbox or request, but so no actual keywords, so append it directly
				{
					relink = relink.replace(/((rid|\&rid)|(vmo|\&vmo)|(lb_view|\&lb_view)|(cartview|\&cartview))=[^\&]+/, '');
					relink = 'Keywords='+kwd+'&'+relink;
					relink = relink.replace(/\&+/, '&');
				}
				relink = relink.replace('&spec_idx=ne', '');
				keywordinfo += '<a href="/SwishSearch?' + relink +'&spec_idx=ne">' + kwd + '</a>, ';
			});

			var displayenlargetid;
			if ( o[encount] ){displayenlargetid=o[encount];} else {displayenlargetid=enlargetid;}

			var dateshot = document.JSONobj.getImgDat('date_shot');
			var rfcdlinkslug = document.JSONobj.getImgDat('rfcdlink');
						
			var tdata = $H({enlargetid: enlargetid,
					rfcdlinkslug: rfcdlinkslug,
					dateshot: dateshot,
					keywordinfo: keywordinfo,
					displayenlargetid: displayenlargetid,
					restrictionsinfo: restrictionsinfo,
     					filesizeinfo: filesizeinfo,
	  				photographerinfo: photographerinfo,
       					releaseinfo: releaseinfo,
	    				ratetierinfo: ratetierinfo,
	 				downloadcomplink: downloadcomplink,
      					navenlargedlinks: navenlargedlinks,
	   				navbacklinks: navbacklink,
					similarscolumn: similarscolumn,
     					themediainsert: themediainsert,
	  				rmrftype: myrmrftype,
					myshortcaption: myshortcaption,
					dimensions: mydimensions
				});
			//write html for enlarge page
			$('Layer1').style.overflow = 'auto';
			MM_setTextOfLayer('Layer1','', Templates.enlarge2_act__body.evaluate(tdata));
			//auto-show keywords switch
			if(typeof(autoshowkeywords) != 'undefined'){
				setTimeout("popkeys2('enlarge_keywords','','enalarge_keywords_text');",500);
			}
			MM_preloadImages('http://gdynx.ipnstock.com/'+dynimagesname+'/420/60/' + nextimageid + '.JPG');
		} 
		else {
			//alert("This is the last image of the search results.");
			gsetCookie('gviewmode','ss', '', '/', gGetCookieDom());

			self.location= nextlink + 'snum=' + (Number(firstpictureonpage) + Number(snum)); //figure out which should be first picture on next page	
		}//end if id[enid]	
/*	}
	else if ( tryCtr < 10 ) 
	{
		tryCtr++;
		setTimeout("enlarge2_act('"+enid+"','"+encount+"','"+featuredimage+"', '"+tryCtr+"', 0, '"+preMem+"')", (500 + (10 * (tryCtr - 1))));
	}
	else // nothing loaded, pop the page w/ missing data..
	{
		enlarge2_act(enid,encount,featuredimage,tryCtr,1,preMem);
	}
*/	
 };




/*

//CALLBACK ACTion for enlarge2
function enlarge2_act(enid,encount,featuredimage,tryCtr,force, preMem) {
        featuredimage = ( featuredimage == 'undefined' ? '' : featuredimage );
        hp();//ensure closure the preview window
        if ( document.ajaxLoaded && (enid.match( document.JSONobj.getImgDat('id') )) || force ) //made it
        {
                //wipe viewmode cookie:
                if(typeof(viewmode) != 'undefined' && viewmode == 'ss')
                        gsetCookie("gcurrentview",'', '', '/', gGetCookieDom());

                if( featuredimage || preMem == 'cartview' || id[encount] )
                {
                        if($('cdheader'))
                                $('cdheader').style.display = 'none';

                        //var tstart = jotTime();

                        //init
                        if ( (! document.thisIsFeatureView && st[encount] && st[encount].length > 13) || overflowtype == 'hidden' )
                                suspendtrap=1;
                        gSetBackpage();
                        if(firstpictureonpage)
                                gsetCookie("gwhichstartpage",firstpictureonpage, '', '/', gGetCookieDom());

                        //set metatdata variables
                        var myshortcaption;
                        var testshortcaption = document.JSONobj.getImgDat('short_caption');
                        testshortcaption = (    testshortcaption        ?  testshortcaption : "n/a");
                        var testlongcaption = document.JSONobj.getImgDat('long_caption');
                        testlongcaption = (     testlongcaption ?  testlongcaption : "n/a");
                        if ( typeof(uselongcaption) != 'undefined' && testlongcaption != "n/a" )
                        {
                                if ( uselongcaption == 'useboth' )
                                {
                                        if ( testshortcaption == "n/a" ) //then just use long
                                        {
                                                myshortcaption = testshortcaption;
                                        }
                                        else //build switcher
                                        {
                                                myshortcaption = '<span id="enlarge_short_caption">'+testshortcaption+
                                                        ' <a href="javascript: return false;" onclick="$(\'enlarge_short_caption\').style.display=\'none\'; $(\'enlarge_long_caption\').style.display=\'inline\'; return false;">more&nbsp;&gt;&gt;</a></span><span style="display:none" id="enlarge_long_caption">'+testlongcaption+'  <a href="javascript: return false;" onclick="$(\'enlarge_long_caption\').style.display=\'none\'; $(\'enlarge_short_caption\').style.display=\'inline\'; return false;">&lt;&lt;&nbsp;less</a></span>'
                                        }
                                }
                                else
                                {
                                        myshortcaption = testlongcaption;
                                }

                        }
                        else
                        {
                                myshortcaption = testshortcaption;
                        }

                        var myrmrftype = document.JSONobj.getImgDat('rmrftype');
                        var myratetiers = document.JSONobj.getImgDat('rfcdimgpricing'); //this is currently preformatted list from templates, could
                                                                //be extended in ajaxhandlers to return a data obj if we need
                                                                //more granular data

                        var myphotographer      = document.JSONobj.getImgDat('photographer') +
                                        ((document.JSONobj.getImgDat('agent_name') && document.JSONobj.getImgDat('agent_name') != '') ? '&nbsp;/&nbsp;'+document.JSONobj.getImgDat('agent_name') : '' );
                        var myfilesize = (      document.JSONobj.getImgDat('file_size') < 5 ?
                                        'Scan on Demand'
                                                :
                                        document.JSONobj.getImgDat('file_size') + ' Mb');
                        var myreleased = document.JSONobj.getImgDat('released');
                        var myrestrictions = document.JSONobj.getImgDat('image_restrictions');
                        var mycompallow = document.JSONobj.getImgDat('comp_allow');
                        var mydimensions = ( typeof(showdimensions) != 'undefined' ? document.JSONobj.getImgDat('dimensions') : '');
                        if (mydimensions) //comes as <XVAL>x<YVAL>
                        {
                                var dimr = mydimensions.match(/^(\d+)x(\d+)$/);
                                if (typeof(dimr) == 'object')
                                        mydimensions = '<br/><b>Original Dimensions:</b>&nbsp;'+dimr[1]+'px&nbsp;x&nbsp;'+dimr[2]+'px';
                        }

                        var nextimage = parseInt(encount) + 1;
                        var nextimageid = id[nextimage];
                        var previmage = parseInt(encount) - 1;
                        var previmageid = id[previmage];

                        //this ifblock becomes template var: themediainsert
                        var themediainsert = '';
                        if((! document.thisIsFeatureView) && v[encount] && (v[encount] == 'H')){
                                var temph= + enid.substring(0,2) + '/' + enid.substring(0,5) + '/' + enid;
                                themediainsert += '<EMBED SRC="http://tools.cgibackgrounds.com/qtvideo/' + temph + '.MOV" WIDTH=420 HEIGHT=280></EMBED>';

                        } else {
                                var tarid = '0000000000';
                                if(featuredimage){tarid = featuredimage;} else {tarid= enid;}
                                themediainsert += '<A HREF="" onclick="currentpage(); return false;">'
                                        +'<img src="http://globaldyn.ipnstock.com/'+dynimagesname+'/'+
                                        ( (typeof(localwatermark) != 'undefined' && ! pngsupport) ? 'wm' : '420' )
                                        +'/60/'+tarid+'.JPG" border=1 style="display:inline; clear:none;" id="'+tarid+'">'
                                        +( (typeof(localwatermark) != 'undefined' && pngsupport) ?
                                                '<img style="z-index: 300; position:absolute; left:0px; bottom:0px;" src="'+localwatermark+'" border="0" onload="fitMeTo(\''+tarid+'\', this)"/>'
                                                :
                                                '');
                                themediainsert += '</A>';
                        }
              //similarscolumn
                        var similarscolumn = '';
                        if(! document.thisIsFeatureView && st[encount] && st[encount].length > 13){
                                var simlist =st[encount];
                                var simarray=simlist.split(" ");
                                var temparray = simarray[1].split(",");
                                if(temparray.length > 1){temparray=simarray[0] + ' ' + temparray.join(' ');simarray=temparray.split(' ');}
                                var simcount =simarray.length;
                                if(simcount>40){simheight=(70 - simcount/2)} else {simheight=70 - simcount;}

                                var simcolinfo = '';
                                for(var i=0;i< simcount;i++){
                                        simcolinfo += '<span valign=bottom style="float:left;">'
                                                                +'<a href="javasc' + 'ript:enlarge2(\'' + enid + '\'' + ',' + '\'' + encount + '\',\'' + simarray[i] + '\');" TITLE="ID:' + simarray[i];
                                        if(showphotographer == 1)
                                                simcolinfo += '  \r&copy; ' + myphotographer;

                                        simcolinfo += ' click image to view similar"><img src=http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/' + simarray[i] + '.JPG border=0 vspace=2 hspace=2 height=' + simheight + ' align=left></a></span>';
                                }
                                similarscolumn = Templates.enlarge2_act__similars.evaluate({simcolinfo: simcolinfo});
                        }

                        //this ifblock becomes var navbacklink
                        var navbacklink = '';
                        if (preMem == 'cartview')
                        {
                                navbacklink = '<A HREF="" onclick="document.currentLayer1Mode=\'cartview\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom());currentpage(); return false;"><img src="/graphics/up_arrow.gif" border="0" /> BACK TO CART</A><BR><BR>';
                        }
                        else if (document.thisIsFeatureView)
                        {
                                navbacklink = '<A HREF="" onclick="document.currentLayer1Mode=\'searchresults\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); self.location = self.location; return false;"><img src="/graphics/up_arrow.gif" border="0" /> BACK TO REQUEST RESULTS</A><BR><BR>';
                        }
                        else
                        {
                                navbacklink = '<A HREF="" onclick="document.currentLayer1Mode=\'searchresults\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); currentpage(); return false; "><img src="/graphics/up_arrow.gif" border="0" /> BACK TO SEARCH RESULTS</A><BR><BR>';
                        }
                        //will become navenlargedlinks
                        var navenlargedlinks = '';
                        if(preMem != 'cartview')
                        {
                                if((snum + encount) > 0){ navenlargedlinks= '                                  <A HREF="" onclick="enlarge2(\'' + previmageid + '\',\'' + previmage + '\'); return false;" TITLE="GO TO THE PREVIOUS IMAGE"><FONT style="font-size:9pt; font-family: Arial;">&#8592;</FONT> PREV IMAGE </A>&nbsp;&nbsp;';}
                                if((Number(snum) + Number(encount) + 1) < Number(total)){ navenlargedlinks= '                                  <A HREF="" onclick="enlarge2(\'' + nextimageid + '\',\'' + nextimage + '\'); return false;" TITLE="GO TO THE NEXT IMAGE">NEXT IMAGE <img src="/graphics/right_arrow.gif" border="" style="margin-top:10px"/></A><BR>';}
                        }

                        var enlargetid = '';
                        if(featuredimage){ enlargetid = featuredimage;} else {  enlargetid = enid;}

                        //will become downloadcomplink
                        var downloadcomplink = '';
                        if(preMem != 'cartview')
                        {
                                if(gsession && gusername && mycompallow == 'Y') {
                                        downloadcomplink = '<a href="Javascr' + 'ipt:displayWindow(\'/comp_view.shtml?' + gusername + '/' + cs[encount] + '/' +
                                        enlargetid
                                        + '.JPG\',\'600\',\'640\');"><img src="/graphics/icon_comp.gif" alt="" border="0"> DOWNLOAD COMP</a><BR><BR>';
                                } else {
                                if(gsession) {
                                        downloadcomplink = '<a href="Javascr' + 'ipt:displayWindow(\'/comp_view.shtml?guest/' + cs[encount] + '/' +
                                        enlargetid
                                        + '.JPG\',\'600\',\'640\');"><img src="/graphics/icon_comp.gif" alt="" border="0"> DOWNLOAD COMP</a><BR><BR>';
                                        }
                                }
                        }

                        // META DATA FOR ENLARGED TARGET IMG:
                        //will become: ratetierinfo
                        var ratetierinfo = ( myratetiers ? '<BR/><div class="enlargeratetiers" style="width:150px;color:#C01920;">' + myratetiers + '</div>' : '' );

                        //becomes releaseinfo
                        var releaseinfo = ( showrelease ? '<b>Release:</b> ' + myreleased + '<br>' : '' );

                        //becomes photographerinfo
                        var linked_photog = myphotographer;
                        if(myphotographer.indexOf('/') > 0)
                                linked_photog = linked_photog.substring(0, linked_photog.indexOf('/'));
                        var photographerinfo = ( (myphotographer && showphotographer) ? '<b>Photographer:</b> <A href="/SwishSearch?Keywords=' + linked_photog + '&spec_idx=ne">' + myphotographer + '</a><br>' : '');

                        //becomes filesizeinfo
                        var filesizeinfo = ( (! featuredimage && showfilesize) ? '<b>File Size:</b> ' + myfilesize : '');

                        //becomes restrictionsinfo
                        var restrictionsinfo = (myrestrictions ? '<BR/><span style="color:#990000">'+myrestrictions+'</span>' : '');

                        //becomes keywordinfo
                        var keywordinfo = '';
                        document.JSONobj.getKeywords().each(function (kwd){
                                var relink = q_args;
                                //e.g. Keywords=shot%20put+haspeople+NOT+imagehasrestrictions
                                if(relink.match(/Keywords=[^\+\&]+\+/))
                                {
                                        relink = relink.replace(/Keywords=[^\+]+\+/, 'Keywords='+kwd+'+');
                                }
                                else if (relink.match(/Keywords=[^\+\&]+\&/))
                                {
                                        relink = relink.replace(/Keywords=[^\+\&]+\&/, 'Keywords='+kwd+'&');
                                }
                                else if (relink.match(/Keywords=[^\+\&]+$/))
                                {
                                        relink = relink.replace(/Keywords=[^\+\&]+$/, 'Keywords='+kwd);
                                }
                                else //might be lightbox or request, but so no actual keywords, so append it directly
                                {
                                        relink = relink.replace(/((rid|\&rid)|(vmo|\&vmo)|(lb_view|\&lb_view)|(cartview|\&cartview))=[^\&]+/, '');
                                        relink = 'Keywords='+kwd+'&'+relink;
                                        relink = relink.replace(/\&+/, '&');
                                }
                                relink = relink.replace('&spec_idx=ne', '');
                                keywordinfo += '<a href="/SwishSearch?' + relink +'&spec_idx=ne">' + kwd + '</a>, ';
                        });

                        var displayenlargetid;
                        if ( o[encount] ){displayenlargetid=o[encount];} else {displayenlargetid=enlargetid;}

                        var dateshot = document.JSONobj.getImgDat('date_shot');

                        var tdata = $H({enlargetid: enlargetid,
                                        dateshot: dateshot,
                                        keywordinfo: keywordinfo,
                                        displayenlargetid: displayenlargetid,
                                        restrictionsinfo: restrictionsinfo,
                                        filesizeinfo: filesizeinfo,
                                        photographerinfo: photographerinfo,
                                        releaseinfo: releaseinfo,
                                        ratetierinfo: ratetierinfo,
                                        downloadcomplink: downloadcomplink,
                                        navenlargedlinks: navenlargedlinks,
                                        navbacklinks: navbacklink,
                                        similarscolumn: similarscolumn,
                                        themediainsert: themediainsert,
                                        rmrftype: myrmrftype,
                                        myshortcaption: myshortcaption,
                                        dimensions: mydimensions
                                });
                        //write html for enlarge page
                        $('Layer1').style.overflow = 'auto';
                        MM_setTextOfLayer('Layer1','', Templates.enlarge2_act__body.evaluate(tdata));
                        MM_preloadImages('http://globaldyn.ipnstock.com/'+dynimagesname+'/420/60/' + nextimageid + '.JPG');
                        //suspendtrap=0;
                        //setbackpagetrap('ss',firstpictureonpage,'ss');

                        //var tend = jotTime();
                        //$('debugDiv').innerHTML = 'ENLARGE: '+( tend - tstart )+' MS <br/>' + $('debugDiv').innerHTML;
                }
                else {
                        //alert("This is the last image of the search results.");
                        gsetCookie('gviewmode','ss', '', '/', gGetCookieDom());

                        self.location= nextlink + 'snum=' + (Number(firstpictureonpage) + Number(snum)); //figure out which should be first picture on next page
                }//end if id[enid]
        }
        else if ( tryCtr < 10 )
        {
                tryCtr++;
                setTimeout("enlarge2_act('"+enid+"','"+encount+"','"+featuredimage+"', '"+tryCtr+"', 0, '"+preMem+"')", (500 + (10 * (tryCtr - 1))));
        }
        else // nothing loaded, pop the page w/ missing data..
        {
                enlarge2_act(enid,encount,featuredimage,tryCtr,1,preMem);
        }

};

*/

