
jQuery.ajaxSetup( {
	cache : false
});
var tino_form_options = {
	target : '#msg', // target element(s) to be updated with server response 
	beforeSubmit : showRequest, // pre-submit callback 
	success : showResponse
// post-submit callback

// other available options:
// url: url // override for form's 'action' attribute
// type: type // 'get' or 'post', override for form's 'method' attribute
// dataType: null // 'xml', 'script', or 'json' (expected server response type)
// clearForm: true // clear all form fields after successful submit
// resetForm: true // reset the form after successful submit

// $.ajax options can be used here too, for example:
// timeout: 3000
};
function showRequest(formData, jqForm, options) {

	var queryString = $.param(formData);
	//alert('About to submit: \n\n' + queryString);
	return true;
}
function showResponse(responseText, statusText) {
	/*
	alert('status: '
			+ statusText
			+ '\n\nresponseText: \n'
			+ responseText
			+ '\n\nThe output div should have already been updated with the responseText.');
	 */
}

function ok_url(url)
{
	location.href=url;
}

function set_value(id_1,id)
{
	$('#'+id).val($('#'+id_1).val());
}
function coutry_set_value(obj,url,id,hiddenid,val)
{
	$('#'+hiddenid).val(0);
	
	$.ajax({
		type: "get",
		url: url+"/?m=region",
		data:{a:"country",val:val,pid:$(obj).val()},
		beforeSend: function(XMLHttpRequest){
			//ShowLoading();
			cityLoading(document.getElementById(id));
		},
		success: function(data, textStatus){
			addOptionGroup(document.getElementById(id),data);
		},
		complete: function(XMLHttpRequest, textStatus){
			//HideLoading();
		},
		error: function(){
			//请求出错处理
			$('#'+hiddenid).val(0);
		}
	});

}
function cityLoading(obj)
{
    obj.length = 0;
    addOption(obj, "请稍后...", "-1");
    obj.disabled = true;
}
function addOptionGroup(obj,str)
{
	obj.disabled = false;
 
    var optGroup = str.split(",");
    obj.length = 0;

    for (i=0; i<optGroup.length; i++)
    {
        if(optGroup[i]!="")
        {
            var opt = optGroup[i].split("|");
            addOption(obj, opt[0], opt[1]);
        }
    }
}
function addOption(obj,txt,val)
{
    var option = document.createElement("option");
    option.text= txt;
    option.value=val;
    obj.options.add(option);
}