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

var Templates = $H({});		

Templates.SiteWeightSet = new Template(
	'<div id="SiteWeightPopUp">'
	+'<h1>ADMIN: Adjust Aphotos Weight</h1>'
	+'Set siteweight for image #{id}<br/>currently set as a #{siteweight}'
	+'<form action=#>'
	+'<div id=setweight4 class=setweightoption><input type=radio value=4 onclick="aphotossetweight(\'#{id}\',\'4\',\'#{saveindex}\');"> 4 Very High </div>'
	+'<div id=setweight3 class=setweightoption><input type=radio value=3 onclick="aphotossetweight(\'#{id}\',\'3\',\'#{saveindex}\');"> 3 High </div>'
	+'<div id=setweight2 class=setweightoption><input type=radio value=2 onclick="aphotossetweight(\'#{id}\',\'2\',\'#{saveindex}\');"> 2 Average</div>'
	+'<div id=setweight1 class=setweightoption><input type=radio value=1 onclick="aphotossetweight(\'#{id}\',\'1\',\'#{saveindex}\');"> 1 Low</div>'
	+'</form><br/><A HREF="" onclick="hidedisplaypanel(1); return false;">[X] close window</A>'
	+'</div>'
);

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="" 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_list__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">"#{currentlbname}"</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><textarea style="float: left" name="lightbox_images" id="lightbox_images" rows="25" cols="50" class="lightbox_new_name">#{content}</textarea>'
        +'<A href="javascript: void(0);" onclick="javascript:$(\'lightbox_images\').focus();$(\'lightbox_images\').select(); return false;" class=lblink style="float: right; font-size: 10pt; font-weight:bold;">Select All</A><br/>'
        +'<input type=checkbox id="ipn_id" name=ipn_id CHECKED onclick="switchList()"> IPN IDs<br /><input type=checkbox id="orig_id" name=orig_id onclick="switchList()"> Original IDs<br /><br /><br />'
        +'<A style="display: block; clear: both" HREF="" onclick="lightbox_list({ mode : \'close\'}); return false;">[X] close window</A>'
        +'<input type="hidden" id="images" name="images" value="#{images}">'
        +'<input type="hidden" id="origs" name="origs" value="#{origs}">'
        +'</form></DIV></TD></TR></TABLE>'
);

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="" 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="" 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; 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="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="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_lightbox.gif" width=21 height=15 border=0 alt=""> ADD TO CURRENT LIGHTBOX </a>'
					+'<br/><a href="" onclick="license(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_price.gif" width=21 height=15 border=0 alt=""> CHECK USAGE RATES</a>'
					+'<br/><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;"><img src="/graphics/icon_cart.gif" width=21 height=15 border=0 alt=""> ADD TO SHOPPING CART</a>'
					+'<br/>#{downloadcomplink}'
                                        +'<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>'
					+'#{locinfo}'
					+'#{release_string}'
					+'#{photographerinfo_string}'
					+'#{filesize_string}'
					+'#{jtag}'
                    +'#{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><TD rowspan=2 align="left" valign="top" style="border-left: 0px solid #bbbbbb; padding-left:15px;">'
                                        +'#{ratetierinfo}'
                                +'</TD></TR>'
                                +'<tr><td>#{rfcdlinkslug}</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.tieredimgpricing__rrslug = new Template (
        '<div align="left"><IMG src=/graphics/h_RightsReady.gif border=0 alt="Royalty Free Licensing"></div>'+
        '<h4 style="text-align: left;">Select one or more uses below</h4>'+
        '<A href="/EULA/Blend_RM_RR_EULA.pdf" TITLE="View License Agreement as a pdf" class="orangelink" target="eula">View Rights Ready License Agreement (pdf file)</A><BR clear=all>'+
        '<table cellspacing=0 cellpadding=0 width="100%" >#{rows}</table>'
);
Templates.tieredimgpricing__rrslug_row = new Template (
        '<tr><td colspan=2><h2>#{name}<h2></td></tr>'+
        '<tr><td align=left style="border-bottom: 1px solid rgb(187, 187, 187);padding-bottom: 3px; padding-top: 4px;"><span><nobr><b>#{optname}</b></nobr></span><BR>'+
        '<div id="d#{id}"><a href="javascript:ShowOrHideComboText(\'d#{id}\', \'none\',\'e#{id}\'); ShowOrHideComboText(\'d#{id}2\', \'block\');" class="orangelink">Show Details</a></div>'+
        '  <div id="d#{id}2" style="display:none;"><a href="javascript:ShowOrHideComboText(\'d#{id}\', \'block\'); ShowOrHideComboText(\'d#{id}2\', \'none\');" class="orangelink">Hide Details</a>'+
        '<br />#{expr}<BR>'+
        '<div id="d#{id}e" style="display:none;"><a href="javascript:ShowOrHideComboText(\'d#{id}e\', \'none\'); ShowOrHideComboText(\'d#{id}e2\', \'block\');" class="orangelink">Show Examples</a></div>'+
        '  <div id="d#{id}e2" style="display:none;"><a href="javascript:ShowOrHideComboText(\'d#{id}e\', \'block\'); ShowOrHideComboText(\'d#{id}e2\', \'none\');" class="orangelink">Hide Examples</a>'+
        '  <div id="e#{id}">#{expr_extended}</div></div>'+
        '</div></td><td align=right valign=top style="border-bottom: 1px solid rgb(187, 187, 187);padding-bottom: 4px; padding-top: 4px;">'+
            '<div style="min-width: 50px; padding-right: 5px;">#{currency} #{price}</div> '+
            '<div style="min-width: 50px;">'+
                '#{removebutton}'+
                '<nobr><A href="#" onclick="cart_addto(\'#{enlargetid}\',{ \'ln\':\'#{enlargetid}\', \'lictype\':\'RR\', \'base\':\'#{price}\', \'Size_opname\':\'#{id}\', \'usage\':\'#{usage}\', \'callback\':\'enlarge2(#{img_id},#{encount},null,1);\' }); return false;" class="orangelink">Add to Cart</a></nobr>'+
            '</div>'+
        '</td></tr>'
);

