var isCamVisible = 0; function CreateUploadButton(elementID) { new Ajax_upload(elementID, { // Location of the server-side upload script action: 'http://www.yodida.com/didaUploadProcess.php', // File upload name name: 'image', // Additional data to send data: { upload : '1', example_key2 : 'example_value2' }, // Submit file after selection autoSubmit: true, // The type of data that you're expecting back from the server. // Html (text) and xml are detected automatically. // Only useful when you are using json data as a response. // Set to "json" in that case. responseType: false, // Fired after the file is selected // Useful when autoSubmit is disabled // You can return false to cancel upload // @param file basename of uploaded file // @param extension of that file onChange: function(file, extension){}, // Fired before the file is uploaded // You can return false to cancel upload // @param file basename of uploaded file // @param extension of that file onSubmit: function(file, extension) { $(elementID).innerHTML = 'uploading...'; }, // Fired when file upload is completed // @param file basename of uploaded file // @param response server response onComplete: function(file, response) { $(elementID).innerHTML = 'Upload Picture'; var newjson = response.evalJSON(); PicUploadComplete(newjson[1]); } }); } function showCancelLink() { if($('parentMsgId').value > 0) { $('cancelPicLink').show(); } } function hideCancelLink() { $('cancelPicLink').hide(); } function AttachPicToMsg(imageId) { showCancelLink(); $('msgImageId').value = imageId; } function AttachInteractPicToMsg(imageId) { showCancelLink(); $('msgInteractId').value = imageId; LoadRoundedPicture(imageId, 'interactImage', '225'); Effect.ScrollTo('commentTool', { duration: 0.5 }); Effect.BlindDown('interactImage', { duration: 1 }); showCamera(); } function ScrollToCommentTool() { Effect.ScrollTo('commentTool', {duration: 0.5}); } function cancelPics() { CancelInteraction(); hideCancelLink(); $('imgHolder').setStyle({ height: '2px' }); } function CancelMsgImage() { $('msgImageId').value = 0; $('imgHolder').innerHTML = ''; } function CancelInteraction() { $('msgInteractId').value = ''; $('msgImageId').value = ''; $('interactImage').innerHTML = ''; $('imgHolder').innerHTML = ''; } function closeCamera() { $('imgHolder').innerHTML = ''; isCamVisible = 0; } function showCamera(){ CancelMsgImage(); if(isCamVisible == 1) { closeCamera(); } else { if($('msgInteractId').value > 0) { $('imgHolder').setStyle({ width: '320px', height: '300px' }); LoadWebCam('imgHolder', 320, 300); } else { $('imgHolder').setStyle({ width: '100%', height: '415px' }); LoadWebCam('imgHolder', 500, 410); } } } function RetakeCamera() { showCamera(); } function AdoptAMini(imageId) { LoadPicture(imageId, 'imgHolder', 'large'); } function PicUploadComplete(imageId) { CancelMsgImage(); AttachPicToMsg(imageId); $('webCamLink').innerHTML = 'Flash A Picture'; $('rightHandUpload').innerHTML = 'Re-Upload'; if($('msgInteractId').value > 0) { LoadRoundedPicture(imageId, 'imgHolder', '300'); } else { LoadRoundedPicture(imageId, 'imgHolder', '500'); } } function LoadPicture(imageId, elementId, size) { new Ajax.Request('http://www.yodida.com/ajaxTools.html', { method:'post', postBody:'p=getImageObject&imageId=' + imageId + '&size=' + escape(size), onSuccess: function(transport) { var response = transport.responseText || ""; var jObject = response.evalJSON(); if(jObject.success == 1) { $(elementId).innerHTML = ''; //Effect.BlindDown(elementId, { duration: 1 }); } else { alert(jObject.error); } } }); } function LoadRoundedPicture(imageId, elementId, maxWidth) { new Ajax.Request('http://www.yodida.com/ajaxTools.html', { method:'post', postBody:'p=getRoundedImageHTML&imageId=' + imageId + '&maxWidth=' + maxWidth, onSuccess: function(transport) { var response = transport.responseText || ""; //var jObject = response.evalJSON(); $(elementId).innerHTML = response; } }); } function LoadWebCam(elementId, width, height) { new Ajax.Request('http://www.yodida.com/ajaxTools.html', { method:'post', postBody:'p=fetchWebCamHTML&width=' + width + '&height=' + height, onSuccess: function(transport) { var response = transport.responseText || ""; //var jObject = response.evalJSON(); $(elementId).innerHTML = response; isCamVisible = 1; } }); } function WebCamCaptureComplete(imageId) { //Effect.BlindUp('webCamHolder', { duration: 0.5 }); AttachPicToMsg(imageId); $('webCamHolder').innerHTML = ''; $('imgHolder').innerHTML = '

Loading...

'; $('webCamLink').innerHTML = 'Retake Pic'; $('rightHandUpload').innerHTML = 'Upload Picture'; isCamVisible = 0; if($('msgInteractId').value > 0) { LoadRoundedPicture(imageId, 'imgHolder', '225'); } else { LoadRoundedPicture(imageId, 'imgHolder', '500'); } }