    function makeRequest(id_target,url) {
        var http_request = false;
        //if (!parameters)
        //parameters='';

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/html');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
		 alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents(http_request,id_target); };
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents(http_request,id_target) {
    	if (http_request.readyState == 1)
    	{document.getElementById(id_target).innerHTML = "<img src='http://pagerss.com/images/loader.gif' width='30' />";}

        if (http_request.readyState == 4) {
            if (http_request.status == 200)
            {
                document.getElementById(id_target).innerHTML = http_request.responseText;
            } else {
                alert('There was a problem with the request http_request.');
            }
        }

    }
    
   function form_submit(obj) {
      var poststr = "?";
      for (i=0; i<obj.childNodes.length; i++) 
      	    {
      	    if (obj.childNodes[i].tagName == "INPUT") {
            poststr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }}
     makeRequest('login', 'login.php', poststr);
           document.getElementById(id_target).innerHTML = "LOADING ...";

     
     
   }
   
   
   function _load(_midd,_sidd)
   {
      var cookinfo = getCookie("center_block");
      if (cookinfo != "")
       	_menu(cookinfo,_midd,_sidd,1);
   }
   
   

function _menu (_var,_midd,_sidd,_fromload)
{
_fromload = (_fromload) ? _fromload : 0;

for (m=1;m<=3;m++)
	{
      	if (m == _var)
      		{
      		document.getElementById('cenbutt'+m).className = 'current';
      		document.getElementById('cenbutt' + m + 'r').className = 'cbr2_current';
      		document.getElementById('cenbutt' + m + 'l').className = 'cbl2_current';
      		}
      	else if (m != _var)
      		{
      		document.getElementById('cenbutt'+m).className = '';
      		document.getElementById('cenbutt' + m + 'l').className = 'cbl2';
      		document.getElementById('cenbutt' + m + 'r').className = 'cbr2';
      		}
      	}
if (_fromload != 1)      	
makeRequest('center_block','http://pagerss.com/center.php?_var='+_var+'&_midd='+_midd+'&_sidd='+_sidd);
document.cookie = "center_block="+_var+"; path=/";  
}



function _menu_index (_var,_midd,_sidd,_number_button)
{

for (m=0;m<=_number_button;m++)
	{
      	if (m == _var)
      		{
      		document.getElementById('cenbutt'+m).className = 'current';
      		document.getElementById('cenbutt' + m + 'r').className = 'cbr2_current';
      		document.getElementById('cenbutt' + m + 'l').className = 'cbl2_current';
      		}
      	else if (m != _var)
      		{
      		document.getElementById('cenbutt'+m).className = '';
      		document.getElementById('cenbutt' + m + 'l').className = 'cbl2';
      		document.getElementById('cenbutt' + m + 'r').className = 'cbr2';
      		}
      	}
//if (_fromload != 1)      	
//alert("heelloo");
makeRequest('center_block','http://pagerss.com/center_index.php?_var='+_var+'&_midd='+_midd+'&_sidd='+_sidd);
document.cookie = "center_block="+_var+"; path=/";  
}







   function _menu_left (_var,menuid)
   {
   for (m=1;m<=3;m++)
	{
	document.getElementById('leftbutt'+m).className = (m==_var)? 'current': 'butt';
	makeRequest('left_block','http://pagerss.com/leftmenu.php?opr='+_var+'&menuid='+menuid);
	}
   //var _diff = 4;
   //document.getElementById('leftbutt'+_var).className = 'current';
   //document.getElementById('leftbutt'+(_diff-_var)).className = 'butt';
   //makeRequest('left_block','http://pagerss.com/leftmenu.php?opr='+_var+'&menuid='+menuid);
   }
   
   
   
   function getCookie(Name){ 
   var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
   if (document.cookie.match(re)) //if cookie found
   return document.cookie.match(re)[0].split("=")[1] //return its value
   return ""
}
function morerss()
{
	document.getElementById('rss_plus').className="h2";
	document.getElementById('morerss_link').href="#";
	document.getElementById("morerss_link").innerHTML="top^";
}

function showHidden (valId)
	{
		document.getElementById(valId).className="h2_form";
		var objects = document.getElementsByTagName("input");
		for(var no=0;no<objects.length;no++)
		{
		objects[no].style.visibility = "visible";
		}
		var objects_textarea = document.getElementsByTagName("textarea");
		objects_textarea[0].style.visibility = "visible";
	}

function showRss(str)
{
if (str.length==0 || str.length==1)
  { 
  document.getElementById("result_feed").innerHTML="";
  return;
  }

makeRequest('result_feed','http://pagerss.com/search_feed2.php?q='+str);
}

