Cufon.replace('h2, .button-red-big span',{textShadow:"rgba(255,255,255,0.7) 0.5px 0px, rgba(0,0,0,1) 1px 1px"});
Cufon.replace('h3',{textShadow:"rgba(255,255,255,1) 1.5px 1.5px"});
Cufon.replace('ul.menu a.main',{textShadow:"rgba(255,255,255,1) 0.5px 0px",hoverable:true,hover: {a:true}});
Cufon.replace('.cufonize',{textShadow:"rgba(0,0,0,1) 1px 1px"});

$(document).ready(function(){
	$("input[type=text],input[type=password],textarea")
	.filter(".auto-clear")
	.bind("focus", function(e) {
		if (this.value==this.defaultValue) { 
			this.value = "";
			$(this).addClass("focused");
		}
	})
	.bind("blur", function(e) {
		if (this.value=="") {
			this.value = this.defaultValue;
			$(this).removeClass("focused");
		}
	})
	.attr("value", function() {
		return this.defaultValue;
	});
	
	$('[id^=map]').each(function(){
		var latlngArr = this.id.split(':')[1].split(',');
		var latlng = new google.maps.LatLng(latlngArr[0],latlngArr[1]);
		var myOptions = {
			zoom: 16,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			scrollwheel: false
		};
		this.gMap = new google.maps.Map(this,myOptions);
		var marker = new google.maps.Marker({
			position: latlng
		});
		marker.setMap(this.gMap);
	});
	
	var slideTimeout = 3000;
	$('.box-client-logos img').each(function(){
		$(this).css({opacity:0,visibility:"visible"});
		
		var newLeft = -(this.offsetWidth - this.parentNode.offsetWidth) / 2;
		var newTop = -(this.offsetHeight - this.parentNode.offsetHeight) / 2;
		
		$(this).css({left:newLeft+"px",top:newTop+"px"});
		
		this.fadeOut = function() {
			var $nextImg = $(this).next('img');
			if ($nextImg.length == 0)
				$nextImg = $('.box-client-logos img:first');
				
			$nextImg.animate({opacity:1},1000,function(){
				var o = this;
				setTimeout(function(){o.fadeOut();},slideTimeout);
			});
			$(this).animate({opacity:0},1000);
		}
		
		if ($(this).hasClass('current')) {
			$(this).css('opacity',1);
			var o = this;
			setTimeout(function(){o.fadeOut();},slideTimeout);
		}
	});
	
	var boxTimeout = 5000;
	$fBoxes = $('.feature-box');
	if ($fBoxes.length > 1) {
		$fBoxes.each(function(){
			this.fadeOut = function() {
				var $nextBox = $(this).next('.feature-box');
				if ($nextBox.length == 0)
					$nextBox = $('.feature-box:first');
					
				$nextBox.animate({opacity:1},1000,function(){
					var o = this;
					setTimeout(function(){o.fadeOut();},boxTimeout);
				});
				$(this).animate({opacity:0},1000);
			}
			
			$(this).css('opacity',0).css('visibility','visible');
			if ($(this).hasClass('current')) {
				$(this).css('opacity',1);
				var o = this;
				setTimeout(function(){o.fadeOut();},boxTimeout);
			}			  
		});
	}
	
	if (!$.browser.msie || $.browser.version >= 9) {
		$ffText = $('h2#feature_form_text');
		$ffText.children().css('opacity',0).each(function(i){
			var delay = 250 * (i+1);
			var o = this;
			setTimeout(function(){$(o).animate({opacity:1},400);},delay);
		}).end();
	}
	$ffText = $('h2#feature_form_text').css('opacity',1);
});
