Index: branches/2.2/expressoMail1_2/js/news_edit.js
===================================================================
--- branches/2.2/expressoMail1_2/js/news_edit.js	(revision 4684)
+++ branches/2.2/expressoMail1_2/js/news_edit.js	(revision 4957)
@@ -9,6 +9,6 @@
 cnews_edit.prototype.read_rss = function(val)
 {
-    Element("border_id_0").innerHTML    = get_lang('News')+'&nbsp;&nbsp;<font face="Verdana" size="1" color="#505050">[ <span id="tot_m"></span> ]</font>';
-    
+    document.getElementById("border_id_0").innerHTML    = get_lang('News')+'&nbsp;&nbsp;<font face="Verdana" size="1" color="#505050">[ <span id="tot_m"></span> ]</font>';
+
     current_folder = "NEWS/"+val;
     openTab.imapBox[0] = "NEWS/"+val;
@@ -23,10 +23,22 @@
         'lang_size'     : get_lang('size')
     };
-    
+
+    // Div
     var _div = document.getElementById("content_id_0");
         _div.innerHTML = this.xtools.parse( this.rssXml, 'stylesheet/news_read.xsl' , langs );
     
+    resizeWindow();    
+
+    var footerMenu = document.getElementById("footer_menu");
+
+    // footer Menu;
+    if( footerMenu )
+    {
+   		footerMenu.style.display = "none";
+    }
+	
     update_menu();
-    var box = Element("tbody_box");
+    
+    var box = document.getElementById("tbody_box");
     
     if(box.childNodes.length > 1)
@@ -41,5 +53,5 @@
     }
     
-    Element("tot_m").innerHTML = box.childNodes.length - 1 ;
+    document.getElementById("tot_m").innerHTML = box.childNodes.length - 1 ;
 }
 
@@ -55,11 +67,14 @@
     }
     
-    var title = this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('title')[0].firstChild.nodeValue;
-    var pubDate = this.dateString(this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('pubDate')[0].firstChild.nodeValue);
-    var link = this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('link')[0].firstChild.nodeValue;
-    var owner = this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('owner')[0];
-    if (currentTab.toString().indexOf('news_') != -1)
+    var title	= this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('title')[0].firstChild.nodeValue;
+    var pubDate	= this.dateString(this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('pubDate')[0].firstChild.nodeValue);
+    var link	= this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('link')[0].firstChild.nodeValue;
+    var owner	= this.rssXml.getElementsByTagName('item')[item_number-1].getElementsByTagName('owner')[0];
+    
+    if ( currentTab.toString().indexOf('news_') != -1 )
         delete_border(currentTab);
-    var border_id = create_border(title, 'news_'+item_number);
+    
+    var border_id = create_border(title, 'news_'+item_number, "RSS" );
+    
     if(!border_id)
         return false;
@@ -68,19 +83,28 @@
 
     var toolbarCode = "<div style='background-color: #FFF; font-size: larger;'>"+
-                      "<table class='table_message' style='width:100%;'><tr><td>"+(owner != undefined?owner.firstChild.nodeValue:get_lang('nobody'))+", "+pubDate+"</td>"+
-                      '<td width="30%" align="left"></td>'+
-                      '<td nowrap="true" width="30%" align="right"><a target="_blank" href="'+link+'" style class="message_options">'+get_lang('Complete news')+'</a>';
-    if ( owner != undefined )
-        toolbarCode += '<span>&nbsp;|&nbsp;</span><span class="message_options">'+get_lang('forward')+'</span><span>&nbsp;|&nbsp;</span>'+
-        '<span class="message_options">Responder</span></td>';
-    toolbarCode += '<td nowrap="true" width="40px" align="right">'+
-    ( item_number == 1 ?  '<img style="cursor: default;" src="./templates/default/images/up.gray.button.png">' :
-        '<img onclick="news_edit.read_item('+(parseInt(item_number)-1)+')" style="cursor: default;" src="./templates/default/images/up.button.png">')+
-    '<span>&nbsp;</span>'+
+                      "<table class='table_message' style='width:100%;'><tr><td>"+pubDate+"</td>"+
+                      "<td width='30%' align='left'></td>"+
+                      "<td nowrap='true' width='30%' align='right'><a target='_blank' href='"+link+"' style class='message_options'>"+get_lang("Complete news")+"</a>";
+    
+    
+    toolbarCode +=  '<td nowrap="true" width="40px" align="right">'+
+    			    ( item_number == 1 ?  '<img style="cursor: default;" src="./templates/default/images/up.gray.button.png">' :
+    			 	'<img onclick="news_edit.read_item('+(parseInt(item_number)-1)+')" style="cursor: default;" src="./templates/default/images/up.button.png">')+
+    			 	'<span>&nbsp;</span>'+
     (this.rssXml.getElementsByTagName('item')[parseInt(item_number)] == undefined ? '<img style="cursor: default;" src="./templates/default/images/down.gray.button.png">' :
-        '<img onclick="news_edit.read_item('+(parseInt(item_number)+1)+')" style="cursor: pointer;" src="./templates/default/images/down.button.png">')+
+    '<img onclick="news_edit.read_item('+(parseInt(item_number)+1)+')" style="cursor: pointer;" src="./templates/default/images/down.button.png">')+
     "</td></tr></table><h2>"+title+"</h2><br>"+description+"</div>";
