
			function ajaxAddMe(photoID, x_coord,y_coord)
			{
	
				DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'addMe',photoID,x_coord,y_coord, getResult);
			}
			
			function ajaxDeleteMe(photoID)
			{
	
				DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'deleteMe',photoID,  getResult);
			}
			
			function ajaxLogout(){
				DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'logout', '0', getResult);
			}

			function ajaxLogin(username,password){
				DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'login', username,password, getResult);
			}

			function getResult(result)
			{
				if(result["type"]){
					if(result.type=="NotLoggedIn") 	{											document.getElementById("login").style.display="block";
						document.getElementById("loginNotice").innerHTML=result.message;
						showAlert("FaceFinder - You are not logged in. Please log in below...");
						alert(result.message);
						}
					else if (result.type=="LoggedIn"){
						document.getElementById("nm").innerHTML=result.name;
						document.getElementById("login").style.display="none";
						}
					else if (result.type=="CREATE"){
						new ExistingPhoto($("OS_PHOTO"),result.name,result.userid,result.x,result.y,result.isverified);
						$("deletelink_self").style.display='inline';
						showAlert("FaceFinder - Your link was created successfully");
						disable();
					} else if (result.type=="UPDATE"){
						if( ExistingPhotos["exist_"+result.userid]) {
							ExistingPhotos["exist_"+result.userid].x=result.x;
							ExistingPhotos["exist_"+result.userid].y=result.y;
						} else
						new ExistingPhoto($("OS_PHOTO"),result.name,result.userid,result.x,result.y,result.isverified);
						$("deletelink_self").style.display='inline';
						showAlert("FaceFinder - Your link was updated successfully");
	
						disable();
					} else if (result.type=="DELETE"){
						if( ExistingPhotos["exist_"+result.userid]) {
							ExistingPhotos["exist_"+result.userid].destroy();
							$("deletelink_self").style.display='none';
							showAlert("FaceFinder - Your link was deleted successfully");
						} 
					}
					else alert("Error: "+result.message);
					return;
				}
				if (result.error=="true"){
					alert("Error: " + result.message);
				}else {
					alert(result.message);
				}
				
			}

		


function findPosX (obj) {
 var curLeft=0;
 if (obj.offsetParent){
  while(obj.offsetParent) {
   curLeft+=obj.offsetLeft;
   obj=obj.offsetParent;
  }
 } else if (obj.x){
  curLeft+=obj.x;
 }
 return curLeft;
}

function findPosY (obj) {
 var curTop=0;
 if (obj.offsetParent){
  while(obj.offsetParent) {
   curTop+=obj.offsetTop;
   obj=obj.offsetParent;
  }
 } else if (obj.y){
  curTop+=obj.y;
 }
 return curTop;
}



function  position(baseImage, squareImage, nameDiv, ix, iy, isHover) {
  var px=findPosX(baseImage); var py=findPosY(baseImage);
 
  var nm=nameDiv;
  var adjx=isHover? -1*squareImage.width/2 :px;
  var adjy=isHover? -1* squareImage.height/2 : py;
  var  sl=mx(px,mn(px+baseImage.width-squareImage.width,ix+adjx));
  squareImage.style.left=sl;
  var st=mx(py,mn(py+baseImage.height-squareImage.height,iy+adjy));
  squareImage.style.top=st;
  nm.style.top=st+squareImage.height;
  var c=sl-(nm.clientWidth/2)+squareImage.width/2;
  nm.style.left=c;
}



function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}


function mtrack(evtx, img) {
	
	if(!work) return;
//	$("instr2").style.display="none";

	var xx=mouseX(evtx); var yy=mouseY(evtx);	 
 	position(img,$("square"),$("nm"),xx,yy,true);
}



function enable(){
//	$("instr1").style.display="block";
//	$("instr3").style.display="none";
	 var square=$("square");
	var nm=$("nm");
	nm.style.visibility="visible";
	nm=$("square");
	nm.style.visibility="visible";
}

