$(document).ready(function () {
  $(".fMap").colorbox({
    html:'<div id="map_canvas_all" style="width:560px; height:450px; font:15px bold arial,sans-serif; color:000000;"></div>',
    scrolling:false,
    width:"600px",
    height:"520px",
    onComplete:function(){ loadScriptGeneral(); }
  });
    
  $(".newsletterLink").click(function(){
    $(".newsletterLinkContainer").fadeOut('fast', function() {
      $(".newsletterContainer").fadeIn('slow', function(){
        $("#newsletterForm label").inFieldLabels();        
        var validatorNewsletter = $("#newsletterForm").validate({
          rules:
          {
              newsletter: { required: true, email: true }
          },
          submitHandler: AjaxSubmitNewsletter
        });
      });
    });
  });
});
function AjaxSubmitNewsletter(){
  $.ajax({
    type: "GET",
    url: "/campaignmonitorservice.aspx?add=" + $("#newsletter").attr("value"),
    success: AjaxSucceeded,
    error: AjaxFailed
  });
};
function AjaxSucceeded(result) {      
  $("#newsletterForm").fadeOut('fast', function(){
    $(".newsletterAction").css("display","block");
    $(".newsletterAction").html(result);  
  });    
  return;
};
function AjaxFailed(result) {
  $("#newsletterForm").fadeOut('fast', function(){
    $(".newsletterAction").css("display","block");
    $(".newsletterAction").html(result);  
  });  
  return;
};
function loadScriptGeneral() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initializeGeneral";
  document.body.appendChild(script);
}; 
function initializeGeneral() {
  var imageG = new google.maps.MarkerImage('images/google.png',
      new google.maps.Size(20, 26),
      new google.maps.Point(0, 0),
      new google.maps.Point(0, 26)
  );
  var shadowG = new google.maps.MarkerImage('images/shadow.png',
      new google.maps.Size(23, 30),
      new google.maps.Point(0, 0),
      new google.maps.Point(0, 30)
  );
  var myLatlngG = new google.maps.LatLng(4.911001,100.894876);
  var myOptionsG = {
      zoom: 10,
      center: myLatlngG,
      mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var mapG = new google.maps.Map(document.getElementById("map_canvas_all"), myOptionsG);

  var markerG = new google.maps.Marker({
      position: myLatlngG,
      map: mapG,
      title: "Syamille Agrofarm & Resort Sdn. Bhd",
      shadow: shadowG,
      icon: imageG 
  });
};

