protected function applyLinkToNode($xml, $node, &$data)
 {
     switch ($linktype = $this->getAttribute('linktype')) {
         case 'login':
             $node->setAttribute('data-linktype', 'login');
             $node->setAttribute('data-href', $this->getAttribute('href'));
             break;
         case 'register':
             $node->setAttribute('data-linktype', 'register');
             $node->setAttribute('data-href', $this->getAttribute('href'));
             break;
         case 'jscode':
             $this->showArrow = false;
             $node->setAttribute('data-linktype', 'jscode');
             $node->setAttribute('data-href', $this->getIdType() . (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->getId());
             break;
         case 'items':
         case 'gallery':
         case 'map':
             if ($this->jsonp || $this->getAttribute('xmlsrc')) {
                 $node->setAttribute('data-linktype', 'remote');
                 $node->setAttribute('data-href', $this->prepareURL($this->jsonp));
             } else {
                 if ($this->screen) {
                     $node->setAttribute('data-linktype', 'screen');
                     $this->screen->getHTMLNode($xml, $data, true);
                     $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->screen->getId());
                     if (!empty($this->elementId)) {
                         $node->setAttribute('data-element', $this->elementId);
                     }
                     //$s->setAttribute('data-parent-type', 'item');
                     //$s->setAttribute('data-parent', $node->getAttribute('id'));
                 }
             }
             break;
         case 'tab':
             if (!empty($this->tab)) {
                 $node->setAttribute('data-linktype', $linktype);
                 $this->tab->getHTMLNode($xml, $data, true);
                 $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->tab->getId());
                 break;
             } else {
                 $node->setAttribute('data-linktype', $linktype);
                 $node->setAttribute('data-href', $this->getAttribute('href'));
                 break;
             }
         case 'refresh':
             $node->setAttribute('data-linktype', 'refresh');
             $node->setAttribute('data-refreshtype', $this->getAttribute('refreshtype') ? 'any' : 'button');
             break;
         case 'app':
             if (!empty($this->app)) {
                 $node->setAttribute('data-linktype', $linktype);
                 $this->app->getHTMLNode($xml, $data, true);
                 $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->app->getId());
                 break;
             }
         case 'screen':
             $node->setAttribute('data-linktype', $linktype);
             $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->getAttribute('href'));
             break;
         case 'email':
             if ($data['settings']['emailPreview']) {
                 $screen = new AppBuilderAPIListScreen('Email');
                 $screen->setId('email' . $this->getId());
                 $screen->setUpdated(false);
                 $screen->setEditable(false);
                 $screen->setBack(isset($data['settings']['currentscreen']) ? $data['settings']['currentscreen'] : true);
                 $screen->setFetchId($data['settings']['fetchscreen'] ? $data['settings']['fetchscreen']->getId() : null);
                 $screen->addChild(new AppBuilderAPIInputItem('email_to', $this->getAttribute('emailto'), 'To'));
                 $screen->addChild(new AppBuilderAPIInputItem('email_subject', $this->getAttribute('emailsubject'), 'Subject'));
                 $screen->addChild(new AppBuilderAPITextAreaItem('email_body', $this->getAttribute('emailbody'), 'Message'));
                 $send = new AppBuilderAPIButtonItem('Send');
                 $send->setWebLink('mailto:{email_to}?subject={email_subject}&body={email_body}', 'external');
                 $screen->addChild($send);
                 $screen->getHTMLNode($xml, $data, true);
                 $node->setAttribute('data-linktype', 'screen');
                 $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $screen->getId());
             } else {
                 $node->setAttribute('data-linktype', 'web');
                 $node->setAttribute('data-href', 'mailto:' . $this->getAttribute('emailto') . '?subject=' . urlencode($this->getAttribute('emailsubject')) . '&body=' . urlencode($this->getAttribute('emailbody')));
                 $node->setAttribute('data-weblinktype', 'external');
             }
             break;
         case 'phone':
             if ($data['settings']['telPreview']) {
                 $screen = new AppBuilderAPIListScreen('Phone');
                 $screen->setId('phone' . $this->getId());
                 $screen->setUpdated(false);
                 $screen->setScrolling(false);
                 $screen->setEditable(false);
                 $screen->setBack(isset($data['settings']['currentscreen']) ? $data['settings']['currentscreen'] : true);
                 $screen->setFetchId($data['settings']['fetchscreen'] ? (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $data['settings']['fetchscreen']->getId() : null);
                 $screen->addClass('phone-screen');
                 $screen->setHeader(false);
                 $screen->setTabs(false);
                 $top = new AppBuilderAPILinkItem($this->getAttribute('href'));
                 $top->addClass('top');
                 $screen->addChild($top);
                 $end = new AppBuilderAPILinkItem('End');
                 $end->addClass('bottom');
                 $end->setBackLink();
                 $screen->addChild($end);
                 $screen->getHTMLNode($xml, $data, true);
                 $node->setAttribute('data-linktype', 'screen');
                 $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $screen->getId());
             } else {
                 $node->setAttribute('data-linktype', 'web');
                 $node->setAttribute('data-href', 'tel:' . $this->getAttribute('href'));
                 $node->setAttribute('data-weblinktype', 'confirm');
                 $node->setAttribute('data-confirm-message', 'Click to make a call to ' . $this->getAttribute('href'));
                 $node->setAttribute('data-okbtn', 'Call');
             }
             break;
             //file
         //file
         case 'pdf':
         case 'excel':
         case 'doc':
         case 'ppt':
         case 'mp4':
         case 'mp3':
         case 'wav':
         case 'video':
             $node->setAttribute('data-linktype', 'file');
             $node->setAttribute('data-href', $this->getAttribute('href'));
             if ($this->filename) {
                 $node->setAttribute('data-filename', $this->filename);
             }
             break;
         case 'web':
         case 'youtube':
         case 'vimeo':
         case 'twitter':
         case 'facebook':
             $node->setAttribute('data-linktype', $linktype);
             $node->setAttribute('data-href', $this->getAttribute('href'));
             if ($this->weblinktype) {
                 $node->setAttribute('data-weblinktype', $this->weblinktype);
             }
             break;
         case 'back':
             $node->setAttribute('data-linktype', $linktype);
             if ($this->backlink) {
                 $node->setAttribute('data-href', (isset($data['settings']['prefix']) && $this->prefixed ? $data['settings']['prefix'] : '') . $this->backlink);
             }
             break;
         case 'bbm':
             $node->setAttribute('data-linktype', 'bbm');
             break;
         case 'toggle':
         case 'app':
         default:
             //
     }
     if ($node->hasAttribute('data-linktype')) {
         $xml->addClass($node, 'link');
         if ($this->showArrow) {
             $node->appendChild($xml->createElement('div', 'link-arrow'));
         } else {
             $xml->addClass($node, 'link-no-arrow');
         }
         $node->setAttribute('x-blackberry-focusable', 'true');
     }
 }