﻿$(document).ready(function() {
$('#images li').cycle({
     fx: 'fade',
    speed: 500,
    timeout: 2000
 }); 
$('#right-column .sites li').hover(function() {
//$(this).siblings().css("opacity", "0.4");
    $(this).siblings().stop().animate({
			 opacity: '0.4'
		    }, 400);
    }, function() {
        $('#right-column .sites li').siblings().stop().animate({
            opacity: '1'
        }, 400);
    });

    $('#right-column .sites li, #right-column .menu li').click(function() {
        $('#display #images li').hide();
        $('.content div').hide();
    });
    $('#right-column .menu li.link1').click(function() {
        $('#display #images li.default').show();
        $('.content .link1').show();
    });
    $('#right-column .menu li.link2').click(function() {
    $('#display #images li.default').show();
        $('.content .link2').show();
    });
    $('#right-column .menu li.link3').click(function() {
    $('#display #images li.default').show();
        $('.content .link3').show();
    });
  $('#right-column .sites li.site1').click(function() {
        $('#display #images li.site1').show();
        $('.content .site1').show();
    });
    $('#right-column .sites li.site2').click(function() {
        $('#display #images li.site2').show();
        $('.content .site2').show();
    });
    $('#right-column .sites li.site3').click(function() {
        $('#display #images li.site3').show();
        $('.content .site3').show();
    });
    $('#right-column .sites li.site4').click(function() {
         $('#display #images li.site4').show();
         $('.content .site4').show();
    });
   
   
   
    $('#submitform').click(validateForm);
    
    //validate form
    function validateForm() {
        var name = document.getElementById("name").value;
        var email = document.getElementById('email').value;
        var tel = document.getElementById('telephone').value;

        if (name.length > 0 && email.length > 0) {
            //check email
            var filter = /^.+@.+\..{2,3}$/
            if (!filter.test(email)) {
                alert('Please input a valid email address.')
                return false;
            }
            IsNumeric(tel);
        }
        else {
            alert('Please give your name and email address.');
            return false;
        }
    }
    //validate numbers only
    function IsNumeric(input) {
        var ValidChars = "0123456789.";
        var IsNumber = true;
        var Char;
        for (i = 0; i < input.length && IsNumber == true; i++) {
            Char = input.charAt(i);
            if (ValidChars.indexOf(Char) == -1) {
                alert('numbers only')
                IsNumber = false;
            }
        }
        return IsNumber;

    }
    
     //slided the div up anddown to hide and show
         $(".toggle_items h3").click(function(event) {
            $(this).next().slideToggle("slow");
        });
        
         //toggles the open and close icon
        $(".toggle_items h3").toggle(function() {
            $(this).addClass("active");
           }, function() {
         $(this).removeClass("active");

 }); 
 
});

