var FLC = {};
FLC.home = {
	current_header:0,
	interval:4000,
	total_header:4,
	prev:0,	
	header: function() {
		if(this.current_header!=0) { $('.flash-'+this.current_header).fadeOut(1000);  $('#box'+this.current_header).removeClass('selected'); $('#anchor'+this.current_header).removeClass('selected_a');}
		if(this.current_header==this.total_header) this.current_header=0;
		this.current_header++;
		//alert(this.current_header);
		$('#box'+this.current_header).addClass('selected');
		$('#anchor'+this.current_header).addClass('selected_a');
		$('.flash-'+this.current_header).hide().css({'visibility':'visible'}).fadeIn(1000);
		setTimeout('FLC.home.header();',this.interval);
	},
	change_images: function(which_img){		
		if(this.prev!=0 && this.prev!=which_img){
			$('.flash-'+this.prev).fadeOut(1000);			
		}		
		$('.flash-'+which_img).fadeIn(1000);
		this.prev = which_img;	
	}	
};
$(document).ready(function(){
	if($('.flash')[0]) {
		//FLC.home.change_images(1);
		FLC.home.header();
	}
	
});
function submitFormData(form_name,form_action,which_form) {	
	var form_data = $('#'+form_name).serialize();		
	$.ajax({url:form_action,
		   type:'POST',
		   data:form_data,
		   success:function(data) {
			  //alert(data);
			   if(jQuery.trim(data)!='') {				 
				  if($.trim(data)!='success') {				 
				  $('#error_msg_'+which_form).html(jQuery.trim(data)).show();
				  $('#success_msg_'+which_form).hide();
				  	if(which_form == 'forgot_form') {
				  		reloadcaptcha('forgot-captcha-img','txtcaptchacode_forgot',false);
					}
					if(which_form == 'email_send_form') {						
						reloadcaptcha('mailer-captcha-img','txtcaptchacode_email_send',false);
					}
				  }else {
					if(which_form == 'login_form') {  
						window.location = SITE_URL_SSL+'my-profile';	  
					}else if(which_form == 'forgot_form') {
						$('#error_msg_'+which_form).hide();
						$('#success_msg_'+which_form).html('We have emailed you a temporary code. <br />Please check your email and use the code to change your password on our website.').show();
						$('#txt_forgot_user_name').val('');
						$('#txtcaptchacode_forgot').val('');
						reloadcaptcha('forgot-captcha-img','txtcaptchacode_forgot',false);
					}else if(which_form == 'email_send_form'){
						$('#error_msg_'+which_form).hide();
						$('#success_msg_'+which_form).html('Your request submitted successfully. Thank You.').show();						
						//$('#mail-box').html('Your request submitted successfuly. Thank You.');
						$('#txt_email_address').val('');
						$('#mailer-captcha').val('');
						reloadcaptcha('mailer-captcha-img','txtcaptchacode_email_send',false);						
					}
				}
			}
		}
	});
}
function validateRegistrationEmail(val,whichEmail){	
	if(whichEmail == 's') param = '&tab=register';
	else param = '';
	ajax_action = SITE_URL+'login';
	var form_data = val;
	$.get(
		ajax_action,
		'e_val='+val+param,
		function(data) {
			var status = data.split('|');
			//alert(status[0]);
			if(status[0]=='error') {
				$('#error_msg_registration').html(status[1]+' Already Exists. Please try with different Email Address.');
				$('#txt_user_name').attr('isrequired','1');
				//$('#txt_user_name').val('');
				$('#ajax_validate_email').attr('isrequired','1');
				//$('#txt_user_name').focus();
			}else {
				//Do nothing
				$('#ajax_validate_email').attr('isrequired','0');
				if(val!='') {
					$('#error_msg_registration').html('');
				}
			}
		}		
	);	
}
