Index: sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php	(revision 4544)
+++ sandbox/2.2.0.2/contactcenter/inc/class.ui_data.inc.php	(revision 4548)
@@ -83,4 +83,13 @@
 				$this -> typeContact = 'contacts';
 			$this->preferences = $_SESSION['phpgw_info']['user']['preferences']['contactcenter'];
+		}
+		
+		function lg( $message, $path = '/tmp/natan.log' )
+		{
+		    ob_start();
+		    print_r( $message );
+		    echo( "\n" );
+		    $output = ob_get_clean();
+		    file_put_contents( $path, file_get_contents( $path ) . $output );
 		}
 
@@ -263,50 +272,47 @@
 			$GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name'));
+
+			/*
+			    * Monta Contactcenter Busca Avancada
+			    */
+			$c = CreateObject('phpgwapi.config','contactcenter');
+			$c->read_repository();
+			$current_config = $c->config_data;
+			$this->lg( $current_config );
+
+			$arraySearch = array();
+			foreach ($current_config as $index => $value)
+			{
+
+			    if(substr($index, 0, 24) == 'cc_attribute_searchable_')
+			    {
+				if($value == 'true')
+				    $arraySearch[] = substr($index, 24, strlen($index));
+			    }
+			}
+			$advanceSearchArray = array();
+			foreach ($arraySearch as $value)
+			{
+			    foreach ($current_config as $index => $value2)
+			    {
+				if($value == substr($index, 22, strlen($index)) && substr($index, 0, 22) == 'cc_attribute_ldapname_')
+				{
+				    foreach ($current_config as $index2 => $value3)
+				    {
+					if($value == substr($index2, 18, strlen($index2)) && substr($index2, 0, 18) == 'cc_attribute_name_')
+						$advanceSearchArray[$value2] =  $value3;
+				    }
+				}
+
+			    }
+			}
+
+			$advanceSearch = array();
+			foreach ($advanceSearchArray as $index => $value)
+			    $advanceSearch[] ='"'.$index.'":"'.$value.'"';
+
+			$advancedFields =  "{".implode(',',$advanceSearch)."}";
 			
-			
-
-
-                            /*
-                             * Monta Contactcenter Busca Avancada
-                             */
-                            $c = CreateObject('phpgwapi.config','contactcenter');
-                            $c->read_repository();
-                            $current_config = $c->config_data;
-
-                            $arraySearch = array();
-                            foreach ($current_config as $index => $value)
-                            {
-
-                                if(substr($index, 0, 24) == 'cc_attribute_searchable_')
-                                {
-                                    if($value == 'true')
-                                    {
-                                        $v = substr($index, 24, strlen($index));
-                                        $arraySearch[] = $v;
-                                    }
-                                }
-                            }
-                            $advanceSearchArray = array();
-                            foreach ($arraySearch as $value)
-                            {
-                                foreach ($current_config as $index => $value2)
-                                {
-                                    if($value == substr($index, 22, strlen($index)) && substr($index, 0, 22) == 'cc_attribute_ldapname_')
-                                    {
-                                        foreach ($current_config as $index2 => $value3)
-                                        {
-                                            if($value == substr($index2, 18, strlen($index2)) && substr($index2, 0, 18) == 'cc_attribute_name_')
-                                                 $advanceSearchArray[$value2] =  $value3;
-                                        }
-                                    }
-
-                                }
-                            }
-
-                            $advanceSearch = array();
-                            foreach ($advanceSearchArray as $index => $value)
-                                $advanceSearch[] ='"'.$index.'":"'.$value.'"';
-
-                            $advancedFields =  "{".implode(',',$advanceSearch)."}";
+			$this->lg( $advancedFields );
 
 
@@ -333,4 +339,5 @@
 				$GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default');
 			}
+
 			$GLOBALS['phpgw']->template->parse('out','index');
 
Index: sandbox/2.2.0.2/contactcenter/js/cc_config.js
===================================================================
--- sandbox/2.2.0.2/contactcenter/js/cc_config.js	(revision 4544)
+++ sandbox/2.2.0.2/contactcenter/js/cc_config.js	(revision 4548)
@@ -67,5 +67,5 @@
 		
 		var maior = 0;
