$(function() {
	var windowSizeArray = [ "width=520,height=650,scrollbars=yes" ];
	$('.newwindow').click(function(){
		var url = $(this).attr("href");
            var windowName = $(this).attr("name");
 
            /*Places the string from the array into the windowSize variable.
              The array slot is determined by the "rel" number on the link.*/
            //var windowSize = windowSizeArray[  $(this).attr("rel")  ];
 
            //This method opens a new browser window.
            window.open(url, windowName, windowSizeArray);
 
            /*Prevents the browser from executing the default action and
              allows us to use the "window.open" within our script.*/
            return false;
		
	});
				/*var framecount = 0;
				//window.setTimeout(function(){
				var moveDiv = setInterval(function() {
					$('#carousel').delay(10000).animate({
						'marginLeft' : "-=703px"
					}, 1000);
					framecount++;
					//window.alert(framecount);
					if(framecount>3) {
					$('#carousel').delay(10000).animate({
						'marginLeft' : "0px"
					}, 1000);
					framecount = 0;
				}
				}, 10000);*/
				
		$('#formsend').click(function() {
		
			if (document.getElementById('formname').value == "Your Name") {
				window.alert ("Please enter your name");
				document.getElementById('formname').focus();
				return false;
			}
			/*if (document.getElementById('formemail').value == "and E-mail") {
				window.alert ("Please enter your e-mail address");
				document.getElementById('formemail').focus();
				return false;
			} */ else if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($('#formemail').val()))) {
			alert("Please make sure you entered a valid Email Address.");
	
			$('#formemail').focus();
			return false;
			}
		
		
			$('#signupmessage span').remove();
			//$('#mailbox').append('<img src="images/hireme_mailbox_loader1.gif" alt="processing" id="loadimage" />');
			
			
			var name = $('#formname').val();
			var email = $('#formemail').val();
			
			$.ajax({
				type: 'POST',
				url: 'http://184.154.130.50/~sierram3/smgc/wp-content/themes/sierramadre/contact_sendmail.php',
				data: 'name=' + name + '&email=' + email,

				success: function(result) {
						//$('#response').remove();
						//$('#signupmessage').append('<span class="result">' + result + '</span>');
						$('#signupmessage').append('<span class="result">Thanks for signing up! You\'ll be getting our newsletter soon.</span>');
						/*$('#loadimage').fadeOut(500, function() {
								$(this).remove();
							});

						$('#mailbox').animate({opacity: 1.0}, 3000)
						    .fadeOut('slow', function() {
						      //$(this).hide();
						    });*/
						}	
				});
			
			$('#formsend').fadeOut();
			$('#formname').fadeOut();
			$('#formemail').fadeOut();
			
			$('#signupmessage').append('<span class="result">Thanks for signing up! You\'ll be getting our newsletter soon.</span>');
			
			return false;
		});				
	
					
				
});
				function slideSwitch() {
		var $active = $('#homeslides a.activeslide');
		
			if ( $active.length == 0 ) $active = $('#homeslides a:last');
		
			var $next =  $active.next().length ? $active.next()
				: $('#homeslides a:first');
		
			$active.addClass('lastactive');
		
			$next.css({opacity: 0.0})
				.addClass('activeslide')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('activeslide lastactive');
				});
		}
		
		$(function() {
			setInterval( "slideSwitch()", 7500 );
		});
