function echeck(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
       alert("Please enter a valid Email Address")
       return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
       alert("Please enter a valid Email Address")
       return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Please enter a valid Email Address")
        return false
    }

     if (str.indexOf(at,(lat+1))!=-1){
        alert("Please enter a valid Email Address")
        return false
     }

     if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        alert("Please enter a valid Email Address")
        return false
     }

     if (str.indexOf(dot,(lat+2))==-1){
        alert("Please enter a valid Email Address")
        return false
     }

     if (str.indexOf(" ")!=-1){
        alert("Please enter a valid Email Address")
        return false
     }

     return true
}




function checkSpade() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && document.body.clientWidth  ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	if ( myWidth <= 1150 ) {
	    $('#spade').css( "display", "none" );
	} else {
	    $('#spade').css( "display", "block" );
	}
}

// CONTROLLING EVENTS IN jQuery
$(document).ready( function() {
    checkSpade();

    // Click the button event!
    $("#submit").click( function() {
        // check the entered values
        checkClick();
    });
    if ( $('#rotator') ) {
        $('#rotator').cycle({
            fx: 'fade',
            speed: 1000,
            timeout: 10000,
            next: '#rotator',
            pause: 3
        });
    }
    if ( $('#stats') ) {
        $('#stats').cycle({
            fx: 'scrollUp',
            speed: 700,
            timeout: 8000,
            next: '#stats',
            random: 1,
            pause: 3
        });
    }

    if ( $('#quotes') ) {
        $('#quotes div').cycle({
            fx: 'fade',
            speed: 700,
            timeout: 7000,
            next: '#quotes div',
            random: 1,
            pause: 3
        });
    }

    $(window).bind( "resize", function(){ checkSpade(); });
});
