/**
  * Get the html node for this element
  * @param AppBuilderAPIDOMDocument $xml 
  * @param array $data
  * @return DOMElement
  */
 public function getHTMLNode($xml, &$data, $link = false)
 {
     if (!$this->node && !$link) {
         $css = new AppBuilderAPICSSDocument();
         if ($this->css) {
             $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId());
             $css->addCSS($this->css, $idselector);
         }
         $this->getCSS($css, $data);
         $this->node = parent::getHTMLNode($xml, $data);
         if ($this->name) {
             $this->node->setAttribute('data-name', $this->name);
         }
         if ($this->description) {
             $this->node->setAttribute('data-description', $this->description);
         }
         if ($this->flag) {
             $this->node->setAttribute('data-flag', $this->flag);
         }
         if ($this->previewUrl) {
             $this->node->setAttribute('data-preview-url', $this->previewUrl);
         }
         if ($this->webviewUrl) {
             $this->node->setAttribute('data-webview-url', $this->webviewUrl);
         }
         if ($this->icon) {
             $this->node->setAttribute('data-icon', $this->icon);
             $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId());
             $css->addRule(array(".android .phone-navigator {$idselector}.app .app-navigator .screen .header .back"), 'background-image', $css->getURLValue($this->icon));
             $css->addRule(array(".blackberry .phone-navigator {$idselector}.app .app-navigator .screen .header"), 'background-image', $css->getURLValue($this->icon));
         }
         if ($this->fetchUrl) {
             $this->node->setAttribute('data-fetch-url', $this->fetchUrl);
         }
         $this->node->appendChild($navigator = $xml->createElement('div', 'app-navigator'));
         $navigator->appendChild($navinner = $xml->createElement('div', 'app-navigator-inner'));
         $navinner->appendChild($xml->createElement('div', 'app-navigator-inner-sides'));
         $navinner->appendChild($xml->createElement('div', 'app-navigator-inner-sides'));
         if ($this->ads) {
             $xml->addClass($navigator, 'ads');
             $this->node->appendChild($xml->createElement('div', 'ad-holder'));
         }
         $this->node->appendChild($tabbarOuter = $xml->createElement('div', 'tab-bar'));
         $tabbarOuter->appendChild($tabbar = $xml->createElement('table'));
         $tabbar->appendChild($tabbarinner = $xml->createElement('tr', 'tar-bar-inner'));
         //take the first tab and insert its screen directly into the navigator
         /* $firstTab = array_shift($this->tabs);
         	  $tabbar->appendChild($tabNode = $firstTab->getHTMLNode($xml, &$data));
         	  $xml->addClass($tabNode, 'selected');
         	  if($firstTab->hasScreenLink()) {
         	  $navigator->appendChild($firstTab->getScreen()->getHTMLNode($xml, &$data));
         	  } */
         foreach ($this->tabs as $tab) {
             $tabbarinner->appendChild($tab->getHTMLNode($xml, $data));
             $tab->getCSS($css, $data);
         }
         //put that tab back on the beginning
         //array_unshift($this->tabs, $firstTab);
         $data['app'][(isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId()] = array('html' => "<style scoped>" . $css->toString() . "</style>" . $xml->saveXML($this->node), 'splashhtml' => $this->hasSplash ? "<style scoped>" . $css->toSplashString() . "</style><div class=\"splash\" id=\"app" . $this->getId() . "\"></div>" : null, 'updated' => $this->updated === true ? time() : $this->updated, 'secure' => array('login' => $this->login, 'register' => $this->register), 'css' => '', 'javascript' => $this->js);
     }
     return $this->node;
 }
 /**
  * Get the html node for this element
  * @param AppBuilderAPIDOMDocument $xml 
  * @param array $data
  * @return DOMElement
  */
 public function getHTMLNode($xml, &$data, $link = false)
 {
     if (!$this->node || !$link) {
         $css = new AppBuilderAPICSSDocument();
         if ($this->css) {
             $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId());
             $css->addCSS($this->css, $idselector);
         }
         $javascripts = array();
         $this->node = $this->getHTMLNodeBase($xml, $data, $css, $javascripts);
         if ($this->secured) {
             $this->node->setAttribute('data-secured', $this->secured);
         }
         $data['screen'][(isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId()] = array('html' => "<style scoped>" . $css->toString() . "</style>" . $xml->saveXML($this->node), 'updated' => $this->updated === true ? time() : $this->updated, 'css' => '', 'secured' => $this->secured, 'javascripts' => $javascripts);
     }
     return $this->node;
 }
 /**
  * Get the css for this element
  * @param AppBuilderAPICSSDocument $css 
  */
 public function getCSS($css, &$data = array())
 {
     $idselector = $css->getIdSelector($this->getIdType() . (isset($data['settings']['prefix']) ? $data['settings']['prefix'] : '') . $this->getId());
     $isScreen = $this instanceof AppBuilderAPIScreen;
     $isItem = $this instanceof AppBuilderAPIItem;
     $css->addRule($idselector, 'text-align', $this->getStyle('align'));
     $css->addRule($idselector, 'font-family', $css->getFontValue($this->getStyle('fontfamily')));
     if ($this->getStyle('color')) {
         $css->addRule($idselector, 'color', $css->getColorValue($this->getStyle('color')));
         $css->addRule($idselector . " button", 'color', $css->getColorValue($this->getStyle('color')));
         $css->addRule($idselector . " .item-icon-inner .title", 'color', $css->getColorValue($this->getStyle('color')));
     }
     $css->addRule(array($idselector, $css->getClassSelector('glow-back')), 'fill', $css->getColorValue($this->getStyle('glowcolor')));
     $css->addRule(array($css->getClassSelector('android'), $idselector, $css->getClassSelector('glow-back'), $css->getClassSelector('back-left')), 'background-color', $css->getColorValue($this->getStyle('glowcolor')));
     $css->addRule(array($idselector, $css->getClassSelector('glow-back'), $css->getClassSelector('back-right')), 'background-color', $css->getColorValue($this->getStyle('glowcolor')));
     $css->addRule(array($idselector, $css->getClassSelector('glow-back'), $css->getClassSelector('back-center')), 'background-color', $css->getColorValue($this->getStyle('glowcolor')));
     $c = $this->getStyle('glowcolor');
     if ($c) {
         $css->addRule(array($idselector, $css->getClassSelector('glow')), 'background-color', "rgba({$c}, 0.5)");
     }
     $css->addRule($idselector, 'font-size', $css->getSizeValue($this->getStyle('size')));
     $this->getCSSImage($css, 'splash', $idselector . $css->getClassSelector('splash'));
     $bold = $this->getStyle('bold');
     if ($bold == 'true') {
         $css->addRule($idselector, 'font-weight', 'bold');
     } else {
         if ($bold == 'false') {
             $css->addRule($idselector, 'font-weight', 'normal');
         }
     }
     $italic = $this->getStyle('italic');
     if ($italic == 'true') {
         $css->addRule($idselector, 'font-style', 'italic');
     } else {
         if ($italic == 'false') {
             $css->addRule($idselector, 'font-style', 'normal');
         }
     }
     $underline = $this->getStyle('underline');
     if ($underline == 'true') {
         $css->addRule($idselector, 'text-decoration', 'underline');
     } else {
         if ($underline == 'false') {
             $css->addRule($idselector, 'text-decoration', 'none');
         }
     }
     if ($this->getStyle('header_display') == 'false') {
         if ($isScreen) {
             $css->addRule(array($idselector . $css->getClassSelector('screen'), $css->getClassSelector('header')), 'display', 'none');
             $css->addRule(array($idselector . $css->getClassSelector('screen'), $css->getClassSelector('items')), 'top', '0');
         } else {
             $css->addRule(array($idselector, $css->getClassSelector('screen'), $css->getClassSelector('header')), 'display', 'none');
             $css->addRule(array($idselector, $css->getClassSelector('screen'), $css->getClassSelector('items')), 'top', '0');
         }
     }
     $css->addRule($idselector, 'border-color', $css->getColorValue($this->getStyle('bordercolor')));
     $css->addRule(array($idselector, $css->getClassSelector('autocomplete')), 'color', $css->getColorValue($this->getStyle('autocompletecolor')));
     $css->addRule(array($idselector, $css->getClassSelector('autocomplete')), 'border-color', $css->getColorValue($this->getStyle('autocompletecolor')));
     $css->addRule(array($idselector, $css->getClassSelector('autocomplete')), 'background-color', $css->getColorValue($this->getStyle('autocompletebackgroundcolor')));
     $css->addRule(array($idselector, $css->getClassSelector('autocomplete'), $css->getClassSelector('completion') . $css->getPseudoClassSelector('hover')), 'color', $css->getColorValue($this->getStyle('autocompletehighlightcolor')));
     $css->addRule(array($idselector, 'textarea'), 'border-color', $css->getColorValue($this->getStyle('bordercolor')));
     $css->addRule(array($idselector, 'input'), 'border-color', $css->getColorValue($this->getStyle('bordercolor')));
     $css->addRule(array($idselector, 'select'), 'border-color', $css->getColorValue($this->getStyle('bordercolor')));
     $css->addRule(array($idselector, $css->getClassSelector('title')), 'color', $css->getColorValue($this->getStyle('titlecolor')));
     $css->addRule(array($idselector, $css->getClassSelector('title')), 'font-size', $css->getSizeValue($this->getStyle('titlesize')));
     $css->addRule(array($idselector, $css->getClassSelector('title')), 'font-family', $css->getFontValue($this->getStyle('titlefont')));
     $css->addRule(array($idselector, $css->getClassSelector('text')), 'color', $css->getColorValue($this->getStyle('subtitlecolor')));
     $css->addRule(array($idselector, $css->getClassSelector('text')), 'font-size', $css->getSizeValue($this->getStyle('subtitlesize')));
     $css->addRule(array($idselector, $css->getClassSelector('text')), 'font-family', $css->getFontValue($this->getStyle('subtitlefont')));
     if ($isScreen) {
         $this->getCSSImage($css, 'gallerybackground', array($idselector . $css->getClassSelector(array('screen', 'gallery')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'gallerybackground', array($idselector . $css->getClassSelector(array('screen', 'photo')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'listbackground', array($idselector . $css->getClassSelector(array('screen', 'list')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'iconbackground', array($idselector . $css->getClassSelector(array('screen', 'icon')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'appsbackground', array($idselector . $css->getClassSelector(array('screen', 'appsscreen')), $css->getClassSelector('items')));
     } else {
         $this->getCSSImage($css, 'gallerybackground', array($idselector, $css->getClassSelector(array('screen', 'gallery')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'gallerybackground', array($idselector, $css->getClassSelector(array('screen', 'photo')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'listbackground', array($idselector, $css->getClassSelector(array('screen', 'list')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'iconbackground', array($idselector, $css->getClassSelector(array('screen', 'icon')), $css->getClassSelector('items')));
         $this->getCSSImage($css, 'appsbackground', array($idselector, $css->getClassSelector(array('screen', 'appsscreen')), $css->getClassSelector('items')));
     }
     //if this is an item
     if ($isScreen) {
         $this->getCSSImage($css, 'item_background', array($idselector . $css->getClassSelector(array('screen', 'list')), $css->getClassSelector('item')));
     } else {
         if ($isItem) {
             $this->getCSSImage($css, 'item_background', array($css->getClassSelector(array('screen', 'list')), $idselector . $css->getClassSelector('item')));
         } else {
             $this->getCSSImage($css, 'item_background', array($idselector, $css->getClassSelector(array('screen', 'list')), $css->getClassSelector('item')));
         }
     }
     if ($isScreen) {
         $css->addRule(array($idselector . $css->getClassSelector('screen'), $css->getClassSelector('header')), 'color', $css->getColorValue($this->getStyle('headertextcolor')));
         $css->addRule(array($css->getClassSelector('android'), $idselector . $css->getClassSelector('screen'), $css->getClassSelector('header'), $css->getClassSelector('back')), 'stroke', $css->getColorValue($this->getStyle('headertextcolor')));
     } else {
         $css->addRule(array($idselector, $css->getClassSelector('screen'), $css->getClassSelector('header')), 'color', $css->getColorValue($this->getStyle('headertextcolor')));
         $css->addRule(array($css->getClassSelector('android'), $idselector, $css->getClassSelector('screen'), $css->getClassSelector('header'), $css->getClassSelector('back')), 'stroke', $css->getColorValue($this->getStyle('headertextcolor')));
     }
     if ($this->getStyle('headertextcolor')) {
         if ($isScreen) {
             $css->addRule(array($idselector . $css->getClassSelector('screen'), $css->getClassSelector('header'), $css->getClassSelector('title')), 'text-shadow', "0px 1px 0px " . $css->getColorValue($this->shadowColor($this->getStyle('headertextcolor'))));
         } else {
             $css->addRule(array($idselector, $css->getClassSelector('screen'), $css->getClassSelector('header'), $css->getClassSelector('title')), 'text-shadow', "0px 1px 0px " . $css->getColorValue($this->shadowColor($this->getStyle('headertextcolor'))));
         }
     }
     if ($isScreen) {
         $css->addRule(array($idselector . $css->getClassSelector('screen'), $css->getClassSelector('header')), 'background-color', $css->getColorValue($this->getStyle('headercolor')));
     } else {
         $css->addRule(array($idselector, $css->getClassSelector('screen'), $css->getClassSelector('header')), 'background-color', $css->getColorValue($this->getStyle('headercolor')));
     }
     $hrafter = $this->getStyle('hr_after');
     if ($hrafter == 'true') {
         $width = $this->getStyle('hrheight');
         if (!$width) {
             $width = 1;
         }
         if ($isItem) {
             $css->addRule($idselector . $css->getClassSelector('item'), 'border-bottom-width', $css->getSizeValue($width));
         } else {
             $css->addRule(array($idselector, $css->getClassSelector('item')), 'border-bottom-width', $css->getSizeValue($width));
         }
     } else {
         if ($hrafter == 'false') {
             if ($isItem) {
                 $css->addRule($idselector . $css->getClassSelector('item'), 'border-bottom-width', 0);
             } else {
                 $css->addRule(array($idselector, $css->getClassSelector('item')), 'border-bottom-width', 0);
             }
         }
     }
     if ($isItem) {
         $css->addRule($idselector . $css->getClassSelector('item'), 'border-bottom-color', $css->getColorValue($this->getStyle('hrcolor')));
     } else {
         $css->addRule(array($idselector, $css->getClassSelector('item')), 'border-bottom-color', $css->getColorValue($this->getStyle('hrcolor')));
     }
     $css->addRule($idselector, 'padding-top', $css->getSizeValue($this->getStyle('paddingtop')));
     $css->addRule($idselector, 'padding-bottom', $css->getSizeValue($this->getStyle('paddingbottom')));
     $css->addRule($idselector, 'padding-left', $css->getSizeValue($this->getStyle('paddingleft')));
     $css->addRule($idselector, 'padding-right', $css->getSizeValue($this->getStyle('paddingright')));
 }