
/** form doğrulama fonksiyonları  **/
function box_isEmpty(box_id,message){
    var box = document.getElementById(box_id);
    if(trim(box.value) == ''){
        alert(message);
        box.focus();
        return true;
    }
    
    return false;
}//end function box_isEmpty();

function box_isNumeric(box_id,message_ifempty,message_ifnotnumeric){
    var box = document.getElementById(box_id);
    
    if(box.value == ''){
        alert(message_ifempty);
        box.focus();
        return false;
    }
    
    if(box.value.replace(/0/g,'') != parseInt(box.value.replace(/0/g,''))){
        alert(message_ifnotnumeric);
        box.focus();
        return false;
    }
    
    return true;
}//end function box_isNumeric();

function box_isNumericIdentity(box_id,message, defaultLength, defaultLength_message){
    var box = document.getElementById(box_id);
    
    if(box.value.replace(/0/g,'') != parseInt(box.value.replace(/0/g,''))){
        alert(message);
        box.focus();
        return false;
    }
    
    if(defaultLength){
        if(trim(box.value).length != defaultLength){
            alert(defaultLength_message);
            box.focus();
            return false;
        }
    }
    
    return true;
}//end function box_isNumericIdentity()


function box_isValidPassword(passBox_id, passRepeatBox_id, message_1, message_2, min_length, message_3){
    var box1 = document.getElementById(passBox_id);
    
    if(box1.value == ''){
        alert(message_1);
        box1.focus();
        return false;
    }
    
    if(min_length != undefined && min_length != '' && min_length != false && min_length==parseInt(min_length)){
        if(box1.value.length < min_length){
            alert(message_3);
            box1.focus();
            return false;
        }
    }
    
    if(box1.value != document.getElementById(passRepeatBox_id).value){
        alert(message_2);
        document.getElementById(passRepeatBox_id).focus();
        return false;
    }
    return true;
}//end function box_isValidPassword()


function box_isEmail(box_id, message){
    var box = document.getElementById(box_id);
    
    if(!isValidEmail(box.value)){
        alert(message);
        box.focus();
        return false;
    }
    
    return true;
}//end function box_isEmail();

function box_isMoney(box_id, message){
    var box = document.getElementById(box_id);
    
    if(box.value != parseFloat(box.value)){
        alert(message);
        box.focus();
        return false;
    }
    
    return true;
}//end function box_isMoney()


function span_toEditableBox(fields){
    if(!isArray(fields)){
        fields = new Array(fields);
    }
    
    var parent;
    var span;
    var inputBox;
    
    for(index in fields){
        an_id = fields[index];
        
        span = Element(an_id);
        parent = span.parentNode;
        
        inputBox = document.createElement('input');
        inputBox.value = span.innerHTML;
        
        parent.removeChild(span);
        inputBox.id = an_id;
        inputBox.name = an_id;
        
        parent.appendChild(inputBox);
    }
}//end function span_toEditableBox()

function editableBox_toSpan(fields){
    if(!isArray(fields)){
        fields = new Array(fields);
    }
    
    var parent;
    var span;
    var inputBox;
    
    for(index in fields){
        an_id = fields[index];
        
        inputBox = Element(an_id);
        parent = inputBox.parentNode;
        
        span = document.createElement('span');
        span.innerHTML = inputBox.value;
        
        parent.removeChild(inputBox);
        span.id = an_id;
        span.name = an_id;
        
        parent.appendChild(span);
    }
}//end function editableBox_toSpan()
