$(document).ready(function() {
        
    $('.slider').cycle({
		fx: 'fade',
		speed:  '1000', 
    timeout: 3000,  
    pager:  '#nav' ,
	  pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="/wp-content/themes/sofscape/img/activeSlide.png" class="arrow" width="15" height="9px" alt=""><img src="' + slide.src + '" width="45" height="28" alt="" /></a></li>'; 
    } 
	});
  
  
  inputText($("#subForm #name"), 'Full Name');
  inputText($("#subForm #udkulr-udkulr"), 'Email');
  inputText($("#s"), "Search");
  
  
  // Simple form validation
  $("#subForm").submit(function(){
    $(this).find(":text").each(function(){
      if($(this).val() == ''){
        return false;
      } else if($(this).attr('name') == 'cm-udkulr-udkulr' && !validateEmail($(this).val())) {
        return false;
      }
    });
    return true;
  });
  
  
  twttr.anywhere(function (T) {
    T('#follow-twitterapi').followButton("sofscape");
  });
  
  // Google maps initialize
  try{
    initialize();
  } catch(e){
    console.log(e);
  }
  
  
  // Technology map
    function initialize2() {
      var latlng = new google.maps.LatLng(30,0);
      var myOptions = {
        zoom: 1,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas_2"),
          myOptions);
          
      
      var image2 = 'http://maps.google.com/mapfiles/kml/paddle/B.png';
      var myLatLng2 = new google.maps.LatLng(25.371328,55.410919);
      var beachMarker2 = new google.maps.Marker({
          position: myLatLng2,
          map: map,
          icon: image2
      });
      
      var image3 = 'http://maps.google.com/mapfiles/kml/paddle/A.png';
      var myLatLng3 = new google.maps.LatLng(18.444391,-66.38767);
      var beachMarker3 = new google.maps.Marker({
          position: myLatLng3,
          map: map,
          icon: image3
      });
      
    }
    initialize2();
  
  
});


// Generic stuff
function validateEmail(elementValue){  
  var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
  return emailPattern.test(elementValue);  
}

function inputText(inputObject, placeholderText){
  inputObject.focus(function(){
    if($(this).val() != '' && $(this).val() == placeholderText) {
      $(this).val('');
    }
  });
  inputObject.blur(function(){
    if($(this).val() == ''){
      $(this).val(placeholderText);
    }
  });
}
