/* easy peasy Template naming pragma function_name__template_name
* results_interstitial
* results_loading_interstitial
* results_pagination
* results_bottom_paging_row
* 	results_prev_link
* 	results_next_link
* 	results_gotopage_form
* 	results_droppanel
* 		results_droppanel_rmonly
* 		results_droppanel_showillusPhotog
* 		results_droppanel_suspendYesNoRestrictions
* 		results_droppanel_suspendWithPeople
* 		results_droppanel_showSearchWithin
* 		results_endofrange
* results_editing_save_all_releases
* results_requests_viewimagesfrom
* results_optimize_search
* results_editing_savereleases
* lightbox_new__body
* lightbox_list__body
* lightbox_email__body
* lightbox_rename__body
* simplemessage__body
* simplemessage__body_lightbox
* enlarge2_act__body
* 	enlarge2_act__similars
* 	enlarge2_lb_backtoresults
* 	enlarge2_act__navback_link
* 		enlarge2_act__previmage_link
* 		enlarge2_act__nextimage_link
* 	enlarge2_act__complink
* 	enlarge2_act__dateshot
*	enlarge2_act__restrictions
*	enlarge2_act__filesize
*	enlarge2_act__photographer
*	enlarge2_act__release
*	enlarge2_act__dimensions
* 	enlarge2_short_and_long_caption_combo
* tieredimgpricing__rfslug
* tieredimgpricing__rfslug_row
* tieredimgpricing__rrslug
* tieredimgpricing__rrslug_row
* tieredimgpricing__rrslug_row_removebutton
* hovercopyright__text
* footer__body
* login
* cart_tabulating_cart_message
* cart_loading_cart_message
* preview_metadata
	* preview_restrictions
 */



var Templates = $H({});		
//******** search results *****************************************************************************************//


function isBlank(val)
{
        if (val == null) { return true; }
        for (var i=0; i < val.length; i++)
        {
                if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n")) { return false; }

        }
        return true;
}


function validEmail(val)
{
        if(val.match(/[A-Za-z][A-Za-z0-9._]+\@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+/))
                return true;

        return false;
}

function testone(formName)
{
        var fName = (typeof(formName)=='undefined' ? 'isn' : formName);
        var regForm = document.forms[fName];
	
        if( (typeof(regForm.elements["name"])!='undefined') && isBlank(regForm.elements["name"].value))
        {
                alert("Please enter your name. (atleast 4 letters)");
                regForm.elements["name"].focus();
                return false;
        }
/*	else if( (typeof(regForm.elements["company"])!='undefined') && isBlank(regForm.elements["company"].value))
        {
                alert("Please enter your Company name.");
                regForm.elements["company"].focus();
                return false;
        }
	else if( (typeof(regForm.elements["type_of_usage"])!='undefined') && isBlank(regForm.elements["type_of_usage"].value))
        {
                alert("Please enter Type Of Usage .");
                regForm.elements["type_of_usage"].focus();
                return false;
        }
	else if( (typeof(regForm.elements["time_frame"])!='undefined') && isBlank(regForm.elements["time_frame"].value))
        {
                alert("Please enter your Time Frame.");
                regForm.elements["time_frame"].focus();
                return false;
        }
	else if( (typeof(regForm.elements["distribution"])!='undefined') && isBlank(regForm.elements["distribution"].value))
        {
                alert("Please enter your Distribution.");
                regForm.elements["distribution"].focus();
                return false;
        }
	else if( (typeof(regForm.elements["phone"])!='undefined') && isBlank(regForm.elements["phone"].value))
        {
                alert("Please enter your phone.");
                regForm.elements["phone"].focus();
                return false;
        }
	else if( (typeof(regForm.elements["username"])!='undefined') && isBlank(regForm.elements["username"].value))
        {
                alert("Please enter your username.");
                regForm.elements["username"].focus();
                return false;
        }*/

        else if( (typeof(regForm.elements["email"]) !='undefined') && ! validEmail(regForm.elements["email"].value))
        {
                alert("Please enter a valid email");
                regForm.elements["email"].focus();
                return false;
        }
        else
        {
                regForm.submit();
                return true;
        }

       // return false;
}





Templates.results_interstitial = new Template (
	'<table width=100% height=100%><tr width=100% height=100%><td valign=middle align=center width=100% height=100%><h1 id="results_interstitial_message">Searching for #{url2} <blink>.</blink></h1></td></tr></table>');
Templates.results_loading_interstitial = new Template (
	'<div id=results_loading_interstitial>loading #{results_loading_interstitial_whatisloading}...</div>');
Templates.results_pagination = new Template (
	'<table width="100%"><tr><td valign="top">'
	+'<div id=results_page_block_top class=page>#{prev_link_html}#{pagehtml}#{next_link_html}</div>'
	+'</td><td align="right">'
	+'</td></tr></table>'
	);
		Templates.results_gotopage_form = new Template (
		'<div id="results_gotopage_block"><NOBR>Go&nbsp;to&nbsp;Page:&nbsp;'
		+'<SELECT name="pageurl" align="absmiddle" onChange="document.currentLayer1Mode=\'searchresults\'; self.location=this.options[this.selectedIndex].value; return false;" class="smallmenu" id="results_gotopage_menu">'
		+'#{thehtml}'
		+'</NOBR></div>');

