            $(document).ready(function() {
                $('div.edit').hide();//hide edit divs on load
                
 
                
                $('a.edit_link').click(function() {
                    var id = $(this).attr('id');
                    var id2 = id.replace('_hlEdit', '');                   
                    var note_original = $('#' + id2 + '_note').html()
                    $('#message' + id2.replace('abuse_', '')).fadeIn(500).html("");
                    $('#' + id2 + '_divEdit').toggle(200);
                    $(':input', 'form.reportAbuseForm').each(function() {
                        var type = this.type;
                        var tag = this.tagName.toLowerCase(); // normalize case
                        if (type == 'text' || type == 'password' || tag == 'textarea')
                        this.value = "";
                    });                      
                    return false;
                });
                
                $('input.cancel').click(function() {                    
                    var id = $(this).attr('id');         
                    var id2 = id.replace('_btnCancel', '');
                    $('#message' + id2.replace('abuse_', '')).fadeIn(500).html("");
                    $('#' + id2 + '_divEdit').hide(200);
                    //clear form fields                        
                    $(':input', 'form.reportAbuseForm').each(function() {
                        var type = this.type;
                        var tag = this.tagName.toLowerCase(); // normalize case
                        if (type == 'text' || type == 'password' || tag == 'textarea')
                        this.value = "";
                    });                                        
                    return false;
                });              
                
                $('form.reportAbuseForm').submit(function() {                    
                    var id = $(this).attr('name');
                    id = id.replace('abuseForm', '');
                    $('#message' + id).html("<span style='font-size:1.1em;'>Submitting the form...</span>").fadeIn(500);
					var data = $(this).serialize();
					jQuery.ajax({ 
						url: this.action,
						data: data,
						timeout: 10000,
						/*error: function() { //on 404
							$('#message' + id).html("Unknown Error. Please try again.").fadeIn(1000);
						},*/
						success: function(r) { 
                            if (r.match("true")) {										
                                $('#message' + id).fadeIn(500).html("<span style='color:green;font-size:1.1em;'>Thank you for your submission. We will review your complaint.</span>");
                                $('#abuse_' + id + '_divEdit').hide(300);
							}
							else {
							    $('#message' + id).html("<span style='font-size:1.1em;'>There was an problem with your submission.</span>" + r).fadeIn(1000);
							}
						}
					})
                    return false;
                });                

                          
        $('a.flashAbuse_link').click(function() {
               var id = 0;
			    try
			     {
			     var swf = thisMovie('subPagePhotoGallerySWF');
			     id = swf.returnActivePhotoId();
			     }
			     catch (Error)
			     {
			     id = 0;
                 }                 
			        
                document.getElementById("idFlash").value = id;
    			        			   			         			        			   			                        
                if (id)
                {  
                    if (id == -1)
			        {
                        alert("Photos submitted by the state cannot be reported.");
			            $('#abuse_Flash_divEdit').hide(300);
			            return false;
                    }
                    else if (id != 0)
                    {                
                        $('#messageFlash').fadeIn(500).html("");
                        $('#abuse_Flash_divEdit').toggle(200);
                    $(':input', 'form.reportAbuseFormFlash').each(function() {
                        var type = this.type;
                        var tag = this.tagName.toLowerCase(); // normalize case
                        if (type == 'text' || type == 'password' || tag == 'textarea')
                        this.value = "";
                    });                         
                        return false;
                    }
                }
                else
                {
                    alert("There are currently no photos to report.");
                    return false;
                }

        });
                                           
                             
        $('form.reportAbuseFormFlash').submit(function() {   
			try
			 {
			 var swf = thisMovie('subPagePhotoGallerySWF');
			 var id = swf.returnActivePhotoId();
			 }
			 catch (Error)
			 {
			 id = 0;
			 }                 
			        
			 document.getElementById("idFlash").value = id;
    			        
                    if (id == -1)
			        {
                        alert("Photos submitted by the state cannot be reported.");
			            $('#abuse_Flash_divEdit').hide(300);
			            $('#messageFlash').html("").fadeIn(300);
			            $('#messageFlash').html("").hide(300);
			            return false;			        
                    }
                    else
                    { 
                       $('#messageFlash').html("Submitting the form...").fadeIn(500);
                            var data = $(this).serialize();
                            jQuery.ajax({ 
					            url: this.action,
						        data: data,
						        timeout: 10000,
						       /* error: function(error) { //on 404
                                $('#messageFlash').html("Unknown Error. Please try again. error: " + error).fadeIn(1000);
						        },*/
                                success: function(r) { 
                                    if (r.match("true")) {										
                                        $('#messageFlash').fadeIn(500).html("<span style='color:green;'>Thank you for your submission. We will review your complaint.</span>");
                                        $('#abuse_Flash_divEdit').hide(300);
							        }
                                    else {
                                        if (id != -1)
                                        {
                                            $('#messageFlash').html("There was an problem with your submission." + r).fadeIn(1000);
                                        }
                                    }
                                }
                        })  
                        return false;                            
                    }			        
                });                                                         
            });   

            function thisMovie(movieName)
		    {
			    if(navigator.appName.indexOf("Microsoft") != -1)
			    {
				    return window[movieName];
			    }
			    else
			    {
				    return document[movieName];
			    }
		    }    		
    		
		    function returnActivePhotoId()
		    {
			    var swf = thisMovie('subPagePhotoGallerySWF');
			    var id = swf.returnActivePhotoId();
			    //window.alert('id: ' + id);
		    }            