Templates.tieredimgpricing__rrslug_row_removebutton = new Template (
        '<nobr><a href="#" class="orangelink" onclick="cart_delete_license(#{img_id},{ \'lictype\':\'RR\', \'usage\':#{usage}, \'opts\':#{id}, \'callback\':\'enlarge2(#{img_id},#{encount},null,1);\' }); return false;">Remove Option</a><nobr> &nbsp;&nbsp;'
);


Templates.hovercopyright__text = new Template (
	'&copy;#{currentyear} #{baseurl}  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>'
);


//CALLBACK ACTion for enlarge2
function enlarge2_act(enid,encount,featuredimage,preMem) {
// new code to force twitter to respond to new image bk 2012-01-05
	if($('twitter-wjs')){$('twitter-wjs').remove();}
	featuredimage = ( featuredimage == 'undefined' ? '' : featuredimage );
	hp();//ensure closure the preview window
        var useInPage = 0;
        if ( id[encount] == document.JSONobj.getImgDat('id') || featuredimage.length==10)
                useInPage = 1;

	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();	// Mantis #1421 - Milan Adamovsky	
			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="" 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="" 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');
			
			// journalistic or jtag j-tag
			var jtag='';
			var on_web = document.JSONobj.getImgDat('on_web');
			if(on_web=='isjournalistic'){
				jtag='<br /><a href="#" onclick="javascript:jtag_explanation();" title="What is this? click to find out more about the J-Tag"><img src="/graphics/jtag_large.gif" class="jtagbig" alt="J-Tag means Journalistic Image" border="0"></a><br />';
			}
			//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') : '');
			var dimensions_value='';
			//alert(mydimensions);
			if (mydimensions && mydimensions !='0' && mydimensions.indexOf('x') > 1){ //comes as <XVAL>x<YVAL>			
				var dimr = mydimensions.match(/^(\d+)x(\d+)$/);
				if (typeof(dimr) == 'object' && dimr !='null' && dimr.length==2){
					mydimensions = '<br/><b>Original Dimensions:</b>&nbsp;'+dimr[1]+'px&nbsp;x&nbsp;'+dimr[2]+'px';
					dimensions_value=dimr[1]+'px&nbsp;x&nbsp;'+dimr[2]+'px';
				}
			}
			var dimensions_string = (dimensions_value != '' ? '<div class=enlarged_field id=enlarged_field_dimensions><div class=enlarged_field_title ie=enlarged_field_title_dimensions>Image Dimensions:</div><div class=enlarged_field_value id=enlarged_field_value_dimensions>' + dimensions_value + '</div></div>' : '');
		
	
			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;}
				themediainsert += '<A HREF="" onclick="currentpage(); return false;">'
					+'<img src="'+
					ImageUrl(((typeof(localwatermark) != 'undefined' && ! pngsupport) ? 'wm' : '420' )+'/60',tarid)
					+'" 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)"/>'
						:
						'');
