School = {
	request_path : "/job01/admin/",
	submit_school : function(){
		var s_id = $('school_id').value.Trim();
		var s_name = $('school_name').value.Trim();
		var s_parent = $('school_parent').value.Trim();

		if( s_name.length == 0||s_parent.length == 0){
			alert( "请输入正确的内容!" );
			return false;
		}
		var param = String.format( "action=add_school&s_name={0}&s_parent={1}" , s_name , s_parent);
		param = s_id.length == 0 ? param : String.format( "{0}&s_id={1}" , param , s_id );

		new Ajax.Request(String.format( '{0}province.php' , School.request_path ),{
			method : 'post',
			parameters : param,
			onSuccess : function(response){
				if(response.responseText == true){
					window.location.reload();
				}else{
					alert(response.responseText);
				}
			}
		});
	},
	modify_school : function( s_id ){
		new Ajax.Request(String.format( '{0}province.php' , School.request_path ),{
			method : 'post',
			parameters : String.format( "action=modify&s_id={0}" , s_id ),
			onSuccess : function(response){
				if(response.responseText != false){
					eval( String.format( "result = {0}" , response.responseText ) );					
					$('school_id').value = result['s_id'];
					$('school_name').value = result['s_name'];
					$('school_parent').value = result['s_parent'];
					$( 'form' ).style.display = "block";
				}else{
					alert("Error");
				}
			}
		});
	},
		change_school : function( s_id , s_status ){	
		if( s_status == 'del' )
			if( confirm( "您确认删除此课程吗？" ) == false )
				return false;
		new Ajax.Request( String.format( '{0}province.php' , School.request_path ),{
			method: 'post',
			parameters: String.format( 'action=change_school&s_id={0}&s_status={1}' , s_id , s_status ),
			onSuccess: function(response){
				if(response.responseText == true){
					window.location.reload();
				}else{
					alert(response.responseText);
				}
			}
		});
	},
		submit_area : function(){
		var s_id = $('school_id').value.Trim();
		var s_name = $('school_name').value.Trim();
		var s_parent = $_GET['s_parent'];

		if( s_name.length == 0||s_parent.length == 0){
			alert( "请输入正确的内容!" );
			return false;
		}
		var param = String.format( "action=add_school&s_name={0}&s_parent={1}" , s_name , s_parent);
		param = s_id.length == 0 ? param : String.format( "{0}&s_id={1}" , param , s_id );

		new Ajax.Request(String.format( '{0}area.php' , School.request_path ),{
			method : 'post',
			parameters : param,
			onSuccess : function(response){
				if(response.responseText == true){
					window.location.reload();
				}else{
					alert(response.responseText);
				}
			}
		});
	},
	submit_point : function(){
		var p_id = $('point_id').value.Trim();
		var p_name = $('point_name').value.Trim();
		var p_address = $('point_address').value.Trim();

		if( p_name.length == 0||p_address.length == 0){
			alert( "请输入正确的内容!" );
			return false;
		}
		var param = String.format( "action=add_point&p_name={0}&p_address={1}" , p_name , p_address);
		param = p_id.length == 0 ? param : String.format( "{0}&p_id={1}" , param , p_id );

		new Ajax.Request(String.format( '{0}point.php' , School.request_path ),{
			method : 'post',
			parameters : param,
			onSuccess : function(response){
				if(response.responseText == true){
					window.location.reload();
				}else{
					alert(response.responseText);
				}
			}
		});
	},
		modify_point : function( p_id ){
		new Ajax.Request(String.format( '{0}point.php' , School.request_path ),{
			method : 'post',
			parameters : String.format( "action=modify&p_id={0}" , p_id ),
			onSuccess : function(response){
				if(response.responseText != false){
					eval( String.format( "result = {0}" , response.responseText ) );					
					$('point_id').value = result['p_id'];
					$('point_name').value = result['p_name'];
					$('point_address').value = result['p_address'];
				}else{
					alert("Error");
				}
			}
		});
	},
		change_point : function( p_id , p_status ){	
		if( p_status == 'del' )
			if( confirm( "您确认删除此代办点吗？" ) == false )
				return false;
		new Ajax.Request( String.format( '{0}point.php' , School.request_path ),{
			method: 'post',
			parameters: String.format( 'action=change_point&p_id={0}&p_status={1}' , p_id , p_status ),
			onSuccess: function(response){
				if(response.responseText == true){
					window.location.reload();
				}else{
					alert(response.responseText);
				}
			}
		});
	}
}