
        function uploadphotos(elem){
            
            url = $(elem).val();
            var file = event.target.files[0];
            //console.log(file);
            // Ensure it's an image
            if(file.type.match(/image.*/)) {
                console.log('An image has been loaded');
                //alert(12);
                // Load the image
                var reader = new FileReader();
                reader.onload = function (readerEvent) {
                    var image = new Image();
                    image.onload = function (imageEvent) {

                        // Resize the image
                        var canvas = document.createElement('canvas'),
                            max_size_width = 500,// TODO : pull max size from a site config
                            max_size_height = 250,// TODO : pull max size from a site config
                            width = image.width,
                            height = image.height;
                    
                        if (width > height) {
                            if (width > max_size_width) {
                                height *= max_size_width / width;
                                width = max_size_width;
                            }
                        } else {
                            if (height > max_size_height) {
                                width *= max_size_height / height;
                                height = max_size_height;
                            }
                        }
                        
                        canvas.width = width;
                        canvas.height = height;
                        canvas.getContext('2d').drawImage(image, 0, 0, width, height);
                        var dataUrl = canvas.toDataURL('image/jpeg');
                        $(elem).next('input[type=hidden]').val(dataUrl);

                        //alert("#image"+dynamicId+"new");
                    }
                    image.src = readerEvent.target.result;
                }
                reader.readAsDataURL(file);
            }else{
                alert('Image type is not supported');
                $(elem).val('');
            }
        }
            


function clearImage(imageId){
    
    document.getElementById(imageId).value = null;
    document.getElementsByName(imageId).value = null;
}
	
 function resetForm(){
	document.getElementById("inputformId").reset(); 
		 
 }
	