dataurlURI = encodeURIComponent('http://' + location.host + '/SwishSearch?enlargeview='+ enid)
				themediainsert += '</A><br />';
				themediainsert += '<div style="float: left;">';
					themediainsert += '<span style="top: -5px;position: relative;padding-right: 6px"><img src="/graphics/share_this_photo.jpg" border="0" height="12" width="88" /></span>';
					themediainsert += '<a class="fb-share-button fb-share-button-22" href="javascript:void(window.open(\'https://www.facebook.com/sharer/sharer.php?u='
						+ location.host +'/SwishSearch?enlargeview='+ enid+'\',\'sharer\',\'width=626,height=436,toolbar=0,status=0\'));"></a>';
				try {
				} catch(e){
				}
					themediainsert += '<a id="' + enid + '" href="https://twitter.com/share" class="twitter-share-button" data-hashtags="AuroraPhotos,Photography" data-url="'+dataurlURI+'" data-counturl="' + dataurlURI + '" data-text="Check out this photo from Auroraphotos.com: " data-lang="en">Tweet</a>';
					!function(d,s,id){
						var js,fjs=d.getElementsByTagName(s)[0];
						if(!d.getElementById(id)){
							js=d.createElement(s);
							js.id=id;
							js.src="//platform.twitter.com/widgets.js";
							fjs.parentNode.insertBefore(js,fjs);
						}
					}(document,"script","twitter-wjs");
				themediainsert += '</div>';
			}
			
			//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="'+ImageUrl('135/50',simarray[i]) + '" 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(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\');"><img src="/graphics/icon_comp.gif" width=21 height=15 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" width=21 height=15 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>' : '' );
			var release_string = ( showrelease ? (myreleased != '' ? '<div class=enlarged_field id=enlarged_field_releases><div class=enlarged_field_title id=enlarged_field_title_releases>Release:</div><div class=enlarged_field_value id=enlarged_field_value_released>'+myreleased + '</div></div>' : '') : '');

			//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>' : '');
			var photographerinfo_string = ( (myphotographer && showphotographer) ? '<div class=enlarged_field id=enlarged_field_photographer><div class=enlarged_field_title id=enlarged_field_title_photographer>Photographer:</div><div class=enlarged_field_value id=enlarged_field_value_photographer>'+'<A href="/SwishSearch?Keywords=' + linked_photog + '&spec_idx=ne&method=photographer">' + myphotographer + '</a></div></div>' : '');

			//becomes filesizeinfo
			var filesizeinfo = ( (! featuredimage && showfilesize) ? '<b>File Size:</b> ' + myfilesize : '');
			var filesize_string = ( (! featuredimage && showfilesize) ? '<div class=enlarged_field id=enlarged_field_filesize><div class=enlarged_field_title id=enlarged_field_title_filesize>File Size:</div><div class=enlarged_field_value id=enlarged_field_value_filesize>'+myfilesize + '</div></div>' : '');
			//becomes restrictionsinfo
			var restrictionsinfo = (myrestrictions ? '<BR/><span style="color:#990000">'+myrestrictions+'</span>' : '');
			var restrictions_string = (myrestrictions ? '<div class=enlarged_field id=enlarged_field_restrictions><div class=enlarged_field_title id=enlarged_field_restrictions>Restrictions:</div><div class=enlarged_field_value id=enlarged_field_value_restrictions>'+myrestrictions+'</div></div>' : '');

