/*
function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
				
				_inputs[i].index = i;
				_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
				}
				_inputs[i].onblur = function(){
					if (this.value == '')
						this.value = _value[this.index];
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", hideFormText, false);
else if (window.attachEvent)
	window.attachEvent("onload", hideFormText);
*/

/* JQUERY FUNCTIONS */
$(function() { 
    $('#slideshow').cycle({
        speed:       700,
        timeout:     5000,
        pager:      '#spotlight_links',
		pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) {
            return '#spotlight_links li:eq(' + (idx) + ') a';
        }
    });
	
	$("a.group").fancybox({
		'frameHeight': 150,
		'frameWidth': 350,
		'hideOnContentClick': false
	});
	
   $("#submit_contact").click(function() {	   
	   var name = $("input#name").val();
	   if (name == "" || name == "Your name" || name == " ") {
	     $("input#name").css({backgroundColor:"#e86b45"});
         return false;
       } else {
	     $("input#name").css({backgroundColor:"#ffffff"});
	   }
	   
	   var email = $("input#email").val();
	   if (email == "" || email == "Your email address" || email == " ") {
	     $("input#email").css({backgroundColor:"#e86b45"});
         return false;
       } else {
	     $("input#email").css({backgroundColor:"#ffffff"});
	   }
	   
	   var dataString = $("form.some-form").serialize()
	   $.ajax({
		 type: "POST",
		 url: "http://www.eclipsetechnology.ca/contact.php",
		 data: dataString,
		 success: function() {
		   $('#getintouchform').html("<h3>Got it</h3>");
		   $('#getintouchform').append("<p>Thanks for getting in touch. We'll respond as soon as possible, within one business day. If it's urgent, just give us a call.</p>")
		   .hide()
			.fadeIn(1000, function() {
			  $('#getintouchform');
			})
		 }
	   });
	   return false;
   });

   $("#submit_signup").click(function() {	   	   
	   var signupemail = $("input#signupemail").val();
	   if (signupemail == "" || signupemail == "Your email address" || signupemail == " ") {
	     $("input#signupemail").css({backgroundColor:"#e86b45"});
         return false;
       } else {
	     $("input#signupemail").css({backgroundColor:"#ffffff"});
	   }
	   
	   var dataString = $("form.info-form").serialize()
	   $.ajax({
		 type: "POST",
		 url: "http://www.eclipsetechnology.ca/signup.php",
		 data: dataString,
		 success: function() {
		   $('#signupform').html("<h3>Got it -- thanks</h3>");
		   $('#signupform').append("<p>We'll send you an update once a month.</p>")
		   .hide()
			.fadeIn(1000, function() {
			  $('#signupform');
			})
		 }
	   });
	   return false;
   });

});