function initPaf() {
		var myGlobalHandlers = {
		onComplete: function() {
			if(Ajax.activeRequestCount == 0){
//			paf_request('portal-column-middle',
//					"portlets/imagegroups/startSlideshow.php");
			Ajax.Responders.unregister(myGlobalHandlers);
//			initLightbox(); 
			}
		}
	};

	Ajax.Responders.register(myGlobalHandlers);
	return false;	
}

function handleLogin(e)
 {
    new Ajax.Request("portlets/login/login.php", {
        parameters : Form.serialize('login-form')
    });
    Event.stop(e);
 }
 
 
 
function paf_request(target, url) {
new Ajax.Updater(target, url,{
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  },
  insertion: Insertion.Bottom,
  evalScripts: true 
  });
}


function paf_request_before(target, url) {
var id = 1337; // random id
new Ajax.Updater(target, url,{
//  method: 'get',
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  }
  ,
  insertion: Insertion.Before,
  evalScripts: true 
  });
}


function paf_request_params(target, url, params) {
var id = 1337; // random id
new Ajax.Updater(target, url,{
  method: 'get',
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  }
  ,
  insertion: Insertion.Bottom,
  evalScripts: true,
  parameters: params 
  });
}

function paf_request_params_top(target, url, params, pid) {
var id = 1337; // random id
check_id(pid);
new Ajax.Updater(target, url,{
  method: 'get',
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  },
  onComplete: function() {
  	new Effect.Highlight(pid);
  	initLightbox();
  },
  insertion: Insertion.Top,
  evalScripts: true,
  parameters: params 
  });
}

function paf_request_top(target, url) {
var id = 1337; // random id
new Ajax.Updater(target, url,{
//  method: 'get',
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  } ,
  insertion: Insertion.Top,
  evalScripts: true 
  });
}

function paf_request_top_replace(target, url, pid) {
check_id(pid);
var id = 1337; // random id
new Ajax.Updater(target, url,{
//  method: 'get',
  onFailure: function(resp) {
  	alert("Oops, there has been an error.");
  } ,
  insertion: Insertion.Top,
  evalScripts: true 
  });
}

function send(){
  var params = Form.serialize($('commentsForm'));
  new Ajax.Updater('updateDiv', 'submit.php', {asynchronous:true, 
  parameters:params});
}

function check_id(id) {
if ($(id)){ 
	Element.remove(id);
//	alert ("id exists: " + id);
	}
	else {
//		alert ("id does not exist: " + id);
	}
}

function viewImage(id){
		url = 'portlets/imagegroups/viewImage.php?id='+id;
        ElementWindow = window.open(url,'preview','width=500,height=500,scrollbars=yes')
        if(ElementWindow == null) {
        alert("You must allow pop up windows to use this feature");
        } else {
        self.status = "";
        ElementWindow.focus();
        }
    }
