var iPhoneApps = [
  {
    url: "http://kennzeichen.speedymarks.com",
    icon: "favicon.png",
    title: "Kennzeichen",
    text: "German car license plates"
  },                  
  {
    url: "http://maxpeak.speedymarks.com",
    icon: "favicon.png",
    title: "Max Peak",
    text: "Find the highest point on a route"
  },                  
  {
    url: "http://timer.speedymarks.com",
    icon: "favicon.png",
    title: "Timer",
    text: "Sum up the time for your tasks"
  },                  
  {
    url: "http://percent.speedymarks.com",
    icon: "favicon.png",
    title: "Percentage",
    text: "Percentage calculator"
  },                  
  {
    url: "http://altitude.speedymarks.com",
    icon: "favicon.png",
    title: "Altitude",
    text: "Your elevation on earth"
  },                  
  {
    url: "http://myposition.speedymarks.com",
    icon: "favicon.png",
    title: "My Position",
    text: "Bearing and distance to a target"
  },                  
  {
    url: "http://montydoors.speedymarks.com",
    icon: "favicon.png",
    title: "Monty Doors",
    text: "Simulate the Monty Hall Paradox"
  },                  
  {
    url: "http://letterdice.speedymarks.com",
    icon: "favicon.png",
    title: "Letter Dice",
    text: "Roll the dice for a random letter"
  },                  
  {
    url: "http://weeknumber.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Week Number",
    text: "The number of the week for any date"
  },                  
  {
    url: "http://golf.speedymarks.com",
    icon: "favicon.png",
    title: "Golf",
    text: "Countdown to the next PGA matches"
  },                  
  {
    url: "http://palindrome.speedymarks.com",
    icon: "favicon.png",
    title: "Palindrome",
    text: "Create and test palindromes easily"
  },                  
  {
    url: "http://easterball.speedymarks.com",
    icon: "favicon.png",
    title: "Easterball",
    text: "Throw the egg into the basket"
  },                  
  {
    url: "http://gradebook.speedymarks.com",
    icon: "favicon.png",
    title: "Grade Book",
    text: "Manage a grade book for teachers"
  },                  
  {
    url: "http://mymarks.speedymarks.com",
    icon: "favicon.png",
    title: "My Marks",
    text: "Track your marks, grades and credits"
  },                  
  {
    url: "http://quickchart.speedymarks.com",
    icon: "favicon.png",
    title: "Quick Chart",
    text: "Quickly chart a set of numbers"
  },                  
  {
    url: "http://average.speedymarks.com",
    icon: "favicon.png",
    title: "Average",
    text: "Calculate the mean value of number sets"
  },
  {
    url: "http://daily.speedymarks.com",
    icon: "favicon.png",
    title: "Daily",
    text: "Motivate yourself to do your daily tasks"
  },
  {
    url: "http://moon.speedymarks.com",
    icon: "favicon.png",
    title: "Moon Phases",
    text: "Countdown to the next moon phases"
  },
  {
    url: "http://3dplotter.speedymarks.com",
    icon: "favicon.png",
    title: "3D Plotter",
    text: "Plot 2D functions in 3D"
  },
  {
    url: "http://racing.speedymarks.com",
    icon: "favicon.png",
    title: "Racing",
    text: "Countdown to the next racing events"
  },
  {
    url: "http://broken.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Broken",
    text: "Play a little prank on all snoopy friends"
  },
  {
    url: "http://sports.speedymarks.com",
    icon: "favicon.png",
    title: "Sports",
    text: "Countdown to the next sport games"
  },
  {
    url: "http://hockey.speedymarks.com",
    icon: "favicon.png",
    title: "Hockey",
    text: "Countdown to the next NHL games"
  },
  {
    url: "http://mailtranslator.speedymarks.com",
    icon: "favicon.png",
    title: "Mail Translator",
    text: "Compose emails in foreign languages"
  },
  {
    url: "http://url.speedymarks.com",
    icon: "favicon.png",
    title: "URL Helper",
    text: "Fast and easy URL entering"
  },
  {
    url: "http://bball.speedymarks.com",
    icon: "favicon.png",
    title: "Basketball",
    text: "Countdown to the next NBA games"
  },
  {
    url: "http://loan.speedymarks.com",
    icon: "favicon.png",
    title: "Loan",
    text: "Loan and mortgage calculator"
  },
  {
    url: "http://savings.speedymarks.com",
    icon: "favicon.png",
    title: "Savings",
    text: "Savings and interest calculator"
  },
  {
    url: "http://soccer.speedymarks.com",
    icon: "favicon.png",
    title: "Soccer",
    text: "Countdown to the next UEFA CL games"
  },
  {
    url: "http://speedymail.speedymarks.com",
    icon: "favicon.png",
    title: "SpeedyMail",
    text: "Send email templates quickly"
  },
  {
    url: "http://baseball.speedymarks.com",
    icon: "favicon.png",
    title: "Baseball",
    text: "Countdown to the next MLB games"
  },
  {
    url: "http://football.speedymarks.com",
    icon: "favicon.png",
    title: "Football",
    text: "Countdown to the next NFL games"
  },
  {
    url: "http://thesaurus.speedymarks.com",
    icon: "favicon.png",
    title: "Thesaurus",
    text: "Find synonyms for every word"
  },
  {
    url: "http://mapmailer.speedymarks.com",
    icon: "favicon.png",
    title: "Map Mailer",
    text: "Send map locations via email"
  },
  {
    url: "http://holidays.speedymarks.com",
    icon: "favicon.png",
    title: "Holidays",
    text: "Countdown to the next holidays"
  },
  {
    url: "http://events.speedymarks.com",
    icon: "favicon.png",
    title: "Events",
    text: "Upcoming events from Google Calendar"
  },
  {
    url: "http://lottery.speedymarks.com",
    icon: "favicon.png",
    title: "Lottery",
    text: "Find random lottery picks"
  },
  {
    url: "http://ruler.speedymarks.com",
    icon: "favicon.png",
    title: "Ruler",
    text: "Measure the scale"
  },
  {
    url: "http://budget.speedymarks.com",
    icon: "favicon.png",
    title: "Budget",
    text: "Monitor your spendings"
  },
  {
    url: "http://mandelbrot.speedymarks.com",
    icon: "favicon.png",
    title: "Mandelbrot Set",
    text: "Explore the beauty of the Mandelbrot fractal"
  },
  {
    url: "http://capitalquiz.speedymarks.com",
    icon: "favicon.png",
    title: "Capital Quiz",
    text: "Can you name all U.S. state capitals?"
  },
  {
    url: "http://callchecker.speedymarks.com",
    icon: "favicon.png",
    title: "Call Checker",
    text: "Right time to call?"
  },
  {
    url: "http://workout.speedymarks.com",
    icon: "favicon.png",
    title: "Workout",
    text: "Control and monitor interval trainings"
  },
  {
    url: "http://photofinder.speedymarks.com",
    icon: "favicon.png",
    title: "Photo Finder",
    text: "Find photos of any location in the world"
  },
  {
    url: "http://compass.speedymarks.com",
    icon: "favicon.png",
    title: "Compass",
    text: "Find out where to go"
  },
  {
    url: "http://phototags.speedymarks.com",
    icon: "favicon.png",
    title: "Photo Tags",
    text: "Search and slideshow the latest photos"
  },
  {
    url: "http://weekday.speedymarks.com",
    icon: "favicon.png",
    title: "Weekday",
    text: "Find out the day of week for any date"
  },
  {
    url: "http://astro.speedymarks.com",
    icon: "favicon.png",
    title: "Astro",
    text: "Explore the night sky, moon and mars"
  },
  {
    url: "http://states.speedymarks.com",
    icon: "favicon.png",
    title: "States",
    text: "Map all states in the USA"
  },
  {
    url: "http://statequiz.speedymarks.com",
    icon: "favicon.png",
    title: "State Quiz",
    text: "Can you spot all states in the USA?"
  },
  {
    url: "http://sun.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Sunrise",
    text: "Worldwide sunrise and sunset times"
  },
  {
    url: "http://countries.speedymarks.com",
    icon: "favicon.png",
    title: "Countries",
    text: "Map all countries of the world"
  },
  {
    url: "http://countryquiz.speedymarks.com",
    icon: "favicon.png",
    title: "Country Quiz",
    text: "Can you spot foreign countries?"
  },
  {
    url: "http://morse.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Morse Code",
    text: "Morse code generator and sender"
  },
  /*
  {
    url: "http://bestsellers.speedymarks.com",
    icon: "favicon.png",
    title: "Bestsellers",
    text: "Best selling goods on amazon.com"
  },
  {
    url: "http://amazon.speedymarks.com",
    icon: "favicon.png",
    title: "Amazon Search",
    text: "Check amazon prices and availability"
  },
  */
  {
    url: "http://vat.speedymarks.com",
    icon: "mobileIcon.png",
    title: "VAT Calculator",
    text: "Calculate sales tax and VAT while you shop"
  },
  {
    url: "http://rates.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Currencies",
    text: "Exchange rates for major currencies"
  },
  {
    url: "http://rss.speedymarks.com",
    icon: "favicon.png",
    title: "Feed Reader",
    text: "News reader for full text RSS feeds"
  },
  {
    url: "http://translator.speedymarks.com",
    icon: "favicon.png",
    title: "Translator",
    text: "Full text language translator"
  },
  {
    url: "http://apps.speedymarks.com",
    icon: "favicon.png",
    title: "iPhone Apps",
    text: "New iPhone apps in the Apple directory"
  },
  {
    url: "http://basketball.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Basketball",
    text: "Play it"
  },
  {
    url: "http://counter.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Games Counter",
    text: "A simple game score counter"
  },
  {
    url: "http://calories.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Calories",
    text: "Track your daily calories"
  },
  {
    url: "http://calculator.speedymarks.com",
    icon: "favicon.png",
    title: "Calculator",
    text: "Full text calculator with history"
  },
  {
    url: "http://plotter.speedymarks.com",
    icon: "favicon.png",
    title: "Plotter",
    text: "Plot graphs of functions"
  },
  {
    url: "http://speedometer.speedymarks.com",
    icon: "mobileIcon.png",
    title: "<i>Speedo</i>Meter",
    text: "Measure your speed"
  },
  {
    url: "http://mileage.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Mileage",
    text: "Monitor your gas consumption"
  },
  {
    url: "http://charts.speedymarks.com",
    icon: "mobileIcon.png",
    title: "Charts",
    text: "Track and chart any data"
  },
  {
    url: "http://m.worldclockr.com",
    icon: "favicon.png",
    title: "WorldClock<i>r</i>",
    text: "World clocks"
  },
  {
    url: "http://m.countdownr.com",
    icon: "favicon.png",
    title: "CountDown<i>r</i>",
    text: "Countdown counters"
  },
  {
    url: "http://m.speedymarks.com",
    icon: "favicon.png",
    title: "<i>Speedy</i>Marks",
    text: "Visual bookmarks"
  },
  {
    url: "http://m.worldwatchr.com",
    icon: "favicon.png",
    title: "WorldWatch<i>r</i>",
    text: "Monitor Webcams on your iPhone"
  },
  {}
];

