function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function topFriend(imgPath, screenname, userID){
	//alert (document.forms['ProfileEdit'].elements['Counter'].value);
	var CounterValue = 12;
	var updateID = "photo";
	if (document.forms['ProfileEdit'].elements['Counter'].value < CounterValue){
		// increment the counter by 1
		var counter = document.forms['ProfileEdit'].elements['Counter'].value;
		var counterTemp = parseInt(counter) + 1;
		document.forms['ProfileEdit'].elements['Counter'].value = counterTemp;
		
		//alert(document.getElementById(updateID).images.length);
		var pwidth = 80;
		var pheight = 60;
		var pthumb = 4;
		var addedsameimage = false;
		var i = 0;
		var NodePreviousSibling = "";

		var randomnumber=Math.floor(Math.random()*10000);

		$('loaderhere').innerHTML = "<img src='/img/loader.gif'/>";
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.friend.top.change', imgPath: imgPath, screenname: screenname, userID: userID, counter: counterTemp, RandomNum: randomnumber },
			method: 'get',
			insertion: Insertion.Before,
			onSuccess: function(transport) {
				$('loaderhere').innerHTML = "Please Select Your Friends You Want to Display";
			}
		});return(false);

	}
	else{
		alert("You can only have a maximum of " + CounterValue + " images.");
	}

}

