//代理城市列表
var menuList=new Array();
menuList[1]="<a href='download_dalian.shtml'>大　连</a>";
menuList[2]="<a href='download_jilin.shtml'>吉　林</a>";
menuList[3]="<a href='download_liaoyang.shtml'>辽　阳</a>";
menuList[4]="<a href='download_nanyang.shtml'>南　阳</a>";
menuList[5]="<a href='download_lijiang.shtml'>丽　江</a>";
menuList[6]="<a href='download_yunnan.shtml'>昆　明</a>";
menuList[7]="<a href='download_jinhua.shtml'>金　华</a>";
menuList[8]="<a href='download_linyi.shtml'>临　沂</a>";
menuList[9]="<a href='download_nantong.shtml'>南　通</a>";
menuList[10]="<a href='download_xiangfan.shtml'>襄　樊</a>";
menuList[11]="<a href='download_suqian.shtml'>宿　迁</a>";
menuList[12]="<a href='download_yancheng.shtml'>盐　城</a>";
menuList[13]="<a href='download_chengdu.shtml'>成　都</a>";
menuList[14]="<a href='download_sanmenxia.shtml'>三门峡</a>";
menuList[15]="<a href='download_shenyang.shtml'>沈　阳</a>";
menuList[16]="<a href='download_changchun.shtml'>长　春</a>";
menuList[17]="<a href='download_fuzhou.shtml'>抚　州</a>";
menuList[18]="<a href='download_taizhou.shtml'>泰　州</a>";
menuList[19]="<a href='download_huaian.shtml'>淮　安</a>";
menuList[20]="<a href='download_anyang.shtml'>安　阳</a>";
menuList[21]="<a href='download_dezhou.shtml'>德　州</a>";
menuList[22]="<a href='download_shijiazhuang.shtml'>石家庄</a>";
menuList[23]="<a href='download_haerbin.shtml'>哈尔滨</a>";
menuList[24]="<a href='download_wuhan.shtml'>武　汉</a>";
menuList[25]="<a href='download_yantai.shtml'>烟　台</a>";
menuList[26]="<a href='download_hangzhou.shtml'>杭　州</a>";
menuList[27]="<a href='download_jinan.shtml'>济　南</a>";
menuList[28]="<a href='download_yulin.shtml'>榆　林</a>";
menuList[29]="<a href='download_panzhihua.shtml'>攀枝花</a>";
menuList[30]="<a href='download_tielu.shtml'>铁　路</a>";
menuList[31]="<a href='download_xuchang.shtml'>许　昌</a>";
menuList[32]="<a href='download_binzhou.shtml'>滨　州</a>";
menuList[33]="<a href='download_beijing.shtml'>北　京</a>";
menuList[34]="<a href='download_wenzhou.shtml'>温　州</a>";
menuList[35]="<a href='download_qiqihaer.shtml'>齐齐哈尔</a>";
menuList[36]="<a href='download_tangshan.shtml'>唐　山</a>";
menuList[37]="<a href='download_yinchuan.shtml'>银　川</a>";
menuList[38]="<a href='download_hegang.shtml'>鹤　岗</a>";
menuList[39]="<a href='download_jiamusi.shtml'>佳木斯</a>";
menuList[40]="<a href='download_rizhao.shtml'>日　照</a>";
menuList[41]="<a href='download_jining.shtml'>济　宁</a>";
menuList[42]="<a href='download_yangzhou.shtml'>扬　州</a>";
menuList[43]="<a href='download_taizhou1.shtml'>台　州</a>";
menuList[44]="<a href='download_tianjin.shtml'>天　津</a>";
menuList[45]="<a href='download_wenling.shtml'>温　岭</a>";

var menuList2=new Array();
menuList2[1]="<a href='download_beijing.shtml'>北　京</a>";
menuList2[2]="<a href='download_fujian.shtml'>福　建</a>";
menuList2[3]="<a href='download_guangzhou.shtml'>广　州</a>";
menuList2[4]="<a href='download_langfang.shtml'>廊　坊</a>";
menuList2[5]="<a href='download_shanghai.shtml'>上　海</a>";
menuList2[6]="<a href='download_wenzhou.shtml'>温　州</a>";

