function next_step()
	{

		if(is_sliding())
		{

		} else {
		var next_step = parseInt(document.getElementById('input-step').value);
		
//			if((next_step > 0) && ((next_step + 1) <= 5))
			if((next_step > 0))
			{
			next_step=next_step+1;
			} else if(next_step !== 5) {
			next_step = 1;
			}

			
			if(next_step <= 5)
			{
			goto(next_step);
			} else {
			
				if($('agree').checked)
				{
				submit_card();
				} else {
				update_statusbar('You must agree to the Terms &amp; Conditions.', 'error');
				}

			}
		}
	}
	
	
function prev_step()
	{
	document.getElementById('continue-button').style.display = 'block';
	
		if(is_sliding())
		{
//		document.getElementById('debug0').innerHTML = 'wait...'; //debug
		} else {
		var prev_step = parseInt(document.getElementById('input-step').value);
		
			if((prev_step > 1))
			{
			prev_step=prev_step-1;
			} else {
			prev_step = 1;
			}
	
		goto(prev_step);
		}
		
	}


function goto(the_step)
	{

		switch(the_step)
		{
		
		case 1:
		show_step(the_step);
		prepare_step1();
		break;
		
		case 2:
		prepare_step2();
		show_step(the_step);
		break;
		
		
		case 3:
				
			if(validate_step2())
			{
			prepare_step3();
			show_step(the_step);
			} else {
			the_step = document.getElementById('input-step').value;
			}
			
		break;
		
		
		case 4:

			if(validate_step3())
			{
			prepare_step4();
			show_step(the_step);
			} else {
			the_step = document.getElementById('input-step').value;
			}

		break;
		
		
		case 5:
	
			if(validate_step4())
			{
			prepare_step5();
			show_step(the_step);
			} else {
			the_step = document.getElementById('input-step').value;
			}
			

		break;
			  
		default:
		the_step = document.getElementById('input-step').value;
		}
	
	document.getElementById('input-step').value = the_step;
	}
	
	
	
	
	
function show_step(id)
	{
	reset(id);
	
	var to = parseInt(id);
	var from = get_current_status();
		
	set_status(id, 'current', 'hide');


	var i;
	
		for(i=1; i <= 5; i++) 
		{
		var step_nav = document.getElementById(steps[i]['id']);
		
			if(i == id)
			{
			step_nav.setAttribute(attribute_name, 'active');
			} else {
			step_nav.setAttribute(attribute_name, '');
			}
		
		}
		
		
		if(id == 5)
		{
		document.getElementById('continue-button').setAttribute(attribute_name, 'button submit');
		} else {
		document.getElementById('continue-button').setAttribute(attribute_name, 'button continue');
		}
		
		if(id == 1)
		{
		document.getElementById('back').style.display = 'none';
		} else {
		document.getElementById('back').style.display = 'block';
		}
		
		
	slide(from, to);
	}
	
	
	



function slide(from, to)
	{
	steps[from]['status'] = 'sliding';
	
	var to_end = '0px';			
	
	var to_start;
	(from < to) ? to_start = '700px' : to_start = '-700px';



	var from_start = '0px';	
				
	var from_end;
	(from < to) ? from_end = '-700px' : from_end = '700px';

	
	
	//debug
//	document.getElementById('debug0').innerHTML = from+' to '+to;
//	document.getElementById('debug1').innerHTML = steps[1]['status'];
//	document.getElementById('debug2').innerHTML = steps[2]['status'];
//	document.getElementById('debug3').innerHTML = steps[3]['status'];
//	document.getElementById('debug4').innerHTML = steps[4]['status'];
//	document.getElementById('debug5').innerHTML = steps[5]['status'];
	

	
		if(os['id'] == 'macosx')
		{
		var fxFrom = new Fx.Tween('step'+from, {duration:500});
		fxFrom.start('left', from_start, from_end);
		
		var fxTo = new Fx.Tween('step'+to, {duration:500});
		fxTo.set('left', to_start);
		fxTo.set('display', 'block');
		fxTo.start('left', to_start, to_end);

		setTimeout('set_not_sliding()',550);
		} else {
		document.getElementById('step'+to).style.display = 'block';
		document.getElementById('step'+from).style.display = 'none';
		set_not_sliding();
		}

	}





function is_sliding()
	{
	var status = false;
	
		for(i=1; i <= 5; i++) 
		{
		
			if(steps[i]['status'] == 'sliding')
			{
			status = true;
			} 
			
		}
	
	return status;
	}
	
	

function set_not_sliding()
	{
	
		for(i=1; i <= 5; i++) 
		{
		
			if(steps[i]['status'] == 'sliding')
			{
			document.getElementById('step'+i).style.display = 'none';
			steps[i]['status'] = 'hide';
			
//			document.getElementById('debug0').innerHTML = 'ok'; //debug
			} 
			
		}
	
	}





function set_status(id, status_true, status_false)
	{
	
		for(i=1; i <= 5; i++) 
		{
		
			if(i == id)
			{
			steps[i]['status'] = status_true;
			} else if(status_false) {
			steps[i]['status'] = status_false;
			}
			
			
		}
	
	
	}
	
	
function get_current_status()
	{
	var current;
	
		for(i=1; i <= 5; i++) 
		{
		
			if(steps[i]['status'] == 'current')
			{
			current = i;
			}
			
		}
	
	return current;	
	}


