function ClearSelectOption(obj){
	obj.options.length=0;
}
function $$(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function GetLocation(ParentID,TargetID,SelectID){
	$$(TargetID).options.length=0;
	var data = "Action=GetLocation&ParentID="+ParentID+'&TargetID='+TargetID+'&SelectID='+SelectID;
	$.ajax({
		type: "GET",
		url: "/include/GetParameter.php",
		data: data,
		dataType: "json",
		success: GetLocationResponse
	});
	
}
function GetLocationResponse(Result){
	
	var data = Result;
	var TargetID = data['TargetID'];
	var SelectID = data['SelectID'];
	var counter =  data['Data'] ? data['Data'].length : 0;
	if(!TargetID) return false;
	var obj = $$(TargetID);
	if(data['Code']=='succ'){
		obj.options[0] = new Option(' - 请选择 - ',"");
		for(var i=0;i<counter;i++){
			obj.options[i+1] = new Option(data['Data'][i].AreaName,data['Data'][i].AreaID);
			if(SelectID&&(parseInt(data['Data'][i].AreaID)==parseInt(SelectID))){
				obj.options[i+1].selected = true;
			}
		}
		if(counter){
			if(obj.style.display=='none'){
				obj.style.display='block';
			}		
		}
		else{
			obj.style.display='none';
		}
	}

}