var iPhoneAppsExtra = [
  {
    url: "http://www.widgetop.com/mobile.html",
    icon: "http://www.widgetop.com/images/WidgetopLogo.png",
    title: "Widgetop",
    text: "Dashboard widgets on the iPhone"
  },
  {
    url: "http://apps.speedymarks.com",
    icon: "favicon.png",
    title: "iPhone Apps",
    text: "New iPhone apps in the Apple directory"
  },
  {
    url: "http://start.speedymarks.com",
    icon: "favicon.png",
    title: "Start Me Up",
    text: "Quick access to all applications"
  },
  {}
];

var appStoreApps = [
                    {
                      url: "http://www.itunes.com/app/maxpeak",
                      icon: "http://maxpeak.speedymarks.com/mobileIcon.png",
                      title: "Max Peak",
                      text: "Find the highest point on a route"
                    },
                    {
                      url: "http://www.itunes.com/app/altitudeapp",
                      icon: "http://altitude.speedymarks.com/mobileIcon.png",
                      title: "Altitude",
                      text: "Your elevation on earth"
                    },
                    {
                      url: "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=288420566",
                      icon: "http://start.speedymarks.com/appstore/compass/mobileIcon.png",
                      title: "Compass",
                      text: "Find out where to go"
                    },
  {
    url: "http://www.itunes.com/app/thesaurusapp",
    icon: "http://thesaurus.speedymarks.com/mobileIcon.png",
    title: "Thesaurus",
    text: "Find synonyms for every word"
  },
  {}
];