Templates.results_bottom_paging_row = new Template (
	'<table id=\"footerpaging\" style=\"position:absolute; z-index:999;\" width=100% height=17 cellpadding=0 cellspacing=0 border=0><tr><td align=left width=40%>'
	+ '#{results_prev_link}</td><td align=\"middle\" width=20%><center><nobr>#{footer}</nobr></center></td><td width=40% align=right>'	
	+ '#{results_next_link}</td></tr></table>');
	Templates.results_prev_link = new Template (
		'<div class="results_prev_link_#{prevactive} results_prev_link_#{prevlink_toporbottom}"><A href="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\';prevpage(); return false;">&#8592; PREV PAGE</A></div>');	
	Templates.results_next_link = new Template (
		'<div class="results_next_link results_next_link_#{nextlink_toporbottom}"><A HREF="javascript: return false;" onclick="document.currentLayer1Mode=\'searchresults\';nextpage(); return false;">NEXT PAGE &#8594;</A></div>');	

	Templates.results_droppanel = new Template (
	'<form action="javascript:g(); return false;" method=get name=displaypanel id=displaypanel>'
	+  '<div id=searchpanelouter><table cellspacing=0 cellpadding=10 border=0 width=100% height=#{panelheight}>'
	+  '<tr><td valign=top align=left class="light1"><div id="searchpanelcolumn1">'
	+  '	<div id=searchpanel_label_orientation class=searchpanel_label>ORIENTATION:</div>'
	+  '		<div class=searchpanel_item><nobr><input type=checkbox name=orient value=horizontal onclick=javascript:fsearchprefs("f","add"); #{temph}> Horizontal</nobr></div>'
	+  '		<div class=searchpanel_item><nobr><input type=checkbox name=orient value=vertical onclick=javascript:fsearchprefs("g","add"); #{tempv}> Vertical</nobr></div>'
	+  '		<div class=searchpanel_item><nobr><input type=checkbox name=orient value=panoramic onclick=javascript:fsearchprefs("h","add"); #{tempp}> Panororamic</nobr></div>'
	+  '		<div class=searchpanel_item_last><nobr><input type=checkbox name=orient value=square onclick=javascript:fsearchprefs("i","add"); #{temps}> Square</nobr></div>'
	+  '	<div id=searchpanel_label_color class=searchpanel_label>COLOR:</div>'
	+  '		<div class=searchpanel_item><nobr><input #{tempcolany} type=radio name=color value="" onclick=javascript:fsearchprefs("color","add");> Any</nobr></div>'
	+  '		<div class=searchpanel_item><nobr><input #{tempcolcol} type=radio name=color value=color onclick=javascript:fsearchprefs("color","add");> Color</nobr></div>'
	+  '		<div class=searchpanel_item_last><nobr><input #{tempcolbw} type=radio name=color value=gray onclick=javascript:fsearchprefs("color","add");> B/W</nobr></div>'
	+  '	#{results_droppanel_rmonly}'
	+  '</td>'
	+  '<td valign=top align=left class="light1"><div id="searchpanelcolumn2">'
	+  '	#{results_droppanel_showillusPhotog}'
	+  '	#{results_droppanel_suspendYesNoRestrictions}'
	+  '	#{results_droppanel_suspendWithPeople}'
	+  '	<div id=searchpanel_label_releases class=searchpanel_label>RELEASES:</div>'
	+  '		<div class=searchpanel_item><input #{temprelany} type=radio name=xtrasql value="" onclick=javascript:fsearchprefs("released","remove");> Any release status</div>'
	+  '		<div class=searchpanel_item_last><input #{temprelonly} type=radio name=xtrasql value=released onclick=javascript:fsearchprefs("released","add");> Only show released images</div>'
	+  '	#{results_droppanel_searchwithin}'
	+  '	<div id="searchpanel_gobutton><a href="javascript: return false;" onclick="g(); return false;"><img src="/graphics/button_go.gif" alt="search" border="0"></a></div>'
	+  '	<div id="searchpanel_closebutton><A href="javascript: return false;" onclick="hidedisplaypanel(1); return false;">[x] close search options panel</A></div>'
	+  '</td></tr></table>');
		Templates.results_droppanel_rmonly = new Template (
				'<div id=searchpanel_label_type class=searchpanel_label>TYPE:</div>'
				+  '	<div class=searchpanel_item><nobr><input type="checkbox" name="rmrftype" value="RM" #{rmc} onclick=javascript:fsearchprefs("RM","add");> Rights Managed</nobr></font></div>'
				+  '	<div class=searchpanel_item_last><nobr><input type="checkbox" name="rmrftype" value="RF" #{rfc} onclick=javascript:fsearchprefs("RF","add");> Royalty Free</nobr></font></div>');
		
		Templates.results_droppanel_showillusPhotog = new Template (
				'<div id=searchpanel_label_media class=searchpanel_label>MEDIA:</div>'
				+  '	<div class=searchpanel_item><input type="checkbox" name="searchinclude" value="illustration"#{tempillustration} onclick=javascript:fsearchprefs("1","add"); />Illustration<br/></div>'
				+  '	<div class=searchpanel_item_last><input type="checkbox" name="searchinclude" value="photography"#{tempphotography} onclick=javascript:fsearchprefs("0","add"); />Photography<br/></div>');
		
		Templates.results_droppanel_suspendYesNoRestrictions = new Template (
				'<div id=searchpanel_label_restrictions class=searchpanel_label>RESTRICTIONS:</div>'
				+  '	<div class=searchpanel_item><input #{temprany} type=radio name=restrictions value="" onclick=javascript:fsearchprefs("norestrictions","remove");> Any</div>'
				+  '	<div class=searchpanel_item_last><input #{temprno} type=radio name=restrictions value=not+imagehasrestrictions  onclick=javascript:fsearchprefs("norestrictions","add");> No Restrictions</div>');
		
		Templates.results_droppanel_suspendWithPeople = new Template (
				'<div id=searchpanel_label_people class=searchpanel_label>PEOPLE:</div>'
				+  '	<div class=searchpanel_item><input #{temppeopany} type=radio name=people value="" onclick=javascript:fsearchprefs("people","remove");> Any</div>'
				+  '	<div class=searchpanel_item><input #{temppeopwith} type=radio name=people value=withpeople onclick=javascript:fsearchprefs("withpeople","add");> With People</div>'
				+  '	<div class=searchpanel_item><input #{temppeopwithout} type=radio name=people value=nobody onclick=javascript:fsearchprefs("nobody","add");> Without People</div>'
				+  '	<div class=searchpanel_item_last><input #{temppeopcrowd} type=radio name=people value=withcrowd onclick=javascript:fsearchprefs("withcrowd","add");> Crowd</div>');
		
		Templates.results_droppanel_showSearchWithin = new Template (
				'<div id=searchpanel_label_method class=searchpanel_label>METHOD:</div/>'
				+  '<div id=searchpanel_method_select><select id="method" name="method" class="smallmenu">'
				+  '<option value="new" #{tempsearchnew}>as a new search</option>'
				+  '<option value="within" #{tempsearchwithin}>within current results</option></select></nobr></div>');
		Templates.results_endofrange = new Template (
			'<span valign=bottom style="float:left;"><div id=results_endofrange_box  class="endof#{endtype}images">'
			+ (typeof(custom) == 'undefined' ? '' : custom.end_message) + '</div></span> ');		

//******* editing templates IPN ***************************************************************************//
Templates.results_editing_save_all_releases = new Template (
	'<a onclick="return save_all_releases();" href="javascript: return false;">Save All Releases</a> &nbsp;&nbsp; '
	+'[ Set All: <a href="javascript: return false;" onclick="return share_set_page(\'shared\'); ">Accepted</a> |'
	+'<a href="javascript: return false;" onclick="return share_set_page(\'rejected\'); ">Rejected</a> |'
	+'<a href="javascript: return false;" onclick="return share_set_page(\'pending\'); ">Pending</a>  &nbsp;|'
	+'&nbsp;  <a onclick="return release_set_page(\'NOT RELEASED\');" href="javascript: return false;" title="NOT RELEASED">NR</a> |'
	+'<a onclick="return release_set_page(\'NOT APPLICABLE\');" href="javascript: return false;" title="NOT APPLICABLE">NA</a> |'
	+'<a onclick="return release_set_page(\'NOT RECOGNIZABLE\');" href="javascript: return false;" title="NOT RECOGNIZABLE">NR</a> |'
	+'<a onclick="return release_set_page(\'MODEL AND PROPERTY RELEASED\');" href="javascript: return false;" title="MODEL AND PROPERTY RELEASED">MaPR</a> ]');
Templates.results_requests_viewimagesfrom = new Template (
		'<a href="/R?#{feat_requestview}" id=results_request_link><nobr>View images from</nobr> <br/><nobr><b>All IPN Members</b></nobr></a>');
Templates.results_optimize_search = new Template (
	'<table cellspacing=0 cellpadding=1 border=0>'
	+ '<FORM name="optimizer" action="#" id=results_form_optimizer>'
	+ '<tr><td>'
	+ '<SELECT id=results_optimizer_select NAME="narrow" ONCHANGE="narrowit(this.form.narrow.options[this.form.narrow.selectedIndex].value);" class="smallmenu">'
	+ '<OPTION VALUE="#">Narrow your search results'
	+ '<OPTION VALUE="colorgray">Remove black and white images'
	+ '<OPTION VALUE="colorrgb">Remove color images'
	+ '<OPTION VALUE="imagehasrestrictions">Remove restricted images'
	+ '<OPTION VALUE="orientationvertical">Remove verticals'
	+ '<OPTION VALUE="(orientationhorizontal+OR+orientationpanoramic)">Remove horizontals'
	+ '<OPTION VALUE="agefiveyears">Only show recent images (<5 yrs)'
	+ '<OPTION VALUE="agetenyears">Remove very old images (>10 yrs)'
	+ '</SELECT></td></tr></form></table>');
