// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function set_wizard_action(el, action) {
	$(el).name = "wizard[action]";
	$(el).value = action;
}

function reset_wizard_action() {
	$('next_button').name = "";
	$('next_button').value = "";
	
	$('back_button').name = "";
	$('back_button').value = "";
}

function reset_errors (form) {
	var elements = $(form).elements
	for (var i=0; i < elements.length; i++) {
		if (elements[i].type != "hidden") {
			elements[i].up(4).down().setStyle('color: #DC7600')
		};
	};
}

function remove_phone(index) {
	$('phone-' + index).fade({afterFinish: function(){
		$('phone-' + index).remove();
	}});
}

function mark_for_remove(index) {
	if (index.indexOf("new") != -1) {
		$('phone_' + index).remove();
	} else {
		$('phone_' + index + '_remove').value = 1;
	 	$('phone_' + index).fade();
	};
}

function menu() {
	$("salam").slideUp({afterFinisg: function(){
		$("m1-div").hide();
	}});
	$("menus").insert({top: '<a id="jing" href="#" class="mnu_sngl" onClick="$(\'jing\').hide();$(\'salam\').show();$(\'m1-div\').slideDown();">Menu Item 1</a>'})
}

function replace_content(id, content) {
	$(id).fade({afterFinish: function(){
		//$(id).hide();
		$(id).innerHTML = content;
		$(id).appear();
	}})
}

function show_loading(){
	$('head').scrollTo();
	$('success').hide();
	$('error-block').hide();
	$('loading').appear();
}

function show_success() {
	$('error-block').hide();
	$('loading').hide();
	$('success').show();
}

function go_to_page(event, el) {
	var key = event.which || event.keyCode;
	if(key == Event.KEY_RETURN) {
		window.location.href = "?page=" + el.value;
	}
}

function dont_submit(event) {
	var key = event.which || event.keyCode;
	if(key == Event.KEY_RETURN) {
		return false;
	}
	return key;
}

var count_down = 5;
function registration_count_down() {
	count_down -= 1;
	$('count_down').innerHTML = count_down;
	if (count_down > 0) {
		setTimeout("registration_count_down()", 1000);
	} else {
		window.location.href='/account';
	}
}