function changeImg(dateCreated, imgID, pcat, dateCreatedFormated){
	// this is the var to look for in the url
	var getThisVar = "p";
	var query = window.location.search.substring(1);
    var hashes = query.split("#");
	
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
		if (hash[0] == getThisVar) {
			// this get's the p= value in the url
			var myPhotoNum = hash[1];
    	}
		else{
			var myPhotoNum = 0;
		}
    }
	// if it's the randmon category (p=4), set the max to 16 photos
	if (myPhotoNum == 4){
		var CounterValue = 16;
	}
	else {
		var CounterValue = 8;
	}
	
	if (pcat == "myphotos"){
		var updateID = "photo";
		if (document.forms['ProfileEdit'].elements['Counter'].value < CounterValue){
			// increment the counter by 1
			var counter = document.forms['ProfileEdit'].elements['Counter'].value;
			var counterTemp = parseInt(counter) + 1;
			document.forms['ProfileEdit'].elements['Counter'].value = counterTemp;
			
			//alert(document.getElementById(updateID).images.length);
			var pwidth = 151;
			var pheight = 113;
			var pthumb = 3;
			var addedsameimage = false;
    		var i = 0;
			var NodePreviousSibling = "";
			/*if (document.forms['ProfileEdit'].elements['Counter'].value != 1){
				var NodeCurrent = document.getElementById(imgID);
				alert(NodeCurrent);
			}
			
			for( i =0; i < parseInt(document.forms['ProfileEdit'].elements['Counter'].value); i++){
				alert("testing" + NodeCurrent.id);
				if (NodeCurrent.id == imgID){
					alert("You already added this image.");
					addedsameimage = true;
				}
				NodePreviousSibling = NodeCurrent.previousSibling;
				NodeCurrent = NodePreviousSibling;
			}*/
			var randomnumber=Math.floor(Math.random()*10000);
			//if (addedsameimage != true){
				$('loaderhere').innerHTML = "<img src='/img/loader.gif'/>";
				new Ajax.Updater(updateID, '/', {
					parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat, ProfileRandomNum: randomnumber, ProfileDate: dateCreatedFormated, ProfileIsItRandom: myPhotoNum },
					method: 'get',
					insertion: Insertion.Before,
					onSuccess: function(transport) {
						$('loaderhere').innerHTML = "Please Select Your Photo's You Want to Display";
					}
				});return(false);
			//}
		}
		else{
			alert("You can only have a maximum of " + CounterValue + " images.");
		}
	}	
	
	else if (pcat == "profilephoto"){
		var pwidth = 202;
		var pheight = 152;
		var pthumb = 2;
		var updateID = "profileimg"
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	
	else if (pcat == "bigphoto"){
		var pwidth = 202;
		var pheight = 152;
		var pthumb = 2;
		var updateID = "bigphoto"
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	
	else if (pcat == "inbox_message"){
		var pwidth = 80;
		var pheight = 60;
		var pthumb = 4;
		var updateID = "attachedphoto"
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	
	else if (pcat == "inbox_compose"){
		var pwidth = 80;
		var pheight = 60;
		var pthumb = 4;
		var updateID = "attachedphoto"
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	
	else if (pcat == "blog_pic1"){
		var pwidth = 318;
		var pheight = 239;
		var pthumb = 1;
		var updateID = "attachedphoto"
		$('AttachPic').addClassName('hidden');
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	
	else if (pcat == "comment"){
		var pwidth = 80;
		var pheight = 60;
		var pthumb = 4;
		var updateID = "attachedphoto"
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileWidth: pwidth, ProfileHeight: pheight, ProfileThumb: pthumb, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	else if (pcat == "contestenterpic"){
		$('contestenterpic').removeClassName('hidden');
		var updateID = "contestenterpic";
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	else if (pcat == "mycontestpicselected"){
		var updateID = "mycontestpicselected";
		document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.photo.change', ProfileFile: dateCreated, ProfileFileID: imgID, ProfileCategory: pcat  },
			method: 'get'
		});return(false);
	}
	//document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
	//$("profileimg").innerHTML = "<img src='/img/loader.gif'/>";
	//document.getElementById("photo1").innerHTML +="<img src='/img/loader.gif'/>"

}
function InboxLoadAttachPhoto(m){
	var updateID = "AttachPic";
	document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.inbox.message.photos.attach', m: m  },
			method: 'get'
		});return(false);
}
function BlogLoadAttachPhoto(m){
	$('captionphoto').removeClassName('hidden');
	$('captionphoto').addClassName('Title');
	$('AddPhoto2').addClassName('hidden');
	var updateID = "AttachPic";
	document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.blog.photos.attach', m: m  },
			method: 'get'
		});return(false);
}
function changePages(paging, usrID, pcat){
	// this is the var to look for in the url
	var getThisVar = "p";
	var query = window.location.search.substring(1);
    var hashes = query.split("#");
	
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
		if (hash[0] == getThisVar) {
			// this get's the p= value in the url
			var myPhotoNum = hash[1];
    	}
		else{
			var myPhotoNum = 0;
		}
    }
	
	if (window.location.pathname.match("profile.myphotos.edit")!= null){
		var pcat = "myphotos";
		var idToChange = "ProfilePics";
	}
	else if (window.location.pathname.match("profile.photouser.edit")!= null){
		var pcat = "photouser";
		var idToChange = "ProfilePics";
	}
	else if (window.location.pathname.match("profile.photobig.edit")!= null){
		var pcat = "photobig";
		var idToChange = "ProfilePics";
	}
	else if (window.location.pathname.match("profile.inbox")!= null){
		var pcat = "inbox_" + myPhotoNum;
		if (pcat == "inbox_message&m"){
			var idToChange = "AttachPic";
		}
		// for attach photo in compose
		// change it because it's the same page as message
		else if (pcat == "inbox_compose" && document.forms['InboxCompose'].elements['Category'].value == 2){
			pcat = "inbox_message&m";
			var idToChange = "AttachPic";
		}
		else if (pcat == "inbox_compose" && document.forms['InboxCompose'].elements['Category'].value == 1){
			pcat = "inbox_compose_all_friends";
			var idToChange = "inbox_compose_friends";
		}
		else{
			var idToChange = "ProfilePics";
		}
	}
	else if (window.location.pathname.match("profile.friend.edit")!= null){
		var pcat = "topfriend";
		var idToChange = "ProfilePics";
	}
	else if (window.location.pathname.match("profile.blog.edit")!= null){
		var pcat = "blog";
		var idToChange = "AttachPic";
	}
	else if (window.location.pathname.match("profile.comments")!= null){
		var pcat = "comment";
		var idToChange = "AttachPic";
	}
	else if (window.location.pathname.match("contest/iwon")!= null){
		var pcat = "mycontestpicselected";
		var idToChange = "ProfilePics";
	}
	else if (window.location.pathname.match("contest")!= null){
		var pcat = "contestenterpic";
		var idToChange = "ProfilePics";
	}
	
	$(idToChange).innerHTML = "<img src='/img/loader.gif'/>";
	//document.getElementById("ProfilePics").style.background ="url('/img/loader.gif') 40px 50px no-repeat";
	
	new Ajax.Updater(idToChange, '/', {
		parameters: { IDX: 'paging.profile.process', ProfilePage: paging, ProfileID: usrID, ProfileCat: pcat  }
	});return(false);
}

