/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

	var admin_win;
	var special_url = 0;
    function report_admin(special_id){
        // create the window on the first click and reuse on subsequent clicks
        if (cur_mem_id) {
        	var name = {
    		    xtype: 'hidden',
	            value: 0,
	            name: 'can_name',
	            id: 'report_admin_name',
	            width: 320
		    };
		    var email = {
    		    xtype: 'hidden',
	            value: 0,
	            name: 'can_email',
	            id: 'report_admin_email',
	            width: 320
		    };
        	var height = 262;
        }
        else {
        	var name = {
    		    xtype: 'textfield',
	            fieldLabel: 'Name',
	            name: 'can_name',
	            id: 'report_admin_name',
	            width: 275
		    };
		    var email = {
    		    xtype: 'textfield',
	            fieldLabel: 'Email',
	            name: 'can_email',
	            id: 'report_admin_email',
	            width: 275
		    };
        	var height = 318;
        }
        if (admin_win)
        	admin_win.destroy();
        admin_win = new Ext.Window({
				title: 'Report Inappropriate Content or Behavior',
				cls: 'feedback',
				id: 'report-to-admin-popup',
				border: false,
				bodyBorder: false,
				
				bodyStyle: 'padding-left: 13px; padding-right:13px;',
				shadow: false,
				resizable: false,
                width       : 364,
                height      : height,
                closeAction :'hide',
				layout: 'fit',
				items: {
					xtype: 'form',
					cls: 'feedback-form',
					border: false,
					labelAlign: 'left',
					labelWidth:40,
					bodyBorder: false,
					autoHeight      : true,
					defaults: {hideMode: 'offsets'},
					items: [{
				    	border: false,
		        		html:'You are about to report inappropriate content or behavior. All reports are confidential, and we appreciate your help.',
		        		bodyStyle: 'margin-top:5px;margin-bottom:5px;background:transparent;color:#F86506;font-size:12px;font-weight:bold;'
		        	},{
				    	border: false,
		        		html:'Please explain what you are reporting and why:',
		        		bodyStyle: 'margin-bottom:4px;padding:3px 3px 3px 0;'
		        	},{
				        xtype: 'textarea',
			            hideLabel: true,
			            name: 'can_text',
			            id: 'report_admin_text',
			            width: 320,
			            height: 100
			        },name,email],
					buttonAlign: 'right',
					buttons: [{
						minWidth: 40,
						icon: g_params["static_media_domain"]+'/public/global/popup/send-report.png',
						cls: "send-report-btn x-btn-text-icon",
						handler: function() {
							$('.x-panel-footer', $('#report-to-admin-popup')).html('<div class="loading-indicator">Sending...</div>');
							//$('.x-window-body', $('#report-to-admin-popup')).height(170);
							Ext.Ajax.request({
								url: '/members/candidates/',
								method: 'post',
								params: { 
									'can_contact_type': 2,
									'can_name': Ext.getCmp("report_admin_name").getValue(),
									'can_email': Ext.getCmp("report_admin_email").getValue(),
									'can_text': Ext.getCmp("report_admin_text").getValue(),
									'can_page_url': (special_url ? special_url : location.href),
									'can_page_type_details': special_id
								},
								callback: function(options, success, response){
									if (success==true){
				                        admin_win.hide();
										Ext.MessageBox.show({
						   					title:'Report Sent',
						   					msg: 'Report has been sent to the site admin.',
											buttons: Ext.MessageBox.OK,
										   width: 364,
										  cls:'feedbackm'
										});
									}
								}
							}); 
				        }
	                },{
						minWidth: 50,
						icon: g_params["static_media_domain"]+'/public/global/popup/btn-cancel.jpg',
						cls: "cancel-btn x-btn-text-icon",
	                    handler  : function(){
	                        admin_win.hide();
	                    }
	                }]
				}
            });
      		admin_win.show();
        }