//alert('p6');			

			//becomes keywordinfo
			var keywordinfo = '';
			var keywordinfoArray = new Array();
			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', '');
				keywordinfoArray.push('<a href="/SwishSearch?' + relink +'">' + kwd + '</a>');
			});

			keywordinfo = keywordinfoArray.join(", ");

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

			var dateshot = document.JSONobj.getImgDat('date_shot');
                        var dateshot_string =  ((dateshot == '00-00-00') || (dateshot=='00-00-0000') || (dateshot=='0000-00-00') ? '' : '<div class=enlarged_field id=enlarged_field_dateshot><div class=enlarged_field_title id=enlarged_field_title_dateshot>Date Shot:</div><div class=enlarged_field_value id=enlarged_field_value_dateshot>'+dateshot + '</div></div>');
 			var rfcdlinkslug = document.JSONobj.getImgDat('rfcdlink');

			var loc="";
			var loc_arr = new Array() ;
			if( typeof(document.JSONobj.getImgDat('location_city')) != 'undefined' && document.JSONobj.getImgDat('location_city') )	
				loc_arr.push(document.JSONobj.getImgDat('location_city'));				
	
			if( typeof(document.JSONobj.getImgDat('location_state')) != 'undefined' && document.JSONobj.getImgDat('location_state') )
				loc_arr.push(document.JSONobj.getImgDat('location_state'));


			if( typeof(document.JSONobj.getImgDat('location_country')) != 'undefined' && document.JSONobj.getImgDat('location_country') )
				loc_arr.push(document.JSONobj.getImgDat('location_country'));

			loc = loc_arr.join(", ");
		
			loc = ( loc!="" ? '<div class=enlarged_field id=enlarged_field_filesize><div class=enlarged_field_title id=enlarged_field_title_filesize>Location:</div><div class=enlarged_field_value id=enlarged_field_value_filesize>'+loc+ '</div></div>' : "");			
	

				
 			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,
					restrictionsinfo: restrictionsinfo,
					jtag: jtag,
					dateshot_string: dateshot_string,
					restrictions_string: restrictions_string,
					restrictions_value: myrestrictions,
     					filesize_value: myfilesize,
   					filesize_string: filesize_string,
	  				photographerinfo_string: photographerinfo_string,
	  				photographer_value: myphotographer,
      					release_string: release_string,
   					release_value: myreleased,
					dimensions_string: dimensions_string,
					dimensions_value: dimensions_value,
					locinfo: loc
				});


			//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(ImageUrl('420/60',nextimageid));
		} 
		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);
	}
*/	
};


function lightbox_list(args){
  var mode=args.mode;
  var lb=args.lb;
  var user=args.user;
  if(mode=="close"){
    hidedisplaypanel(1);
  }else{
    var d=new Date();
    ajax_JSON("/bin/UserAdmin?lb_list="+lb+"&user="+user+"&noise="+d.getTime(),"GET",
      {"callback":function(){
        var _118=document.JSONobj.oJSON.images.image_id;
        var _119=document.JSONobj.oJSON.images.orig_id;
        var _11a=_118.join("\n");
        var _11b={content:_11a,images:_118,origs:_119,currentlbname:lb};
        center_panel(390,380,Templates.lightbox_list__body.evaluate(_11b),"",{"topX":(self.innerWidth/2)-(380/2),"topY":(self.innerHeight/2)-(390/2),"static":1});
        }
      });
  }
}



