function checkFormatImage(value){
    var val = value.toLowerCase();
    var regex = new RegExp("(.*?)\.(jpg|jpeg|png|gif|svg)$");
    if(!(regex.test(val))){
        return false;
    }else{
        return true;
    }
}
function sizeFile(file){
    return file.value != "" ? file.files[0].size : "";
}
function checkFormatFile(value){
    var val = value.toLowerCase();
    var regex = new RegExp("(.*?)\.(jpg|jpeg|png|doc|docx|xls|xlsx|ppt|pptx|pdf|zip|rar)$");
    if(!(regex.test(val))){
        return false;
    }else{
        return true;
    }
}
function rowPhoto() {
    var tot_photo = $('.iphoto').length;
    $("#image-list").append(createPhotoForm(tot_photo));
};
function randomString() {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for (var i = 0; i < 5; i++)
    text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
};
function createPhotoForm(onumber){
    var param_num = randomString();
    var resultHTML = "";
    resultHTML += "<div id='bar-imagej-"+param_num+"' class='form-group' style='width: 500px;'>";
    resultHTML += "<div class='input-group'>";
    resultHTML += "<span class='input-group-addon imageg-addon'>";
    resultHTML += "<input type='file' id='photoj-"+param_num+"' name='image[]' class='iphoto' >";
    resultHTML += "</span>";
    resultHTML += "<input type='text' id='ptitlej-"+param_num+"' name='ititle[]' class='form-control' placeholder='Image Title'>";
    resultHTML += "<span class='input-group-btn'>";
    resultHTML += "<a href='javascript:void(0);' onclick='deleteRowImage(&#39;"+param_num+"&#39;);' class='btn btn-danger'>";
    resultHTML += "<i class='fa fa-remove'></i>";
    resultHTML += "</a>";
    resultHTML += "</span>";
    resultHTML += "</div>";
    resultHTML += "</div>";
    return resultHTML;
};
function deleteRowImage(param){
    $("#bar-imagej-"+param).remove();
};
function setPrimary(param){
    $(".il-star").hide();
    $('input[name=imagePrimary]').attr('checked',false);
    $("#istar-"+param).show();
    $('#iprimary-'+param).attr('checked',true);
};
function setPrimaryPhoto(param){
    $(".il-star").hide();
    $('.iprimary').val('0');
    $("#istar-"+param).show();
    $('#iprimary-'+param).val('1');
};
//success alert
function successAlert(text){
  Command: toastr["success"](text)
  toastr.options = {
    "closeButton": true,
    "debug": false,
    "newestOnTop": false,
    "progressBar": false,
    "positionClass": "toast-top-right",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
  }
}
//error alert
function errorAlert(text){
  Command: toastr["error"](text)
  toastr.options = {
    "closeButton": true,
    "debug": false,
    "newestOnTop": false,
    "progressBar": false,
    "positionClass": "toast-top-right",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "5000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
  }
}