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

var Templates = $H({});		

Templates.lightbox_new__body = new Template(
        '<div>'
        +'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="left" width="320" height="200" id="lightboxPopUp"><TR>'
        +'<td class="dark1" valign=bottom><DIV class="barheader">&nbsp;<FONT class="bartitle">Make a new lightbox</font></DIV></td></tr>'
        +'<tr><TD ALIGN="left" VALIGN="top" class="light1"><DIV class="light1" style="width:290px;margin: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="" onclick="lightbox_new_send(); return false;" class=lblink style="font-size: inherit; 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="350" height="280" class="dark1" id="emaillb_table"><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="light1"><DIV class="light1" style="margin: 15px;width:390px"><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/>'
        +'<B>4.</B> <input type="checkbox" name="notify" id="notify" value="1"><font class="small">Notify me when this lightbox is viewed</font>'
        +'#{emaillbaddhtml}<p><A href="" onclick="lightbox_email_send(); return false;" class=lblink style="font-size:inherit ;font-weight:bold;">Send the Lightbox</A>'
        +'<input type="hidden" name="ot" value="2"><input type="hidden" name="dsm" value="1"></center></form><p>If you have changed your mind, click <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="280" id="renamelb_table"><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="light1"><DIV class="light1" style="margin: 15px;width:290px"><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="" onclick="lightbox_rename_send(); return false;" class=lblink style="font-size: inherit; 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; height:100px; 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} #{dimensions} :: #{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="450" height="440" style="min-width: 440px">'
					+'<div style="position:relative;margin-left: 14px;margin-top: 5px;">#{themediainsert}</div>'
				+'<br/></td>'


				+'#{similarscolumn}'
				+'<TD align="left" valign="top" width="320"><BR>'
					+'#{navbacklinks}'
					+'#{navenlargedlinks}'
					+'<br/><a href="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;">Add to Current Lightbox </a>'
					+'<br/><a href="" onclick="license(\'#{enlargetid}\'); return false;">Check Usage Rates</a>'
					+'<br/><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;">Add to Cart</a>'
					+'<br/>#{downloadcomplink}'
					+'#{ratetierinfo}'
                                        +'<div class="enlarged_field" id="enlarged_field_id"><div class="enlarged_field_title" id=enlarged_field_title_id>Image Number:</div><div class="enlarged_field_value">#{displayenlargetid}&nbsp;[#{rmrftype}]</div></div>'
                                        +'#{dateshot_string}'
                                        +'<div class="enlarged_field" id="enlarged_field_caption"><div class="enlarged_field_title" id=enlarged_field_title_caption>Caption:</div>#{myshortcaption}</div>'
                                        +'#{release_string}'
                                        +'#{photographerinfo_string}'
                                        +'#{filesize_string}'
                                        +'#{dimensions_string}'
                                        +'#{restrictions_string}'
                                        +'<div class="enlarged_field"><A class="olink" id="enalarge_keywords_text" onclick="popkeys2(\'enlarge_keywords\', this); return false;">Show keywords</A></div>'
                                        +'<div id="enlarge_keywords" style="display:none; overflow-y:auto;">'
                                        +'#{keywordinfo}'
                                        +'</div>'
				+'</td></TR></table>'
	+'<BR></td></TR></table>'
);
*/


