function PbAjax (url, methodtype, params, elementid, runscripts, completeFunction) {

	if (completeFunction == null) {
		new Ajax (
			url, 
			{
				method: methodtype, 
				postBody: params,
				evalScripts: runscripts,
				update: elementid
			}
			 ).request();
	} else {
		new Ajax (
			url, 
			{
				method: methodtype, 
				postBody: params,
				evalScripts: runscripts,
				update: elementid,
				onComplete: completeFunction
			}
			 ).request();
	}

}


function PbNewImg (elementobj, url) {
	elementobj.src = url;
}


function doNothing() {}


function PbGetSitePass(btnbase,friendsite,greenmsg,goldmsg) {
	var postbody = 'ajax=true';
	if (friendsite != null && friendsite.length >= 3) {
		postbody += '&friend=' + friendsite;
	}
	new Ajax (
          '/site/passnew.html',
		{
			method: 'post',
			postBody: postbody,
			evalScripts: false,
			onComplete: function (msg) {
				msg = msg.substring(0,4);
                    if (msg == "pass") {
                         document.getElementById('modstatusimg').innerHTML =
                              '<img src="' + btnbase + 'green.gif" width="72" height="72" alt="Passholder" border="0" />';
                         document.getElementById('modstatustext').innerHTML = 'Success! ' + greenmsg;
                    } else if (msg == "pend") {
                         document.getElementById('modstatusimg').innerHTML =
                              '<img src="' + btnbase + 'gold.gif" width="72" height="72" alt="Pass pending" border="0" />';
                         document.getElementById('modstatustext').innerHTML = goldmsg;
                    } else if (msg == "fail") {
                         document.getElementById('modstatusimg').innerHTML =
                              '<img src="' + btnbase + 'gray.gif" width="72" height="72" alt="Pass not available" border="0" />';
                         document.getElementById('modstatustext').innerHTML =
                              'A pass could not be granted to this site.';
                    } else {
                         document.getElementById('modstatustext').innerHTML =
                              'There was an error during your request.';
                    }
               }
		}
          ).request();
}


function PbApproveFriend(friendsite,elementname) {
	var postbody = 'ajax=true&friend=' + friend;
	if (friendsite != null && friendsite.length >= 3) {
		postbody += '&friend=' + friendsite;
	}
	new Ajax (
          '/site/gofriendsapprove.html',
		{
			method: 'post',
			postBody: postbody,
			evalScripts: false,
			onComplete: function (msg) {
				msg = msg.substring(0,4);
                    if (msg == "pass") {
                         document.getElementById(elementname).innerHTML = "<b>Approved.</b>";
                    } else {
                         document.getElementById(elementname).innerHTML += "<span class='err'>&nbsp;Server error, approval failed.</span>";
                    }
               }
		}
          ).request();
}
