// clear the form that contains the specified input object
function clearForm(inputObject){
    var elements = inputObject.form.elements;
    var length = elements.length;

    for(var i=0; i<length; i++){
    	if(elements[i].type!="button" && elements[i].type!="reset" && elements[i].type!="submit"){
        	elements[i].value = "";
        }
    }
}

// open a popup window that can assist users to find a record
function seePhoto(url) {
    var width;
    var height;
    var photoName = "." + url;

    /*var image = new Image();
    image.src = photoName;
    height = image.height + 50;
    width = image.width + 50;
    new_url = "photo-viewer.faces?photo=" + url*/

    var popupwin = window.open(photoName, "Photo Viewer", "resizable=no,toolbar=0,scrollbars=yes,directories=0,status=0,menubar=0, width=350,height=350");
    //popupwin.resizeTo(width, height);
    //popupwin.focus();
}

// open a popup window that can assist users to find a record
function openPhotoViewer(width, height) {
    window.resizeTo(width, height);
    window.focus();
}

// open a popup window that can assist users to find a record
function popup(source, url){
    var popupwin = window.open(url, "popup", 
                "height=400,width=350,toolbar=no,menubar=no,scrollbars=yes, status=no");

    popupwin.openerFormId = source.form.id;
    popupwin.focus();
}

// get the specified record
function getRecord(value){
    var formId = "bodyForm";
    if(typeof window.opener == "object"){
        window.opener.document.forms[formId][formId + ":body:itemId"].value = value;
    }
} 

// close current active window
function closeWindow(){
    window.close();
}

// get the preset file name of the photo
function getPhotoFilename(){
    var formId = "bodyForm";
    if(typeof window.opener == "object"){
        window.opener.document.forms[formId][formId + ":body:filename"].value = value;
    }
}

// clear the text input area
function clearInputArea(object){
    object.value = "";
}

// select the text in the input area
function selectText(object){
    object.select();
}

// copy filename to destination input box
function copyFilename(object){
    var formId = object.form.id;
    var photoFilename = document.forms[formId].elements[0].value

    var openerFormId = "bodyForm";
    if(typeof window.opener == "object"){
        window.opener.document.forms[openerFormId][openerFormId + ":body:filename"].value = photoFilename;
    }
}

function breakLongText(text){
    
}

