function getObject( Id )
{
	if ( document.getElementById )	return document.getElementById( Id );
 	else if ( document.layers )	 return document.layers( Id );
    else if ( document.all )	 return document.all[ Id ];
}

function setasHome(){
	if(document.all){
		if(document.getElementById('email_hash')!=null){
			setHome(document.getElementById('email_hash').value)
		}
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://' + document.write(location.host) );
		stat();
	}
}

function addToFavorites(){
	if(document.all){
		if(document.getElementById('email_hash')!=null){
			setFavorites(document.getElementById('email_hash').value)
		}
		window.external.AddFavorite(location.href, document.title);
	}
}



function CreateBookmarkLink(url, title) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) {
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) {
		return true; 
	}
}


/* ajax */

var http_request = false;

var innerTag = 'innerTag';   

function makeRequest(url, parameters) {
   http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType) {
      	// set type accordingly to anticipated content type
         //http_request.overrideMimeType('text/xml');
         http_request.overrideMimeType('text/html');
      }
   } 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('Cannot create XMLHTTP instance');
      return false;
   }
   http_request.onreadystatechange = alertContents;
   http_request.open('GET', url + parameters, true);
   http_request.send(null);
}

function alertContents() {
   if (http_request.readyState == 4) {
      if (http_request.status == 200) {
         //alert(http_request.responseText);
         result = http_request.responseText;
         getObject(innerTag).innerHTML = result;            
      } else {
         alert('There was a problem with the request.');
      }
   }
}
   
function doAjax(get){
	innerTag = 'innerTag';
	makeRequest('admin_do.php', get+'&dummy='+Math.floor(Math.random()*1000001)); 
}

function doAjaxFromIndex(get,it){
	innerTag = it;
	makeRequest('admin/admin_do.php', get+'&dummy='+Math.floor(Math.random()*1000001));  
}

/* end of ajax */







function ajax_call(postData,inner,loading){
	$.ajax({
		type: "POST",
	   url: "admin_do.php",
	   dataType: "json",
	   data: postData,
	   beforeSend: function(){
	   	   if (loading) $('#'+inner).html('<img alt="Loading" src="../img/loading.gif" />');
	   },
	   success: function(rData){
		   $('#'+inner).html(rData.output);		  
	   }
	 });
}

