//Javascript Document
profilePrompt = cropPrompt = addingPrompt = donePrompt = profileXML = currentSort = lastAction = imgLoc = null;
function addProfileBox() {
	addHtml = '<form action="http://celebrityeventsnetwork.ca/backbone/talent.php?addProfile=true" target="fileUpload" method="post" enctype="multipart/form-data"> '
+ '	<table border="0" cellspacing="0" cellpadding="0">'
+ '  <tr>'
+ '    <td width="83">First Name</td>'
+ '    <td><input type="text" name="firstName" id="firstName" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td>Last Name</td>'
+ '    <td><input type="text" name="lastName" id="lastName" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td>Alias</td>'
+ '    <td><input type="text" name="alias" id="alias" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td>Title</td>'
+ '    <td><input type="text" name="title" id="title" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td>Profession</td>'
+ '    <td><select name="profession" id="profession">'
+ '    <option value="Home Renovation">Home Renovation</option>'
+ '    <option value="Home Decor">Home Decor</option>'
+ '    <option value="Culinary Expert">Culinary Expert</option>'
+ '    <option value="Gardening / Outdoor Decor">Gardening / Outdoor Decor</option>'
+ '    <option value="Real Estate Expert">Real Estate Expert</option>'
+ '    <option value="Consumer Expert">Consumer Expert</option>'
+ '    <option value="Casino Event">Casino Event</option>'
+ '    <option value="Kids">Kids</option>'
+ '    <option value="Nickelodeon">Nickelodeon</option>'
+ '    <option value="Antique Expert">Antique Expert</option>'
+ '    <option value="Soap Star">Soap Stars</option></select></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td>Picture</td>'
+ '    <td><input type="file" name="picture" id="picture" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td><input name="cancel" value="Cancel" type="button" onclick="closeAddProfilePrompt()" /></td>'
+ '    <td><input name="add" value="Add" type="submit" onclick="addingProfile()" /></td>'
+ '  </tr>'
+ '</table>'
+ '<input name="windowWidth" value="'+pageWidth()+'" type="hidden" /><input name="windowHeight" value="'+pageHeight()+'" type="hidden" /></form>';
	profilePrompt = new customPrompt('alert', document.getElementById('dimmer2Front'), document.getElementById('dimmer2Back'));
	profilePrompt.doNotShowButton = true;
	profilePrompt.setFadeTime(125);
	profilePrompt.setMsg(addHtml);
	profilePrompt.setOpacity(0.55);
	profilePrompt.setTitle('Add Profile');
	profilePrompt.init();
}
function changePicture(pId) {
	addHtml = '<form action="http://celebrityeventsnetwork.ca/backbone/talent.php?changePicture=true" target="fileUpload" method="post" enctype="multipart/form-data"> '
+ '	<table border="0" cellspacing="0" cellpadding="0">'
+ '  <tr>'
+ '    <td>Picture</td>'
+ '    <td><input type="file" name="picture" id="picture" /></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td><input name="cancel" value="Cancel" type="button" onclick="closeAddProfilePrompt()" /></td>'
+ '    <td><input name="add" value="Add" type="submit" onclick="addingProfile()" /></td>'
+ '  </tr>'
+ '</table>'
+ '<input name="windowWidth" value="'+pageWidth()+'" type="hidden" /><input name="id" value="'+pId+'" type="hidden" /><input name="windowHeight" value="'+pageHeight()+'" type="hidden" /></form>';
	profilePrompt = new customPrompt('alert', document.getElementById('dimmer2Front'), document.getElementById('dimmer2Back'));
	profilePrompt.doNotShowButton = true;
	profilePrompt.setFadeTime(125);
	profilePrompt.setMsg(addHtml);
	profilePrompt.setOpacity(0.55);
	profilePrompt.setTitle('Change Picture');
	profilePrompt.init();
}
function closeAddProfilePrompt() {
	profilePrompt.dir=1;
	profilePrompt.timeCount=0;
	profilePrompt.fade();
}
function addingProfile() {
	//show a loader here
	profilePrompt.resetFade(1);
	profilePrompt.fade();
	profilePrompt = null;
	addingPrompt = new customPrompt('default', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	addingPrompt.doNotShowButton = true;
	addingPrompt.setFadeTime(125);
	addingPrompt.setInnerHTML('<p><h3>Please wait while the image uploads!</h3></p>');
	addingPrompt.setOpacity(0.55);
	addingPrompt.setTitle(null);
	addingPrompt.init();
}
function donePromptClose() {
	donePrompt.resetFade(1);
	donePrompt.fade();
	loadProfiles();
	eval(lastAction);
}
function stopUpload(msg, img) {
	addingPrompt.resetFade(1);
	addingPrompt.fade();
	addingPrompt = null;
	if(msg == 'Profile added successfully!') {
		uploadMsg = '<table cellpadding="1" cellspacing="0" border="0px"><tr><td>Profile added successfully!</td></tr></table>'
		+' <tr><td><input type="button" name="crop" value="Ok" onclick="donePromptClose();" /></td></table>'; 
	} else {
		uploadFrame = document.getElementById('fileUpload').contentWindow.document.body.innerHTML;
		uploadMsg = '<table cellpadding="1" cellspacing="0" border="0px"><tr><td>'+msg+'::'+uploadFrame+'</td></tr>'
		+' <tr><td><input type="button" name="crop" value="Ok" onclick="donePromptClose();" /></td></table>'; 
	}
	donePrompt = new customPrompt('default', document.getElementById('dimmer2Front'), document.getElementById('dimmer2Back'));
	donePrompt.doNotShowButton = true;
	donePrompt.setFadeTime(125);
	donePrompt.setInnerHTML(uploadMsg);
	donePrompt.setOpacity(0.55);
	donePrompt.setTitle(null);
	donePrompt.init();
}
function startCrop(img) {
	crop(img);
	donePrompt.resetFade(1);
	donePrompt.fade();
}
function loadProfiles() {
	loading = new customPrompt('alert', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	loading.doNotShowButton = true;
	loading.setFadeTime(125);
	loading.setMsg('Please wait while the profiles are loaded.');
	loading.setOpacity(0.55);
	loading.setTitle(' ');
	loading.init();
	div = document.getElementById('talentArea');
	ajax = createXmlHttpRequestObject();
	ajax.onreadystatechange = function() {
		if(ajax.readyState != 4) return false;
		if(ajax.responseXML) {
			profileXML = ajax.responseXML;		
			var j = 0;
			var nPr = 4;
			var tdWidth = 100/nPr;
			var profileHTML = '';
			allProfiles = profileXML.getElementsByTagName('profile');
			showCategories();
			loading.dir = 1;
			loading.timeCount = 0;
			loading.fade();
			//alert(profileHTML);
		} else {
			document.getElementById('talentArea').innerHTML = ajax.responseText;
			loading.dir = 1;
			loading.timeCount = 0;
			loading.fade();
		}
	}
	ajax.open("GET","../backbone/talent.php",true);
	ajax.send(null);
}
function findImageLocation(pId) {
	try
	{
		var loc = 'Img-bin/profile/profile_' + pId;
		imgLoc = loc + '.gif';
		var img = new Image();
		img.src = imgLoc;
		if(img.width == 0)
			imgLoc = loc + '.jpg';
	}
	catch(err)
	{
		imgLoc = loc + '.jpg';
	}
	return null;
}

function profile(constraint, type) 
{	
	lastAction = 'showCategories()';
	
	//Loading screen do not touch
	loading = new customPrompt('alert', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	loading.doNotShowButton = true;
	loading.setFadeTime(125);
	loading.setMsg('Please wait while the profiles are filtered.');
	loading.setOpacity(0.55);
	loading.setTitle(' ');
	loading.init();
	
	//sizing variables
	var j = 0;
	var nPr = 4;
	var tdWidth = 100/nPr;
	
	//constraint management
	currentSort = constraint;
	if(!constraint) constraint = '*';
	
	//variable initialization
	var profileHTML = '';
	
	//sorter
	allProfiles = profileXML.getElementsByTagName('profile');
	for(var i = 0; i < allProfiles.length; i++) 
	{
		if(allProfiles[i].attributes.getNamedItem("alias").value) 
		{
			var name = allProfiles[i].attributes.getNamedItem("alias").value;
		} else 
		{
			var name = allProfiles[i].attributes.getNamedItem("title").value + ' ' + allProfiles[i].attributes.getNamedItem("firstname").value + ' ' + allProfiles[i].attributes.getNamedItem("lastname").value;
		}
		
		if(constraint != '*') 
		{
			if(type == 'exp') 
			{
				if(allProfiles[i].attributes.getNamedItem("profession").value != constraint) 
				{
					if(i == (allProfiles.length - 1) ) 
					{
						//if there is no profiles left, fill it with white space.
						while(j%nPr) 
						{
							profileHTML = profileHTML + '<td width="'+tdWidth+'%">&nbsp;</td>';
							j++; 
						}
						profileHTML = profileHTML + '</tr>';
					}
					continue;
				}
			} 
			else 
			{
				//this is where we check for names
			}
		}
		
		//if there will be no white space, check to see if we are at the end.
		if(!(j%nPr))  
		{
			if(j) 
			{ 
				profileHTML = profileHTML + '</tr><tr>' 
			} 
			else 
			{ 
				profileHTML = profileHTML + '<tr>' 
			}
		}
		
		//build the table
		pId = allProfiles[i].attributes.getNamedItem("id").value;
		profession = allProfiles[i].attributes.getNamedItem("profession").value;
		if(!pId || !name) continue;
		
		//enable user admin features
		if(userAdmin) 
		{
			sortNum = allProfiles[i].attributes.getNamedItem("sortNum").value;
			removeFeature = '[<a onclick="removeTalent(\''+pId+'\')">Remove</a>] [<a onclick="changePicture(\''+pId+'\')">Change Picture</a>]<br />';
			removeFeature = '[Sort Num:<form action="../backbone/profile.php" target="fileUpload" method="post">'
			+ '<input type="text" size="5" value="'+sortNum+'" name="num" id="num" /><input type="hidden" name="sortNum" id="sortNum" value="'+pId+'" />'
			+ '<input type="submit" value="Update" />]</form>' + removeFeature;
		} else removeFeature = '';
		//find out what image to use 
		//actual hteml
		findImageLocation(pId);
				profileHTML += '<td width="'+tdWidth+'%"><table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center"><div onclick="loadProfile(\''+pId+'\',\''+profession+'\')" class="button"><img src="'+imgLoc+'" /></div></td>' + "\n"
		+'  </tr>' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center">'+removeFeature+'<b>'+name+'</b></td>' + "\n"
		+'  </tr>' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center" onclick="loadProfile('+pId+','+profession+')">&nbsp;</td>' + "\n"
		+'  </tr>' + "\n"
		+'</table></td>' + "\n";
		if(i == (allProfiles.length - 1)) {
			while(j%nPr) {
				profileHTML = profileHTML + '<td width="'+tdWidth+'%">&nbsp;</td>';
				j++; 
			}
			profileHTML = profileHTML + '</tr>';
		}
		
		j++; 
	}
	document.getElementById('talentArea').innerHTML = '<table cellspacing="4" width="100%">'+profileHTML+'</table>';
	document.getElementById('backbutton').innerHTML = '<img src="images/back.gif">';
	loading.dir = 1;
	loading.timeCount = 0;
	loading.fade();
}
function showCategories()
{
	var html = '<table cellpadding="5" cellspacing="1" border="0">' +
                '<tr>' +
                 '<td><img src="images/Home Reno.gif" width="174" height="102" class="button" onClick="profile(\'Home Renovation\', \'exp\')"></td>' +
                 '<td><img src="images/Home Decor.gif" width="174" height="102" class="button" onClick="profile(\'Home Decor\', \'exp\')"></td>' +
                 '<td><img src="images/Cull Exp.gif" width="174" height="102" class="button" onClick="profile(\'Culinary Expert\', \'exp\')"></td>' +
                 '<td>' +
				 '<img src="images/gardening.gif" width="174" height="102" class="button" onClick="profile(\'Gardening / Outdoor Decor\', \'exp\')">'+
				 '</td>' +
                 '<td><img src="images/real estate.gif" width="174" height="102" class="button" onClick="profile(\'Real Estate Expert\', \'exp\')"></td>' +
				 '</tr>' +
                 '<tr>' +
                 '<td><img src="images/Soap Star.gif" width="174" height="102" class="button" onClick="profile(\'Soap Star\', \'exp\')"></td>' +
                 '<td><img src="images/Consume.gif" width="174" height="102" class="button" onClick="profile(\'Consumer Expert\', \'exp\')"></td>' +
                 '<td><img src="images/kids.gif" width="174" height="102" class="button" onClick="kidsSection()"></td>' +
                 '</tr>' +
                 '</table>';
	document.getElementById('talentArea').innerHTML = html;
	document.getElementById('backbutton').innerHTML = '&nbsp;';
}
function kidsSection()
{
	//variable initialization
	var profileHTML = '';
	var constraint = 'Kids';
	var type = 'exp';
	lastAction = 'showCategories()';
	//sizing variables
	var j = 0;
	var nPr = 4;
	var tdWidth = 100/nPr;
	
	//constraint management
	currentSort = constraint;
	if(!constraint) constraint = '*';
	
	//variable initialization
	var profileHTML = '';
	
	//sorter
	allProfiles = profileXML.getElementsByTagName('profile');
	for(var i = 0; i < allProfiles.length; i++) 
	{
		if(allProfiles[i].attributes.getNamedItem("alias").value) 
		{
			var name = allProfiles[i].attributes.getNamedItem("alias").value;
		} else 
		{
			var name = allProfiles[i].attributes.getNamedItem("title").value + ' ' + allProfiles[i].attributes.getNamedItem("firstname").value + ' ' + allProfiles[i].attributes.getNamedItem("lastname").value;
		}
		
		if(constraint != '*') 
		{
			if(type == 'exp') 
			{
				if(allProfiles[i].attributes.getNamedItem("profession").value != constraint) 
				{
					if(i == (allProfiles.length - 1) ) 
					{
						//if there is no profiles left, fill it with white space.
						while(j%nPr) 
						{
							profileHTML = profileHTML + '<td width="'+tdWidth+'%">&nbsp;</td>';
							j++; 
						}
						profileHTML = profileHTML + '</tr>';
					}
					continue;
				}
			} 
			else 
			{
				//this is where we check for names
			}
		}
		
		//if there will be no white space, check to see if we are at the end.
		if(!(j%nPr))  
		{
			if(j) 
			{ 
				profileHTML = profileHTML + '</tr><tr>' 
			} 
			else 
			{ 
				profileHTML = profileHTML + '<tr>' 
			}
		}
		
		//build the table
		pId = allProfiles[i].attributes.getNamedItem("id").value;
		profession = allProfiles[i].attributes.getNamedItem("profession").value;
		if(!pId || !name) continue;
		
		//enable user admin features
		if(userAdmin) 
		{
			sortNum = allProfiles[i].attributes.getNamedItem("sortNum").value;
			removeFeature = '[<a onclick="removeTalent(\''+pId+'\')">Remove</a>] [<a onclick="changePicture(\''+pId+'\')">Change Picture</a>]<br />';
			removeFeature = '[Sort Num:<form action="../backbone/profile.php" target="fileUpload" method="post">'
			+ '<input type="text" size="5" value="'+sortNum+'" name="num" id="num" /><input type="hidden" name="sortNum" id="sortNum" value="'+pId+'" />'
			+ '<input type="submit" value="Update" />]</form>' + removeFeature;
		} else removeFeature = '';
		//find out what image to use 
		//actual hteml
		findImageLocation(pId);
				profileHTML += '<td width="'+tdWidth+'%"><table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center"><div onclick="loadProfile(\''+pId+'\',\''+profession+'\')" class="button"><img src="'+imgLoc+'" /></div></td>' + "\n"
		+'  </tr>' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center">'+removeFeature+'<b>'+name+'</b></td>' + "\n"
		+'  </tr>' + "\n"
		+'  <tr>' + "\n"
		+'    <td align="center" onclick="loadProfile('+pId+','+profession+')">&nbsp;</td>' + "\n"
		+'  </tr>' + "\n"
		+'</table></td>' + "\n";
		if(i == (allProfiles.length - 1)) {
			while(j%nPr) {
				profileHTML = profileHTML + '<td width="'+tdWidth+'%">&nbsp;</td>';
				j++; 
			}
			profileHTML = profileHTML + '</tr>';
		}
		
		j++; 
	}
	var html = '<table cellpadding="5" cellspacing="1" border="0">' +
                '<tr>' +
                 '<td><img src="images/nickelodeon.gif" width="174" height="102" class="button" onClick="profile(\'Nickelodeon\', \'exp\'); lastAction=\'kidsSection()\'"></td>' +
                 '<td><img src="images/fisher.gif" width="174" height="102" class="button" onClick="profile(\'Fisher-Price\', \'exp\'); lastAction=\'kidsSection()\'"></td>' +
                 '</tr>' +
                 '</table>';
	document.getElementById('talentArea').innerHTML = html + '<table cellspacing="4" width="100%">'+profileHTML+'</table>';
	document.getElementById('backbutton').innerHTML = '<img src="images/back.gif">';
}
function updateSortNum(pId,num) {
	var xmlHttp = createXmlHttpRequestObject();  
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState != 4) {return false;}
			if(xmlHttp.responseText) alert(xmlHttp.responseText);
			loadProfiles();
			eval(lastAction);
	}
	xmlHttp.open("GET", "../backbone/profile.php?sortNum=" + pId + "&num=" + sortNum, true);
	xmlHttp.send(null);
}
function removeTalent(pId) {
	var xmlHttp = createXmlHttpRequestObject();  
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState != 4) {return false;}
		 //if(xmlHttp.responseText) { 
			//then procede to get the second image if the response if correct
			if(xmlHttp.responseText) alert(xmlHttp.responseText);
			addingPrompt.resetFade(1);
			addingPrompt.fade();
			loadProfiles();
			eval(lastAction);
		//}
	}
	addingPrompt = new customPrompt('default', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	addingPrompt.doNotShowButton = true;
	addingPrompt.setFadeTime(125);
	addingPrompt.setInnerHTML('<p><h3>Please wait while the profile is removed!</h3></p>');
	addingPrompt.setOpacity(0.55);
	addingPrompt.setTitle(null);
	addingPrompt.init();
	xmlHttp.open("GET", "../backbone/profile.php?removeProfile="+pId, true);
	xmlHttp.send(null);
}
function crop(imgInput) {
	var orig = new Image();
	orig.src = imgInput;
	cropHtml = '<table border="1" cellspacing="0" cellpadding="2">'
+'  <tr>'
+'    <td><img src="'+imgInput+'" id="imgToCrop" /></td>'
+'  </tr>'
+'  <tr>'
+'    <td><input type="button" name="next" value="Next" onclick="changeCrop(\''+imgInput+'\')" /></td>'
+'  </tr>'
+'</table>'
+'<div id="cropper" style="border: 2px dashed #fff; position: absolute; width: 200px; height: 250px;"><div id="ciDragHandler"></div><div id="ciResizeHandler"></div></div>';
	cropPrompt = new customPrompt('alert', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	cropPrompt.doNotShowButton = true;
	cropPrompt.setFadeTime(125);
	cropPrompt.setMsg(cropHtml);
	cropPrompt.setOpacity(0.70);
	cropPrompt.setTitle('Crop Image');
	cropPrompt.init();
	cropImage = document.getElementById('imgToCrop');
	cropDiv = document.getElementById('cropper');
	ciDragHandler = document.getElementById('ciDragHandler');
	ciResizeHandler = document.getElementById('ciResizeHandler');
	cropDiv.style.top = cropImage.offsetTop;
	cropDiv.style.left = cropImage.offsetLeft;
	ciDragHandler.style.height = cropDiv.offsetHeight * 0.90 + 'px';
	ciDragHandler.style.width = cropDiv.offsetWidth + 'px';
	ciResizeHandler.style.height = cropDiv.offsetHeight * 0.10 + 'px';
	ciResizeHandler.style.width = cropDiv.offsetWidth + 'px';
	crd = new Array(cropDiv, ciDragHandler, ciResizeHandler);
	additionalMove = function() {
		ciDragHandler.style.height = cropDiv.offsetHeight * 0.90 + 'px';
		ciDragHandler.style.width = cropDiv.offsetWidth + 'px';
		ciResizeHandler.style.height = cropDiv.offsetHeight * 0.10 + 'px';
		ciResizeHandler.style.width = cropDiv.offsetWidth + 'px';

	}
	maxHeight = cropImage.offsetHeight;
	maxWidth = cropImage.offsetWidth;
	maxTop = findPosY(cropImage);
	minLeft = findPosX(cropImage);
	makeDraggable(cropDiv, ciDragHandler);
	makeDraggable(crd, ciResizeHandler, 1.25);
}
function changeCrop(img) {
	cropImage = document.getElementById('imgToCrop');
	cropDiv = document.getElementById('cropper');
	var xmlHttp = createXmlHttpRequestObject();  
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState != 4) {return false;}
		 //if(xmlHttp.responseText) { 
			//then procede to get the second image if the response if correct
			cropPrompt.resetFade(1);
			cropPrompt.fade();
		//}
	}
	xmlHttp.open("GET", "backbone/resize.php?img="+img+"&x="+cropDiv.style.left+"&y="+cropDiv.style.right+"&w="+cropDiv.offsetWidth+"&h="+cropDiv.offsetHeight, true);
	xmlHttp.send(null);
}
function loadProfile(id, profession) {
		if(profession == 'Kids')
			lastAction = 'kidsSection()';
		else
			lastAction = 'profile(\'' + profession + '\', \'exp\')';
	
	var profileURL = 'profiles/profile.php?id='+id;
	var xmlHttp = createXmlHttpRequestObject();  
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState != 4) {return false;}
		if(xmlHttp.responseText) 
		{ 
			document.getElementById('talentArea').innerHTML = xmlHttp.responseText;
		}
		else
		{
			document.getElementById('talentArea').innerHTML = "Error";
		}
	}
	xmlHttp.open("GET", profileURL, true);
	xmlHttp.send(null);
}
function vewTest(id) {
	//this will have-to work later
}
function addMediaCancel() {
	profilePrompt.dir=1;
	profilePrompt.timeCount=0;
	profilePrompt.fade()
}
function addMedia(id) {
	addHtml = '<form action="../backbone/profile.php?addMedia=true" target="fileUpload" method="post" enctype="multipart/form-data"> '
+ '	<table border="0" cellspacing="0" cellpadding="0">'
+ '  <tr>'
+ '    <td>Media</td>'
+ '    <td><input type="file" name="media" id="media" /><input type="hidden" name="id" value="'+id+'"/></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td><input name="cancel" value="Cancel" type="button" onclick="addMediaCancel()" /></td>'
+ '    <td><input name="add" value="Add" type="submit" onclick="addingProfile()" /></td>'
+ '  </tr>'
+ '</table>'
+ '<input name="windowWidth" value="'+pageWidth()+'" type="hidden" /><input name="windowHeight" value="'+pageHeight()+'" type="hidden" /></form>';
	profilePrompt = new customPrompt('alert', document.getElementById('dimmer2Front'), document.getElementById('dimmer2Back'));
	profilePrompt.doNotShowButton = true;
	profilePrompt.setFadeTime(125);
	profilePrompt.setMsg(addHtml);
	profilePrompt.setOpacity(0.55);
	profilePrompt.setTitle('Add Media');
	profilePrompt.init();
}
function removeMedia(id) {
	var xmlHttp = createXmlHttpRequestObject();  
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState != 4) {return false;}
		 //if(xmlHttp.responseText) { 
			//then procede to get the second image if the response if correct
			if(xmlHttp.responseText) alert(xmlHttp.responseText);
			addingPrompt.resetFade(1);
			addingPrompt.fade();
			window.location.reload();
		//}
	}
	addingPrompt = new customPrompt('default', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	addingPrompt.doNotShowButton = true;
	addingPrompt.setFadeTime(125);
	addingPrompt.setInnerHTML('<p><h3>Please wait while the media is removed!</h3></p>');
	addingPrompt.setOpacity(0.55);
	addingPrompt.setTitle(null);
	addingPrompt.init();
	xmlHttp.open("GET", "../backbone/profile.php?remove="+id, true);
	xmlHttp.send(null);
}
function sMUClose() {
	donePromptClose();
	show
}
function stopMediaUpload(msg) {
	addingPrompt.resetFade(1);
	addingPrompt.fade();
	addingPrompt = null;
	uploadMsg = '<table cellpadding="1" cellspacing="0" border="0px"><tr><td>'+msg+'</td></tr>'
	+' <tr><td><input type="button" name="crop" value="Done" onclick="sMUClose();" /></td></table>';  
	donePrompt = new customPrompt('default', document.getElementById('dimmer2Front'), document.getElementById('dimmer2Back'));
	donePrompt.doNotShowButton = true;
	donePrompt.setFadeTime(125);
	donePrompt.setInnerHTML(uploadMsg);
	donePrompt.setOpacity(0.55);
	donePrompt.setTitle(null);
	donePrompt.init();
	loadProfiles();
	profile('*');
}
function addingMedia() {
	//show a loader here
	profilePrompt.resetFade(1);
	profilePrompt.fade();
	profilePrompt = null;
	addingPrompt = new customPrompt('default', document.getElementById('dimmerFront'), document.getElementById('dimmerBack'));
	addingPrompt.doNotShowButton = true;
	addingPrompt.setFadeTime(125);
	addingPrompt.setInnerHTML('<p><h3>Please wait while the media uploads!</h3></p>');
	addingPrompt.setOpacity(0.55);
	addingPrompt.setTitle(null);
	addingPrompt.init();
}
