function registerBack()
{
	$('#r_form').removeAttr('action');
	$('#r_form').attr('action',base_url+'register/signup/')	;
	$('#r_form').submit();
}

function backToTypes()
{
	$('#r_form').removeAttr('action');
	$('#r_form').attr('action',base_url+'register/')	;
	$('#r_form').submit();
	
}
 

function showHideOnIam(sel)
{
	$('#college_status_row').hide();
	$('#college_year_row').hide();

	$('#high_school_row').hide();
	$('#high_school_year_row').hide();

	if(sel == 0)
	{
		$('#college_status_row').show();
		$('#college_year_row').show();
	}
	else if(sel == 2)
	{
		$('#high_school_row').show();
		$('#high_school_year_row').show();
	}
}

function setvalue(typeval)
{
	$('#memtype').val(typeval);
}

function frmsubmit()
{
	if($('#memtype').val() != '')
		$('#frmmembertype').submit();	
		
}

function newCaptchaImage()
{
	$.ajax({
		type: 'GET',
		url: base_url + 'captcha/index/' + Math.random(),
		data: '',
		success: function(responseText){
			var imgArray	= responseText.split('|');
			
			$('#randWord').val(imgArray[0]);
			$('#time').val(imgArray[1]);
			$('#captch_image').html('<img src="' + base_url + 'application/images/captcha/' + imgArray[1] + '.jpg?' + Math.random() + '" height="30" width="150">');
			$('#randKey').val(imgArray[2]);			
		}
	});
}

function handleBirthdays(sex)
{
	if(sex == 'male')
	{
		$('#birthrow').show();
		$('#hisbirthrow').hide();
		$('#herbirthrow').hide();		
	}
	else if(sex == 'female')
	{
		$('#birthrow').show();		
		$('#hisbirthrow').hide();
		$('#herbirthrow').hide();		
		
	}
	else if(sex == 'couple')
	{
		$('#birthrow').hide();		
		$('#hisbirthrow').show();
		$('#herbirthrow').show();		
		
	}
	
}

function postToPaymentOptions()
{
	$('#r_form').removeAttr('action');
	$('#r_form').attr('action',base_url+'paypal/')	;
	$('#r_form').submit();
	
}

function getState(countrySymbol)
{
	$("#loadingstate").show();
	$("#loadingzip").show();
	$("#showState").hide();
	$("#showZip").hide();
	$.ajax({
		type: 'POST',
		dataType: 'json',
		url: base_url + 'register/getState/' + Math.random(),
		data: 'countrysymbol='+countrySymbol,
		success: function(response){
			var stateVar = response.states;
			$("#state")[0].options.length = 0;
			//$("#state")[0].options[0] = new Option(defaultstate, '');
			if(stateVar.length > 0)
			{
				for (var i=0; i<stateVar.length-1;i++)
				{
					$("#state")[0].options[i] = new Option(stateVar[i].state_name , stateVar[i].state_symbol);
				}
				$("#showState").show();
				$("#loadingstate").hide();
	
				
				var zipVar = response.zips;
				$("#zip")[0].options.length = 0;
				//$("#state")[0].options[0] = new Option(defaultstate, '');
				if(zipVar.length > 0)
				{
					for (var i=0; i<zipVar.length-1;i++)
					{
						$("#zip")[0].options[i] = new Option(zipVar[i].zip_code , zipVar[i].zip_code);
					}
					$("#showZip").show();
					$("#loadingzip").hide();
				}
				else
				{
					$("#showZip").hide();
					$("#loadingzip").hide();
				}
				
			}
			else 
			{	
				$("#showState").hide();
				$("#showZip").hide();	
				$("#loadingstate").hide();
				$("#loadingzip").hide();
			}
		}
		   
	});
}

function getZip(stateSymbol)
{
	$("#loadingzip").show();
	$("#showZip").hide();
	$.ajax({
		type: 'POST',
		dataType: 'json',
		url: base_url + 'register/getZipAjax/' + Math.random(),
		data: 'stateCode='+stateSymbol,
		success: function(response){
				var zipVar = response.zips;
				$("#zip")[0].options.length = 0;
			
				if(zipVar.length > 0)
				{
					for (var i=0; i<zipVar.length-1;i++)
					{
						$("#zip")[0].options[i] = new Option(zipVar[i].zip_code , zipVar[i].zip_code);
					}
					$("#showZip").show();
					$("#loadingzip").hide();
					
					
				}
				else
				{
					$("#showZip").hide();
					$("#loadingzip").hide();
				}
				
			
		}
		   
	});
}