  var factory = null;

(function() {
  // We are already defined. Hooray!
  if (window.google && google.gears) {
    return;
  }



  // Firefox
  if (typeof GearsFactory != 'undefined') {
    factory = new GearsFactory();
  } else {
    // IE
    try {
      factory = new ActiveXObject('Gears.Factory');
      // privateSetGlobalObject is only required and supported on WinCE.
      if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
        factory.privateSetGlobalObject(this);
      }
    } catch (e) {
      // Safari
      if ((typeof navigator.mimeTypes != 'undefined')
           && navigator.mimeTypes["application/x-googlegears"]) {
        factory = document.createElement("object");
        factory.style.display = "none";
        factory.width = 0;
        factory.height = 0;
        factory.type = "application/x-googlegears";
        document.documentElement.appendChild(factory);
      }
    }
  }

  // *Do not* define any objects if Gears is not installed. This mimics the
  // behavior of Gears defining the objects in the future.
  if (!factory) {
    return;
  }

  // Now set up the objects, being careful not to overwrite anything.
  //
  // Note: In Internet Explorer for Windows Mobile, you can't add properties to
  // the window object. However, global objects are automatically added as
  // properties of the window object in all browsers.
  if (!window.google) {
    google = {};
  }

  if (!google.gears) {
    google.gears = {factory: factory};
  }
})();


function createShortcut() {

  if (!factory) {
 setupSample();
    return;
  }else{



var desktop = google.gears.factory.create("beta.desktop");
var description = "Launch shortcut for NCN website.";

  var icons = {
    "8x8": "ncn8x8.png",
    "16x16": "ncn16x16.png",
	"32x32": "ncn32x32.png"
  };
  
  var desktoppath = $('#desktoppath').val();
desktop.createShortcut("NCN Shortcut",  // name
                         desktoppath,  // url
                          icons,  // icons (must specify at least one)
                         description);  // description (optional)
						 
	}


}


function setupSample() {
 // Make sure we have Gears. If not, tell the user.
 if (!window.google || !google.gears) {
 if (confirm("Install Google Gears to Create Desktop Shortcut of this website !")) {
 var spliceStart = location.href.indexOf("/samples");
 location.href = "http://gears.google.com";
 //location.href.substring(0, spliceStart) + "/";
 return;
 }
 }
}