﻿function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function mobiChow() {
 
 
}

window.mobiChow = new mobiChow();

// This code will add a WebApp iLayer if exists in the hash
// but not in the DOM so that the WA.AddEventListener load
// event will have the proper target layer
window.mobiChow.webAppAddMissingLayer = function (hash) {

    // remove the '#_' from the ash
    var layerId = hash.substring(2);

    // Check to see if there are any parameters
    // (starting w/ '/') and remove if exist
    var slashIndex = layerId.indexOf('/');
    if (slashIndex != -1) {
      layerId = layerId.substring(0, slashIndex);
    }

    // Add the 'wa' for the layerId
    layerId = 'wa' + layerId;


    // If it does not exist add it to the DOM
    if (document.getElementById(layerId) == null) {

      var element = document.createElement('div');
      element.setAttribute('id', layerId);
      element.setAttribute('class', 'iLayer');
      document.getElementById('iGroup').appendChild(element);
    }
  }