var firstImageInBrowse=imgurl+'d/gallery_browse_first.gif';var lastImageInBrowse=imgurl+'d/gallery_browse_last.gif';var loaded_firstStrip=false;var loaded_lastStrip=false;var success_icon=new Image();success_icon.src=imgurl+"d/icons/accept.png";var errorIcon=new Image();errorIcon.src=imgurl+'d/my/exclamation.png';var ratedUp_mono=new Image();ratedUp_mono.src=imgurl+'d/icons/thumb_s_up_grey.png';var ratedDown_mono=new Image();ratedDown_mono.src=imgurl+'d/icons/thumb_s_down_grey.png';var img_strip_ajax=false;$(document).ready(function(){$.ajaxSetup({type:"POST",timeout:15000,success:function(html){if(html=="false"){window.location.reload();}},error:function(){}});$("div#psign img#prev1,div#nsign img#next1").click(function(){image_strip(this);});$("#prev3, #next3").click(function(){image_strip(this);image_strip(this);image_strip(this);});$("legend.link_collapse").livequery('click',function(){$(this).removeClass('link_collapse').addClass('link_expand');$(this).next('.fieldbody').slideUp();});$("legend.link_expand").livequery('click',function(){$(this).removeClass('link_expand').addClass('link_collapse');$(this).next('.fieldbody').slideDown();});$('#hidden_box_reset').livequery('click',function(){$("#options #hidden_box").html('').hide();});$('.report_image').click(function(){$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=generate_report_image_reasons&imageid="+v_imageid,success:function(html){if(html.indexOf('Error:')!=-1){$("#options #hidden_box").html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();setTimeout('$("#options #hidden_box").hide().removeClass("errorbox")',3000);}else{var btns='<a href="#" onclick="return false;" class="link" id="report_image_submit"><input type="image" src="'+imgurl+'d/my/tick.png" name="report_image_submit" title="Report Image" onclick="return false;" />Report Image</a> <a href="#" onclick="return false;" class="link" id="hidden_box_reset"><input type="image" title="Reset" src="'+imgurl+'d/my/cross.png" onclick="this.form.reset();return false;" />Cancel</a>';$("#options #hidden_box").html(html+btns).show();}}});});$('#report_image_submit').livequery('click',function(){var reasonStr=$('#options form textarea[name="reason"]').val();if(jQuery.trim(reasonStr)!=''){var formArray=$('#options form').serialize();$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=report_image&imageid="+v_imageid+"&"+formArray,success:function(html){$("#options #hidden_box").html('<img src="'+success_icon.src+'" alt="Done!" /> Thank you, the report has been filed and our moderators will handle it very soon.').addClass('msgbox');setTimeout('$("#options #hidden_box").hide().removeClass("msgbox")',3000);}});}else{alert('You must enter a reason for reporting this image.');}});$('.resolve_reports').click(function(){$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=keep_img_remove_image_reports&imageid="+v_imageid,success:function(html){if(html.indexOf('Error:')!=-1){$("#report_msgbox").html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{$("#report_msgbox").html('<img src="'+success_icon.src+'" alt="Done!" /> Thank you, the reports have been removed and the image will be restored to view.').addClass('msgbox').show();$('#ireports').fadeTo('slow',0.3);setTimeout('$("#ireports").remove();',3000);}}});});$('.remove_img_and_reports').livequery('click',function(){$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=generate_report_image_reasons&imageid="+v_imageid+'&upon_removal=1',success:function(html){if(html.indexOf('Error:')!=-1){$("#report_msgbox").html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{var btns='<a href="#" onclick="return false;" class="link" id="remove_img_and_reports_submit"><input type="image" src="'+imgurl+'d/my/tick.png" name="remove_img_and_reports_submit" title="Remove Image &amp; its reports" onclick="return false;" />Remove Image &amp; its reports</a> <a href="#" onclick="return false;" class="link" id="ireports_form_reset"><input type="image" title="Reset" src="'+imgurl+'d/my/cross.png" onclick="this.form.reset();return false;" />Cancel</a>';var cssObj={border:'1px solid #C0C0C0',background:'#F0F0F0',padding:'3px',marginBottom:'16px'};$("#report_msgbox").html('<form method=post" action="">'+html+btns+'<\/form>').css(cssObj).show();}}});});$('#remove_img_and_reports_submit').livequery('click',function(){var formArray=$('#report_msgbox form').serialize();$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=remove_image_and_reports&imageid="+v_imageid+'&'+formArray,success:function(html){if(html.indexOf('Error:')!=-1){$("#report_msgbox").html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{$("#report_msgbox").html('<img src="'+success_icon.src+'" alt="Done!" /> Thank you, the image and all of its reports have been removed. This URL will become unavailable to all visitors.<br />Go back to <a href="'+gallery_url+'reports/">Gallery Reports Home</a>').addClass('msgbox').show();$('#ireports').fadeTo('slow',0.3);setTimeout('$("#ireports").remove();',3000);}}});});$('#ireports_form_reset').livequery('click',function(){$('#report_msgbox').html('').hide();});$('.ban_user_from_report').click(function(){var mid=$(this).attr('id').split('_')[$(this).attr('id').split('_').length-1];$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=ban_user_from_report&memberid="+mid,success:function(html){if(html.indexOf('Error:')!=-1){$("#report_msgbox").html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{$(this).replaceWith('<span class="banned"><strong>BANNED</strong> from image posting</span>');}}});});$('.send_pm').livequery('click',function(){var rid=$(this).parents('.ireport').attr('id').split('_')[$(this).parents('.ireport').attr('id').split('_').length-1];$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=generate_pm_box&reportid="+rid+"&imageurl="+window.location,success:function(html){if(html.indexOf('Error:')!=-1){$('#pmbox_'+rid).html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{$('#pmbox_'+rid).html(html).show();}}});});$('.append_link').livequery('click',function(){var rid=$(this).parents('.ireport').attr('id').split('_')[$(this).parents('.ireport').attr('id').split('_').length-1];var pmbody=$('#postingform_'+rid+' textarea').val();if(pmbody.indexOf("You got this PM from")==-1){var imageurl=$('#postingform_'+rid+' input[name="imageurl"]').val();$('#postingform_'+rid+' textarea').val(pmbody+'\r\n\r\n-----\r\nYou got this PM from [link name=your image report]'+imageurl+'#ir_'+rid+'[/link] in this [link name=gallery image]'+imageurl+'[/link] thread');}});$('.send_pm_submit').livequery('click',function(){var rid=$(this).parents('.ireport').attr('id').split('_')[$(this).parents('.ireport').attr('id').split('_').length-1];var formArray=$('#postingform_'+rid).serialize();$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=send_pm&"+formArray,success:function(html){if(html.indexOf('Error:')!=-1){$('#pmbox_'+rid).html('<img src="'+errorIcon.src+'" alt="Error!" /> '+html).addClass('errorbox').show();}else{$('#pmbox_'+rid).html('<img src="'+success_icon.src+'" alt="Done!" /> Thank you, PM sent!').addClass('msgbox').show();setTimeout('$("#pmbox_'+rid+'").html("").removeClass("msgbox").hide()',3000);}}});});$('#disable_gallery').click(function(){$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=get_disable_gallery_form",success:function(html){if(html.indexOf('Error:')!=-1){alert(html);}else{var btns='<a href="#" onclick="return false;" class="link" id="disable_gallery_submit"><input type="image" src="'+imgurl+'d/my/tick.png" name="disable_gallery_submit" title="Disable Gallery" onclick="return false;" />Disable Gallery</a> <a href="#" onclick="return false;" class="link" id="disable_gallery_reset"><input type="image" title="Reset" src="'+imgurl+'d/my/cross.png" onclick="this.form.reset();return false;" />Cancel</a>';$('#gallery_mod').html(html+btns);}}});});$('#disable_gallery_reset').livequery('click',function(){$('#gallery_mod').html('');});$('#disable_gallery_submit').livequery('click',function(){var formArray=$('#gallery_mod').serialize();$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=disable_gallery&mid="+MID+"&"+formArray,success:function(html){if(html.indexOf('Error:')!=-1){alert(html);}else{window.location.reload();}}});});$('#restore_gallery_view').click(function(){$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=restore_gallery_view&mid="+MID,success:function(html){if(html.indexOf('Error:')!=-1){alert(html);}else{window.location.reload();}}});});$('.userhome_browse_nav a').click(function(){var page=$(this).html();$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=browse_gallery&page="+page,success:function(html){if(html=='false'){window.location.reload();}else{$('.userhome_browse_nav a.onpage').toggleClass('onpage');$('.p'+page).addClass('onpage');$('#userhome_browse').html(html);}}});});$('.rate_image').each(function(i){$(this).data('click',0);});$('#imageinfo .rate_image').click(function(){if($(this).data('click')>1){return false;}
var activityid=$(this).parent('div').attr('id').split('_')[$(this).parent('div').attr('id').split('_').length-1];$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=rate_image&activityid="+activityid,success:function(html){if(html=='false'){window.location.reload();}else{$('#image_rating_'+activityid+' a.rate_image').html(html);$('#image_rating_'+activityid+' .rate_image').data('click',$('#image_rating_'+activityid+' .rate_image').data('click')+1);}}});});});function favourites(imageid,memberid,fav_action){var star_is_blank=new RegExp("unsubscribed_star");var star_image=document.getElementById('favorite_star');var star_text=document.getElementById('favourite');new AjaxRequest.post({'url':gallery_url+'ajaxhandler.php','parameters':{'action':'favourite','imageid':imageid,'memberid':memberid,'fav_action':fav_action},'onSuccess':function(req){if(star_is_blank.test(star_image.src)){star_image.src=star_on.src;star_text.innerHTML='Unfavourite this image';star_image.onclick=function(){favourites(imageid,memberid,'remove');}
star_text.onclick=function(){favourites(imageid,memberid,'remove');}}else{star_image.src=star_off.src;star_text.innerHTML='Favourite this image';star_image.onclick=function(){favourites(imageid,memberid,'add');}
star_text.onclick=function(){favourites(imageid,memberid,'add');}}}});return false;}
function image_strip(oEl){var direction=$(oEl).attr('id').replace(/\d/,'');if(direction=='prev'&&$("#browsepanel div#"+direction+" a img").attr('src')!=firstImageInBrowse){$("#browsepanel #prev").removeClass('current');$("#browsepanel #current").removeClass('current');$("#browsepanel #next").removeClass('current');if((cv_pos+1)==img_ids.length){$("#browsepanel #next a").attr('onclick','');}
if(img_strip[img_ids[cv_pos-2]]){$("#browsepanel #prev a").attr('href',img_strip[img_ids[cv_pos-2]].url);$("#browsepanel #prev a img").attr('src',img_strip[img_ids[cv_pos-2]].icon.src).attr('alt',img_strip[img_ids[cv_pos-2]].caption);}else{$("#browsepanel #prev a").attr('href','#');$("#browsepanel #prev a img").attr('src',firstImageInBrowse).attr('alt','First photo');}
if(cv_pos-2==v_pos)$("#browsepanel #prev").addClass('current');$("#browsepanel #current a").attr('href',img_strip[img_ids[cv_pos-1]].url);$("#browsepanel #current a img").attr('src',img_strip[img_ids[cv_pos-1]].icon.src).attr('alt',img_strip[img_ids[cv_pos-1]].caption);if(cv_pos-1==v_pos)$("#browsepanel #current").addClass('current');$("#browsepanel #next a").attr('href',img_strip[img_ids[cv_pos]].url);$("#browsepanel #next a img").attr('src',img_strip[img_ids[cv_pos]].icon.src).attr('alt',img_strip[img_ids[cv_pos]].caption);if(cv_pos==v_pos)$("#browsepanel #next").addClass('current');cv_pos--;}else if(direction=='next'&&$("#browsepanel div#"+direction+" a img").attr('src')!=lastImageInBrowse){$("#browsepanel #prev").removeClass('current');$("#browsepanel #current").removeClass('current');$("#browsepanel #next").removeClass('current');$("#browsepanel #prev a").attr('href',img_strip[img_ids[cv_pos]].url);if(cv_pos==0){$("#browsepanel #prev a").attr('onclick','');}
$("#browsepanel #prev a img").attr('src',img_strip[img_ids[cv_pos]].icon.src).attr('alt',img_strip[img_ids[cv_pos]].caption);if(cv_pos==v_pos)$("#browsepanel #prev").addClass('current');$("#browsepanel #current a").attr('href',img_strip[img_ids[cv_pos+1]].url);$("#browsepanel #current a img").attr('src',img_strip[img_ids[cv_pos+1]].icon.src).attr('alt',img_strip[img_ids[cv_pos+1]].caption);if(cv_pos+1==v_pos)$("#browsepanel #current").addClass('current');if(img_strip[img_ids[cv_pos+2]]){$("#browsepanel #next a").attr('href',img_strip[img_ids[cv_pos+2]].url);$("#browsepanel #next a img").attr('src',img_strip[img_ids[cv_pos+2]].icon.src).attr('alt',img_strip[img_ids[cv_pos+2]].caption);}else{$("#browsepanel #next a").attr('href','#');$("#browsepanel #next a img").attr('src',lastImageInBrowse).attr('alt','Last photo');}
if(cv_pos+2==v_pos)$("#browsepanel #next").addClass('current');cv_pos++;}
download_pos_trigger=Math.floor((img_cv_end-img_cv_front)/4);last_section=Math.floor(strip_size/4*3)-1;if((!loaded_firstStrip&&direction=='prev'&&cv_pos<img_cv_front+download_pos_trigger+1)||(!loaded_lastStrip&&direction=='next'&&cv_pos>v_pos+download_pos_trigger-1)){var urlhash=(direction=='prev')?img_strip[img_ids[cv_pos]].urlhash:img_strip[img_ids[cv_pos]].urlhash;if(!img_strip_ajax){img_strip_ajax=true;$.ajax({url:gallery_url+'ajaxhandler.php',data:"action=load_prevnext_image_strip&direction="+direction+"&mid="+MID+"&edge_image_urlhash="+urlhash+"&current_albumid="+v_albumid,success:function(html){img_strip_ajax=false;if(html=="false"){window.location.reload();}else if(html=='empty'){if(direction=='prev')
loaded_firstStrip=true;else
loaded_lastStrip=true;}else{eval(html);strip_size_in_view+=strip_size;}}});}}}