/*******

	***	jQuery/javascript for Tony Paves   ***
	*** http://www.tonypaves.com ***
	
*****/


		

var jQuery = jQuery.noConflict();
var barOffSet =-90;
var myPath = 'wordpress/wp-content/themes/tonypaves/';

jQuery(document).ready(function() {
	
	//for (var i=0; i< jQuery("#slideCount").size()-1; i++) {
	for (var i=0; i< 20; i++) {
		jQuery("#slides-"+i).slides({
			preload: true,
			preloadImage: myPath + "images/loading.gif",
			//play: 5000,
			pause: 2500,
			generateNextPrev: true, 
			hoverPause: true
		});
		
	}
	
	contactMap();
	initPageSlide();
	//projectLink();
	//jQuery("img").lazyload();
	//jQuery("img").lazyload({         
    	//placeholder : myPath + "images/grey.gif",
    	//container: jQuery("#main")
	//});
	/*var nua = navigator.userAgent;
		if ((nua.match(/iPad/i)) || (nua.match(/iPhone/i)) || (nua.match(/iPod/i))) {
			viewport.attr('content', 'width=device-width, minimum-scale=1.0, maximum-scale=1.0');
		jQuery('body')[0].addEventListener("gesturestart", gestureStart, false);
		}
		function gestureStart() {
			viewport.attr('content', 'width=device-width, minimum-scale=0.25, maximum-scale=1.6');
		}*/

});


function initPageSlide() {
	jQuery("a.topLink").anchorAnimate();
	jQuery("a.shadow").anchorAnimate();
	jQuery("a.infoLink").anchorAnimate();
	jQuery("a.contactLink").anchorAnimate();
}

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 500
	}, settings);	
	
	return this.each(function(){
		var caller = this
		jQuery(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = jQuery(caller).attr("href")
			
			var destination = jQuery(elementClick).next('h2').offset().top + barOffSet;
			jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed/*, function() {
				window.location.hash = elementClick
			}*/);
		  	return false;
		})
	})
}

function contactMap() {
	jQuery("#my_label").animate({opacity:0},0);
	jQuery("#my_map a").hover(function() {
		jQuery("#my_label").animate({left:"93px", opacity:1},500).animate ({left:"99px" }, 370 );
	});
	//jQuery("#my_label").animate ({left:"5px" }, 400 ).animate ({left:"0px " }, 370 );
	//jQuery("#my_label").everyTime(10, function() {
		//jQuery("#my_label").animate ({left:"113px" }, 400 ).animate ({left:"113px" }, 370 );
	//});
	
	//jQuery("#my_label").stop().fadeTo(1000,1);
	
}

function projectLink() {
	jQuery("#project_link").hover(function() {
		jQuery("#project_link").animate({width:"280px"},100);
	});
}