Templates.results_editing_savereleases = new Template (
	'<div id="shortrel#{showid}">Release: #{shortrel}</div> <div>  <form id="releasecontrol#{showid}" > #{relcon} <input type="hidden" name="shdex" value="#{showid}"/></form>'
	+ '<a href="javascript: return false;" onclick="sor(#{showid}); return false;" >Save Release</a></div>');
	
//******** pop-up panels ******************************************************************************************//
	
Templates.lightbox_new__body = new Template (	
	'<div id="lightboxPopUpNew" class="PopUpWindoid">'
	+'<table width="100%" cellspacing="0" cellpadding="0" border="0" class="guidebox2"><tbody><tr><td class="guideTopL"/><td class="guideTopM"/><td class="guideTopR"/></tr><tr><td class="guideMid guideMidL"/><td valign=top align=left class=guideMidM>'
	+'<h1>Make new lightbox</h1>'
	+'<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></form>'
	+'</td><td class="guideMid guideMidR"/></tr><tr><td class="guideBotL"/><td class="guideBotM"/><td class="guideBotR"/></tr></tbody></table>'
	+'</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 (
	'<div id="lightboxPopUpEmail" class="PopUpWindoid">'
	+'<table width="100%" cellspacing="0" cellpadding="0" border="0" class="guidebox2"><tbody><tr><td class="guideTopL"/><td class="guideTopM"/><td class="guideTopR"/></tr><tr><td class="guideMid guideMidL"/><td valign=top align=left class=guideMidM>'
	+'<h1>Email your lightbox to a friend</h1>'
	+'<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>.</form>'
	+'</td><td class="guideMid guideMidR"/></tr><tr><td class="guideBotL"/><td class="guideBotM"/><td class="guideBotR"/></tr></tbody></table>'
	+'</div>' );
			
Templates.lightbox_rename__body = new Template (
	'<div id="lightboxPopUpRename" class="PopUpWindoid">'
	+'<table width="100%" cellspacing="0" cellpadding="0" border="0" class="guidebox2"><tbody><tr><td class="guideTopL"/><td class="guideTopM"/><td class="guideTopR"/></tr><tr><td class="guideMid guideMidL"/><td valign=top align=left class=guideMidM>'
	+'<h1>Rename  lightbox</h1>'
	+'<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/>'
	+'<br/><A HREF="" onclick="lightbox_email(\'close\'); return false;">[X] close window</A>'
	+'</form>'
	+'</td><td class="guideMid guideMidR"/></tr><tr><td class="guideBotL"/><td class="guideBotM"/><td class="guideBotR"/></tr></tbody></table>'
	+'</div>' );

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>');


//******** enlarge view ******************************************************************************************//
		
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="auto" height="470" style="margin-left: 8px;">'
				+'<tr><td>'
				 +'#{enlarge_navback_link}'
                                        +'<div id="enlarged_navlinks" style="float : right;">#{enlarge_previmage_link}#{enlarge_nextimage_link}</div>'
				+'</td></tr>'
				+'<tr><td valign="top" align="center" width="430" height="440" style="min-width: 440px">'
					+'<div style="position:relative">#{themediainsert}</div>'
				+'<br/>'
				+'<div style="margin-left: 12px; line-height: 11px;">'
				+'<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><br clear=all/></div>'
                                        +'#{dateshot_string}'
                                        //+'<div class="enlarged_field" id="enlarged_field_caption" style="text-align: left;"><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" style="text-align: left;"><A class="olink" id="enlarge_keywords_text" onclick="popkeys2(\'enlarge_keywords\', this); return false;">Show keywords</A></div>'
                                      	+'</div>'
					+'<div id="enlarge_keywords" style="display: none; margin-left: 10px; overflow-y: auto; text-align: left;">' 
                                        +'#{keywordinfo}'
					+'</div></td>'


				+'#{similarscolumn}'
				+'<td align="left" valign="top" width="320" id="enlarged_link_data_column">'
					+'<div class="enlarged_icon"><div id="iconlb"><a href="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;"></a></div><div class="iconlabel"><a href="" onclick="lightbox_addto(\'#{enlargetid}\'); return false;">ADD TO CURRENT LIGHTBOX</a></div></div>'
        				+'<div class="enlarged_icon"><div id="iconflip"><a href="" onclick="popflip(\'#{enlargetid}\');return false;"></a></div>'
					+'<div class="iconlabel"><a href="javascript:popflip(\'#{enlargetid}\');">VIEW IMAGE FLIPPED</a></div></div>'
			//		+'<div class=enlarged_icon><div id="iconprice"><a href="" onclick="license(\'#{enlargetid}\'); return false;"></a></div><div class="iconlabel"><a href="" onclick="license(\'#{enlargetid}\'); return false;">CHECK USAGE RATES</a></div></div>'
				//	+'<div class=enlarged_icon><div id="iconcart"><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;"></a></div><div class="iconlabel"><a href="" onclick="cart_addto(\'#{enlargetid}\'); return false;">ADD TO SHOPPING CART</a></div></div>'
					+'#{downloadcomp_link}'
       
          +'<div id="QTVRVideo" style="display: none;">'
          +'<br><FONT size="-2" COLOR="#666666">QTVR:</FONT><br>'
          +'<a href="http://tools.cgibackgrounds.com/qtvideo/'
              +'#{enlargetid1}'
              +'/#{enlargetid2}'
              +'/#{enlargetid}'
              +'.MOV" Target="_new" width=420 height=280>View QTVR movie</a> There is a Quicktime file associated with this image. If you would like to view it, please click the link above.'
          +'<br><br>'          
          +'</div>'
          
				 
         +'<B>All Print including: Advertising, Collateral, Out of Home, and Web usages:</B><BR>'
					+'Unlimited Use for Unlimited Time: $5,000.00<BR>' 
					+'Unlimited Use 2 yrs:  $4,000.00<BR>'
					+'Unlimited Use 1 yr:   $3,000.00<BR><BR>'
					+'Exclusivity for Print only: Add $5,000.00 to 1 year, 2 year, or unlimited use fee.<BR><BR>'
          +'<span class="title">Web Advertising, Banner Ads, Trade Shows, Social Media:</span><br>'
          +'Unlimited Time: $3,000.00<br>'
          +'2 yrs: $2,000.00<br>'
          +'1 yr: $1,500.00<br>'
          +'<br>'
          +'<span class="title">Website Only, dealer kiosk Usages:</span><br>'
          +'Unlimited Time: $1,500.00<br>'
          +'2 yrs: $1,000.00<br>'
          +'1 yr: $750.00<br>'
          +'<br>'
					+'<B>HDR Images</B><BR>'
					+'<B>Matching or Compatible HDRI Rendering Domes:</B><BR>'
					+'Unlimited Use for Unlimited Time:  $1000.00<BR>'
					+'<B>Interactive "Virtual World" environments:</B><BR>'
					+'1 yr: $1,500.00, unlimited time: $3,000.00, (website or advertising).<BR><BR>'
					+'*Please call to discuss your specific project needs including<br>limited usage,partial images, or special circumstances.<br><br>*Volume discounts apply to multiple image orders.<br><br>Have questions or need a custom quote? <br>Use the form below to <a href="/contact.shtml">contact us.</a></td>'

					+'<td rowspan=2 align="left" valign="top" id="enlarged_rates_column_3">'
					
					+'<td style="width: 300px;">'
					   +'<form method="post" action="/cgi-bin/formmail.cgi" name="tform1"><input type="hidden" name="recipient" value="info@cgibackgrounds.com"><input type="hidden" name="redirect" value="/thanks.shtml">'

						+'<table cellspacing="0" cellpadding="0" border="0">'
							+'<tr>'
                                                                +'<td><b>Fields in * are required</b></td>'
                                                        +'</tr>'
							+'<tr><td>&nbsp;</td></tr>'

							+'<tr>'
								+'<td><font class="small">* <b>Name:</b></font></td>'
								+'<td><input size=20 name="name"></td>'
							+'</tr>'
							+'<tr>'

								+'<td><font class="small">Company:</font></td>'
								+'<td><input size=20 name="company"></td>'
							+'</tr>'
							+'<tr>'
								+'<td><font class="small">* <b>E-mail Address:</b></font></td>'
								+'<td><input size=20 name="email"></td>'
							+'</tr>'
							+'<tr>'

								+'<td><font class="small">Type of Usage:</font></td>'
								+'<td><input size=20 name="type_of_usage"></td>'
							+'</tr>'
							+'<tr>'
								+'<td><font class="small">Time Frame:</font></td>'
								+'<td><input size=20 name="time_frame"></td>'
							+'</tr>'
							+'<tr>'

								+'<td><font class="small">Distribution:</font></td>'
								+'<td><input size=20 name="distribution"></td>'
							+'</tr>'
							+'<tr>'
								+'<td><font class="small">Phone Number:</font></td>'
								+'<td><input size=20 name="phone"></td>'
							+'</tr>'
							+'<tr>'

								+'<td><font class="small">Username:</font></td>'
								+'<td><input size=20 name="username"></td>'
							+'</tr>'
						+'</table>'
						+'<div align=left>'
							+'<font class="small">Comments:</font><br>'
							+'<textarea rows=6 cols=45 name="comments"></textarea><br>'
							+'<b>CGIBACKGROUNDS.COM</b><br>101 W BIG BEAVER RD, 14TH FL<br>TROY, MI 48084<br>ph.866-303-0733<br>fx. 866-303-0744<br><br>'
							+'<div class="spritebuttons" id="buttonsubmit"><a href="javascript:return testone(\'tform1\');" onclick="javascript:return testone(\'tform1\');"></a><div>'
						+'</div>'
					    +'</form>'
					+'</td>'					


					+'#{ratetierinfo}'
					+'</td></tr>'
					+'<tr><td>#{rfcdlinkslug}</td></tr>'
					+'</table>'


	+'<br /></td></tr></table>');

	Templates.enlarge2_act__navback_link = new Template (
		'<div class="enlarged_field" id="enlarged_field_navback">'
		+ '<A HREF="" onclick="document.currentLayer1Mode=\'#{currentLayer1Mode}\'; viewmode=\'#{viewmode}\';gsetCookie(\'gviewmode\',\'#{viewmode}\', \'\', \'/\', gGetCookieDom());#{postprocessfunction} return false;">'
		+ '&#8593; #{navbacklinktext}'
		+ '</A></div>');
	Templates.enlarge2_lb_backtoresults = new Template (
		'&nbsp;&nbsp;<A href="javascript: return false;" onclick="viewmode=\'#{viewmode}\';gsetCookie(\'gviewmode\',\'#{viewmode}\', \'\', \'/\', gGetCookieDom()); self.location=\'/SwishSearch#{pre_q_args}\'; return false;"><font style="font-size:9pt; font-family:Arial;">&#8593;</font> BACK TO SEARCH RESULTS</A><BR/><BR/>');
	
	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__previmage_link = new Template (
			'<div id="enlarged_field_previmage">'
			+ '<A HREF="" onclick="enlarge2(\'#{previmageid}\',\'#{previmage}\'); return false;" TITLE="GO TO THE PREVIOUS IMAGE">&#8592; PREV IMAGE </A></div>');
			
		Templates.enlarge2_act__nextimage_link = new Template (
			'<div id="enlarged_field_nextimage">'
			+'<A HREF="" onclick="enlarge2(\'#{nextimageid}\',\'#{nextimage}\'); return false;" TITLE="GO TO THE NEXT IMAGE">NEXT IMAGE &#8594;</A><br style="clear: both;"/></div>');

	Templates.enlarge2_act__complink = new Template (
		'<div class=enlarged_icon><div id="iconcomp">'
		+ '<a href="/bin/Comp/'
		+ '#{downloadcomp_username}'
		+ '/#{downloadcomp_key}'
		+ '/#{enlargetid}'
		+ '.JPG"></a></div>'
		+ '<a href="/bin/Comp/'
                + '#{downloadcomp_username}'
                + '/#{downloadcomp_key}'
                + '/#{enlargetid}'
                + '.JPG">DOWNLOAD&nbsp;COMP&nbsp;IMAGE</a></div></div><br /><br />');
	
	Templates.enlarge2_short_and_long_caption_combo = new Template (
		'<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>');
		
	Templates.enlarge2_act__dateshot = new Template (
		'<!--<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>-->');

	Templates.enlarge2_act__restrictions = new Template (
		'<div class=enlarged_field id=enlarged_field_restrictions><div class=enlarged_field_title id=enlarged_field_title_restrictions>Restrictions:</div><div class=enlarged_field_value id=enlarged_field_value_restrictions>#{myrestrictions}</div></div>');
	Templates.enlarge2_act__filesize = new Template (
		'<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>');
	Templates.enlarge2_act__photographer = new Template (
		'<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>');
	Templates.enlarge2_act__release = new Template (
		'<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>');
	Templates.enlarge2_act__dimensions = new Template (
		'<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>');
	