function ratePage()
{
var sel = document.comment.userrate.selectedIndex;
if (sel != 0)
	document.getElementById("rateimg").src="http://pagerss.com/images/rate"+document.comment.userrate.selectedIndex+".gif";
}
function getComment()
{
var obj = document.getElementById('comment');
var getstr = "?";
     for (i=0; i<obj.childNodes.length; i++) 
     {
         if (obj.childNodes[i].tagName == "INPUT") 
         {
            if (obj.childNodes[i].type == "text") 
            {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
         }
     }
getstr += "textcomment=" + document.getElementById('textcomment').value + "&";
getstr += "userrate=" + document.getElementById('userrate').value + "&";

makeRequest('usercomment','http://pagerss.com/about_comment.php'+getstr);


		//document.getElementById('comment_form').className="h2_form";
		var objects = document.getElementsByTagName("input");
		for(var no=0;no<objects.length;no++)
		{
		objects[no].style.visibility = "hidden";
		}
		var objects_textarea = document.getElementsByTagName("textarea");
		objects_textarea[0].style.visibility = "hidden";


document.getElementById('comment_form').className="h";
}

function expandrss (postid) { 

   whichrss = document.getElementById(postid); 

   if (whichrss.className=="h2") { 
      whichrss.className="h"; 
      document.getElementById(''+postid+'l').innerHTML="+";
      
   } 
   else { 
      whichrss.className="h2"; 
      document.getElementById(''+postid+'l').innerHTML="-";
   } 
} 



function months (postid) { 
	if (postid =="prev_month")
	{
	 document.getElementById(postid).className="h2"; 
	 document.getElementById('current').className="h";
	  }
	 else
	 {
	 document.getElementById('prev_month').className="h"; 
	  document.getElementById(postid).className="h2"; 

	  	 }
} 
function _calendar (_sid,_year,_month)
{
makeRequest('calendar','http://pagerss.com/include/calendar.inc.php?_sid='+_sid+'&_year='+_year+'&_month='+_month);
}
function _saved(_sid)
{
makeRequest('saved','http://pagerss.com/saved.php?_sid='+_sid);
}

function _set_element(_element,_color)
{
var element_arr = new Array('border', 'title', 'news', 'background');
var txt = document.getElementById(''+_element+'');
	for (var _key in element_arr) 
 	{
 	var obj = document.getElementById(element_arr[_key]);
 		obj.style.fontWeight = (element_arr[_key] == _element) ? 'bold' : 'normal'
 	}
	
	//txt.style.fontWeight = (txt.style.fontWeight == 'bold') ? 'normal' : 'bold';
	//alert('col'+_color);
	document.getElementById('col'+_color+'').focus();
}



function _set_color(_color)
{
var element_arr = new Array('border', 'title', 'news', 'background');
var elementprop_arr = new Array('borderColor', 'title', 'news', 'backgroundColor');

 for (var _key in element_arr) 
 { 
 var obj = document.getElementById(element_arr[_key]);
 if (obj.style.fontWeight == 'bold')
 	{
 	//alert(_key);
 	//alert(element_arr[_key]);
 	document.getElementById(element_arr[_key]+'_box').style.backgroundColor = '#'+_color;
 	//document.getElementById(element_arr[_key]+'_box').style.elementprop_arr[_key] = '#'+_color;
 	
 	switch (_key)
 		{
 		case '0':
 		document.getElementById('widget').style.borderColor = '#'+_color;
 		break;
 		case '1':
		document.getElementById('widget_title').style.color = '#'+_color;
 		break;
 		case '2':
		document.getElementById('widget_link1').style.color = '#'+_color;
		document.getElementById('widget_link2').style.color = '#'+_color;
		document.getElementById('widget_link3').style.color = '#'+_color;
 		break;
 		case '3':
 		document.getElementById('widget').style.backgroundColor = '#'+_color;
 		break;
 		}
 	}
  }
}


function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {
 if (N==null) return "FF";
 N=parseInt(N); if (N==0 || isNaN(N)) return "00";
 N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
 return "0123456789ABCDEF".charAt((N-N%16)/16)
      + "0123456789ABCDEF".charAt(N%16);
}

function _save_widget ()
{
var element_arr = new Array('border_box', 'title_box', 'news_box', 'background_box');
var element_color = new Array();
 for (var _key in element_arr) 
 { 
  var obj = document.getElementById(element_arr[_key]);
 //rgb to html color 
 	var color_hex = obj.style.backgroundColor;
 	var color_length = color_hex.length-1;
 	var color_hex = color_hex.substring(4,color_length);
 	color_hex_array = color_hex.split(",");
 	var htmlColor = RGBtoHex(color_hex_array[0],color_hex_array[1],color_hex_array[2]);
 
 
  //alert ('color1:'+color_hex_array[0]+'color2:'+ color_hex_array[1]+'color3:'+ color_hex_array[2]+'---++--'+htmlColor);
  element_color[element_arr[_key]] = htmlColor;
 }
 var _border = element_color['border_box'];
 var _title = element_color['title_box'];
 var _news = element_color['news_box'];
 var _background = element_color['background_box'];
 
//alert(_border+"--"+element_color['title_box']+element_color['news_box']+element_color['background_box']);
//document.getElementById('widget_code').disabled=false;
//document.getElementById('widget_code').value="hello";
makeRequest("saved","http://pagerss.com/widget_save.php?_border="+_border+"&_title="+_title+"&_news="+_news+"&_background="+_background);
}


function _drop_menu ()
{
///var manu_obj = document.getElementById("main_cat").selectedIndex;
///var menu_id = document.getElementById("main_cat")[manu_obj].value;
///makeRequest("sub_menu","http://boostspot.com/fill_drop.php?_mid="+menu_id);



		var maincat_obj = document.getElementById("main_cat").selectedIndex;
		var maincat_id = document.getElementById("main_cat")[maincat_obj].value;
		for (x in drop_menu[maincat_id])
			{
					var y=document.createElement('option');
					y.text= drop_menu[maincat_id][x]
					y.value= x
					var x=document.getElementById("sub_category");
						try
						  {
						  x.add(y,null); // standards compliant
						  }
						catch(ex)
						  {
						  x.add(y); // IE only
						  }
			}

}

function _fill_menu(_array)
{
var count = _array.length;
alert("array length: "+count);
}

function change_css (filename, filetype, color)
{
if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)

document.cookie = "skincolor="+color+"; path=/"; 
}

function boostit(_id)
{
var _points = document.getElementById('rate'+_id).innerHTML;
makeRequest('rate'+_id,'http://boostspot.com/boostit.php?_points='+_points+'&_id='+_id);
}
