$(document).ready(function(){

	$('#nojs').remove();

	$('#btn-req-h').toggle(function(){
		$('#estimate-dd').stop().animate({'top' : '0px'}, 1200, 'easeInOutExpo'); 

	},function(){
		$('#estimate-dd').stop().animate({'top' : '-410px'}, 1200, 'easeInOutExpo'); 
		
	});


    if($('#form').length)
	{
		$("#form").validate();	

	}
	
	
	$('#gobtn2').click(function(){
		
		
		// Remove any errors on new click
		if( $('input').hasClass('error')) { $('input').removeClass('error'); }	 
		 
		// Set erros to false  
		var hasError = false;
	
		// Validatie Fields
		var nameVal = $("#name").val();
		if((nameVal == '') || (nameVal == 'Full Name')) { $("#name").addClass('error'); hasError = true; }
		
		var emailToVal = $("#email").val();
		if((emailToVal == '') || (emailToVal == 'Email')) { $("#email").addClass('error'); hasError = true; }
	
		var phoneVal = $("#phone").val();
		if((phoneVal == '') || (phoneVal == 'Phone')) { $("#phone").addClass('error'); hasError = true; }			
			
		var hueVal = $("#human").val();
		if((hueVal == '') || (hueVal == 'Human? 2 + 4 =')) { $("#human").addClass('error'); hasError = true; $("#human").val();}	
		
		// Extra validation for email		
		if( $('input').hasClass('error')) { hasError = true ; }	 	 
	
			
		// If no form fields have an error, submit the form
		if (!hasError) 
		{
			return;
		} else {
			return false;
		}
		
		
	});	
	// SLIDESHOW
	$('#fadein').fadeOut(1200);
	$('#sshow').cycle({
			fx: 'fade',
			timeout: 5000,
			speed: 1000
	});	
	
	$('.blank').click(function(){ window.open(this.href);return false });
		
	$('#header li a').hover(
		function(){
			$(this).stop().animate({'color' : '#fff'}, 50);
			
		}, 
		function(){
			$(this).stop().animate({'color' : '#999'}, 300);	
	});	
	
	$('#footer a').hover(
		function(){
			$(this).stop().animate({'color' : '#fff'}, 50);
			
		}, 
		function(){
			$(this).stop().animate({'color' : '#666'}, 300);	
	});		
			
	
	$('#c3 li a').hover(
		function(){
			$(this).stop().animate({'color' : '#000'}, 50);
			
		}, 
		function(){
			$(this).stop().animate({'color' : '#666'}, 300);	
	});				

	$('#c1 a').hover(
		function(){
			$(this).find('strong').stop().fadeTo(50, 1);
		}, 
		function(){
			$(this).find('strong').stop().fadeTo(500, 0);
		}
	);
	$('#c1 a').hover(
		function(){
			$(this).find('strong').stop().fadeTo(50, 1);
		}, 
		function(){
			$(this).find('strong').stop().fadeTo(500, 0);
		}
	);	

	$('#c1 a').hover(
		function(){
			$(this).stop().animate({'color' : '#fff'}, 50);
			
		}, 
		function(){
			$(this).stop().animate({'color' : '#666'}, 300);	
	});	
	
	$('#c1 a').prepend('<strong></strong>');
	/*
	$('#nav a').hover(
		function(){
			$(this).stop().animate({'color' : '#fff'}, 50);
			
		}, 
		function(){
			$(this).stop().animate({'color' : '#666'}, 300);	
	});		
	*/
	$("a[rel=lbx]").fancybox({
			'transitionIn'		: 'fade',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + '<\/span>';
		}			
	});
	$('#b1, #b2').click(function(){
		$('#btn-proj').click(); return false;
	});
	
	$("#bbb").fancybox({
				'width'				: 1020,
				'height'			: '90%',
				'autoScale'			: false,
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
				'type'				: 'iframe'	
	});			
	
	/*
	   $(".extra").css("display","none");
 
        // Add onclick handler to checkbox w/id checkme
       $(".check").click(function(){						  
			// If checked
			if (this.checked)
			{
				//show the hidden div
				$('.extra').slideDown(200);
			}
			else
			{     
				//otherwise, hide it
				$('.extra').slideUp(200);
			}
  		});
	  
	  */
});

var is = document.getElementsByTagName('input'), dv = [], dvt = [];

for (var i=0,len=is.length;i<len;i++) {
	dv.push(is[i].value);
	is[i].i = i;
	is[i].onclick = function () { if (this.value==dv[this.i]) this.value=''; };
	is[i].onblur = function() { if (!this.value) this.value = dv[this.i]; };
}

for (var i=0,tx=document.getElementsByTagName("textarea"),len=tx.length;i<len;i++) {
	dvt.push(tx[i].value);
	tx[i].i = i;
	tx[i].onclick = function () { if (this.value==dvt[this.i]) this.value=''; };
	tx[i].onblur = function() { if (!this.value) this.value = dvt[this.i]; };
}