//******** enlarge view pricing display templates ******************************************************************************************//


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">Rights Ready Licensing</div>'+
        '<h4 style="text-align: left;">Select one or more uses below</h4>'+
        '<A href="/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.shtml#Terms_Conditions class=disclaimer>Terms</a> <a href=/help.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.login = new Template (
 '<div id="loginRegister" >'
        +'<table BORDER="0" CELLSPACING="0" CELLPADDING="1" ALIGN="left" width="450" height="275"><tr>'
        +'<td class="dark1" valign=bottom width="100%"><DIV class="barheader"><div style="float:right"><A HREF="javascript:return false;" onclick="javascript:hide_login(); return false;" style="text-decoration:none;font-size:85%">&nbsp;[x] close window&nbsp;</A></div><div style="float:left">&nbsp;<font class="bartitle">Login</font></div></DIV></td></tr>'
        +'<tr><td ALIGN="left" VALIGN="top" width="290" class="dark1"><DIV class="light1" style="padding: 15px;font-size:85%"><p>By signing back in you will be able to buy images through your Cart, use your Lightboxes, download comp images and access and amend your profile details.</p><p>If you have not had a chance to Register yet, please take a moment to do so. You will be able to use all the features of this site once you have.</p>'
	+'<p><div id="loginMessage"></div></p>'
        +'<p><form name="loginForm" id="loginForm"><table cellspacing=5 cellpadding=5>'
	+'<tr><td>Email</td><td>:</td><td><input type="text" name="username" id="username" size="25" class="emailbox" ></td><td></tr>'
        +'<tr><td>Password</td><td>:</td><td><input type="password" name="password" id="password" size="25" class="emailbox" ><input type="hidden" name="sphotog" id="sphotog" value="cgibackgrounds"></td><td>'
	+'<div id=sbuttonenter class="spritebuttons"><a href="javascript:return false;" onclick="javascript:return evaluate_login();"></a></div>'+'</td></tr>'
	+'</table></form></p>'
	+'<br /><a href="/bin/Register" class="small">Not a registered user?</a>&nbsp;&nbsp;'
	+'<a href="/bin/Lostpass" class="small">Forgot your password?</a>&nbsp;&nbsp;'
	+'<a href="/bin/Changepass" class="small">Change your password?</a><br />'
        +'</div>');

Templates.cart_tabulating_cart_message = new Template (
	'<a id="cart_tabulating_cart_message_link" title="click here if you find you are waiting too long to load." onclick="cart_check();">Tabulating Shopping Cart <blink>.</blink> </a>');