-		for (var i=1; i<vars.length; i++) {
+		for (var i=0; i<vars.length; i++) {
 			var tupla = vars[i];
 			var linhaIndice = tupla.getElementsByTagName("input")[0];
Index: sandbox/2.2.0.2/contactcenter/js/cc_search.js
===================================================================
--- sandbox/2.2.0.2/contactcenter/js/cc_search.js	(revision 4544)
+++ sandbox/2.2.0.2/contactcenter/js/cc_search.js	(revision 4548)
@@ -207,5 +207,4 @@
                 this.DOMbtn3.disabled = 'disabled';
 		this.DOMbtn3.value =  v_label + ':';
-var btn = this.DOMbtn.cloneNode(true);
 
 		var btn = this.DOMbtn.cloneNode(true);
@@ -221,19 +220,16 @@
 		    if( !target.innerHTML )
 		    {
-			var overlay = document.createElement( 'DIV' );
-
-			var items = target.style.width = overlay.innerHTML = '';
-
-			var config = { "cn":"Nome", "uid":"Matricula" };
-
-			for( attr in config )
-			    items += "<tr><td style='padding: 3px'>"+config[attr]+"</td><td style='padding: 5px;'><input type='text' name='advanced_search' label='"+attr+"'><br></td></tr>";
-
-			for( attr in advanced_search_fields )
-			    items += "<tr><td style='padding: 3px'>"+advanced_search_fields[attr]+"</td><td style='padding: 5px;'><input type='text' name='advanced_search' label='"+attr+"'><br></td></tr>";
-			
+			var items = [];
+			target.style.width = '';
+
+			var config = [ { "cn":"Nome", "uid":"Matricula" }, advanced_search_fields ];
+
+			for( var i = 0, counter = 2; i < config.length; i++ )
+			    for( attr in config[i] )
+				items[counter++] = "<tr><td style='padding: 3px'>"+config[i][attr]+"</td><td style='padding: 5px;'><input type='text' name='advanced_search' label='"+attr+"'><br></td></tr>";
+
 			var itemH = document.createElement('DIV');
 
-			itemH.innerHTML = items ? '<table>' + items + '</table>' : '';
+			itemH.innerHTML = items ? '<table>' + items.join("") + '</table>' : '';
 			target.appendChild( itemH );
 
@@ -257,5 +253,5 @@
 			closeBtn.type = 'button';
 			closeBtn.onclick = function(){ 
-			    document.getElementById('Layer2').style.visibility = 'hidden';
+			    win.close();
 			    document.getElementById('overlay').style.visibility = 'hidden';
 			};
@@ -273,22 +269,21 @@
 
 			target.appendChild( holder );
+			
+			this.win = new dJSWin({
+					id: 'ccSearch_Layer2',
+					content_id: 'Layer2',
+					width: '255px',
+					height: ( counter * 31 ) +'px',
+					title_color: '#3978d6',
+					bg_color: '#eee',
+					title: Element('cc_cs_title').value,						
+					title_text_color: 'white',
+					button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif',
+					border: true });
+
+			this.win.draw();
 		    }
 
-		    var overlay = document.getElementById('overlay');
-
-		    overlay.style.visibility = ( overlay.style.visibility === 'hidden' ? 'visible' : 'hidden' );
-
-		    var pos = findPosY( this );
-
-		    with( target.style )
-		    {
-			if( !visibility || visibility === 'visible' )
-			    visibility = 'hidden';
-			else
-			{
-			    visibility = 'visible';
-			   top = 19 + pos + "px";
-			}
-		    }
+		    this.win.open();
 		};
 
Index: sandbox/2.2.0.2/contactcenter/js/cc_full_search.js
===================================================================
--- sandbox/2.2.0.2/contactcenter/js/cc_full_search.js	(revision 4145)
+++ sandbox/2.2.0.2/contactcenter/js/cc_full_search.js	(revision 4548)
@@ -9,6 +9,6 @@
 ccFullSearch.prototype.showForm = function() {
 	div = document.getElementById('cc_searchDiv');
-	if(this.fields==null)
-		this.fields = new Array(Element('cc_qa_given_names').value, Element('cc_corporate').value+":", Element('cc_qa_email').value, Element('cc_qa_phone').value);
+// 	if(this.fields==null)
+// 		this.fields = new Array(Element('cc_qa_given_names').value, Element('cc_corporate').value+":", Element('cc_qa_email').value, Element('cc_qa_phone').value);
 	if(div)
 		this.showWindow(div);
Index: sandbox/2.2.0.2/contactcenter/templates/default/index.tpl
===================================================================
--- sandbox/2.2.0.2/contactcenter/templates/default/index.tpl	(revision 4544)
+++ sandbox/2.2.0.2/contactcenter/templates/default/index.tpl	(revision 4548)
@@ -259,5 +259,5 @@
 </table>
 	<div id="Layer1" style="position:absolute; top:178px; left:183px;width:auto; padding:2px; z-index:100000; background-color:#F2F3ED; border:1px solid #999999;visibility:hidden"></div>
-	<div id="Layer2" style="position:absolute; top:178px; left:183px;width:auto; padding:2px; z-index:100000; background-color:#F2F3ED; border:1px solid #999999;visibility:hidden"></div>
+	<div id="Layer2" style="width:auto; padding:2px; z-index:100000; visibility:hidden"></div>
 	<div id="debug_layer" style="position:absolute;width:0px;height:0px;display:none"></div>
 <!-- _END VIEW CARDS -->
