/**
 * Implements hook_block_info().
 */
function my_module_block_info() {
  var blocks = {};
  blocks['my_custom_block'] = {
    delta: 'my_custom_block',
    module: 'my_module'
  };
  blocks['logo_block'] = {
    delta: 'logo_block',
    module: 'my_module'
  };
  blocks['header_right_block'] = {
    delta: 'header_right_block',
    module: 'my_module'
  };
  return blocks;
}

/**
 * Implements hook_block_view().
 */
/*function my_module_block_view(delta, region) {
    var content = {};
    if (delta == 'my_custom_block') { 
    var attrs = {
        'data-role': 'controlgroup',
        'data-type': 'horizontal',
        'class': 'ui-btn-right',
        'class': 'ui-nodisc-icon',
    };
    var uid = Drupal.user.uid;
    var content = '<div ' + drupalgap_attributes(attrs) + '>' +
    bl('Home', '', {
    attributes: {
        'data-icon': 'home',
        'data-iconpos': 'top',
        'data-corners': 'false',
        'class': 'equal-button',
    },
   // transition: 'slide'
    }) 
    +
    bl('Shop', 'products', {
    attributes: {
        'data-icon': 'shop',
        'data-iconpos': 'top',
        'data-corners': 'false',
        'class': 'equal-button',
    },
    }) 
    +
    bl('Orders', 'order-list', {
    attributes: {
        'data-icon': 'shop',
        'data-iconpos': 'top',
        'data-corners': 'false',
        'class': 'equal-button',
    },
    }) 
    +
    bl('Cart', 'cart', {
    attributes: {
        'data-icon': 'shop',
        'data-iconpos': 'top',
        'data-corners': 'false',
        'class': 'equal-button',
    },
    }) 
    +
    bl('Profile', 'user/' + uid, {
    attributes: {
        'data-icon': 'user',
        'data-iconpos': 'top',
        'data-corners': 'false',
        'class': 'equal-button',
    },
    //transition: 'slide'
    }) +
    '</div>';
    }
    return content;
}
*/
/**
 * Implements hook_block_view().
 */
function getArraySum(a){
    var total=0;
    for(var i in a) { 
        total += a[i];
    }
    return total;
}
 
function my_module_block_view(delta, region) {
    var content = {}; 
    if (delta == 'my_custom_block') { 
        var uid = Drupal.user.uid;
        if(uid > 0){
            ///
            var home_param = "'home'";
            var contact_param = "'node/14'";
            var account_param = "'accountpage'";
            
            content = '<div data-role="footer" data-id="foo1">';
        	content += '<div data-role="navbar">';
        	content += '<ul>';
        	content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ home_param +', {});" class="ui-icon-home ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Home"></a></li>';
        	content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ contact_param +', {});" class="ui-icon-star ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Contact"></a></li>';
            content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ account_param +', {});" class="ui-icon-user ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></li>';
        	content += '</ul>';
        	content += '</div>';
            content += '</div>';
            //
        }else{
            var home_param = "'home'";
            var contact_param = "'node/33'"; 
            var account_param = "'accountpage'";
            
            content = '<div data-role="footer" data-id="foo1">';
        	content += '<div data-role="navbar">';
        	content += '<ul>';
        	content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ home_param +', {});" class="ui-icon-home ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Home"></a></li>';
        	content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ contact_param +', {});" class="ui-icon-star ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Contact"></a></li>';
         	content += '<li><a href="#" onclick="javascript:drupalgap_goto('+ account_param +', {});" class="ui-icon-user ui-btn-icon-top" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></li>';
        	content += '</ul>';
        	content += '</div>';
            content += '</div>';
        }
    }else if(delta == 'logo_block'){
        var uid = Drupal.user.uid;
        var profile_param = "'user'";
        var profilel_param = "'user/login'";
        //content = '<img src="app/modules/custom/my_module/gvmlogo.jpg" style="width:24% !important">';
        if(uid > 0){
            content = '<div style="padding:10px;font-size:18px;text-shadow:none;font-weight:bold;"><span style="color:#f76e00;">GVM</span><span style="color:orange; float:right;"><a href="#" onclick="javascript:drupalgap_goto('+ profile_param +', {});" class="ui-icon-user ui-btn-icon-right" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></span></div>';
        }else{
            content = '<div style="padding:10px;font-size:18px;text-shadow:none;font-weight:bold;"><span style="color:#f76e00;">GVM</span><span style="color:orange; float:right;"><a href="#" onclick="javascript:drupalgap_goto('+ profilel_param +', {});" class="ui-icon-lock ui-btn-icon-right" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></span></div>';
        
        }
    }else if(delta == 'header_right_block'){
        var uid = Drupal.user.uid;
        var profile_param = "'user'";
        var profilel_param = "'user/login'";
        if(uid > 0){
            //content = '<img src="app/modules/custom/my_module/gvmlogo.jpg" style="width:24% !important">';
            content = '<div style="padding:10px;font-size:18px;text-shadow:none;font-weight:bold;"><span style="color:#f76e00;">GVM</span><span style="color:orange; float:right;"><a href="#" onclick="javascript:drupalgap_goto('+ profile_param +', {});" class="ui-icon-user ui-btn-icon-right" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></span></div>';
        }else{
            content = '<div style="padding:10px;font-size:18px;text-shadow:none;font-weight:bold;"><span style="color:#f76e00;">GVM</span><span style="color:orange; float:right;"><a href="#" onclick="javascript:drupalgap_goto('+ profilel_param +', {});" class="ui-icon-lock ui-btn-icon-right" style="background:#ffffff;color:#80d742;border-color:#ffffff;" title="Account"></a></span></div>';
        
        }
    }
    return content;
}

function my_module_form_alter(form, form_state, form_id) {
  if (form_id == 'user_login_form') {
      /*form.elements['login_logo'] = {
         markup: '<p align="center"><img src="app/modules/custom/my_module/gvmlogo.jpg" style="width:24% !important"></p><br>'
      };*/
  }
}

 