/*function changePagesComments(paging, usrID, pcat){
	 $("Comments").innerHTML = "<img src='/img/loader.gif'/>";
	//document.getElementById("ProfilePics").style.background ="url('/img/loader.gif') 40px 50px no-repeat";
	
	new Ajax.Updater('Comments', '/', {
		parameters: { IDX: 'paging.profile.comments.process', ProfilePage: paging, ProfileID: usrID, ProfileCat: pcat  },
		method: 'get'
	});return(false);
}*/

function removeElement(divNum) {
  var NodeParent = document.getElementById(divNum).parentNode;
  var NodeCurrent = document.getElementById(divNum);

  //d.removeChild(sibling);
  NodeParent.removeChild(NodeCurrent);
  
  // count down to keep in sync with how many images are up on the screen
  var counter = document.forms['ProfileEdit'].elements['Counter'].value;
  var counterTemp = parseInt(counter) - 1;
  document.forms['ProfileEdit'].elements['Counter'].value = counterTemp;
}

function nextElement(divNum){
  var NodeParent = document.getElementById(divNum).parentNode;
  var NodeSibling = document.getElementById(divNum).nextSibling;
  var NodeCurrent = document.getElementById(divNum);
  
  //alert(NodeParent.id);
  
  // check to see if it's not the last photo. If it's not, go through
  if (NodeSibling.id != "photo"){
	  
	  // move photo over to the right.
	  var clone1 = NodeSibling.cloneNode(true);
	  var clone2 = NodeCurrent.cloneNode(true);
	  var replaced1 = NodeParent.replaceChild(clone2, NodeSibling);
	  var replaced2  =NodeParent.replaceChild(clone1, NodeCurrent);
  }
}
function previousElement(divNum){
  var NodeParent = document.getElementById(divNum).parentNode;
  var NodePrevious = document.getElementById(divNum).previousSibling;
  var NodeCurrent = document.getElementById(divNum);
  
  //alert(NodeParent.id);
  
  // check to see if it's not the last photo. If it's not, go through
  //if (NodePrevious.id != undefined){
	  // move photo over to the left.
	  var clone1 = NodePrevious.cloneNode(true);
	  var clone2 = NodeCurrent.cloneNode(true);
	  var replaced1 = NodeParent.replaceChild(clone2, NodePrevious);
	  var replaced2 = NodeParent.replaceChild(clone1, NodeCurrent);
  //}
}

function textCount(textField, maxCount) {
	// if there are more than maxCount chars in the field
    if (textField.value.length > maxCount) {
		// trim the field
        textField.value = textField.value.substring(0, maxCount);
    }
}