Templates.cart_loading_cart_message = new Template (
	'<a id="cart_loading_cart_message_link" title="click here if you find you are waiting too long to load." onclick="cart_build(\'changing_again\');"> Loading Shopping Cart <blink>.</blink></a>');
Templates.preview_metadata = new Template (
	'<div id=preview_text_block>'
	+'<!--	<div class="preview_text"># #{displayimageid} #{rmrftype} #{filesize} #{dimensions} :: #{shortcaption} #{photographer} #{imagerestrictions}</div>-->'
	+'<div class="preview_text"># #{displayimageid} #{rmrftype}</div>'
	+'<div class="preview_warning"> To turn off previews select Big previews off at top of page </div></div>');
	Templates.preview_restrictions = new Template (
		' :: <span id=preview_restrictions> This image has restrictions. Click to View </span>');
		


Templates.preview_window = new Template (
'<div id=previewpaneshadow2><div id=previewpaneshadow1><div id=previewpane><div id=preview_image_wrapper>'
+'<IMG id=previewimg_#{prid} src=/graphics/loading.png border=0 alt="#{alt}" #{sizeoption} lowsrc="/graphics/spacer.gif">'
+'<div id=previewpane_metdat_#{prid}>'
//+'<img src="#{previewdynamic}" style="display:none;" onload="if($(\'previewimg_#{prid}\')) $(\'previewimg_#{prid}\').src = this.src">'
+'</div></div></div></div>' );


