/* -- 18.10.11 -- */

$(function(){	
	$.fn.clearInput = function(){
		$(this).focus(function(){				
			if($(this).val() == this.defaultValue){
				$(this).val('');
			}
		});
		
		$(this).blur(function(){	
			if($(this).val() == ''){
				$(this).val(this.defaultValue);
			}
		});
	}
});


/* -- detect iPad user agent | 31.10.11 -- */
function isiPad(){
    return (navigator.platform.indexOf("iPad") != -1);
}



/* -- clear input calls -- */
$().ready(function(){ 
	$('#contact_form input[type = "text"]').clearInput();	
	$('#newsletter_form input[type = "text"]').clearInput();	
});



/* -- contact form -- */
$().ready(function(){ 

	/*
	$(".form-container .action-btn").click(function(){
		$(this).hide();
		
		$("#contact_form .intro").hide();
		$(".form-container fieldset").hide();
		$(".form-footer").hide();
		
		$(".response").show();
		
		$(".form-container").trigger('reposition');
	});*/

	

	$('#hire').click(function(eventObj){
		$('.form-container').lightbox_me({
			centered: true, 
			lightboxSpeed: "normal",
			overlayCSS: {background: '#000', opacity: 0.6}
		});
						
		eventObj.preventDefault();
	});	
	
	
	$('.request-btn').click(function(eventObj){		
		$('.form-container').lightbox_me({
			centered: true, 
			lightboxSpeed: "normal",
			overlayCSS: {background: '#000', opacity: 0.6}
		});
		
		eventObj.preventDefault();
		$("html, body").stop().animate({scrollTop:0},"slow");
	});		
		
});



/* -- scroll top | 27.10.11 -- */
$(function(){
	$.fn.scrollToTop=function(){
		$("#scrollTop").hide().removeAttr("href");
		
		if($(window).scrollTop()!="0"){
			$(this).fadeIn("slow")
		}
		
		var scrollDiv=$(this);
		
		$(window).scroll(function(){
			if($(window).scrollTop()=="0"){
				$(scrollDiv).fadeOut("slow")
				
			}else{
				$(scrollDiv).fadeIn("slow")
			}
		});
		
		$(this).click(function(){
			$("html, body").animate({scrollTop:0},"slow");
		});
	}
});

$(function() {	
	if(isiPad() == true){
		return;
	}else{
		var $scroller = '<a href="#" id="scrollTop"></a>';
		$('body').append($scroller);
		
		$("#scrollTop").scrollToTop();
	}
});
