// GEN basis

function $rgb(id)
{
	if( document.getElementById(id) == null) alert(id);
	
	return document.getElementById(id);	
}
function selection(id)
{

	return $rgb(id);
}
function hide(id)
{
		
	$rgb(id).style.display = 'none';
}
function show(id)
{
		
	$rgb(id).style.display = 'block';
}

// AJAX basis
	
var parsing_xml = false;
var lang = "";
function loadXMLFromText(xmlData)
{
	if (window.ActiveXObject) {
			//for IE
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(xmlData);
			return xmlDoc;
		} else if (document.implementation && document.implementation.createDocument) {
			//for Mozila
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(xmlData,"text/xml");
			return xmlDoc;
		}

}

														
function processData(responseText, responseStatus)
	 { 
		
		//document.getElementById('loadingbar').style.display ='none';
		if (responseStatus==200) // succes
		{
			if(responseText == 'error')
							alert('Error updating data!'+responseText);
			else
			{
				if(parsing_xml)
					processXmlTwitter(responseText);
				else
				{
					//alert(responseText);
					eval(responseText);
				}
				
			}
		 }
		else if(responseStatus == 0)
		{
		
		}
		else 
		{ 
		   alert(responseStatus + ' -- Error Processing Request');
		}
	  }
function ajaxObject(url) {
		  var that=this;      
		   this.updating = false;
			  this.abort = function() {
					that.AJAX.onreadystatechange = function () {}
				  that.updating=false;
				  that.AJAX.abort();
				  that.AJAX=null;
				
			  }
		  this.update = function(form,postMethod) { 
			if(that.updating) that.abort();
			 that.AJAX = null;                      
			 var passData = getFormValues(form,"validate");
			 
			 
					
			if (window.XMLHttpRequest) {              
			  that.AJAX=new XMLHttpRequest();              
			} else {                                  
			  that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
			}                                             
			if (that.AJAX==null) {                             
			  return false;                               
			} else {
			
				
				  that.AJAX.onreadystatechange = function() {  
					if (that.AJAX.readyState==4) {             
					  that.updating=false;                
					  that.callback(that.AJAX.responseText,that.AJAX.status);        
					  that.AJAX=null;                                         
					} 
					}
																
			  that.updating = new Date();                              
			  if (/post/i.test(postMethod)) {
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
				//that.AJAX.setRequestHeader("Content-Length", passData.length);
				that.AJAX.send(passData);
			  } else {
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
				that.AJAX.open("GET", uri, true);                             
				that.AJAX.send(null);                                         
			  }              
			  return true;                                             
			}                                                                           
		  }
		  var urlCall = url;        
		  this.callback = processData;
		  }
		  
		
	
function getFormValues(fobj,valFunc, url) 			
	{ 
	
	   var str = ""; 
	
	   var valueArr = null; 
	
	   var val = ""; 
	
	   var cmd = ""; 
	
	   for(var i = 0;i < fobj.elements.length;i++) 
	
	   { 
	
		   switch(fobj.elements[i].type) 
	
		   { 
			case "checkbox":
					var myval = fobj.elements[i].checked;
					if(myval) 
						myval = 1;
					else
						myval = 0;								   
				   str += fobj.elements[i].name + 
	
					"=" + myval + "&"; 
	
					   break; 
			  case "textarea":
				 str += fobj.elements[i].name + 
	
						 "=" + escape(fobj.elements[i].value) + "&"; 
						 break; 
		   
				case "password":
					str += fobj.elements[i].name + 
	
						 "=" + escape(fobj.elements[i].value) + "&"; 
						  break; 
				case "hidden":
					str += fobj.elements[i].name + 

					 "=" + (fobj.elements[i].value) + "&"; 
					  break; 
			   case "text": 
	
							
					str += fobj.elements[i].name + 
	
					 "=" + escape(fobj.elements[i].value) + "&"; 
	
					 break; 
	
			   case "select-one": 
	
					str += fobj.elements[i].name + 
	
					"=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 
	
					break; 
	
		   } 
	
	   } 
							
				
					 
					 
	   str = str.substr(0,(str.length - 1)); 
	
	   return str; 
	
	}


	


var myRequest = new ajaxObject( 'http://www.2bfm.be/'+'ajax/refresh.php');

function refresh()
{
	
	myRequest.update( $rgb('myform'), 'POST');	
}


