var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject){
	Sys.ie = ua.match(/msie ([\d.]+)/)[1];
}else if (document.getBoxObjectFor){
	Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1];
}else if (window.MessageEvent && !document.getBoxObjectFor){
	Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1];
}else if (window.opera){
	Sys.opera = ua.match(/opera.([\d.]+)/)[1];
}else if (window.openDatabase){
	Sys.safari = ua.match(/version\/([\d.]+)/)[1];
}

function clear(o){
	l = o.length;
	for(i = 0; i < l; i++){
		o.options[0] = null;
	}
}

function fullcity(obj, selectItem){
	var num = 0;
	for(i = 0; i < P.length; i++){
		for(j = 0; j < C[i].length; j++){
			if(Sys.ie && Sys.ie != '7.0'){
				obj.add(new Option(C[i][j], C[i][j], 0, 0));
				if(selectItem != '' && C[i][j] == selectItem){
					obj.options[num].selected = true;
				}
			}else{
				if(selectItem != '' && C[i][j] == selectItem){
					obj.add(new Option(C[i][j], C[i][j], 0, 1));
				}else{
					obj.add(new Option(C[i][j], C[i][j], 0, 0));
				}
			}
			num = num + 1;
		}
	}
}

function sdistrict(oj, v, selectItem){
	m = -1;
	n = -1;
	var num = 1;
	for(i = 0; i < P.length; i++){
		for(j = 0;j < C[i].length; j++){
			if(C[i][j] == v){
				m = i;
				n = j;
			}
		}
	}
	clear(oj);
	oj.add(new Option("全部区县", "全部区县"));
	if(m != -1 && n != -1){
		for(i = 0; i < D[m][n].length; i++){
			if(Sys.ie && Sys.ie != '7.0'){
				oj.add(new Option(D[m][n][i], D[m][n][i], 0, 0));
				if(selectItem != '' && D[m][n][i] == selectItem){
					oj.options[num].selected = true;
				}
			}else{
				if(selectItem != '' && D[m][n][i] == selectItem){
					oj.add(new Option(D[m][n][i], D[m][n][i], 0, i + 1));
				}else{
					oj.add(new Option(D[m][n][i], D[m][n][i], 0, 0));
				}
			}
			num = num + 1;
		}
	}
}

function sarea(oj, cv, dv, selectItem){
	if(dv == "全部区县"){
		clear(oj);
		oj.add(new Option("商圈", ""));
		var tmpArea = "";
		for(i = 0; i < P.length; i++){
			for(j = 0; j < C[i].length; j++){
				if(C[i][j] == cv){
					for(k = 0; k < D[i][j].length; k++){
						for(r = 0; r < A[i][j][k].length; r++){
							if(tmpArea.indexOf(A[i][j][k][r]) < 0){
								tmpArea = tmpArea + A[i][j][k][r];
								if(selectItem != '' && A[i][j][k][r] == selectItem){
									oj.add(new Option(A[i][j][k][r], A[i][j][k][r], 0, r + 1));
								}else{
									oj.add(new Option(A[i][j][k][r], A[i][j][k][r], 0, 0));
								}
							}
						}
					}
					break;
				}
			}
		}
	}else{//按区县绑定
		m = -1;
		n = -1;
		q = -1;
		for(i = 0; i < P.length; i++){
			for(j = 0; j < C[i].length; j++){
				if(C[i][j] == cv){
					for(k = 0; k < D[i][j].length; k++){
						if(D[i][j][k] == dv){
							m = i;
							n = j;
							q = k;
						}
					}
				}
			}
		}
		clear(oj);
		oj.add(new Option("商圈", ""));
		if(m != -1 && n != -1 && q != -1){
			for(r = 0; r < A[m][n][q].length; r++){
				if(selectItem != '' && A[m][n][q][r] == selectItem){
					oj.add(new Option(A[m][n][q][r], A[m][n][q][r], 0, r + 1));
				}else{
					oj.add(new Option(A[m][n][q][r], A[m][n][q][r], 0, 0));
				}
			}
		}
	}
}

function LoadJS(file){
	var head = document.getElementsByTagName('HEAD').item(0);
	var script = document.createElement('SCRIPT');
	script.src = file;
	script.type = "text/javascript";
	head.appendChild(script);
}

function fullprice(market,city){
	if(market == "企业持有" && city == "北京"){
		document.getElementById('spspan').innerHTML = "<select name='Strprice' class='input2 input_height' style='width:135px;margin-right:5px;'><option value='' selected>售价</option><option value='0-10000'>10000元/㎡ 以下</option><option value='10000-15000'>10000-15000元/㎡</option><option value='15000-20000'>15000-20000元/㎡</option><option value='20000-30000'>20000-30000元/㎡</option><option value='30000'>30000元/㎡ 以上</option></select>";
	}else if(market == "企业持有" && city == "天津"){
		document.getElementById('spspan').innerHTML = "<select name='Strprice' class='input2 input_height' style='width:135px;margin-right:5px;'><option value='' selected>售价</option><option value='5000-6000'>5000-6000元/㎡ 以下</option><option value='6000-8000'>6000-8000元/㎡</option><option value='8000-10000'>8000-10000元/㎡</option><option value='10000-12000'>10000-12000元/㎡</option><option value='12000'>12000元/㎡ 以上</option></select>";
	}else if(market == "企业持有" && city == "上海"){
		document.getElementById('spspan').innerHTML = "<select name='Strprice' class='input2 input_height' style='width:135px;margin-right:5px;'><option value='' selected>售价</option><option value='0-10000'>10000元/㎡ 以下</option><option value='10000-15000'>10000-15000元/㎡</option><option value='15000-20000'>15000-20000元/㎡</option><option value='20000-25000'>20000-25000元/㎡</option><option value='25000-35000'>25000-35000元/㎡</option><option value='35000'>35000元/㎡ 以上</option></select>";
	}else if(market == "企业持有" && city == "深圳"){
		document.getElementById('spspan').innerHTML = "<select name='Strprice' class='input2 input_height' style='width:135px;margin-right:5px;'><option value='' selected>售价</option><option value='0-20000'>20000元/㎡ 以下</option><option value='20000-30000'>20000-30000元/㎡</option><option value='30000-40000'>30000-40000元/㎡</option><option value='40000'>40000元/㎡ 以上</option></select>";
	}else if(market == "企业持有" && city == "东莞"){
		document.getElementById('spspan').innerHTML = "<select name='Strprice' class='input2 input_height' style='width:135px;margin-right:5px;'><option value='' selected>售价</option><option value='0-20000'>20000元/㎡ 以下</option><option value='20000-30000'>20000-30000元/㎡</option><option value='30000-40000'>30000-40000元/㎡</option><option value='40000'>40000元/㎡ 以上</option></select>";
	}
}

function search_shop(){
	if(document.form_shop.strCity.value == ''){
		alert('请选择城市！');
		return false;
	}else{
		form_shop.action = "/commerce/list.aspx";
		form_shop.target = "_blank";
	}
}