function addApps() {
  var icon = function(app) {
    if (app.icon.indexOf("http")< 0) {
      return app.url + '/' + app.icon;
    }
    return app.icon;
  }

  var element = document.getElementById("MoreApps");
  var agent = navigator.userAgent.toLowerCase();
  if (agent.indexOf("android") < 0) {  
    ul = document.createElement("ul");
    element.appendChild(ul);
    var header = document.createElement("div");
    header.innerHTML = "<b><small>App Store:</small></b>";
    ul.appendChild(header);
    for (var i = 0; i < appStoreApps.length - 1; i++) {
    	var li = document.createElement("li");
    	ul.appendChild(li);
    	li.innerHTML = '<a href="' + appStoreApps[i].url +
    	    '&mt=8" target="_self"><img src="' + icon(appStoreApps[i]) +
    	    '" width="32" alt=""> ' + appStoreApps[i].title + '</a> - ' + appStoreApps[i].text;
    }
    element.appendChild(document.createElement("hr"));
  }
  else {
    var install = document.getElementById("iPhoneInstall");
    if (install) {
      install.style.display = "none";
    }
    var more = document.getElementById("More");
    if (more) {
      more.style.display = "none";
    }      
  }  
  var ul = document.createElement("ul");
  element.appendChild(ul);
  var header = document.createElement("div");
  header.innerHTML = "<b><small>Web Apps:</small></b>";
  ul.appendChild(header);
  var size = Math.min(iPhoneApps.length - 1, 6);
  for (var i = 0; i < size; i++) {
  	var li = document.createElement("li");
  	ul.appendChild(li);
  	li.innerHTML = '<a href="' + iPhoneApps[i].url +
  	    '" target="_blank"><img src="' + icon(iPhoneApps[i]) +
  	    '" width="32" alt=""> ' + iPhoneApps[i].title + '</a> - ' + iPhoneApps[i].text;
  }
  var more = document.createElement("button");
  more.innerHTML = "All Applications...";
  more.onclick = function() {
    window.open("http://start.speedymarks.com", "_blank");
  };
  element.appendChild(more);

  element.appendChild(document.createElement("hr"));
  ul = document.createElement("ul");
  element.appendChild(ul);
  for (var i = 0; i < iPhoneAppsExtra.length - 1; i++) {
  	var li = document.createElement("li");
  	ul.appendChild(li);
  	li.innerHTML = '<a href="' + iPhoneAppsExtra[i].url +
  	    '" target="_blank"><img src="' + icon(iPhoneAppsExtra[i]) +
  	    '" width="32" alt=""> ' + iPhoneAppsExtra[i].title + '</a> - ' + iPhoneAppsExtra[i].text;
  }
}

addApps();  