
var redirect_url = '';

function show_download_form(url){
			redirect_url = url;
			jQuery('#download-teaser').fadeOut('slow', function(){
				document.getElementById('download-email-form').style.position = 'static';
				document.getElementById('download-email-form-inner').style.position = 'static';
				jQuery('#download-email-form').fadeIn();
			});
		}
		function validate_download_email(){
			var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
			if (!filter.test(document.getElementById('download-email-input').value)) {
				//jQuery('#download-email-error').fadeIn();
				jQuery("#download-email-label").fadeOut('fast', function(){
					jQuery("#download-email-label").html("Invalid email address");
					jQuery("#download-email-label").css('color', '#EF4638');
					jQuery("#download-email-label").fadeIn();
				});
			
			}else{
			
				jQuery('#download-email-error').fadeOut();
				//document.forms['download-email-form'].submit();
				if (window.XMLHttpRequest){
					// code for IE7+, Firefox, Chrome, Opera, Safari
					send_download = new XMLHttpRequest();
				}else{
					// code for IE6, IE5
					send_download = new ActiveXObject("Microsoft.XMLHTTP");
				}
				send_download.onreadystatechange = function(){
					if (send_download.readyState == 4 && send_download.responseText == 'success'){
						$.cookie("RiggsDownload", "true", { path: '/', expires: 365 });
						jQuery('#download-email-form').fadeOut('slow', function(){
							jQuery('#download-email-success').fadeIn();
							window.location = redirect_url;
						});
    				}
				}
				var email = document.getElementById('download-email-input').value;
				var title = document.getElementById('download-title').value;
				var download_url = document.getElementById('download-url').value;
				var site_url = "<?php bloginfo('wpurl') ?>";
				//send_download.open("GET", "/wp-content/themes/creative/send_download.php?email=" + email + '&subject=' + title + '&download_url=' + download_url + '&site_url=' + site_url, true);
				send_download.open("GET", "/wp-content/themes/creative/send_download.php?email=" + email, true);
				send_download.send();
				//alert("/wp-content/themes/creative/send_download.php?email=" + email + '&subject=' + title + '&download_url=' + download_url + '&site_url=' + site_url);
			}
		}
		
		function validate_download_email_without_sending_email(){
			var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
			if (!filter.test(document.getElementById('download-email-input').value)) {
				//jQuery('#download-email-error').fadeIn();
				jQuery("#download-email-label").fadeOut('fast', function(){
					jQuery("#download-email-label").html("Invalid email address");
					jQuery("#download-email-label").css('color', '#EF4638');
					jQuery("#download-email-label").fadeIn();
				});
			
			}else{
			
				jQuery('#download-email-error').fadeOut();
				//document.forms['download-email-form'].submit();
				if (window.XMLHttpRequest){
					// code for IE7+, Firefox, Chrome, Opera, Safari
					send_download = new XMLHttpRequest();
				}else{
					// code for IE6, IE5
					send_download = new ActiveXObject("Microsoft.XMLHTTP");
				}
				send_download.onreadystatechange = function(){
					if (send_download.readyState == 4 && send_download.responseText == 'success'){
						$.cookie("RiggsDownload", "true", { path: '/', expires: 365 });
						jQuery('#publication-form').fadeOut('slow', function(){
							if(!emailAddressForm) {
								window.location = redirect_url;
							}
						});
    				}
				}
				var email = document.getElementById('download-email-input').value;
				var title = document.getElementById('download-title').value;
				var download_url = document.getElementById('download-url').value;
				var site_url = "<?php bloginfo('wpurl') ?>";
				if(emailAddressForm) {
					send_download.open("GET", "/wp-content/themes/creative/store_email.php?email=" + email, true);
				} else {
					send_download.open("GET", "/wp-content/themes/creative/send_download.php?email=" + email, true);
				}
				send_download.send();
				//alert("/wp-content/themes/creative/send_download.php?email=" + email + '&subject=' + title + '&download_url=' + download_url + '&site_url=' + site_url);
			}
		}
		
		function validate_subscribe_email(){
			var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
			if (!filter.test(jQuery("#subscribe-form > #email").val())){
				jQuery("#subscribe-invalid-email-warning").fadeIn();
			}else{
				jQuery("#subscribe-invalid-email-warning").fadeOut('slow', function(){
					jQuery("#subscribe-form").submit();
				});
			}
		}

		function show_publication_form(url){
			redirect_url = url;
			jQuery("#publication-form").fadeIn();
		}
		
		function close_publication_form(){
			jQuery("#publication-form").fadeOut();
		}
		
		jQuery(document).ready(function(){
			if(document.getElementById('download-email-form')){
				document.getElementById('download-email-form').style.height = document.getElementById('download-teaser').offsetHeight + 'px';
				document.getElementById('download-email-form-inner').style.top = (document.getElementById('download-teaser').offsetHeight * -1) + 'px';
			}
		});
		
		
		
/*
*	Home Slider Scripts
*/


function slideImages(){
		//jQuery(".single-slider:first").addClass("active");
		var current_img = jQuery("#image-slider .active");
		
		current_img.removeClass('active').fadeOut('slow', function(){
			if(jQuery(this).next().length){
				jQuery(this).next().addClass('active').fadeIn('slow');
			}else{
				jQuery(".single-slider:first").addClass('active').fadeIn();
			}
		});
		
		var current_caption = jQuery("#image-caption .active");
		
		current_caption.removeClass('active').fadeOut('slow', function(){
			if(jQuery(this).next().length){
				jQuery(this).next().addClass('active').fadeIn('slow');
			}else{
				jQuery(".single-caption:first").addClass('active').fadeIn();
			}
		});
	}
	
jQuery(document).ready(function(){
	jQuery(".single-slider:first").addClass('active').fadeIn('slow');
	jQuery(".single-caption:first").addClass('active').fadeIn('slow');
	setInterval("slideImages()", 5000);
});
