// JavaScript Document


function submitSubcribeForm(){
	
	if( $('#s_name').val() != '' && $('#s_email').val() != '' ){
	
		var formData = $('#subscribeform').serialize();
	
		$("#subscribe_submit").hide();
		$("#subscribe_loading").show();
		$('#subscribeform .formtext').attr('disabled','true');
		//$('.loading').show();

		$.ajax({
			url: "subscribe.php",	
			type: "POST",
			data: formData,		
			cache: false,
			success: function (html) {	
				if (html=="1") {					
					//hide the form
					$("#subscribe_loading").hide();
					$('#subscribeform').fadeOut('slow');					
					
					//show the success message
					$('#subcribeformsent').fadeIn('slow');
				
				} else {
					alert('Sorry, there was an error with the subscription. Please try again later.');
					$("#subscribe_loading").hide();
					$("#subscribe_submit").show();
					alert(html);
				}
			}		
		});

	
	}


}

function submitContactForm(){
	
	if( $('#name').val() != '' && $('#email').val() != '' && $('#enquiry').val != '' ){
	
		var formData = $('#contactform').serialize();
	
		$('#contactform .formtext').attr('disabled','true');
		//$('.loading').show();

		$.ajax({
			url: "sendmail.php",	
			type: "POST",
			data: formData,		
			cache: false,
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('#contactform').fadeOut('slow');					
					
					//show the success message
					$('#contactformsent').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});

	
	}


}

function loadFeed(divid, type){	
	$('#'+divid).load('rssfeed.php?type='+type, function(responseText, textStatus, XMLHttpRequest) {
														 Cufon.replace('#wordpress .rss_title') ;
	  //alert('Load was performed.');
	});
}
