/**
 * Anthanh Javascript
 * 
 * @param url
 * @return
 */

function formSubmit(url) {
	if (document.forms['_anthanh_form_']) {
		document.body.removeChild(document.forms['_anthanh_form_']);
	}
	var form = document.createElement("form");
	form.setAttribute("name", "_anthanh_form_");
	if (location.href.indexOf("https") != -1)
		form.setAttribute("method", "get");
	else
		form.setAttribute("method", "post");

	document.body.appendChild(form);

	if (url.indexOf("?") < 0) {
		form.setAttribute("action", url);
		form.submit();
	} else {
		var arg = url.split("?");
		form.setAttribute("action", arg[0]);
		arg = arg[1].split("&");
		var input;
		var xxx;
		for ( var i = 0; i < arg.length; i++) {
			xxx = arg[i].indexOf("=");
			input = document.createElement("input");
			input.setAttribute("type", "hidden");
			input.setAttribute("name", arg[i].substring(0, xxx));
			input.setAttribute("value", arg[i]
					.substring(xxx + 1, arg[i].length));
			form.appendChild(input);
		}
		form.submit();
	}
}

function linkToURL(url) {
	location.href = url;
}

(function($) {
	$.extend( {
		getGo : function(url, params) {
			document.location = url + '?' + $.param(params);
		},
		postGo : function(url, params) {
			var $form = $("<form>").attr("method", "post").attr("action", url);
			$.each(params, function(name, value) {
				$("<input type='hidden'>").attr("name", name).attr("value",
						value).appendTo($form);
			});
			$form.appendTo("body");
			$form.submit();
		}
	});
})(jQuery);

function goBack() {
	history.go(-1);
}