Templates.enlarge2_act__body = new Template (
        '<table cellspacing="0" cellpadding="0" border="0" width="99%" style="overflow:auto">'
                +'<TR >'
                        +'<TD align="left" valign="top" width="99%" style="overflow:auto;padding-left:6px;">'
                                +'<table cellspacing="4" cellpadding="0" border="0" width="100%" >'
                                +'      <TR><TD valign="top" align="left" width="420" height="440" style="min-width: 440px">'
                                        +'<div style="position:relative">#{themediainsert}</div>'
                                +'<br/></td>'
                                +'#{similarscolumn}'
                                +'              <TD align="left" valign="top" style="min-width:350px;width:370px;border-left: 1px solid #bbbbbb;" width="600"><div style="padding-left: 15px;">'
                                        +'#{navbacklinks}'
                                        +'#{navenlargedlinks}'
                                        +'<br/><br/>&nbsp;<div id="iconprice"> <a href="" onclick="license(\'#{enlargetid}\'); return false;">&nbsp;</a></div><div style="float:left"><a href="" onclick="license(\'#{enlargetid}\'); return false;">&nbsp;CHECK USAGE RATES</a></div>'
                                        +'<div id="iconlb" style="clear:both"><a href="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;"></a></div><div style="float:left"><a href="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;">&nbsp;ADD TO CURRENT LIGHTBOX</a></div>'
                                        +'<div id="iconcart" style="clear:both"><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;"></a></div><div style="float:left"><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;">&nbsp;ADD TO SHOPPING CART</a></div>'
                                        +'<div style="clear:both"><div style="float:left;width:25px">&nbsp;</div>#{downloadcomplink}</div>'
                                        +'<div class="enlarged_field" id="enlarged_field_id"><div class="enlarged_field_title" id=enlarged_field_title_id>Image Number:</div><div class="enlarged_field_value">#{displayenlargetid}&nbsp;[#{rmrftype}]</div></div>'
                                        +'#{dateshot_string}'
                                        +'<div class="enlarged_field" id="enlarged_field_caption"><div class="enlarged_field_title" id=enlarged_field_title_caption>Caption:</div>#{myshortcaption}</div>'
                                        +'#{release_string}'
                                        +'#{photographerinfo}'
                                        +'#{filesize_string}'
                                        +'#{dimensions_string}'
                                        +'#{restrictions_string}'
                                        +'<div class="enlarged_field"><A class="olink" id="enalarge_keywords_text" onclick="popkeys2(\'enlarge_keywords\', this); return false;">Show keywords</A></div>'
                                        +'<div id="enlarge_keywords" style="display:none; overflow-y:auto;">'
                                        +'#{keywordinfo}'
                                        +'</div></div>'
 +'</td><TD rowspan=2 align="left" valign="top" style="border-left: 1px solid #bbbbbb; padding-left:15px">'
                                        +'#{ratetierinfo}'
                                +'</TD></TR>'
+'<tr><td>#{rfcdlinkslug}</td></tr>'
                                +'</table>'
        +'<BR></td></TR></table>'
);



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

Templates.footer__body = new Template (
	'<DIV id="copyright"><span class="disclaimer"><A href="/aboutus_mission.shtml" onmouseover="hovercopyright();" class="disclaimer">&copy; #{currentyear} </A></span></DIV>'
);
Templates.tieredimgpricing__rfslug = new Template (
        '<h4 style="text-align: left;" class=RFselectfilesize>Select a File Size</h4>'+
        '<table style="text-align: left;width: 95%;" cellpadding=0 cellspacing=0 id=rfselectfilesizetable>#{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;" id=rfselectfilesizetabletdexpr>#{expr}</td>'+
        '<td align="right" valign=top style="border-bottom: solid #999 1px;padding-bottom: 4px; padding-top: 4px;" id=rfselectfilesizetabletdcurrency>#{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;"' +
        ' id=rfselectfilesizetabletdaddtocart>Add to Cart</a></nobr></td></tr>' 
);


