<!--
/*===========================================================================*/
/* (c)copyright 2000-2004 FreeSky & liqwei                                   */
/*  Email:liqwei#liqwei.com                                                  */
/*  WebSite: http://www.liqwei.com/                                          */
/*  Oicq: 20865662                                                           */
/*  Icq: 309675035                                                           */
/*  Msn: liqweijack#hotmail.com                                              */
/*  Yahoo M.: liqweijack#yahoo.com                                           */
/*===========================================================================*/

//===========================================================================
function initRoot(defaultRootId){
	var rootId = document.getElementById("rootId");
	var array = trim(SendRequest("http://www.uei114.com/system/category/0.js", false)).split("|");
	with(rootId){
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultRootId==array[i]){ options[j].selected=true; }
		}		
	}
}

function changeRoot(defaultParentId){
	var rootId = document.getElementById("rootId");
	var parentId = document.getElementById("parentId");
	var catalogId = document.getElementById("catalogId");
	
	if(isEmpty(rootId.value)){ 
		with(parentId){
			while(length>0)
				remove(0);
			options[0]=new Option("选择二级分类", "");
		}
		if(catalogId != null){
			with(catalogId){
				while(length>0)	
					remove(0);
				options[0]=new Option("选择三级分类", "");
			}	
		}
		changeCategory();
		return ;
	}
	var array = trim(SendRequest("http://www.uei114.com/system/category/"+ rootId.value +".js", false)).split("|");
	with(parentId){
		while(length>0)
				remove(0);
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultParentId==array[i]){ options[j].selected=true; }
		}		
	}
	if(catalogId != null){
		with(catalogId){
			while(length>0)	
				remove(0);
			options[0]=new Option("选择三级分类", "");
		}	
	}
	changeCategory();
	return;
}

function changeParent(defaultCatalogId){
	var parentId = document.getElementById("parentId");
	var catalogId = document.getElementById("catalogId");
	
	if(isEmpty(parentId.value)){ 
		with(catalogId){
			while(length>0)
				remove(0);
			options[0]=new Option("选择三级分类", "");
		}
		changeCategory();
		return;
	}
	var array = trim(SendRequest("http://www.uei114.com/system/category/"+ parentId.value +".js", false)).split("|");
	with(catalogId){
		while(length>0)
				remove(0);
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultCatalogId==array[i]){ options[j].selected=true; }
		}		
	}
	changeCategory();
	return;
}

function changeCatalog(){
	return changeCategory();
}

function changeCategory(){
	var rootId = document.getElementById("rootId");
	var parentId = document.getElementById("parentId");
	var catalogId = document.getElementById("catalogId");
	var categoryId = document.getElementById("categoryId");
	
	if(categoryId == null) return;
	if(!isEmpty(catalogId.value)) categoryId.value=catalogId.value;
	else if(!isEmpty(parentId.value)) categoryId.value=parentId.value;
	else if(!isEmpty(rootId.value)) categoryId.value=rootId.value;
	else categoryId.value = "";
	return;
}
//===========================================================================
function initProvince(defaultProvinceId){
	var provinceId = document.getElementById("provinceId");
	var array = trim(SendRequest("http://www.uei114.com/system/location/0.js", false)).split("|");
	with(provinceId){
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultProvinceId==array[i]){ options[j].selected=true; }
		}
	}
}

function changeProvince(defaultCityId){
	var provinceId = document.getElementById("provinceId");
	var cityId = document.getElementById("cityId");
	var countyId = document.getElementById("countyId");
	
	if(isEmpty(provinceId.value)){
		with(cityId){
			while(length>0)
				remove(0);		
			options[0]=new Option("选择城市", "");
		}	
		with(countyId){
			while(length>0)
				remove(0);		
			options[0]=new Option("选择区县", "");
		}	
		changeLocation();
		return ;
	}
	var array = trim(SendRequest("http://www.uei114.com/system/location/"+ provinceId.value + ".js", false)).split("|");
	with(cityId){
		while(length>0)
			remove(0);
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultCityId==array[i]){ options[j].selected=true; }
		}
	}
	with(countyId){
		while(length>0)
			remove(0);		
		options[0]=new Option("选择区县", "");
	}
	changeLocation();
	return ;
}

function changeCity(defaultCountyId){
	var cityId = document.getElementById("cityId");
	var countyId = document.getElementById("countyId");
	
	if(isEmpty(cityId.value)){
		with(countyId){
			while(length>0)
				remove(0);		
			options[0]=new Option("选择区县", "");
		}	
		changeLocation();
		return ;
	}
	var array = trim(SendRequest("http://www.uei114.com/system/location/"+ cityId.value + ".js", false)).split("|");
	with(countyId){
		while(length>0)
			remove(0);
		for(i=0, j=0; i<array.length; i+=2, j++){
			options[j]=new Option(array[i+1], array[i]);
			if(defaultCountyId==array[i]){ options[j].selected=true; }
		}
	}
	changeLocation();
	return ;
}

function changeCounty(){
	return changeLocation();
}

function changeLocation(){
	var provinceId = document.getElementById("provinceId");
	var cityId = document.getElementById("cityId");
	var countyId = document.getElementById("countyId");
	var locationId = document.getElementById("locationId");
	
	if(locationId == null) return;
	if(!isEmpty(countyId.value)) locationId.value=countyId.value;
	else if(!isEmpty(cityId.value)) locationId.value=cityId.value;
	else if(!isEmpty(provinceId.value)) locationId.value=provinceId.value;
	else locationId.value = "";
	return;
}
//===========================================================================【图片处理】
// 自动缩放图片在指定大小范围之内，针对 img 标签；
function zoomImage(imageHaddle, maxWidth, maxHeight){
	if(imageHaddle.width>0 && imageHaddle.height>0){
		var rate, isSelectWidth;
		if(maxWidth>0 && maxHeight>0){		
			isSelectWidth = (maxWidth/imageHaddle.width > maxHeight/imageHaddle.height);
			rate = isSelectWidth?(maxHeight/imageHaddle.height):(maxWidth/imageHaddle.width);			
		}else if(maxWidth < 0){
			isSelectWidth = false;
			rate = (maxHeight-imageHaddle.height)>0?1:maxHeight/imageHaddle.height;
		}else if(maxHeight < 0){
			isSelectWidth = false;
			rate = (maxWidth-imageHaddle.width)>0?1:maxWidth/imageHaddle.width;
		}
		if(rate < 1){
			if(isSelectWidth){
				imageHaddle.width = imageHaddle.width*rate;
			}else{
				imageHaddle.height = imageHaddle.height*rate;
			}
		}
	}
}
//===========================================================================【Cookie读写】
function getCookie(name) {
  var value = "";
  if(document.cookie.length > 0){
	  var prefix = name + "="; 
	  var begin = document.cookie.indexOf(prefix);
	  if (begin != -1) {
			begin += prefix.length;
			var end = document.cookie.indexOf(";", begin);
			if (end == -1)	end = document.cookie.length;
			value = unescape(document.cookie.substring(begin, end));
	  }
  }
  return value;
}

function setCookie(name, value){
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null){
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}
//===========================================================================
// 功能：添加到收藏夹；
function addFavorite(url, urlName){
	var len = addFavorite.arguments.length;
	if(len<2){ 
		url = "http://www.uei114.com";
		urlName = "锐索黄页网 - 提供面向中国企业的商务黄页垂直搜索服务";
	}
	window.external.AddFavorite(url, urlName);
}
// 功能：设置主页；
function setHomepage(obj){
	url = "http://www.uei114.com";
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage(url);
}
-->