function RequestFriend(form){
	Encoder.EncodeType = "entity";
	var Message = Encoder.htmlEncode(form.Message.value,true);
	var FriendRequestTo = form.FriendRequestTo.value;

	var IDtoChange = "addFriend";
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.friend.request.process', FriendRequestTo: FriendRequestTo, Message: Message  }
	});return(false);
}
function RequestFriendProfile(form){
	Encoder.EncodeType = "entity";
	var Message = Encoder.htmlEncode(form.Message.value,true);
	var FriendRequestTo = form.FriendRequestTo.value;

	var IDtoChange = "addFriend"+FriendRequestTo;
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.friend.request.process', FriendRequestTo: FriendRequestTo, Message: Message  }
	});return(false);
}
function addFriend(RequestFrom, Username, Response, picPath){
	$(RequestFrom).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(RequestFrom, '/', {
		parameters: { IDX: 'profile.friend.add.process', RequestFrom: RequestFrom, Username: Username, Response: Response, picPath: picPath }
	});return(false);
}
function unblockFriend(RequestFrom, ID, Username){
	$(RequestFrom).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(RequestFrom, '/', {
		parameters: { IDX: 'profile.friend.unblock.process', RequestFrom: RequestFrom, ID: ID, Username: Username }
	});return(false);
}
function blockFriend(form){
	var FriendID = form.FriendID.value;
	var IDtoChange = "blockUser";
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.friend.block.process', FriendID: FriendID }
	});return(false);
}
function SendMessage(form){
	var ToID = form.ToID.value;
	var Message = form.Message.value;
	var IDtoChange = "sendMessage";
	if(form.Message.value.strip().stripScripts() == ''){
		alert('Your message is blank. Please type in a response.');
	}
	else{
		Encoder.EncodeType = "entity";
		var Message = Encoder.htmlEncode(form.Message.value,true);
		$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'profile.inbox.sendmessage.process', ToID: ToID, Message: Message }
		});return(false);
	}
}
function SendMessageUpdates(form){
	var ToID = form.ToID.value;
	var Message = form.Message.value;
	if(form.Message.value.strip().stripScripts() == ''){
		alert('Your message is blank. Please type in a response.');
	}
	else{
		var IDtoChange = form.IDtoChange.value;
		Encoder.EncodeType = "entity";
		var Message = Encoder.htmlEncode(form.Message.value,true);
		$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'profile.inbox.sendmessage.process', ToID: ToID, Message: Message }
		});return(false);
	}
}
function ReplyMessage(form){
	var IDtoChange = "sendMessage";
	if(form.Message.value.strip().stripScripts() == ''){
		alert('Your message is blank. Please type in a response.');
	}
	else{ 
		Encoder.EncodeType = "entity";
		var Message = Encoder.htmlEncode(form.Message.value,true);
		var Subj = Encoder.htmlEncode(form.Subj.value,true);
		$('Reply').innerHTML = "<img src='/img/loader.gif'/>";
		$('SendBtn').disabled = true;
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'profile.inbox.sendmessage.process', ToID: form.ToID.value, Message: Message, RepliedTo: form.RT.value, RepliedSet: form.R.value, Subj: Subj, ImageID: form.ImageID.value },
			method: 'post',
			insertion: Insertion.After,
			onSuccess: function(transport) {
				form.Message.value = '';
				$('SendBtn').disabled = false;
				$('Reply').innerHTML = "Reply";
			}
		});return(false);
	}
}
function ComposeMessage(form){
	var IDtoChange = "Subject";
	if(form.Message.value.strip().stripScripts() == ''){
		alert('Your message is blank. Please type in a response.');
	}
	else{ 
		Encoder.EncodeType = "entity";
		var Message = Encoder.htmlEncode(form.Message.value,true);
		var Subj = Encoder.htmlEncode(form.Subj.value,true);
		$('AttachPic').innerHTML = "<img src='/img/loader.gif'/>";
		$('SendBtn').disabled = true;
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'profile.inbox.sendmessage.process', ToID: form.ToID.value, Message: Message, Subj: Subj, ImageID: form.ImageID.value },
			method: 'post'
		});return(false);
	}
}
function bkgOver(color, ID, triangle){
	var e = document.getElementById(ID);
	e.style.background = color;
	MM_swapImage(triangle,'','/img/profile.triangle.over.gif',1);
};
function bkgOut(color, ID){
	var e = document.getElementById(ID);
	e.style.background = color;
	MM_swapImgRestore();
};
function InboxRemoveMessage(id, id2, m){
	if (m == 'yes'){
		var IDtoChange = id;
	}
	else{
		var IDtoChange = id;
	}
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.inbox.removemessage.process', ID: id, ID2: id2, m:m }
	});return(false);
}
function InboxRemoveSentMessage(id, id2){
	var IDtoChange = id;
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.inbox.removemessagesent.process', ID: id, ID2: id2 }
	});return(false);
}
function InboxRemoveMessageUndo(id, id2, m){
	if (m == 'yes'){
		var IDtoChange = id;
	}
	else{
		var IDtoChange = id;
	}
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.inbox.removemessageundo.process', ID: id, ID2: id2, m:m }
	});return(false);
}
function InboxComposeChangeFriends(v){
	var IDtoChange = 'inbox_compose_friends';
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	if (v == 'PanelFriends1'){
		var thisidx = 'profile.inbox.compose.friendpanel';
	}
	else{
		var thisidx = 'profile.inbox.compose.all.friends';
	}
	new Ajax.Updater(IDtoChange, '/', {
	  parameters: { IDX: thisidx }
	});return(false);
}
function InboxComposeTo(thumb, usernm, id){
	// you're going into the compose section
	document.forms['InboxCompose'].elements['Category'].value = 2;

	$('To').removeClassName('hidden');
	$('To').addClassName('MyPics');
	$('SendTo').addClassName('hidden');
	$('Subject').removeClassName('hidden');

	var IDtoChange = 'To';
	var thisidx = 'profile.inbox.compose.to';
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
	  parameters: { IDX: thisidx, thumb: thumb, usernm: usernm, id:id }
	});return(false);
}