function htmlit_custom(showid){						// build html for each image depending on viewing mode
	var html='';
	switchpage = false;
	if (id[showid]){
		
		var myrmrftype = rm[showid];
		myid = id[showid];
		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 = Templates.results_editing_savereleases.evaluate({'showid':showid,'relcon':relcon[showid],'shortrel':shortrel});
		} 
		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="' + ImageUrl('135/50',myid,showid) + '" border=0 class=pimg vspace=2 hspace=3';
						html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";html += '" onmouseout="hp();" id=' + myid + '>';

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

 		//                       if ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) )
					
					if ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && !q_args.match(/fn=/) && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/))) )
					{
                                                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 class="iconnormal" 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=298 cellspacing=2 cellpadding=0 border0><tr><td valign=top>';

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

					html += '<img src="' + ImageUrl('135/50',myid,showid) + '" border=0 class=pimg vspace=2 hspace=3';
					html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";html += '" onmouseout="hp();" id=' + myid + '>';
					html += '</a><br />';
					if(myhrdlink)
						html += '<center><a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a></center>';
					html += '</td><td valign="top"><font class=xsmall><span style="margin-left: 10px;float: left;">ID:' + displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
					//	html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html += '</div><DIV class=icons style="float:left;">';

					//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=/))) ) )	

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

					html += '<div class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';

					html += '<div class="iconnormal" id="iconprice"><a href="/price.shtml?'+displayid+'" class="iconlink" Title="Price Image"></a></div>';

					if (! thisisacoverimage_feature )
						html += '<div class="iconnormal" id="iconenlarge"><a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class=iconlink title="Enlarge image and more info"></a></div>';
					
	//				html += '</DIV>';
					
					if(showphotographer == 1){html +='<br /><div style="float: left;">&copy; '+currentYear+' ' + myphotographer;}
					html += '<nobr>';
					if(showfilesize){html += myfilesize;}
					html += '</nobr></div><br/><span style="float: left;">CAPTION: ' + myshortcaption + '<div>'+myreleased+'</span></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 = 100 + adminheight;
				if ( mysimilarto.length < 13){	
					
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:95px; height:' + theight + 'px; overflow: hidden;">';

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

					if(document.page.previews.selectedIndex == 1){html +=' TITLE="ID:' + displayid;
						if(showphotographer == 1){html += '\r&copy; ' + myphotographer;}
						if(showfilesize){html += '\rSIZE: '+ myfilesize ;}
						html +=  ' \r' + 'CAPTION: ' + myshortcaption + '"';
					}
					html += '><img src="' +ImageUrl('135/50',myid,showid)+ '" 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=icons style="margin-left: 22px;">';

			//		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=/))) ) )

					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && !q_args.match(/fn=/) && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/))) ) )
					{
						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="icontiny" id="smalliconlb"><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 class="iconnormal" 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 class="icontiny" id="smalliconcart"><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 class="icontiny" id="smalliconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlinktiny" Title="Price Image"></a></div>';
					
					html += '<div class="icontiny" id="smalliconprice"><a href="/price.shtml?'+displayid+'" class="iconlinktiny" Title="Price Image"></a></div>';


					if (! thisisacoverimage_feature)
						html += '<div class="icontiny" id="smalliconenlarge"><a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlinktiny" title="Enlarge image and more info"></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 + '\'); 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>';
					}  */

					html += '</DIV></font>';
					html += '<DIV class=imidxxsmall style="float: left;margin-left: 13px;">' + displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
					//	html += '  <font class=rmrfindicator>'+rm[showid]+'</font>';
					}
					html +='</DIV>';

					if (myhrdlink)
						html += '<a href="'+myhrdlink+'" class="hiresdl_link"><font color="#cc0000">Download Hires</font></a>';
					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 == "ss"){			
				html = '  ';
			} else if (viewmode == "huge"){		
				var theight = 255 + 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 += '  "><img src="' + ImageUrl('420/60',myid,showid) + '" border="0" vspace="1" hspace="3" alt="loading..." height="192"></a><br />';
			
					html += '<font class="xsmall"><DIV class=icons>';	
			//		 if ( ! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/) || q_args.match(/fn=/))) ) )

					if ( !thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && !q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && !q_args.match(/fn=/) && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/))) ) )
			              {
                           //             html+='<span id="iconlbremove"><A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="lblink" TITLE="Remove this image from the lightbox"></A></span>';
                                        }
					html += '<div class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
			
					html += '<div class="iconnormal" id="iconprice"><a href="/price.shtml?'+displayid+'" class="iconlink" Title="Price Image"></a></div>';	
	

					if (! thisisacoverimage_feature)
						html += '<div class="iconnormal" id="iconenlarge"><a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"></a></div> ';
                                        if (myhrdlink)
                                                html += '<span id="icondlhigh"><a href="'+myhrdlink+'" class="hiresdl_link"></a></span>';

					html += '</DIV></font><br>';
					html += '<div style="float: left;margin-left: 132px;">';
					
					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>';
					}
					html += displayid;
					if(typeof(suppressrmrftype) == 'undefined'){
						//html += '  <font class=rmrfindicator>'+rm[showid]+'</font> ';
					}
					html += '</div><br>';	
	                               /* html += '<div style="float: left;margin-left: 114px;">';
					if (myhrdlink)
						html += '<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 = 199 + adminheight;
				if ( mysimilarto.length < 13){		
					html += '<span valign=bottom style="float:left;">';
					html += '<div align=center valign=bottom style="width:187px; height:' + theight + 'px; overflow:hidden;">';
                                        if(thisisacoverimage_feature) //myid is in the info for the link, hence this is the cover image
                                                html += '<a href="/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd" ';
                                        else
                                                html += '<a href="javascript: return false;" onclick="hp(); enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;"'

         if(viewmode=='table'){
            html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";
            html += '" onmouseout="hp();" '
          }
					html += ' id=' + myid + '>';
					html += '</a><br />';
					html += '<font class="xsmall"><DIV class=icons style="margin-left: 20px;">';

					
					//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=/))) ) )						{
					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && !q_args.match(/fn=/) && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/))) ) )
					{

					html+='<span id="iconlbremove"><A href="javascript: return false;" onclick="lightbox_delete_image_enl(\'' + myid + '\'); return false;" class="iconlink" TITLE="Remove this image from the lightbox"></A></span>';
					}

					html += '<div class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';
					html += '<div class="iconnormal" id="iconprice"><a href="/price.shtml?'+displayid+'" class="iconlink" Title="Price Image"></a></div>';				


					if (! thisisacoverimage_feature )
						html += '<div class="iconnormal" id="iconenlarge"><a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"></a></div><br>&nbsp;';

					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>';
					}

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

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

					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 = 155 + 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;"'

					html += '><img src="' + ImageUrl('135/50', myid,showid) + '" class=pimg border="0" vspace="0" hspace="3"';
         if(viewmode=='table'){
            html += " onmouseover=\"prloadimg('"+ myid +"'); sp(this, '" + myid + "','" + showid + "','"+tset+"');";
            html += '" onmouseout="hp();" '
          }
					html += ' id=' + myid + '>';
					
					html += '</a><br />';
					html += '<font class="xsmall"><DIV class=icons style="margin-left: 7px;">';

					
				//	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=/))) ) )						{
					
					if (! thisisacoverimage_feature && ((typeof(pre_q_args) != 'undefined' && pre_q_args.match(/fn=/) ) || (typeof(q_args) != 'undefined' && !q_args.match(/fn=/) && ( q_args.match(/vmo=/) || q_args.match(/rid=/) || q_args.match(/lb_view=1/))) ) )
					{

					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 class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" 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 class="iconnormal" id="iconprice"><a href="javascript: return false;" ONCLICK="return price_image(\'' + myid + '\',\''+myrmrftype+'\');" class="iconlink" Title="Price Image"></a></div>';

					html += '<div class="iconnormal" id="iconprice"><a href="/price.shtml?'+displayid+'" class="iconlink" Title="Price Image"></a></div>'; 

					if (! thisisacoverimage_feature)
						html += '<div class="iconnormal" id="iconenlarge"><a href="javascript: return false;" ONCLICK="enlarge2(\'' + myid + '\'' + ',' + '\'' + showid + '\'); return false;" class="iconlink" title="Enlarge image and more info"></a></div>&nbsp;';
					if (myhrdlink)
                                                html += '<span id="icondlhigh"><a href="'+myhrdlink+'" class="hiresdl_link"></a></span>';				


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

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

					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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function lightbox_build(tlba,lname,secr,lbl){ // major code to build the lightbox area
	if(cartview && carnit)
	{
		carnit = 0;
		document.currentlbstash=tlba;
		cart_build('changing');//preempt initial lightbox build if we've been asked to go direct to cart.
		//cart_display();
		return;
	}
	hidedisplaypanel(1)	// clears the message that was saying loading lightbox or any other transition messages

	//I got called but there is no lightbox data anywhere
	if(typeof(tlba) != 'object' && typeof(document.currentlbstash) == 'undefined') 
		return;
	else if(typeof(document.currentlbstash) == 'object' && typeof(tlba) != 'object' )
		tlba=document.currentlbstash;

	currentLbdivMode = 'lightbox';
	
	if(lname)  // called from the LBframe results routine otherwise, usually we don't need to change lb just rebuild it
		currentlbname=lname;
	
	if(lbl)
		currentlblist=lbl.split('|');
	
	if(secr)
		scr=secr; // secret auth tag passed from server to prevent from an open lightbox security vulnerability

	var lbdPos = $('LBdiv') ? Position.cumulativeOffset($('LBdiv')) : [0,0];

	var lbbgH = winH - lbdPos[1] - 18; //18 being height of lbbuttons	

	document.currentlbstash=tlba;
	
	if($('LBdiv'))
	{
		// acts as the root node.. logical analog to the dom object they'll be apended to
		var thehtmlElements = $A([]); 
	
		thehtmlElements.push(  
		Builder.node('div', {id:'lbbuttons'},[
		//	Builder.node('a', {href:'javascript: return false;', onclick:"cart_build('changing'); return false;", title:phrase.lightbox_switch_to_cart_title, id:"tab_lightbox"})
			Builder.node('a', {href:'javascript: void(0);', id:"tab_lightbox"})
		])	
		);
		
		var thehtmlLinkList = $A([]);
		if ( currentlblist && currentlblist.length > 0)
		{
			var hasplaceholder = 0;
			$A(tlba).each( function(lbItem) { if(lbItem.id == 1) hasplaceholder = 1; });
			var displen = ( hasplaceholder ? ( tlba.length - 1 ) : tlba.length );
						
			thehtmlLinkList.push(
			Builder.node('b', {}, currentlbname + phrase.lightbox_name_suffix),
			'  (' + displen + ')  ',
			Builder.node('b', {}, phrase.lightbox_changeto_text)
			);
	
			//build selects longhand.. IE bugs... of course
			var selFix = document.createElement('select');
			selFix.setAttribute('name','n');
			selFix.setAttribute('id','lightbox_menu');
			selFix.setAttribute('class','smallmenu');
			//double IEfix.. must set this programatically (implied eval w/ setAttribute fails in IE7)
			selFix.onchange = function () { lightbox_change(this.options[this.selectedIndex].value); };
			
			for(var i=0;i<currentlblist.length;i++){
				if (currentlblist[i] != '')
				{
					var theOpt;
					theOpt = document.createElement('option');
					theOpt.setAttribute('value', currentlblist[i]);
					theOpt.appendChild(document.createTextNode(currentlblist[i].substring(0,25) 
						+ (currentlblist[i].length > 25 ? '...' : '')));
	
					if(currentlblist[i]==currentlbname)
						theOpt.setAttribute('selected', 'selected');
	
					selFix.appendChild(theOpt);
				}
			}
	
			thehtmlLinkList.push(selFix);
		}
	
		var tlb1 = '';
		var tlb2 = '';
		var tlb3 = '';
		var tlb4 = '';
		var tlb5 = '';
		var tlb6 = '';
		var tlb7 = '';
		var tlb8 = '';
		var tlb9 = '';
		if(winW>832){
			tlb1 = phrase.lbmenu_new;//'New Lightbox'
			tlb2 = phrase.lbmenu_expanded;//'View Expanded Lightbox';
			tlb3 = phrase.lbmenu_email;//'Email Lightbox';
			tlb4 = phrase.lbmenu_add2cart;//'Add Lightbox to Cart';
			tlb6 = phrase.lbmenu_rename;//'Rename Lightbox';
			tlb7 = phrase.lbmenu_makefeature;//'Make LB a Feature';
			tlb8 = phrase.lbmenu_copytouser;//'Copy LB to User';
			tlb5 = phrase.lbmenu_delete;//'Delete Lightbox';
			tlb9 = phrase.lbmenu_resort;//'Resort LB';
		} else {
			tlb1 = phrase.lbmenu_new_s;//'New Lightbox'
			tlb2 = phrase.lbmenu_expanded_s;//'View Expanded Lightbox';
			tlb3 = phrase.lbmenu_email_s;//'Email Lightbox';
			tlb4 = phrase.lbmenu_add2cart_s;//'Add Lightbox to Cart';
			//tlb5 = phrase.lbmenu_delete_s;//'Delete Lightbox';
			tlb6 = phrase.lbmenu_rename_s;//'Rename Lightbox';
			tlb7 = phrase.lbmenu_makefeature_s;//'Make LB a Feature';
			tlb8 = phrase.lbmenu_copytouser_s;//'Copy LB to User';
			tlb5 = phrase.lbmenu_delete;//'Delete Lightbox';
			tlb9 = phrase.lbmenu_resort_s;//'Resort LB';
		}
	
		thehtmlLinkList.push(
  		Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick': "lightbox_new(); return false;" }, tlb1),
		' | ',
  		Builder.node( "a", { 'href': "javascript: return false;", 'onclick':"var d = new Date(); d.setMinutes(d.getMinutes()+5); gsetCookie('gprewhichstartpage', showstartnumber_trap, d, '/', gGetCookieDom()); toplightboxrefresh(); return false;", 'class': "lblink"}, tlb2),
		' | ',
  		Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick':"lightbox_email(); return false;"}, tlb3),
		' | ',
//  		Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick':"lightbox_add2cart(); return false;"}, tlb4),
//		' | ',
  		Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick':"lightbox_rename(); return false;"}, tlb6) 	
//		' | ',
	//	Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick':"lightbox_delete(); return false;"}, tlb5)	
		);
	
		if(typeof(makelightboxfeature) != 'undefined')
		{
			thehtmlLinkList.push(
   			' | ',
			Builder.node('a', {'href':'javascript: return false;', 'class':'lblink', 'onclick':"launchwin('"+makelightboxfeature + currentlbname+"', 'make feature', 500, 400, 100, 100); return false;"}, tlb7)
			);
		}
	
		if(typeof(copylightboxtouser) != 'undefined')
		{
			thehtmlLinkList.push(
   			' | ',
			Builder.node('a', {href:'javascript: return false;', 'class':'lblink', 'onclick':"launchwin('" + copylightboxtouser + "', 'copy_lightbox', 300, 300, 300, 400); return false;"},tlb8)
			);
		}

		if(typeof(enlargedlbsort) != 'undefined')
		{
                        thehtmlLinkList.push(
                        ' | ',
                        Builder.node('a', {href:'javascript: return false;', 'class':'lblink', 'onclick':"if(pagetype=='lb') { center_panel(390,120, '<div style=\"background:#F7E6A9;height:120px;font-size:6pt;text-align:center;padding:20px 10px 0 10px;\"><br/><h1>Your display will be refreshed once you close the Lightbox Sort popup window.</h1></div>'); } launchwin('" + enlargedlbsort + currentlbname + "', 'resort_lightbox', 450, 750, 200, 300); return false;"},tlb9)
                        );

		}
		thehtmlLinkList.push(
	         ' | ',	
		 Builder.node( "a", { 'href': "javascript: return false;", 'class': "lblink", 'onclick':"lightbox_delete(); return false;"}, tlb5)
                );


//	        if (viewmode == 'editing')
//		{
			thehtmlLinkList.push(
			' | ',
       			Builder.node('a', {'href':'javascript: return false;', 'class':"lblink", 'onclick':"showhideLB(); return false;", style:"cursor:pointer"},phrase.lightbox_minimize_link)
			);
//		}

		var lbdisplaymode_style = 'block';
	      	if ( lbdisplaymode && viewmode == 'editing')
	        {
	                lbdisplaymode_style = 'none';
	        }
		
		thehtmlElements.push( 
		Builder.node('div', {'id':'lblinks','class':'lbname lbscroll', 'style':'overflow: auto; overflow-y:hidden'},[
			Builder.node('nobr', {}, thehtmlLinkList)
		])
		);
		
		var thehtmlLightboxStrip = $A([]);
		
		var heightOfLbDiv = 30;
		if(tlba.length>0){

			if ( lbdisplaymode_style == 'block')
				heightOfLbDiv = 130;
			else if (lbdisplaymode_style == 'none')
				heightOfLbDiv = 40;

			var scrollins = 'hidden';
			var perrow = parseInt(winW / 79);
			var wishwidth = '100%';
			if ( perrow < tlba.length )
			{
				scrollins = 'scroll';
				wishwidth = 79 * tlba.length;
				wishwidth = wishwidth + 'px';
			}
	
			
			var tofit=50;
			if(truevertHeight < 340){vlim=25;} else if(truevertHeight < 450){vlim=35;} else {vlim=58;}
			for (lbi=0;lbi<tlba.length;lbi++){
				if (tlba[lbi].id == '')
					continue;
	
				lbid=tlba[lbi].id;
				
				if ((lbid == 1 && tlba.length < 2) || lbid != 1){ // hide image 1 from view unless new box...
					var lbLinkArgs = { 'className':'lblink lblinkPreviewImage', 'title':phrase.lbstrip_enlarge_title };
					var lbImgLinkArgs = { 'id': 'dlb'+lbi+'s_lbi' };
                    if (tlba[lbi].rfcd && tlba[lbi].rfcd.toString().length) //myid is in the info for the link, hence this is the cover image
						{
                     	var pm = unescape(tlba[lbi].rfcd.toString()).match(/SwishSearch\?n\=1\&fn\=(.*)\&supst\=cd/);
		             	if(pm != null)
						{
	            			var thisisacoverimage_feature = pm[1];
                            lbLinkArgs.href = '/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd';
                            lbImgLinkArgs.href = '/SwishSearch?n=1&fn='+thisisacoverimage_feature+'&supst=cd';
						}
                    } else {
                        lbLinkArgs.href = 'javascript: return false;';
						lbLinkArgs['onclick'] = "hp(); enlarge2('" + lbid + "','" + lbi + "'); return false;";
                        lbImgLinkArgs.href = 'javascript: return false;';
						lbImgLinkArgs.onclick = "if (suspendpreviews==0) { hp(); enlarge2('" + lbid + "', '" + lbi + "'); } return false;";
					}
					var theSlug = ( lbid != 1 ?
						Builder.node('div', {'style':'padding-left: 2px; padding-right: 2px; padding-bottom:6px;'},[
						Builder.node('a', {'onclick':"lightbox_delete_image('" + lbid + "'); return false;", className:'lblink lblinkDeleteImage', 'title':phrase.lbstrip_remove_image_from_lb_title,'href':'javascript: return false;'},phrase.lbstrip_remove_image_from_lb_linktext),

						Builder.node('a', lbLinkArgs,phrase.lbstrip_preview_image_from_lb_linktext)
       					])
						:
		       			''
					);

					thehtmlLightboxStrip.push(
					Builder.node('div', {'id':'dlb_'+lbi, 'name':'dlb_'+lbi, 'style':'float:left; height:' + (tofit + 18) + 'px; overflow:hidden', 'align':'center'}, [
						Builder.node('a', lbImgLinkArgs,[
							Builder.node('img', {'id':'dlb_'+lbid, 'onmouseover':"prloadimg('"+lbid+"'); pmousedelta[1] = -180; sp(this, '" + lbid + "', '" + lbi +  "','" + tset + "');", onmouseout:"hp(); pmousedelta[1] = -30;", 'src':ImageUrl('135/50', lbid), border:0, height:tofit, className:'lbimg', 'hspace':2})
						]),
						Builder.node('br'),
      						theSlug
					])
					);
				}
			}
		}
		else if (currentlbname)
		{
			thehtmlLightboxStrip.push(
			Builder.node('div', {'id':'dlb_0', 'name':'dlb_0', 'style':'float:left; height:' + (tofit + 18) + 'px; overflow:hidden;', 'align':'center'},[
				Builder.node('a',{'href':'javascript: return false;', 'onclick':'return false;', 'id':'dlb0s_lbi', 'onmouseover':"prloadimg('1'); sp(this, '1', '0','" + tset + "');", 'onmouseout':"hp();"},[
					Builder.node('img', {'src':'http://globaldyn.ipnstock.com/'+dynimagesname+'/135/50/1.JPG', border:0, height:tofit, className:'lbimg', 'hspace':2})
				])
			])
			);
		}
		thehtmlElements.push(
		Builder.node('div', {'class':'lbscroll', 'style':'position: relative; overflow:'+scrollins+'; overflow-y:hidden;height:'+(heightOfLbDiv-41)+'px;'},[ 
				Builder.node('div', {'id':'LBimgdiv', 'style':'position:absolute; left:0; top:0; padding: 1px 0 0 0; height:'+(heightOfLbDiv-40)+'px; width:'+wishwidth+'; display:'+lbdisplaymode_style+';'},[
				thehtmlLightboxStrip
			])	
		])
		);
 
		//write the lb to the div
		$('LBdiv').replace('<div id="LBdiv"></div>');
		$('LBdiv').innerHTML = '';
		$('LBdiv').style.height = heightOfLbDiv+'px';


		thehtmlElements.each(function(domer){
			$('LBdiv').appendChild(domer);	
		});

                if ( lbdisplaymode == 1 && viewmode == 'editing') //minimize
                        $('LBimgdiv').hidden = 1;

   		//Mini Sortable used to go here.  Moved to expanded sort.

    }

      global.lightBoxBuilt = 1;
	lightbox_built = global.lightBoxBuilt;  // backward compatibility
	return;
 };

function setupPageSize(){
	adminheight = 0;
	if( typeof(hrdl) != 'undefined' && hrdl[0] && hrdl[0] !=''){
                if (typeof(viewmode) != 'undefined' && viewmode == 'editing')
                        adminheight=0;
                else
			if(typeof(adminheight_custom) != 'undefined'){adminheight=adminheight_custom} else {adminheight=11;}
	} 

	if(typeof(shcon) == 'object' && shcon[0] && shcon[0] !='') {
		adminheight+=11;
	}

	if ( $('Layer1') )
	{
		winW = Element.getWidth('Layer1');
	}
	else if (window.innerWidth)
       	{
              	winW = window.innerWidth;
        }
       	else if(document.documentElement && document.documentElement.clientWidth)
        {
        	winW = document.documentElement.clientWidth;
        }
        else if(document.body && document.body.clientWidth)
        {
        	winW = document.body.clientWidth;
        }
        else if(document.body && document.body.offsetWidth)
        {
        	winW = document.body.offsetWidth;
        }




	if (window.innerHeight)
	{
		trueh = window.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		trueh = document.documentElement.clientHeight;
	}
	else if(document.body && document.body.clientHeight)
	{
		trueh = document.body.clientHeight;
	}
	else if(document.body && document.body.offsetHeight)
	{
		trueh = document.body.offsetHeight;
	}

/*
            if (document.documentElement.clientHeight && document.documentElement.clientHeight > trueh && (typeof(viewmode) != 'undefined' && (viewmode != 'med' || yourBrowse == 'IE' ) ))
            {
                trueh = document.documentElement.clientHeight - 0;
            }
	*/

	truew = winW;
	safetyspace = 16;
	menuheight = 20;
	winH = parseInt(trueh) - ( $('row2') ? (parseInt(Element.getHeight("row2")) + Position.cumulativeOffset($('row2'))[1]) : 20 );

	//alert(winH);
	if(document.currentLayer1Mode == 'enlarge')
	{
		winH = winH - safetyspace;
	}
	else
	{
	 	winH = winH - safetyspace - menuheight;
	}

	//tweakheight -- if you just can't get it right:
	if (typeof(tweakheight) != 'undefined' && tweakheight != 0)
		winH = winH - tweakheight;

	if(gsession){//logged in
//switched to fixed lb height, 
		if(document.getElementById('LBdiv')){//lightbox is present measure height
			var lbh = parseInt(Element.getHeight("LBdiv"));
			if(lbh < 140 && ! ( lbdisplaymode == 1 && viewmode == 'editing') ){//be safe and leave room unless we're hiding the LB
				winH = winH - 140;
			} else {
				winH = winH - lbh;
			}
		} 
	}
	if (typeof(setuppagesize_cellsizes_custom) == 'function')
	{
		setuppagesize_cellsizes_custom(); //this function must init the same globals as in the base case below:
	}
	else
	{

	    imagerows=Math.floor(winH/(155 + adminheight));
	    imagespaceheight=imagerows * (155 + adminheight);
	    area=imagerows * Math.floor(winW/153);
	    if(! viewmode && imagerows == 1)
	    { 
		viewmode='med';
		gsetCookie('gviewmode','med', '', '/', gGetCookieDom());
	    }

	    if(viewmode){
			if(viewmode == 'table' || viewmode == 'med'){
			    if(typeof(InitSafetyCheck)=='function'){InitSafetyCheck('135/50');};
				imagerows=Math.floor(winH/(155 + adminheight));
				if(imagerows == 0)
					imagerows=1;
				imagespaceheight=imagerows * (155 + adminheight);
				area=imagerows * Math.floor(winW/153);
			} else 	if (viewmode == 'tiny'){
			    if(typeof(InitSafetyCheck)=='function'){InitSafetyCheck('135/50');};
				imagerows=Math.floor(winH/(106.00 + adminheight));
				if(imagerows == 0)
					imagerows=1;
				imagespaceheight=imagerows * (106 + adminheight);
				area=imagerows * Math.floor(winW/96.00);
			} else if (viewmode == 'huge'){
			    if(typeof(InitSafetyCheck)=='function'){InitSafetyCheck('420/60');};
				imagerows=Math.floor(winH/(255.00 + adminheight));
				if(imagerows == 0)
					imagerows=1;
				imagespaceheight=imagerows * (255 + adminheight);
				area=imagerows * Math.floor(winW/333.00);
			} else if (viewmode == 'large'){
			    if(typeof(InitSafetyCheck)=='function'){InitSafetyCheck('170/85');};
			
				imagerows=Math.floor(winH/(199.00 + adminheight));
				if(imagerows == 0)
					imagerows=1;
				imagespaceheight=imagerows * (199 + adminheight);
				area=imagerows * Math.floor(winW/187.00);
			}
				
	    }


	}