-    Element('content_id_'+border_id).innerHTML = toolbarCode;
+    
+    document.getElementById('content_id_'+border_id).innerHTML = toolbarCode;
+    
     resizeWindow();
+    
+    var footerMenu = document.getElementById("footer_menu");
+
+    // footer Menu;
+    if( footerMenu )
+    {
+   		footerMenu.style.display = "none";
+    }
 }
 
@@ -99,161 +123,94 @@
 }
 
-cnews_edit.prototype.makeWindow = function(options)
-{
-    _this = this;
-
-    var params = 
-    {
-        'lang_label1'       :   get_lang('Enter the URL of RSS service'),
-        'lang_label2'       :   get_lang('List of registered RSS'),
-        'lang_subscribe'    :   get_lang('Subscribe') 
-    };
-
-    var el = document.createElement("DIV");
-        el.style.visibility = "hidden";
-        el.style.position = "absolute";
-        el.style.left = "0px";
-        el.style.top = "0px";
-        el.style.width = "0px";
-        el.style.height = "0px";
-        el.id = 'dJSWin_newswin';
-        el.innerHTML = this.xtools.parse( this.xtools.xml('make_window'), 'stylesheet/makeWindow.xsl', params );
-
-    document.body.appendChild(el);
-    
-    var butt = Element('dJSWin_wfolders_bok');
-    
-    if ( !butt )
-    {
-        butt = document.createElement('INPUT');
-        butt.style.margin = "3px";
-        butt.id = 'dJSWin_wfolders_bok';
-        butt.type = 'button';
-        butt.value = get_lang('Close');
-        el.appendChild(butt);
-    }
-    
-    butt.onclick = function ()
-    {
-        news_edit.arrayWin[el.id].close();
-    }
-
-    _this.showWindow(el);
-}
-
-cnews_edit.prototype.showWindow = function (div)
-{
-    if(! this.arrayWin[div.id])
-    {
-        div.style.height = "280px";
-        div.style.width = "340px";
-        var title = "<label style='margin-left:5px;'>:: "+get_lang("News edit")+" ::</label> ";
-        var wHeight = div.offsetHeight + "px";
-        var wWidth =  div.offsetWidth   + "px";
-        div.style.width = div.offsetWidth - 5;
-
-        win = new dJSWin({
-            id: 'win_'+div.id,
-            content_id: div.id,
-            width: wWidth,
-            height: wHeight,
-            title_color: '#3978d6',
-            bg_color: '#eee',
-            title: title,
-            title_text_color: 'white',
-            button_x_img: '../phpgwapi/images/winclose.gif',
-            border: true
-        });
-        this.arrayWin[div.id] = win;
-        win.draw();
-    }
-    else
-    {
-        win = this.arrayWin[div.id];
-    }
-    
-    win.open();
-    
-    var handlerChannel = function( data )
-    {
-        var _listRss =  document.getElementById("listRSS");
-        
-        if( data != null )
-        {
-            for( var i = 0 ; i < data.length; i++)
-            {    
-                _listRss.innerHTML += "<div>" +
-                                        "<img onclick='news_edit.unsubscribe(\""+data[i].rss_url+"\",this);' style='width:16px; height:16px; cursor: pointer;' src='../phpgwapi/templates/default/images/foldertree_trash.png' />" +
-                                        "<label style='margin-right: 2px'>"+data[i].name+"</label>" +                
-                                       "</div>";
-            }
-        }
-    }
-    
-    cExecute('$this.rss.getChannels',handlerChannel);
-}
+cnews_edit.prototype.trim = function(inputString)
+{
+	if (typeof inputString != "string")
+		return inputString;
+	
+	var retValue = inputString;
+	var ch = retValue.substring(0, 1);
+	
+	while (ch == " ")
+	{
+		retValue = retValue.substring(1, retValue.length);
+		ch = retValue.substring(0, 1);
+	}
+		ch = retValue.substring(retValue.length-1, retValue.length);
+	
+	while ( ch == " ")
+	{
+		retValue = retValue.substring(0, retValue.length-1);
+		ch = retValue.substring(retValue.length-1, retValue.length);
+	}
+	
+	while (retValue.indexOf("  ") != -1) 
+	{
+		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
+	}
+	
+	return retValue;
+}
+
+
 cnews_edit.prototype.unsubscribe = function(url,el)
 {
-    var rem_handler = function (data)
-    {
-        if ( data != "Success" )
-        {    
-            if (data == "Error")
-                alert(get_lang("Database Error"));
-            else
-                alert(get_lang("Invalid entry"));
-        }
-        else
-        {
-           el.parentNode.parentNode.removeChild( el.parentNode );
-        }
-    };
-
-    cExecute('$this.rss.removeChannel&url='+escape(url),rem_handler);
-}
+	var _select = document.getElementById("list_rss");
+	
+	for( var i = 0 ; i < _select.options.length; i++ )
+	{
+		if( _select.options[i].selected == true )
+		{
+			_select.removeChild(_select.options[i]);
+			i--;
+		}
+	}
+}
+
 cnews_edit.prototype.subscribe = function()
 {
-    var newTableEl  = document.getElementById("listRSS");
-    var val         = trim( Element('rssEnter').value );
-    
-    if( val != "" )
-    {
-        this.rssXml = this.xtools.load('controller.php?action=$this.rss.getContent&url='+escape(val));
-
-        var params =
-        {
-            'linkURL' : val
-        };
-
-        var _div = document.createElement("div");
-            _div.innerHTML = this.xtools.parse( this.rssXml, 'stylesheet/news_add.xsl', params );
-
-        var add_handler = function (data)
-        {
-            if ( data != "Success" )
-            {
-                if ( data == "Error" )
-                    alert( get_lang("Database Error") );
-                else
-                    alert( get_lang("Invalid entry") );
-            }
-            else
-            {
-                newTableEl.appendChild(_div);
-            }
-        };
-
-        try
-        {
-            if( _div.childNodes[2].getAttribute("titleRss") )
-            {    
-                var name = _div.childNodes[2].getAttribute("titleRss");
-
-                cExecute('$this.rss.addChannel&url='+escape(val)+'&name='+name,add_handler);
-            }
-        }
-        catch(e){ }
-    }
-
+	var _select = document.getElementById("list_rss");
+	
+    var _rssUrl	= this.trim( document.getElementById('rssEnter').value );
+
+    if( _rssUrl != "" )
+    {
+    	var _lang = document.getElementById('lang_can_not_access_this_rss').value
+    	
+    	try
+    	{
+	        this.rssXml = this.xtools.load('expressoMail1_2/controller.php?action=$this.rss.getContent&url='+escape(_rssUrl));
+	        
+	        title = this.rssXml.getElementsByTagName("title");
+	
+	        if( title.length > 0 && this.trim(title[0].childNodes[0].nodeValue) != "" )
+	        {
+	        	var flag = false;
+	        	
+	        	for( var i = 0; i < _select.options.length; i++ )
+	        	{
+	        		if( this.trim( _select.options[i].value ) == this.trim( _rssUrl ) )
+	        		{
+	        			flag = true;
+	        		}
+	        	}
+	        	
+	        	if( !flag )
+	        	{
+	        		var _value = _rssUrl + "|" + title[0].childNodes[0].nodeValue;
+	        		_select.options[_select.length] = new Option( title[0].childNodes[0].nodeValue, _value , false, true );
+	        	}
+	        	
+	        	document.getElementById('rssEnter').value = "";
+	        }
+	        else
+	        {
+	        	alert( _lang + "!!" );
+	        }
+    	}
+    	catch(e)
+    	{
+    		alert( _lang + "!!" );
+    	}
+    }
 };
 