function InboxChangeUser(){
	// you're going into the send to friend section
	document.forms['InboxCompose'].elements['Category'].value = 1;

	$('To').addClassName('hidden');
	$('SendTo').removeClassName('hidden');
	$('Subject').addClassName('hidden');
	return(false);
}
function ProfileAccountEdit(form) {
	if (form.Email.value != form.EmailConfirm.value){
		alert('Please type in the same email address in both boxes.');
		return false;
	}
	else if(!(form.Email.value.match(/^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}/))){
		alert('Email is invalid. Please re-enter.'); 
		return false;
	}
    else{return (true);};
}
function ProfileReport(m){
	var updateID = "reportProfile";
	$('reportProfileLink').addClassName('hidden');
	document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'report_bad.profile.process', m: m  },
			method: 'get'
		});
	$(updateID).removeClassName('hidden');
	return(false);
}
//myField accepts an object reference, myValue accepts the text strint to add
function insertAtCursor(myField, myValue) {
	myField = document.getElementById(myField);
	//IE support
	if (document.selection) {
		myField.focus();
		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = myValue;
	}

	//Mozilla/Firefox/Netscape 7+ support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		//Here we get the start and end points of the
		//selection. Then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//Then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	} 
	else {
		myField.value += myValue;
	}
}
function BlogRemove(id){
	var IDtoChange = "Blog" + id;
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.blog.remove.process', ID: id }
	});return(false);
}
function BlogRemoveUndo(id){
	var IDtoChange = "Blog" + id;
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'profile.blog.remove.undo.process', ID: id }
	});return(false);
}
function RemoveComment(id){
	var IDtoChange = id;
	$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(IDtoChange, '/', {
		parameters: { IDX: 'comment.update.process', CommentID: id }
	});return(false);
}
function PostComment(form){
	var IDtoChange = "Comments";
	Encoder.EncodeType = "entity";
	var Comment = Encoder.htmlEncode(form.Comment.value,true);

	if(form.Comment.value.strip().stripScripts() == ''){
		alert('Your Comment is blank. Please type in a comment.');
	}
	else{ 
		$('AttachPic').innerHTML = "<img src='/img/loader.gif'/>";
		$('SubmitBtn').addClassName('hidden');
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'comment.save.process', CommentOn: form.CommentOn.value, CommentOnID: form.CommentOnID.value, Comment: Comment, AttImageID: form.AttImageID.value },
			method: 'post',
			insertion: Insertion.Top,
			onSuccess: function(transport) {
				location.replace(transport.responseText);
			}
		});
		return(false);
	}
}
function PostCommentUpdates(form){
	var CommentOn = form.CommentOn.value;
	var CommentOnID = form.CommentOnID.value;
	Encoder.EncodeType = "entity";
	var Comment = Encoder.htmlEncode(form.Comment.value,true);
	var CommentOnUpdates = form.CommentOnUpdates.value;
	
	if (CommentOn == 'image'){
		var UP = form.UP.value;
		var UID = form.UID.value;
		var USN = form.USN.value;
		var Owner= form.Owner.value;
		var IDtoChange = form.IDtoChange.value;
	}
	else{
		var UP = '';
		var UID = '';
		var USN = '';
		var IDtoChange = form.IDtoChange.value;
	}
	if(form.Comment.value.strip().stripScripts() == ''){
		alert('Your Comment is blank. Please type in a comment.');
	}
	else{ 
		$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
		
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'comment.save.process', CommentOn: CommentOn, CommentOnID: CommentOnID, Comment: Comment, CommentOnUpdates: CommentOnUpdates, UP: UP, UID: UID, USN: USN, Owner: Owner }
		});
		return(false);
	}
}
function PostCommentImage(form){
	var IDtoChange = "Response";
	Encoder.EncodeType = "entity";
	var Comment = Encoder.htmlEncode(form.Comment.value,true);

	if(form.Comment.value.strip().stripScripts() == ''){
		alert('Your Comment is blank. Please type in a comment.');
	}
	else{ 
		var Owner= form.Owner.value;
		$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
		$('SubmitBtn').addClassName('hidden');
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'comment.save.process', CommentOn: form.CommentOn.value, CommentOnID: form.CommentOnID.value, Comment: Comment, WhatPage: form.WhatPage.value, Owner: Owner  },
			method: 'post',
			insertion: Insertion.Top,
			onSuccess: function(transport) {
				location.replace(transport.responseText);
			}
		});
		return(false);
	}
}
function PostCommentBlog(form){
	var CommentOn = form.CommentOn.value;
	var CommentOnID = form.CommentOnID.value;
	Encoder.EncodeType = "entity";
	var Comment = Encoder.htmlEncode(form.Comment.value,true);

	if(form.Comment.value.strip().stripScripts() == ''){
		alert('Your Comment is blank. Please type in a comment.');
	}
	else{ 
		var Owner= form.Owner.value;
		var IDtoChange = form.IDtoChange.value;
		var UP = form.UP.value;
		var UID = form.UID.value;
		var USN = form.USN.value;
		
		$(IDtoChange).innerHTML = "<img src='/img/loader.gif'/>";
		new Ajax.Updater(IDtoChange, '/', {
			parameters: { IDX: 'comment.save.process', CommentOn: CommentOn, CommentOnID: CommentOnID, Comment: Comment, WhatPage: form.WhatPage.value, UP: UP, UID: UID, USN: USN, Owner: Owner  }
		});
		return(false);
	}
}
function CommentAttachPhoto(){
	var updateID = "AttachPic";
	document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'profile.comment.photos.attach' },
			method: 'get'
		});return(false);
}
function RankingHistory(a,updateID){
	$('rankinghistorybut').addClassName('hidden');
	document.getElementById(updateID).innerHTML = "<img src='/img/loader.gif'/>";	
	new Ajax.Updater(updateID, '/', {
			parameters: { IDX: 'ranking.history', a: a },
			method: 'get'
		});return(false);
}
function profileLoadMoreComment(a, b, c){
	var c = c;
	$(c).innerHTML = "<img src='/img/loader.gif'/>";
	new Ajax.Updater(c, '/', {
		parameters: { IDX: 'profile.comment.loadmore', a: a, b: b}
	});
	return(false);

}