function agentcity1 () {
document.writeln("&nbsp;|&nbsp;");
for(i=1;i<menuList.length;i++)
	{
     document.writeln(menuList[i]);
     document.writeln("&nbsp;|&nbsp;");	
		if(i%7==0) {document.writeln("<br>&nbsp;|&nbsp;");}
	}
}

function agentcity2 () {
document.writeln("&nbsp;|&nbsp;");
for(i=1;i<menuList2.length;i++)
	{
     document.writeln(menuList2[i]);
     document.writeln("&nbsp;|&nbsp;");
		if(i%7==0) {document.writeln("<br>&nbsp;|&nbsp;");}
	}
}

function showcitylist() {
	city_list.style.visibility="visible";
}

//模仿像册的图片下载浏览功能
var loadingImage = 'loading.gif';		
var closeButton = 'close.gif';		

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}



//function getKey(e){
//	if (e == null) { // ie
//		keycode = event.keyCode;
//	} else { // mozilla
//		keycode = e.which;
//	}
//	key = String.fromCharCode(keycode).toLowerCase();
//	
//	if(key == 'x'){ hideLightbox(); }
//}


//function listenKey () {	document.onkeypress = getKey; }

function showLightbox(objLink)
{
	var objOverlay = document.getElementById('overlay');
	var objLightbox = document.getElementById('lightbox');
	var objCaption = document.getElementById('lightboxCaption');
	var objImage = document.getElementById('lightboxImage');
	var objLoadingImage = document.getElementById('loadingImage');
	var objLightboxDetails = document.getElementById('lightboxDetails');
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}

	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

	imgPreload = new Image();

	imgPreload.onload=function(){
		objImage.src = objLink.href;

		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";

		objLightboxDetails.style.width = imgPreload.width + 'px';
		
		if(objLink.getAttribute('title')){
			objCaption.style.display = 'block';
			//objCaption.style.width = imgPreload.width + 'px';
			objCaption.innerHTML = objLink.getAttribute('title');
		} else {
			objCaption.style.display = 'none';
		}
		
		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (objLoadingImage) {	objLoadingImage.style.display = 'none'; }

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

	
		objLightbox.style.display = 'block';

		// After image is loaded, update the overlay height as the new image might have
		// increased the overall page height.
		arrayPageSize = getPageSize();
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		
		// Check for 'x' keypress
//		listenKey();

		return false;
	}
	imgPreload.src = objLink.href;
}

function hideLightbox()
{
	objOverlay = document.getElementById('overlay');
	objLightbox = document.getElementById('lightbox');

	objOverlay.style.display = 'none';
	objLightbox.style.display = 'none';

	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}

	document.onkeypress = '';
}

function initLightbox()
{
	
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")){
			anchor.onclick = function () {showLightbox(this); return false;}
		}
	}

	var objBody = document.getElementsByTagName("body").item(0);

	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {hideLightbox(); return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	var imgPreloader = new Image();
	
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		imgPreloader.onload=function(){};

		return false;
	}

	imgPreloader.src = loadingImage;

	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';	
	objBody.insertBefore(objLightbox, objOverlay.nextSibling);

	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Click to close');
	objLink.onclick = function () {hideLightbox(); return false;}
	objLightbox.appendChild(objLink);

	// preload and create close button image
	var imgPreloadCloseButton = new Image();

	// if close button image found, 
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.position = 'absolute';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;

	// create image
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	
	// create details div, a container for the caption and keyboard message
	var objLightboxDetails = document.createElement("div");
	objLightboxDetails.setAttribute('id','lightboxDetails');
	objLightbox.appendChild(objLightboxDetails);

	// create caption
	var objCaption = document.createElement("div");
	objCaption.setAttribute('id','lightboxCaption');
	objCaption.style.display = 'none';
	objLightboxDetails.appendChild(objCaption);

	// create keyboard message
//	var objKeyboardMsg = document.createElement("div");
//	objKeyboardMsg.setAttribute('id','keyboardMsg');
//	objKeyboardMsg.innerHTML = 'press <kbd>x</kbd> to close';
//	objLightboxDetails.appendChild(objKeyboardMsg);


}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

addLoadEvent(initLightbox);