/*	if(document.currentLayer1Mode == 'enlarge'){
			imagespaceheight=winH - menuheight;
		} */
	truevertHeight = winH;
	//winH=imagespaceheight + menuheight; // restore it to accomodate narrowbar and footer // it's already limited.. this crop is too close..
	if(winH<450){
		smallscreen=1;
	}
	if(area > 0){
		totalimagesthatcanfit=area;
		gpixperpagev=totalimagesthatcanfit;
                if ($('pixperpage'))  // Mantis #1157 - Needed to guarantee pop-ups show up - Milan Adamovsky 07/06/2009
                 $('pixperpage').value = gpixperpagev;
	} else {
		// load images per page into field
		gpixperpagev = ggetCookie('gpixperpage');
		if(! gpixperpagev)
			gpixperpagev=12;
	}


	//set up coverlayer
        createCoverLayer();
        $('coverlayer').style.width = winW + 'px';

                if($('lbbuttons'))
                {
                        $('coverlayer').style.height =
                        ( Position.cumulativeOffset($('lbbuttons'))[1] - Position.cumulativeOffset($('row2'))[1]  + Element.getHeight("lbbuttons") ) + 'px';// + 'px';//$('Layer1').style.height;
                }
                else
                {
                        $('coverlayer').style.height = (winH + 30) + 'px';
                }

                var co = [];
                if ( $('row2') )
                        co = Position.cumulativeOffset($('row2'));
                else
                {
                   if ($('navContainer'))  // Check why sometimes this doesn't exist - Milan Adamovsky 06/17/2009
                    {
                        co = Position.cumulativeOffset($('navContainer'));
                        co[1] += $('navContainer').getHeight();
                    }
                }


                $('coverlayer').style.top = co[1] + 'px';
                $('coverlayer').style.left = co[0]  + 'px';

 };

function popflip(flipid){
        window.open("/flip.shtml?" + flipid,"flip","width=460,height=480,resizable=0,scrollbars=no,menubar=no,status=no");
};