function htmlit_custom(showid){

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

		if (! relcon[showid])
			myreleased = rel[showid];

		if (typeof(relcon) != 'undefined' && relcon[showid] && mysimilarto.length < 13) {  //share control style..
			var shortrel = myreleased; ///( $('gRelease'+showid) && $('gRelease'+showid).value ) ? $('gRelease'+showid).value : 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){
                        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';
                                }
                                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="'+iconclass+'">';

                                        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><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a></NOBR>';
                                        html += '<br/><div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';

                                        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 = 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=280 cellspacing=2 cellpadding=0 border=0><TR><TD valign=top align="middle">';

                                        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 += '<br/><center><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a></center>';
					html += '</TD><TD valign="top"><font class=xsmall style="margin-left:10px">ID:' + displayid+'<br>';
					html += '<DIV class="'+iconclass+'" style="float:left;margin-left:0px;text-align:left">';


					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"></a></div>';}

					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
					//if (! thisisacoverimage_feature )
					//	html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class=iconlink title="Enlarge image and more info"><font class=eye>i</font></a>';

					if(typeof(suppressrmrftype) == 'undefined'){
                                        	html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
                                        }
					  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+='<br/><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 += '</DIV>';
					showphotographer = 1;
					html += '<div style="float:left;text-align:left;margin-left:10px">  ';
					if(showphotographer == 1){html +='&copy; '+currentYear+'<br/> ' + myphotographer;}
					if(showfilesize){html += "&nbsp;"+myfilesize;}
					html += '<br/>CAPTION: ' + myshortcaption + '<br/>'+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, myreleased);
                                        //html += myhrdlink + '<br/>' + myreleased + mysharestatuses;

					html += '</DIV></SPAN>';
				}
				
			
			} else if (viewmode == "tiny"){
				//adminheight += 8;
				var theight = 110 + 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 += '<font class="xxsmall"><DIV class="'+iconclass+'">';



					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlinktiny" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlinktiny" title="Add this image to your shopping cart"></a></div>';}

					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlinktiny" Title="Price Image"></a></div>';
				//	if (! thisisacoverimage_feature)
				//		html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlinktiny" title="Enlarge image and more info"><font class=eye>i</font></a>';

					/*  if(typeof(gusert) != 'undefined' && gusert =='IPN'){
						html += '<A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?good=1&id=' + myid + '&q=' + dsplkys + '\'); return false;"><IMG src=/graphics/rating_enhance.gif width=18 height=12 border=0 style="margin-bottom: -3px;"></a><A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?bad=1&id=' + myid + '&q=' + dsplkys + '\'); return false;"><IMG src=/graphics/rating_discourage.gif width=18 border=0 height=12 style="margin-bottom: -3px;"></a>';
					}  */

					if(typeof(suppressrmrftype) == 'undefined'){
					html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
					}
					html += '</DIV></font>';
					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 += '<DIV class=imidxsmall style="clear:both;height:10px;padding:0px">' + displayid;

					if (myhrdlink)
						html += '<br/><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';
					html +='</DIV>';
					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',myhrdlink,myreleased);		
					html += '</DIV></SPAN>';
				}
			
			
			} else if (viewmode == "med"){
				//adminheight += 4; // tweaking adminheight...
				var theight = 130 + 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 += '<font class="xsmall"><DIV class="'+iconclass+'">';


					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"></a></div>';}

					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
				//	if (! thisisacoverimage_feature)
				//		html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><font class=eye>i</font></a>';

					if(typeof(suppressrmrftype) == 'undefined'){
                                       	 	html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
                                        }
					if(typeof(gusert) != 'undefined' && gusert =='IPN'){
						html += '<A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?good=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_enhance.gif width=18 height=12 border=0 style="margin-bottom: -3px;"></a><A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?bad=1&id=' + myid + '&q=' + dsplkys + '\', getpost); return false;"><IMG src=/graphics/rating_discourage.gif width=18 border=0 height=12 style="margin-bottom: -3px;"></a>';
					}

					  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+='<br/><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 += '</DIV></font>';


					html += '<DIV class=imidxxsmall style="clear:both;height:10px;padding:0px">' + displayid;
					if (myhrdlink)
						html += '<br/><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';
					
					
					html +='</DIV>';

					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',myhrdlink,myreleased);		
					html += '</DIV></SPAN>';
				}
			} else if (viewmode == "ss"){			
				html = '  ';
			} else if (viewmode == "huge"){		
				var theight = 240 + 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 += '<font class="xsmall"><DIV class="'+iconclass+'">';

					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"></a</div>';}

					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
//					if (! thisisacoverimage_feature)
//						html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><font class=eye>i</font></a> ';

                                        if(typeof(suppressrmrftype) == 'undefined'){
                                                html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
                                        }
					if(typeof(gusert) != 'undefined' && gusert =='IPN'){
						html += '<A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?good=1&id=' + myid + '&q=' + dsplkys + '\', getpost); return false;"><IMG src=/graphics/rating_enhance.gif width=18 height=12 border=0 style="margin-bottom: -3px;"></a><A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?bad=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_discourage.gif width=18 border=0 height=12 style="margin-bottom: -3px;"></a>';
					}
					    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+='<br/><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 += '</DIV>';

                                        html += '<DIV style="clear:both;height:10px;padding:0px">' + displayid;


					if (myhrdlink)
						html += '<br/><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';

	                                html += '</DIV>';
					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, myreleased);

					html += '</DIV></SPAN>';
				}				
			} else if (viewmode == "large"){
				var theight = 219 + 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+'/140/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 += '<font class="xsmall"><DIV class="'+iconclass+'">';

					

					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"></a></div>';}
					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
			//		if (! thisisacoverimage_feature )
			//			html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><font class=eye>i</font></a>&nbsp;';

					if(typeof(suppressrmrftype) == 'undefined'){
                                                html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
                                        }
					if(typeof(gusert) != 'undefined' && gusert =='IPN'){
						html += '<A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?good=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_enhance.gif width=18 height=12 border=0 style="margin-bottom: -3px;"></a><A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?bad=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_discourage.gif width=18 border=0 height=12 style="margin-bottom: -3px;"></a>';
					}
					          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 += '</DIV></font>';

                                        html += '<DIV class=imid style="clear:both;height:10px;padding:0px">' + displayid;


					if (myhrdlink)
	                                        html += '<br/><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';

					html += '</DIV>';
					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', myhrdlink, myreleased);

					html += '</DIV></SPAN>';
				}
			} else {
				var theight = 196 + 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 += '<font class="xsmall"><DIV class="'+iconclass+'">';

					

					html += '<div id="iconlb"><a href="javascript: return false;" ONCLICK="lightbox_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add to your current lightbox"></a></div>';
					if(gsession){html += '<div id="iconcart"><a href="javascript: return false;" ONCLICK="cart_addto(\'' + myid + '\'); return false;" class="iconlink" title="Add this image to your shopping cart"></a></div>';}
					html += '<div id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
				//	if (! thisisacoverimage_feature)
				//		html += '<a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"><font class=eye>i</font></a>&nbsp;';

					 if(typeof(suppressrmrftype) == 'undefined'){
                                                html += '<DIV id="icon'+rm[showid]+'"><a href="javascript: return false;"></a></div>';
                                        }
					if(typeof(gusert) != 'undefined' && gusert =='IPN'){
						html += '<A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?good=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_enhance.gif width=18 height=12 border=0 style="margin-bottom: -3px;"></a><A href="javascript: return false;" onclick="ajax_TEXT(\'/bin/KeywordAdjust?bad=1&id=' + myid + '&q=' + dsplkys + '\',getpost); return false;"><IMG src=/graphics/rating_discourage.gif width=18 border=0 height=12 style="margin-bottom: -3px;"></a>';
					}
				
					    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 += '</DIV></font>';

                                        html += '<DIV class=imid style="clear:both;height:10px;padding:0px">' + displayid;

 
					if (myhrdlink)
	                                        html += '<br/><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';

					html += '</DIV>';
					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', myhrdlink, myreleased);

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

			}
		}
	} 
	return html;
 };


 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="" onclick="document.currentLayer1Mode=\'cartview\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom());currentpage(); return false;"><FONT style="font-size:9pt; font-family:Arial;">&#8593;</font> 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;"><FONT style="font-size:9pt; font-family:Arial;">&#8593;</font> BACK TO REQUEST RESULTS</A><BR><BR>';
			    }
			    else
			    {
				navbacklink = '<A HREF="" onclick="document.currentLayer1Mode=\'searchresults\'; viewmode=\'' + viewmode + '\';gsetCookie(\'gviewmode\',\'' + viewmode + '\', \'\', \'/\', gGetCookieDom()); currentpage(); return false; "><FONT style="font-size:9pt; font-family:Arial;">&#8593;</font> 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"><FONT style="font-size:9pt; font-family: Arial;">&#8592;</FONT> 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 <FONT style="font-size:9pt; font-family: Arial;">&#8594;</FONT></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\');">&nbsp;DOWNLOAD COMP</a><BR><BR>';
				} else {
				if(gsession) {
					downloadcomplink = '<a href="Javascr' + 'ipt:displayWindow(\'/comp_view.shtml?guest/' + cs[encount] + '/' +
					enlargetid			
					+ '.JPG\',\'600\',\'640\');">&nbsp;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);
	}
*/	
 };



