var auto = $.jqwidont.auto();
$.jqwidont.auto(false); 

$(document).ready(function() {


function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
  }


$('a[href*=#]').click(function(){
	$("#container").scrollTo(filterPath($(this).attr('href')),500)
})

function intro() {
	$("#line-1").animate({opacity:1},'slow','easeInOutCirc',function(){if ($.browser.msie){this.style.removeAttribute('filter')}});
	$("#line-2").delay(250).animate({opacity:1},'slow','easeInOutCirc',function(){if ($.browser.msie){this.style.removeAttribute('filter')}});
	$("#line-3").delay(500).animate({opacity:1},'slow','easeInOutCirc',function(){if ($.browser.msie){this.style.removeAttribute('filter')}});
	$("#home .columns").delay(750).animate({opacity:1},'slow','easeInOutCirc',function(){if ($.browser.msie){this.style.removeAttribute('filter')}});
};

intro();




function positionMasks(){
    var y = $(window).scrollTop();
	$(".screen").each(function(i,s){
		var position = $(s).position();
		var height = position.top + $(s).height() - 140;
		if ((y <= (position.top  )) || ( y > (height - 140))) {
			$(s).find(".mask").removeClass('fixed');
		}
		else {
			$(s).find(".mask").addClass('fixed');
		}
	})
}


if ($(".no-touch").length > 0) {
	positionMasks()
	$("#container").scroll(function () {
		positionMasks();
		});
	$("#container").resize(function () {
		positionMasks()
	});
}

$("#work li a").click(function(e){
	var p = $(this).attr('href');
	$(p).fadeIn();
	e.preventDefault();
})

$(".project-panel").each(function(p){
	$(this).append('<div class="close">Close</div>');
})

$("#work").find(".close").click(function(){
	$(this).closest(".project-panel").fadeOut();
})

function createMap() {

  // Create an array of styles.
  var myStyles = [
    {
      featureType: "all",
      stylers: [
      	{ hue: "#33ddff" },
        { saturation: 0 },
        {lightness: -30}
      ]
    }
  ];

  // Create a new StyledMapType object, passing it the array of styles,
  // as well as the name to be displayed on the map type control.
  var mapType = new google.maps.StyledMapType(myStyles,
    {name: "Whitepoint"});

  var mapOptions = {
    zoom: 15,
    center: new google.maps.LatLng(23.589003,58.382742),
    disableDefaultUI: true,
      zoomControl: false,
       scrollwheel: false,
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'my_map']
    }
  };
  var map = new google.maps.Map(document.getElementById('map'),
    mapOptions);

  //Associate the styled map with the MapTypeId and set it to display.
  map.mapTypes.set('my_map', mapType);
  map.setMapTypeId('my_map');


    //var image = '/images/interface/marker.png';
    var myLatLng = new google.maps.LatLng(23.586589,58.409886);
    var marker = new google.maps.Marker({
        position: myLatLng, 
        map: map
    });   

}
createMap() 

//$.jqwidont.init();
$('p:not(#hero)').widont();

})
















