
/*newsletter*/


$(document).ready(function(){
   $("#news_submit").click(function(e){
		var email_val = $('#email').val();
		var check_val = $("#termeni_si_conditii:checked").size();
		
		var err_msg = '';

		if(email_val == '' || !isEmail(email_val)) {
			err_msg = err_msg + 'Please enter a valid e-mail address! \n';
		}
		if(check_val == 0) {
			err_msg = err_msg + 'You must agree our terms and conditions! \n';
		}
		if(err_msg != '') {
			alert(err_msg);
			e.preventDefault();
		}
		
   });
 });


function isEmail(string)
{
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}


function newsletter_send() { 
	var sw = 0;
	
	

	if	((document.getElementById('email').value == 0)&& (sw==0)) {
		alert('Please enter your e-mail address! \n');
		sw = 1;
				
	}
	if (isEmail(document.getElementById('email').value) == false&& (sw==0)) {
		alert('Please enter a valid e-mail address! \n');
		sw = 1;		
	}
	
	if ((!document.getElementById('termeni_si_conditii').checked)&& (sw==0))
	{
		alert('You must agree our terms and conditions! \n');	
		sw = 1;
	}
	

	 
	if (sw == 0) 
	{
	
		document.forms[0].submit();
	/*window.location.href='http://www.chicagoicecreamfestival.com';*/
		}
	
	
}





/*Picture slide*/

function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 4000 );
});