function disable(){
//$("instr1").style.display="none";
//$("instr2").style.display="none";
//$("instr3").style.display="block";
	 var square=$("square");
var nm=$("nm");
nm.style.visibility="hidden";
nm=$("square");
 nm.style.visibility="hidden";
}

var committedX=-1;
var committedY=-1;

function commit(){
	var i=$("OS_PHOTO");
	var s=$("square");
	var realx=findPosX(s)- findPosX(i);
	var realy=findPosY(s) - findPosY(i);
	
        committedX=realx; committedY=realy;
//	$("instr1").style.display="none";
//	$("instr2").style.display="block";
}


var work=false;
function mx(a,b){ return a>=b?a:b;}
function mn(a,b){ return a<b?a:b;}

var ExistingPhotos=new Object();

function ExistingPhoto(pic, name, userid, xcoord, ycoord, isverified, fsid_, displayfs_){
	this.verified=isverified;
        this.fsid=fsid_;
        this.displayfs=displayfs_;
	this.userid=userid;
	this.id="exist_"+userid;
	this.pic=pic; this.name=name; this.x=xcoord; this.y=ycoord;
        this.square=document.createElement("img");
        this.label= document.createElement("div");
        this.label.className="nameLabel";
	
	
	this.label.innerHTML=name;
        this.square.src=app_siteroot+"/galleries/square.gif";
        this.square.className="hoverImage";

	this.setVisible=function(b){
		if (b) position(this.pic, this.square, this.label, this.x, this.y,false);
     		this.square.style.visibility=b?"visible":"hidden";
		this.label.style.visibility =b?"visible":"hidden";
	};

	this.destroy=function(){
		this.setVisible(false);
		this.label.parentNode.removeChild(this.label);
		this.square.parentNode.removeChild(this.square);
		this.memberSpan.parentNode.removeChild(this.memberSpan);
		ExistingPhotos[this.id]=null;
	}
	$("container").appendChild(this.label);
	$("container").appendChild(this.square);

	var myID=this.id;
	var f_on=function(){ ExistingPhotos[myID].setVisible(true);};
	var f_off=function(){ ExistingPhotos[myID].setVisible(false);};
        
	this.memberSpan=document.createElement("span");
    	this.memberSpan.className="userLabel";


        var contactLink=document.createElement("a");
       if(this.displayfs){
	contactLink.href="http://www.futuresimchas.com/future/index.cfm?fuseaction=profile.view&u="+this.fsid;
            } else {
         contactLink.href="javascript:pmsg("+this.userid+");";
       }
	contactLink.onmouseover=f_on;
      	contactLink.onmouseout =f_off;
	contactLink.className="hoverLink";

        var memberLink=document.createElement("a");
	memberLink.href=app_index+"galleries.mypics/userid:"+this.userid;
        memberLink.innerHTML=this.name;
	memberLink.title="View all pics of this user";
	memberLink.onmouseover=f_on;
      	memberLink.onmouseout =f_off;
	memberLink.className="hoverLink";

	var profileLink=document.createElement("a");
	if(this.displayfs){
	profileLink.href=app_index+"galleries.mypics/fsid:"+this.userid;
	} else {
	profileLink.href=app_index+"galleries.mypics/userid:"+this.userid;
	}
	profileLink.className="hoverLink";
	profileLink.onmouseover=f_on;
      	profileLink.onmouseout =f_off;


        var img=document.createElement("img");
	img.src=app_fullroot+"/future/images/m_unread.gif";
	img.align="absmiddle";
	img.border=0;
	img.title="Contact this user";

	var img2=document.createElement("img");
	img2.src=app_siteroot+"/galleries/go.gif";
	img2.align="absmiddle";
	img2.border=0;
	img2.title="View all pics of this user";

	contactLink.appendChild(img);
	profileLink.appendChild(img2);
	
	
	this.memberSpan.appendChild(memberLink);
	this.memberSpan.appendChild(contactLink);
	this.memberSpan.appendChild(profileLink);

	$("members").appendChild(this.memberSpan);
	

	 ExistingPhotos[this.id]=this;
        return this;
	
}
