
	function Sect()
	{
		
		this.SetHeaderStyle=function(cell)
		{
			cell.style.borderBottom="solid 2px red";
			cell.style.fontSize="14px";
			cell.style.color="gray";
			cell.style.fontFamily="Tahoma";
			
			cell.style.backgroundImage="url(section/headergrad.jpg)";
			cell.style.backgroundRepeat="repeat-x";
			
			//cell.style.backgroundColor="#cccccc";
		}	
		
		this.SetFooterStyle=function(cell)
		{
			
			cell.style.fontSize="14px";
			cell.style.color="gray";
			cell.style.fontFamily="Tahoma";
			
			cell.style.backgroundImage="url(section/headergrad.jpg)";
			cell.style.backgroundRepeat="repeat-x";
			
			//cell.style.backgroundColor="#cccccc";
		}	
		
		
		this.SetAnchoreStyle=function(obj)
		{
			cell.style.color="gray";
			cell.style.fontFamily="Tahoma";
			cell.style.fontSize="10";
		}
		
		this.SetContentStyle=function(cell)
		{
			cell.style.height="50px";
			cell.style.color="gray";
			cell.style.backgroundColor="white";
			cell.style.fontFamily="Tahoma";
			cell.style.fontSize="10";
			cell.style.cursor="hand";
		}
		
		
		this.SetContentStyleEven=function(cell)
		{
			cell.style.height="50px";
			cell.style.color="gray";
			cell.style.backgroundColor="#effff0";
			cell.style.fontFamily="Tahoma";
			cell.style.fontSize="10";
			cell.style.cursor="hand";
		}
		
		this.SetContentStyleHot=function(cell)
		{
			cell.style.height="50px";
			cell.style.color="white";
			cell.style.backgroundColor="#cccccc";
			cell.style.fontFamily="Tahoma";
			cell.style.fontSize="10";
			cell.style.cursor="hand";
		}
		
		
		this.SetTableStyle=function(table)
		{
			
			table.style.border="solid 1px #ffcccc";
			table.style.backgroundColor="white";
			table.style.width="275px";
		}
		
		this.Rendre=function()
		{
			this.ContentPage=0;
			
			this.table=document.createElement("TABLE");
			//this.table.setAttribute("cellspacing","0");
			this.table.cellSpacing="0";
			this.table.cellPadding="0";
			
			this.Container.appendChild(this.table);
			
			this.SetTableStyle(this.table);
			
			this.tableHead=document.createElement("THEAD");			
			this.table.appendChild(this.tableHead);
			
			this.tableBody=document.createElement("TBODY");			
			this.table.appendChild(this.tableBody);
			
			this.tableFoot=document.createElement("TFOOT");			
			this.table.appendChild(this.tableFoot);
			////////////////////
			
			
			//Header Row//
			row=document.createElement("TR");
			this.tableHead.appendChild(row);
			
			
			cell=document.createElement("TD");
			
			row.appendChild(cell);
			this.SetHeaderStyle(cell);
			
			
			this.stateimg=document.createElement("IMG");
			cell.appendChild(this.stateimg);			
			this.stateimg.src="section/ToCollapse-down.png";
			this.stateimg.obj=this;
			this.stateimg.onclick=function(){this.obj.ShowHide();};
			this.stateimg.onmouseover=function(){ if (this.obj.IsExpanded()) this.src="section/ToExpand-over.png"; else this.src="section/ToCollapse-over.png"; };
			this.stateimg.onmouseout=function(){ if (this.obj.IsExpanded()) this.src="section/ToExpand-down.png"; else this.src="section/ToCollapse-down.png"; };
	
			
			
			this.headerCell=document.createElement("TD");
			this.headerCell.colSpan="4";
			row.appendChild(this.headerCell);
			this.headerCell.setAttribute("align","right");
			this.SetHeaderStyle(this.headerCell);
			this.headerCell.style.width="300px";
			
			
			this.headerCell.obj=this;
			
					
			title=document.createTextNode(this.Title);
			this.headerCell.appendChild(title);
			
			
			////////////////////////////
			
			
			
			
			
			
			
			///Footer //
			row=document.createElement("TR");
			this.tableFoot.appendChild(row);
			
			
			cell=document.createElement("TD");	
			cell.setAttribute("align","left");			
			this.SetFooterStyle(cell);
			row.appendChild(cell);
			this.prevcell=cell;
			
			cell=document.createElement("TD");	
			cell.setAttribute("align","center");			
			this.SetFooterStyle(cell);
			row.appendChild(cell);
			
			cell=document.createElement("TD");	
			cell.setAttribute("align","center");			
			this.SetFooterStyle(cell);
			row.appendChild(cell);
			this.statecell=cell;
			this.statecell.style.fontSize="10px";
			
			
			cell=document.createElement("TD");	
			cell.setAttribute("align","center");			
			this.SetFooterStyle(cell);
			row.appendChild(cell);
			
			
			cell=document.createElement("TD");	
			cell.setAttribute("align","right");			
			this.SetFooterStyle(cell);
			row.appendChild(cell);
			this.nextcell=cell;
			
			
			
			/*
			img=document.createElement("IMG");
			img.obj=this;
			this.prevcell.appendChild(img);
			img.src="section/ToLeft.png";
			img.onclick=function(){this.obj.LoadPrev();};
			img.onmouseover=function(){ this.src="section/ToLeftHot.png";  };
			img.onmouseout=function(){ this.src="section/ToLeft.png"; };
			
			//cell.appendChild(document.createTextNode("\t"));
			
			img=document.createElement("IMG");
			img.obj=this;
			this.nextcell.appendChild(img);
			img.src="section/ToRight.png";
			img.onclick=function(){this.obj.LoadNext();};
			img.onmouseover=function(){ this.src="section/ToRightHot.png";  };
			img.onmouseout=function(){ this.src="section/ToRight.png"; };
			*/
			
			span=document.createElement("SPAN");
			prevtext=document.createTextNode("السابق");
			span.appendChild(prevtext);
			this.prevcell.appendChild(span);
			
			span.style.fontSize="10px";
			span.style.cursor="hand";
			span.obj=this;
			span.onclick=function(){this.obj.LoadPrev();};
			span.onmouseover=function(){ this.style.color="red";  };
			span.onmouseout=function(){ this.style.color="gray"; };
			
			
			
			span=document.createElement("SPAN");
			nexttext=document.createTextNode("التالي");
			span.appendChild(nexttext);
			this.nextcell.appendChild(span);
			
			span.style.fontSize="10px";
			span.style.cursor="hand";
			span.obj=this;
			span.onclick=function(){this.obj.LoadNext();};
			span.onmouseover=function(){ this.style.color="red";  };
			span.onmouseout=function(){ this.style.color="gray"; };
			
			//////
			
			
			
			
			
			
			
			//this.LoadContentPage();
		}
		
		this.Content=null;
		
		this.ShowContent=function()
		{
			if (this.Content==null)
			{
				this.ContentPage=0;
				this.LoadContentPage();
				return;
			}
			
			for(i=0;i<this.Content.length;i++)
			{
			
				row=document.createElement("TR");
				this.tableBody.appendChild(row);
				
				cell=document.createElement("TD");
				cell.colSpan="5";
				row.appendChild(cell);
				//cell.setAttribute("colspan","2");
				cell.setAttribute("align","right");
				cell.setAttribute("dir","rtl");
				
				cell.obj=this;
				cell.onmouseover=function(){this.obj.SetContentStyleHot(this);};
				
				if (((i+2)%2)==0)
				{
					this.SetContentStyle(cell);
					cell.onmouseout=function(){this.obj.SetContentStyle(this);};
				}
				else
				{
					this.SetContentStyleEven(cell);
					cell.onmouseout=function(){this.obj.SetContentStyleEven(this);};
				}	
				
				cell.onclick=function(){window.location=this.link;};
				
				data=document.createTextNode(this.Content[i][0]);
				
		
				cell.link=this.Content[i][1];
				cell.appendChild(data);
				
				//
				
				row=document.createElement("TR");
				this.tableBody.appendChild(row);
				
				
				cell=document.createElement("TD");
				//cell.setAttribute("colspan","2");
				cell.colSpan="5";
				row.appendChild(cell);
				cell.setAttribute("align","center");
				//this.SetContentStyle(cell);
				
				
				img=document.createElement("IMG");
				cell.appendChild(img);
				img.setAttribute("src","section/Seperator.png");
				
				//<tr><td align="center"><img src="Seperator.png"></td></td>
				
				
			}
			
			if ((this.Content==null) || (this.Content.length==0))
			{
			
				row=document.createElement("TR");
				this.tableBody.appendChild(row);
				
				cell=document.createElement("TD");
				row.appendChild(cell);
				//cell.setAttribute("colspan","2");
				cell.colSpan="5";
				cell.setAttribute("align","center");
				cell.setAttribute("valign","center");
				cell.setAttribute("dir","rtl");
				this.SetContentStyle(cell);
				
				cell.obj=this;
				
				data=document.createTextNode("لا يوجد اعلانات");
				
				cell.link="";
				cell.appendChild(data);		
				
				
				
				row=document.createElement("TR");
				this.tableBody.appendChild(row);
				
				
				cell=document.createElement("TD");
				//cell.setAttribute("colspan","2");
				cell.colSpan="5";
				row.appendChild(cell);
				cell.setAttribute("align","center");
				//this.SetContentStyle(cell);
				
				
				img=document.createElement("IMG");
				cell.appendChild(img);
				img.setAttribute("src","section/Seperator.png");
				
			}
				
				
			
			
			
		}
		
		this.HideContent=function()
		{			
			while (this.tableBody.childNodes.length>0)
				this.tableBody.removeChild(this.tableBody.childNodes[0]);
		}
		
		this.SetStateAs=function(state)
		{
			/*
			while (this.statecell.childNodes.length>0)
				this.statecell.removeChild(this.statecell.childNodes[0]);
			
			this.statecell.appendChild(document.createTextNode(state));
			*/	
		}
		
		this.IsExpanded=function()
		{
			return this.tableBody.childNodes.length>0;		
		}
		
		this.ShowHide=function()
		{
			if ((this.tableBody!=null) && (this.tableBody.childNodes.length>0))
			{
				this.HideContent();
			}
			else
			{
				this.ShowContent();
			}
		}
		
		this.LoadNext=function()
		{
			this.ContentPage++;
			//alert("Next");
			this.LoadContentPage();
		
		}
		
		
		this.LoadPrev=function()
		{
			this.ContentPage--;
			//alert("Prev");
			this.LoadContentPage();
		}
		
		this.Filter=null;
		this.FromDate=null;
		this.ToDate=null;
		
		this.UrlEncode=function(data)
		{
			data=data.replace(" ","+");
			return data;
		}
			
		this.LoadContentPage=function()
		{
			var url="rss.php?limit=5";
			
			if (this.ContentPage!=null)
				url+="&page=" + this.ContentPage;
			
			if (this.CatID!=null)
				url+="&cat=" + this.CatID;
			
			
			if (this.Ctry!=null)
				url+="&ctry=" + this.Ctry;
			
			
			if (this.ActID!=null)
				url+="&act=" + this.ActID;
			
			
			if (this.FromDate!=null)
				url+="&fromdate=" + this.UrlEncode(this.FromDate);
			
			
			if (this.ToDate!=null)
				url+="&todate=" + this.UrlEncode(this.ToDate);
			
			
			if (this.Filter!=null)
				url+="&fltr=" + this.UrlEncode(this.Filter);
			
			//alert(url);
			
			this.runAjax(url);
			this.SetStateAs("Loading");	
		}
		
			
		this.runAjax = function(url)
		{
			this.xmlhttp=null;
			
			if (window.ActiveXObject)
				this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			else if (window.XMLHttpRequest)
	  			this.xmlhttp=new XMLHttpRequest();
			
			if (this.xmlhttp!=null)
			{
				
				f=this;
				this.xmlhttp.onreadystatechange=function(){this.obj=f;this.obj.ajaxStateChanged()};
				this.xmlhttp.open("GET",url,true);
				this.xmlhttp.send(null);
				
			}
		}
		
			
		this.ajaxStateChanged=function ()
		{
			res=new Array();
			
			if (this.xmlhttp.readyState==4)
			{
				this.SetStateAs("");
			}
			
			if ((this.xmlhttp.readyState==4) && (this.xmlhttp.status==200))
			{
				
				if (this.finishLoading!=null)
				{
				
					this.finishLoading();
				}
					
				data=this.xmlhttp.responseXML;
				urls=data.documentElement.getElementsByTagName("item");
				
				//alert(xmlhttp.responseText);
				
				for (i=0;i<urls.length;i++)
	  			{
	  				
	  				if (urls[i].getElementsByTagName("link")[0].text!=null)
	  					loc=urls[i].getElementsByTagName("link")[0].text;
	  				else
	  					loc=urls[i].getElementsByTagName("link")[0].textContent;
	  					
	  				
	  				
	  				if (urls[i].getElementsByTagName("description")[0].text!=null)
	  					disc=urls[i].getElementsByTagName("description")[0].text;
	  				else
	  					disc=urls[i].getElementsByTagName("description")[0].textContent;
	  							
	  				disc=disc.substring(0,200);
	  				
	  				res[i]=new Array(disc,loc);
	  				//res[i]=disc;
	  			}
	  			
	  			//alert(res[0][0]);
	  			
	  			//if (res.length>0)
	  			//{
					this.Content=res;
					
					this.HideContent();
					this.ShowContent();
				//}
				
				
		
			}
			
			
		}
	}