/**
* gMap section
*/
function gmapIntro() {
    jQuery.beautyOfCode.init({
        brushes: ['JScript'],

        ready: function() {
            jQuery.beautyOfCode.beautifyAll();
        }
    });

	jQuery(window).load(function()
	{
		jQuery("#map").gMap({
      address:'Kraków, Poland',
      zoom:12
    });
	});
}

function gmapDocumentation() {
    jQuery.beautyOfCode.init({
        brushes: ['Xml','JScript'],

        ready: function() {
            jQuery.beautyOfCode.beautifyAll();
        }
    });
}

function gmapExamplesAlpha() {
  jQuery(window).load(function()
  {
    var random = [];
    for(var i = 0; i < 1000; i+=1) {
      random.push({
          latitude: 180*Math.random() - 90,
          longitude: 360*Math.random() - 180
      });
    }


    jQuery("#map1").gMap({
        markers: random,
        zoom: 1,
        latitude: 0.1,
        longitude: 0.1,
        clustering: true,
        fastClustering: true,
        clusterSize: 40 //radius as % of viewport width
    });

    var map2 = jQuery("#map2");
    map2.gMap({
        markers: [
            {
                latitude: 50.083,
                longitude: 19.917,
            },
            {
                latitude: 50.20917,
                longitude: 19.75435,
            },
            {
                latitude: 50.502343,
                longitude: 19.91243,
            }
          ],
      zoom: "fit",
      latitude: "fit",
      longitude: "fit",
      onComplete: function() {
          var center = map2.data('gmap').gmap.getCenter();
          map2.gMap('addMarker', {
              latitude: center.lat(),
              longitude: center.lng(),
              icon: {
                  image: "http://thydzik.com/thydzikGoogleMap/markerlink.php?text=X&color=5680FC",
              }
          });
      }
    });


    var keyNum = 1;
    var changeMarker = function () {
        map3.gMap('getMarker', 'key' + keyNum).setIcon("http://www.google.com/mapfiles/marker.png");
        keyNum += 1;
        if(keyNum > 3) {keyNum = 1; }
        map3.gMap('getMarker', 'key' + keyNum).setIcon("http://thydzik.com/thydzikGoogleMap/markerlink.php?text=X&color=5680FC");

        window.setTimeout(changeMarker, 1000);
    };

    var map3 = jQuery("#map3");
    map3.gMap({
      markers: [
              {
                  latitude: 50.083,
                  longitude: 19.917,
                  key: 'key1'
              },
              {
                  latitude: 50.20917,
                  longitude: 19.75435,
                  key: 'key2'
              },
              {
                  latitude: 50.502343,
                  longitude: 19.91243,
                  key: 'key3'
              }
          ],
      zoom: "fit",
      latitude: "fit",
      longitude: "fit",
      onComplete: function() {
          changeMarker();
      }
    });

    var map4 = jQuery('#map4');
    map4.gMap({
      markers: [
          {
              latitude: 50.083,
              longitude: 19.917
          },
          {
              latitude: 50.20917,
              longitude: 19.75435
          },
          {
              latitude: 50.502343,
              longitude: 19.91243
          }
      ],
      zoom: "fit",
      latitude: "fit",
      longitude: "fit"
    });

    jQuery('#resize').click(function (e) {
        map4.height(map4.height() + 300);
        e.preventDefault();
    });

    jQuery('#repair').click(function (e) {
        map4.gMap('fixAfterResize');
        e.preventDefault();
    });

    jQuery('#repair_ugly').click(function (e) {
        map4.gMap('fixAfterResize', true);
        e.preventDefault();
    });
  });
    
  jQuery.beautyOfCode.init({
      brushes: ['JScript'],

      ready: function() {
          jQuery.beautyOfCode.beautifyAll();
      }
  });

    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Number of markers');
      data.addColumn('number', 'MB of RAM');
      data.addRows([
        ['10K', 40],
        ['50K', 48],
        ['100K', 51],
        ['500K', 79],
        ['1M', 112],
        ['5M', 354],
        ['10M', 500]
      ]);

      var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
      chart.draw(data, {width: 547, height: 320, title: 'Memory usage',
                        hAxis: {title: 'Number of markers', titleTextStyle: {color: '#000000'}}
      });
    }
}

function gmapExamples() {
    jQuery.beautyOfCode.init({
        brushes: ['JScript'],

        ready: function() {
            jQuery.beautyOfCode.beautifyAll();
        }
    });

    jQuery(window).load(function() {
        var tabs = jQuery('#examples_tabs').tabs({fx:{opacity:'toggle'}});
        tabs.bind( "tabsshow", function(event, ui) {
          examples.load(tabs.tabs('option', 'selected'));
        });
        examples.load(tabs.tabs('option', 'selected'));
    });
}

/**
* others
*/

function js3d() {
  jQuery(document).ready(function() {
    jQuery("#canvas").js3d(
      '/scripts/malpa.dae',
      {
        theme: 'light',
        displayScale: 100,
        width: 550,
        height: 500,
        gridWidth: 50,
        log: 0
      });
  });
}
