// JavaScript Document

String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.HTMLEncode = function()
{
	var s=this;
	if (s == null)
		return '';
	s = s.replace(/ /g,"&nbsp;");
	s = s.replace(/\n/g,"<br>");
	s = s.replace(/</g, '&lt;');
	s = s.replace(/>/g, '&gt;');
	s = s.replace(/&/g, '&amp;');
	s = s.replace(/"/g, '&quot;');
	//s = s.replace(/&reg;/g, '?');
	//s = s.replace(/&copy;/g, '?');
	//s = s.replace(/&trade;/g, '?');
	//s = s.replace(/\s/g, '&nbsp;');
	return s;
}

String.prototype.ClearStyle = function()
{
	var s=this;
	while(s.indexOf('<') >=0 && s.indexOf('>') >= 0){
		s = s.replace(/<[^<^>]*>/g, "");
	}
	return s;
}

String.prototype.HTMLDecode = function()
{
	var s=this;
	if (s == null)
		return '';
	s = s.replace(/&lt;/g, '<');
	s = s.replace(/&gt;/g, '>');
	s = s.replace(/&amp;/g, '&');
	s = s.replace(/&quot;/g, '"');
	s = s.replace(/&reg;/g, '?');
	s = s.replace(/&copy;/g, '?');
	s = s.replace(/&trade;/g, '?');
	s = s.replace(/&nbsp;/g, ' ');
	return s;
}

String.prototype.HTMLInputValueEncode = function()
{
	var s=this;
	if (s == null)
		return '';
//	s = s.replace(/ /g,"&nbsp;");
//	s = s.replace(/\n/g,"<br>");
	s = s.replace(/</g, '&lt;');
	s = s.replace(/>/g, '&gt;');
//	s = s.replace(/&/g, '&amp;');
	s = s.replace(/"/g, '&quot;');
	//s = s.replace(/&reg;/g, '?');
	//s = s.replace(/&copy;/g, '?');
	//s = s.replace(/&trade;/g, '?');
	//s = s.replace(/\s/g, '&nbsp;');
	return s;
}


/*String.prototype.HTMLEncode = function()
{
	var s=this;
	if (s == null)
		return '';
	//s = s.replace(/</g, '&lt;');
	//s = s.replace(/>/g, '&gt;');
	//s = s.replace(/&/g, '&amp;');
	s = s.replace(/"/g, '&quot;');
	//s = s.replace(/&reg;/g, '?');
	//s = s.replace(/&copy;/g, '?');
	//s = s.replace(/&trade;/g, '?');
	s = s.replace(/\s/g, '&nbsp;');
	return s;
}
*/
String.prototype.TitleEncode = function()
{
	return this.replace(/"/g,'&quot;');
}

String.prototype.JSStringEncode = function()
{
	return this.replace(/'/g,'\\\'');
}


String.prototype.Keywords = function()
{
	var s = this;
	var ah='<a href="javascript:void(0)" onmouseover="this.style.color=\'#003399\';" onmouseout="this.style.color=\'\';" onclick="NewSearch(this.innerText,this.innerText);">';
	var ae='</a>';
	s = s.replace(/，/g,',');
	s = s.replace(/(^\s*)|(\s*$)/g, "");
	s = s.replace(/(^,*)|(,*$)/g, "");
	if (s != ''){
		s = s.replace(/,/g,ae+','+ah);
		s = ah+s+ae;
	}
	
	return s;
}


CombineObject = function(object1, object2, override){
	var name;
	if (override == null){
		override = true;
	}
	for (name in object2){
		if (object1[name] == null || override == true)
			object1[name] = object2[name];
	}
}

function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;
      
    elements.push(element);
  }
  
  return elements;
}

function LoadPng(target,src,sizingMethod, property){
	target.onload = null;
	var width, height;
	if (sizingMethod == null)
		sizingMethod = 'image';
	//if (property != null){
		//if (property.width != null){
		//	width = property.width;
		//}else{
			width = target.width;
		//}
		//if (property.height != null){
		//	height = property.height;
		//}else{
			height = target.height;
		//}
	//}
	if (navigator.appName == 'Microsoft Internet Explorer'){
		//alert(target.src+'|'+src+'|'+height);
//		alert();
		target.src='images/space.gif';
		var oDiv = document.createElement("DIV")
		oDiv.style.width=height+'px';
		oDiv.style.height=height+'px';;
		oDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='"+sizingMethod+"'";
		target.applyElement(oDiv , "outside");
		
	}else{
		if (target.src.substring(target.src.length-src.length,target.src.length) != src){
			target.src = src;
		}
	}
}

function $reload() { document.location.reload(true); }


function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}


function ResizeImage(image, newWidth, newHeight){
	var newImage = document.createElement("img");
	newImage.src=image.src;/*
	var currentScale = newImage.width/newImage.height;
	var targetScale = newWidth/newHeight;
	if (newImage.width<=newWidth && newImage.height<=newHeight){
		image.width = newImage.width;
		image.height = newImage.height;
	}else if (currentScale > targetScale){
		image.width = newWidth;
		image.height = newImage.height*(newWidth/newImage.width);
	}else if (currentScale <targetScale){
		image.height = newHeight;
		image.width = newImage.width*(newHeight/newImage.height);
	}else{
		image.width = newWidth;
		image.height = newHeight;
	}*/
	if (newImage.width > newWidth){
		newImage.height = newWidth / newImage.width * newImage.height;
		newImage.width = newWidth;
	}
	if (newImage.height > newHeight){
		newImage.width = newHeight / newImage.height * newImage.width;
		newImage.height = newHeight;
	}
	image.width = newImage.width;
	image.height = newImage.height;
	//alert(image.src);
}


function NewRequest(responseObject,loadingLayer,displayLoading){
	var CDate = new Date();
	var CT = CDate.getTime();
	if (refreshPool.length>0){
		if (CT <= refreshPool[refreshPool.length-1][0]){
			CT = refreshPool[refreshPool.length-1][0]+1;
		}
	}
	if (loadingLayer == null)
		loadingLayer = responseObject;
	if (displayLoading != false)
		displayLoading = true;
	refreshPool.push([CT, responseObject, loadingLayer, displayLoading]);
	if (displayLoading == true){
		if (loadingLayer != null && loadingLayer.nodeName == 'DIV'){
			responseObject.loadProcess = 'start';
			NewLoading(loadingLayer);
			//DelayCall(function (){NewLoading(loadingLayer);});
		}
	}
	return CT;
}

function GetResponseObject(CT){
	var loop;
	var responseObject, loadingLayer, displayLoading;
	for (loop=0;loop<refreshPool.length;loop++){
		if 	(refreshPool[loop][0] == CT){
			responseObject = CheckRefreshState(refreshPool[loop][1],CT);
			if (responseObject != null)
				loadingLayer = refreshPool[loop][2];
				displayLoading = refreshPool[loop][3];
				refreshPool.splice(loop,1);
				responseObject.loadProcess = 'complete';
				if (displayLoading == true)
					LoadComplete(loadingLayer);
		}
	}
	return responseObject;
}


function CheckRefreshState(object,CT){
	if (object != null){
		if (object.CT <= CT || object.CT == null){
			object.CT=CT;
		}else{
			object = null;
		}
	}
	return object;
}

function NewLoading(loadObject){
	//alert(loadObject.loadProcess);
	//if (ExistLoading(loadObject) || loadObject.loadProcess != 'start'){
		//return;
	//}
	if (loadObject.loading != null)
		return;
	/*
	var loading=document.createElement("div");
	loading.id="DLoading";
	loading.style.position="absolute";
	//alert(loadObject.offsetWidth-50);
	loading.style.width = ((loadObject.offsetWidth-4) > 0 ? (loadObject.offsetWidth-4) : (loadObject.offsetWidth))+'px';
	loading.style.height = ((loadObject.offsetHeight-4) > 0 ? (loadObject.offsetHeight-4) : (loadObject.offsetHeight))+'px';
	//loading.style.height = (loadObject.offsetHeight-50)+'px';
	//loading.style.width = '50px';
	//loading.style.height = '50px';
	loading.style.left='0px';
	loading.style.top='0px';
	loading.style.backgroundColor="#FFFFFF";
	loading.style.filter="alpha(opacity=70)";
	loading.style.opacity = "0.7";
	loading.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=70);alpha(opacity=70)";
	
	var loadingImage=document.createElement("div");
	loadingImage.id="DLoadingImage";
	loadingImage.style.position="absolute";
	var right=loadObject.offsetWidth/2-16;
	var top=loadObject.offsetHeight/2-16;
	if (right < 0)
		right = 0;
	if (top < 0)
		top = 0;
	if (top>100)
		top=100;
	loadingImage.style.right=right+"px";
	loadingImage.style.top=top+"px";
	loadingImage.style.width="32px";
	loadingImage.style.height="32px";
	loadingImage.innerHTML='<img border="0" width="32" height="32" src="images/loading.gif" />';
	loading.appendChild(loadingImage);*/
	
	var width = ((loadObject.offsetWidth-4) > 0 ? (loadObject.offsetWidth-4) : (loadObject.offsetWidth))+'px';
	var height = ((loadObject.offsetHeight-4) > 0 ? (loadObject.offsetHeight-4) : (loadObject.offsetHeight))+'px';
	var right=loadObject.offsetWidth/2-16;
	var top=loadObject.offsetHeight/2-16;
	if (right < 0)
		right = 0;
	if (top < 0)
		top = 0;
	if (top>100)
		top=100;
	//alert(height);
	//alert(loadObject.offsetHeight);
	//var loading = NewElement('div', 'DLoading', 'CPA', {width:width, height:height, backgroundColor:'#FFFFFF', filter:'alpha(opacity=70)', opacity:'0.7', filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=70);alpha(opacity=70)'});
	var loading = NewElement('div', 'DLoading', 'CPA CT0 CL0', {width:width, height:height, backgroundColor:'#FFFFFF', filter:'alpha(opacity=70)', opacity:'0.7', filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=70);alpha(opacity=70)'});

		var loadImage = NewImage('images/loading.gif', 32, 32, 0, 'CPA', {right:right+'px', top:top+'px'});
		loading.appendChild(loadImage);
	loadObject.appendChild(loading);
	loadObject.loading=loading;
//		alert('load');

}

function LoadComplete(loadObject){
	var loading = loadObject.loading;
	if (loading != null)
		loadObject.removeChild(loading);
	loadObject.loading = null;
}

function ExistLoading(object){
	var div = object.getElementsByTagName('DIV');
	var i;
	for (i=0;i<div.length;i++){
		if (div[i].id == 'DLoading'){
			return true;
		}
	}
	return false;
}



function GetResult(XML){
	var state = XML.childNodes[0];
	var request = XML.childNodes[1];
	var response = XML.childNodes[2];
	var action = GetNodeText(state.childNodes[0]);
	var success = GetNodeText(state.childNodes[1]);
	var message = GetNodeText(state.childNodes[2]);
	if (success == 'true'){
		success = true;
	}else{
		success = false;
	}
	var result = {action:action, success:success, message:message, request:request, response:response};
	return result;
}


function TextAndInputHTML(mainProperty, headProperty, bodyProperty, inputProperty, textProperty){
	if (mainProperty == null)
		mainProperty = {};
	if (headProperty == null)
		headProperty = {};
	if (bodyProperty == null)
		bodyProperty = {};
	if (inputProperty == null)
		inputProperty = {};
	if (textProperty == null)
		textProperty = {};
	var mainStyleHTML = 'width:auto;height:16px;';
	//mainStyle.Add(mainProperty.style);

	var headStyleHTML = 'width:auto;height:16px;font-size:12px;line-height:16px;';
	//headStyle.Add(headProperty.style);
	var headText = headProperty.text == null ? '' : headProperty.text;
	
	var bodyStyleHTML = 'width:auto;color:#000000;';
	//bodyStyle.Add(bodyProperty.style);
	//var bodyName = bodyProperty.name == null ? '' : bodyProperty.name;
	//var bodyStyle = bodyProperty.style == null ? '' : bodyProperty.style;
	//var defaultText = bodyProperty.defaultText == null ? '' : bodyProperty.defaultText;
	//var blankString = bodyProperty.blankString == null ? '' : bodyProperty.blankString;
	//var replaceBlankString = bodyProperty.replaceBlankString == null ? '' : bodyProperty.replaceBlankString;
	
	//var singleLine = inputProperty.singleLine != false ? true : false;
	var inputStyleHTML = 'width:200px;height:12px;font-size:12px;line-height:12px;';
	//inputStyle.Add(inputProperty.style);
	
	var inputName = inputProperty.name == null ? 'input' : inputProperty.name;
	
	
	var textStyleHTML = 'max-width:200px;word-break:break-all;';
	var HTML = '';
	HTML = '<div id="DTIMain" class="CPR CT0 CL0" style="'+mainStyleHTML+'">';
		HTML += '<div id="DTIHead" class="CPR CL" style="'+headStyleHTML+'">'+headText+'</div>';
		HTML += '<div id="DTIBody" class="CPR CL" style="'+bodyStyleHTML+'">';
			HTML += '<div id="DTIText" class="CPR" style="width:auto;height:auto;line-height:16px;overflow:display;">';
				//HTML += '<span id="text" class="CPR CL" style="'+textStyleHTML+'"></span>';
				//HTML += '<div id="modifyButton" class="CPR CL CHand" onclick="TextAndInputSwap(this.parentNode.parentNode, \'input\', true);"><img src="images/fli3.gif" width="15" height="16" border="0" ></div>';
				HTML += '<table><tr><td id="text"></td><td valign="top"><div id="modifyButton" class="CPR CL CHand" onclick="TextAndInputSwap(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode, \'input\', true);"><img src="images/fli3.gif" width="15" height="16" border="0" ></div></td></tr></table>'
			HTML += '</div>';
			HTML += '<div id="DTIInput" class="CPR CVH CDN" style="width:auto;height:16px;line-height:16px;color:#CCCCCC;">';
				HTML += '<input type="text" id="input" name="'+inputName+'" value="" class="CPR CL" style="'+inputStyleHTML+'" />';
				HTML += '<div id="OKButton" class="CPR CL CHand" onok="" onclick="this.onok();this.parentNode.firstChild.value = this.parentNode.parentNode.firstChild.firstChild.firstChild.firstChild.firstChild.innerHTML;TextAndInputSwap(this.parentNode.parentNode, \'text\');"><img src="images/fli3.gif" width="15" height="16" border="0" ></div>';
				//HTML += '<div id="OKButton" class="CPR CL CHand CBorder" onclick="alert(2);"><img src="images/fli3.gif" width="35" height="36" border="0" ></div>';
				HTML += '<div id="CancelButton" class="CPR CL CHand" oncancel="" onclick="this.oncancel();this.parentNode.firstChild.value=this.parentNode.parentNode.firstChild.firstChild.firstChild.firstChild.firstChild.innerHTML;TextAndInputSwap(this.parentNode.parentNode, \'text\');"><img src="images/fli2.gif" width="15" height="16" border="0" ></div>';
			HTML += '</div>';
		HTML += '</div>';
	HTML += '</div>';
	return HTML;
}

function TextAndInput(mainProperty, headProperty, bodyProperty, inputProperty, textProperty){
	if (mainProperty == null)
		mainProperty = {};
	if (headProperty == null)
		headProperty = {};
	if (bodyProperty == null)
		bodyProperty = {};
	if (inputProperty == null)
		inputProperty = {};
	if (textProperty == null)
		textProperty = {};
	var mainStyle = {width:'auto', height:'16px'};
	//mainStyle.Add(mainProperty.style);

	var headStyle = {width:'auto', height:'16px', fontSize:'12px', lineHeight:'16px', cssFloat:'left', styleFloat:'left'};
	//headStyle.Add(headProperty.style);
	var headText = headProperty.text == null ? '' : headProperty.text;
	
	var bodyStyle = {width:'auto', color:'#000000', cssFloat:'left', styleFloat:'left'};
	//bodyStyle.Add(bodyProperty.style);
	//var bodyName = bodyProperty.name == null ? '' : bodyProperty.name;
	//var bodyStyle = bodyProperty.style == null ? '' : bodyProperty.style;
	//var defaultText = bodyProperty.defaultText == null ? '' : bodyProperty.defaultText;
	//var blankString = bodyProperty.blankString == null ? '' : bodyProperty.blankString;
	//var replaceBlankString = bodyProperty.replaceBlankString == null ? '' : bodyProperty.replaceBlankString;
	
	//var singleLine = inputProperty.singleLine != false ? true : false;
	var inputStyle = {width:'200px', height:'12px', fontSize:'12px', lineHeight:'12px'};
	//inputStyle.Add(inputProperty.style);
	
	var inputName = inputProperty.name == null ? 'input' : inputProperty.name;
	
	
	var textStyle = {};
	//textStyle.Add(textProperty.textStyle);
	//var headText = '';
	//var inputName = 'abc'
	var ti = NewElement('div', 'DTIMain', 'CPR CT0 CL0', mainStyle);
	
		var tiHead = NewElement('div', 'DTIHead', null, headStyle, null, headText);
		var tiBody = NewElement('div', 'DTIBody', null, bodyStyle);
			var tiText = NewElement('div', 'DTIText', null, {width:'auto', height:'16px', lineHeight:'16px', overflow:'hidden'});
				var text = NewElement('span', 'text', 'CL', textStyle);
				var modifyButton = NewElement('div', 'modifyButton', 'CL CHand', null, {onclick:function(){alert(1);TextAndInputSwap(tiBody, 'input', true);}});
				modifyButton.appendChild(NewImage('images/fli3.gif', 15, 16));
			tiText.appendChild(text);
			tiText.appendChild(modifyButton);
			
			var tiInput = NewElement('div', 'DTIInput', null, {width:'auto', height:'auto', color:'#CCCCCC', visibility:'hidden', display:'none'});
				var input = NewElement('input', 'input', 'CL', inputStyle, {type:'text', name:inputName, onchange:function(){}});
				var okButton = NewElement('div', null, 'CL', null, {onclick:function(){TextAndInputSwap(tiBody, 'text');}});
					okButton.appendChild(NewImage('images/fli3.gif', 15, 16));
			tiInput.appendChild(input);
			tiInput.appendChild(okButton);
		tiBody.appendChild(tiText);
		tiBody.appendChild(tiInput);
	ti.appendChild(tiHead);
	ti.appendChild(tiBody);
	//ti.tiBody = tiBody;
	//ti.tiHead = tiHead;
	//ti.text = text;
	//ti.input = input;
	return ti;
}


function TextAndInputSwap(object,display,setFocus){
	//alert(object.id);
		var text = object.childNodes(1).childNodes[0].value;
		text = text.replace(/[\n]/g,"<br>");
		text = text.replace(/[ ]/g,"&nbsp;");
		object.childNodes[0].childNodes[0].firstChild.firstChild.firstChild.innerHTML = text;
//	}
	if (display == "text" && !object.childNodes[1].focused){
		object.childNodes[0].style.display="block";
		object.childNodes[0].style.visibilty="visible";
		object.childNodes[1].style.display="none";
		object.childNodes[1].style.visibility="hidden";
	}else{
		object.childNodes[0].style.display="none";
		object.childNodes[0].style.visibilty="hidden";
		object.childNodes[1].style.display="block";
		object.childNodes[1].style.visibility="visible";
		if (setFocus == true)
			object.childNodes[1].childNodes[0].focus();
	}
}


function TextAndInputString(mainProperty,headProperty,bodyProperty,inputProperty){
	if (mainProperty == null)
		mainProperty = new Object();
	if (headProperty == null)
		headProperty = new Object();
	if (bodyProperty == null)
		bodyProperty = new Object();
	
	var mainStyle = mainProperty.style == null ? '' : mainProperty.style;
	var headStyle = headProperty.style == null ? '' : headProperty.style;
	var headText = headProperty.text == null ? '' : headProperty.text;
	
	var bodyStyle = bodyProperty.style == null ? '' : bodyProperty.style;
	var bodyName = bodyProperty.name == null ? '' : bodyProperty.name;
	var bodyStyle = bodyProperty.style == null ? '' : bodyProperty.style;
	var defaultText = bodyProperty.defaultText == null ? '' : bodyProperty.defaultText;
	var nullColor = bodyProperty.nullColor == null ? '#CCCCCC' : bodyProperty.nullColor;
	var notNullColor = bodyProperty.notNullColor == null ? '#000000' : bodyProperty.notNullColor;
	var blankString = bodyProperty.blankString == null ? '' : bodyProperty.blankString;
	var replaceBlankString = bodyProperty.replaceBlankString == null ? '' : bodyProperty.replaceBlankString;
	
	var singleLine = inputProperty.singleLine != false ? true : false;
	var inputStyle = inputProperty.style == null ? '' : inputProperty.style;
	var inputName = inputProperty.name == null ? 'input' : inputProperty.name;
	var inputOtherProperty = inputProperty.otherProperty == null ? '' : inputProperty.otherProperty.replace(/this.parentNode/g,'this.parentNode.parentNode.parentNode.parentNode');
	
	var returnHTML="";
	returnHTML += '<div style="position:relative;top:0px;left:0px;width:auto;height:16px;'+mainStyle+'">';
		returnHTML += '<div style="height:16px;font-size:12px;line-height:16px;float:left;width:auto;'+headStyle+'">'+headText+'</div>';
		returnHTML += '<div id="'+bodyName+'" style="color:#000000;float:left;width:auto;'+bodyStyle+'">';
			returnHTML += '<div id="text" style="height:16px;line-height:16px;width:auto;overflow:hidden;">';
				returnHTML += '<div style="float:left;color:'+nullColor+';" onmouseover="TextAndInput(this.parentNode.parentNode,\''+nullColor+'\',\''+notNullColor+'\',\'\',\''+replaceBlankString+'\',\'input\');" onmouseout="TextAndInput(this.parentNode.parentNode,\''+nullColor+'\',\''+notNullColor+'\',\''+blankString+'\',\''+replaceBlankString+'\',\'text\');">'+defaultText+'</div><div style="float:left;cursor:pointer;" onclick="TextAndInput(this.parentNode.parentNode,\''+nullColor+'\',\''+notNullColor+'\',\'\',\''+replaceBlankString+'\',\'input\', true);"><img src="images/fli3.gif" border="0" width="15" height="16" /></div>';
			returnHTML += '</div>';

			returnHTML += '<div style="height:auto;color:#CCCCCC;display:none;visibility:hidden;width:auto;">';
				returnHTML += '<input type="text" name="'+inputName+'" id="input" value="'+defaultText+'" style="height:14px;font-size:12px;line-height:14px;width:200px;'+inputStyle+'" onfocus="this.parentNode.focused=true;" onblur="this.parentNode.focused=false;TextAndInput(this.parentNode.parentNode,\''+nullColor+'\',\''+notNullColor+'\',\'\',\''+replaceBlankString+'\',\'text\');" '+inputOtherProperty+' />';
			returnHTML += '</div>';
		returnHTML += '</div>';
	returnHTML += '</div>';
	return returnHTML;
}

function TextAndInputSwap2(object,nullColor,notNullColor,blankString,replaceBlankString,display,setFocus){
	if (object.childNodes[1].childNodes[0].value==blankString || object.childNodes[1].childNodes[0].value == replaceBlankString){
		object.childNodes[0].childNodes[0].innerHTML = replaceBlankString;
		object.childNodes[0].childNodes[0].style.color=nullColor;
		object.childNodes[1].childNodes[0].value="";
	}else{
		var text = object.childNodes(1).childNodes[0].value;
		text = text.replace(/[\n]/g,"<br>");
		text = text.replace(/[ ]/g,"&nbsp;");
		object.childNodes[0].childNodes[0].innerHTML = text;
		object.childNodes[0].childNodes[0].style.color=notNullColor;
	}
	if (display == "text" && !object.childNodes[1].focused){
		object.childNodes[0].style.display="block";
		object.childNodes[0].style.visibilty="visible";
		object.childNodes[1].style.display="none";
		object.childNodes[1].style.visibility="hidden";
	}else{
		object.childNodes[0].style.display="none";
		object.childNodes[0].style.visibilty="hidden";
		object.childNodes[1].style.display="block";
		object.childNodes[1].style.visibility="visible";
		if (setFocus == true)
			object.childNodes[1].childNodes[0].focus();
	}
}




function NavigationBar(page,pageCount,skipFunction,float){
	if (float != 'right')
		float = 'left';
	var loop;
	var navigationBarLayer = document.createElement("div");
	navigationBarLayer.id = 'DNavigationBar';
	navigationBarLayer.style.position = 'relative';
	navigationBarLayer.style.width = 'auto';
	navigationBarLayer.style.height = "14px";
	//navigationBarLayer.style.margin = "3px 15px 0px 15px";
	navigationBarLayer.style.top = '3px';
	if (float == 'left'){
		navigationBarLayer.style.left = '15px';
	}else{
		navigationBarLayer.style.right = '15px';
	}
	//navigationBarLayer.style.border = '1px solid #000000';
	navigationBarLayer.style.styleFloat = float;
	navigationBarLayer.style.cssFloat = float;
	//navigationBarLayer.innerHTML = 'aaaa';
	//navigationBarLayer.style.overflow = 'auto';
	if (pageCount <= 0)
		return navigationBarLayer;
	if (page<=0)
		page=1;
	if (page>pageCount)
		page=pageCount;

	var HTMLString="";
	var pageStart=1, pageEnd=1, pageLeft=0, loop=0;
	skipFunction = skipFunction.replace(/this\./g,'this.parentNode\.');
	//HTMLString += '<div style="border:0px solid #000000;float:left;width:40px;height:18px;margin-right:0px;line-height:16px;font-size:12px;">第<font color=red>'+page+'</font>页</div>';
	//显示前3页的页数
	pageStart=page-3;
		
	//如前3页小于1，则最前页为第一页
	if (pageStart<=0){
		//前3页少掉的页数，由后3页补齐，共7页
		pageLeft=pageStart-1;
		pageStart=1;
	}
	//后3页的页数+前3页少掉的页数
	pageEnd=page+3-pageLeft;
	//如后面的页数超出总数，则最后一页结束
	if (pageEnd>pageCount){
		//如前3页未从第一页开始，则重新计算前数页
		if (pageStart>1){
			pageStart=pageStart-(pageEnd-pageCount);
			//如计算结果超出第一页，则从第一页开始
			if (pageStart<=0)
				pageStart=1;
		}
		pageEnd=pageCount;
	}

	if (pageStart<=4){
		pageStart=1;
	}else{
		for (loop=1;loop<=3;loop++){
			HTMLString += '<div align="center" style="border:1px solid #EEEEEE;background-color:#FFFFFF;float:left;width:14px;height:14px;margin-left:5px;line-height:14px;font-size:12px;cursor:pointer;" onclick="'+skipFunction.replace(/page/g,loop)+'">'+loop+'</div>';
		}
		HTMLString += '<div align="center" style="float:left;width:14px;height:14px;margin-left:5px;line-height:14px;font-size:12px;">...</div>';
	}

	if (pageEnd>=pageCount-3){
		pageEnd=pageCount;
	}
	
	//循环显示前后3页
	for (loop=pageStart;loop<=pageEnd;loop++){
		HTMLString += '<div align="center" style="border:'+(loop == page?'1px solid #006699':'1px solid #EEEEEE')+';background-color: '+(loop == page?'#FFFFFF':'#FFFFFF')+';float:left;width:12px;height:12px;margin-left:5px;line-height:12px;font-size:12px;'+(loop == page?'color:#003366;':'')+'cursor:pointer;" onclick="'+skipFunction.replace(/page/g,loop)+'">'+loop+'</div>';
	}
	
	if (pageEnd<=pageCount-4){
		HTMLString += '<div align="center" style="float:left;width:14px;height:14px;margin-left:5px;line-height:14px;font-size:12px;">...</div>';
		for (loop=pageCount-2;loop<=pageCount;loop++){
			HTMLString += '<div align="center" style="border:1px solid #EEEEEE;background-color:#FFFFFF;float:left;width:14px;height:14px;margin-left:5px;line-height:14px;font-size:12px;cursor:pointer;" onclick="'+skipFunction.replace(/page/g,loop)+'">'+loop+'</div>';
		}
	}
	HTMLString += '<div style="border:0px solid #000000;float:left;height:14px;margin-left:15px;line-height:14px;font-size:12px;"><font color="#FF0000">'+page+'</font>/'+pageCount+'</div>';
	//alert(HTMLString);
//alert(1);
	//判断前一页，后一页
	if (page>1){
		HTMLString += '<div style="float:left;height:11px;width:11px;margin-left:10px;margin-top:1px;cursor:pointer;" onclick="'+skipFunction.replace(/page/g,page-1)+'"><img src="images/PreviewButton.gif" border="0" /></div>';
	}else{
		HTMLString += '<div style="float:left;height:11px;width:11px;margin-left:10px;margin-top:1px;"><img src="images/PreviewButtonDisable.gif" border="0" /></div>';
	}
	
	if (page<pageCount){
		HTMLString += '<div style="float:left;height:11px;width:11px;margin-left:5px;margin-top:1px;cursor:pointer;" onclick="'+skipFunction.replace(/page/g,page+1)+'"><img src="images/NextButton.gif" border="0" /></div>';
	}else{
		HTMLString += '<div style="float:left;height:11px;width:11px;margin-left:5px;margin-top:1px;"><img src="images/NextButtonDisable.gif" border="0" /></div>';
	}
	
	//'直接跳转翻页
	//'从原变量中分离变量名和变量，用隐藏变量保存，然后用get方式传递到下一页
	//CategoryArray=split(CategoryList,"&")
	//for CategoryLoop=0 to Ubound(CategoryArray)
		//ParameterArray=split(CategoryArray(CategoryLoop),"=")
		//Response.Write("<input type=hidden name="&ParameterArray(0)&" value="&ParameterArray(1)&">")
	//next
	//Response.Write("<input type=""text"" name=""page"" size=""1"" value="""" class=""PageInput""><input type=""submit"" value=""GO"" name=""submit"" class=""PageInput""></td></tr></form></table>")
	//alert(HTMLString);
	navigationBarLayer.innerHTML = HTMLString;
	navigationBarLayer.HTML = '<div id="DNavigationBar" class="CPR" style="width:auto;height:14px;margin:3px 15px 0px 15px;float:'+float+';">'+HTMLString+'</div>';

	//return HTMLString;
	//document.write(sReturn);
	return navigationBarLayer;
}



function GetCookieVal(offset)
//获得Cookie解码后的值
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value)
//设定Cookie值
{
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	expires = 1000000;
	if(expires!=null)
		expdate.setDate(expdate.getDate() + expires);
	//expdate.setDate(expdate.getDate() + expires);
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//删除Cookie
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return GetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function GetNodeText(node){
	//if (node.childNodes.length==0){
	//	return '';
	//}else{
	//	return node.firstChild.nodeValue;
	//}
	var textNode = node.firstChild;
	return textNode == null ? '' : textNode.nodeValue;
}

function SetPageProperty(pageLayer, type, property){
	pageLayer.type=type;
	pageLayer.property=property;
}

function SetTabProperty(tab,type,property){
	tab.type=type;
	tab.property=property;
}


function DddDate(type,NumDay,dtDate){ 
	var date = new Date(dtDate) 
	type = parseInt(type) //类型  
	lIntval = parseInt(NumDay)//间隔 
	switch(type){ 
		case 6 ://年 
			date.setYear(date.getYear() + lIntval) 
			break; 
		case 7 ://季度 
			date.setMonth(date.getMonth() + (lIntval * 3) ) 
			break; 
		case 5 ://月 
			date.setMonth(date.getMonth() + lIntval) 
			break; 
		case 4 ://天 
			date.setDate(date.getDate() + lIntval) 
			break 
		case 3 ://时 
			date.setHours(date.getHours() + lIntval) 
			break 
		case 2 ://分 
			date.setMinutes(date.getMinutes() + lIntval) 
			break 
		case 1 ://秒 
			date.setSeconds(date.getSeconds() + lIntval) 
			break; 
		default: 	
	}
	return date;
}



function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
			}
		);
	}
}
sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
			}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}
//suckerfish(sfFocus, "INPUT");
//suckerfish(sfFocus, "TEXTAREA"); 
function DelayCall(f, time){
	//if (time == null)
	//	time = 1;
	window.setTimeout(f,time);
}

function KeywordsBuild(s){
	if (s == null){
		return null;
	}else{
		return s.Keywords();
	}
}

function NewImage(src, width, height, border, className, style, property){
	var image;
	image = document.createElement("IMG");
	image.src = src;
	if (width != null)
		image.width = width;
	if (height != null)
		image.height = height;
	if (border != null)
		image.border = border;
	if (className != null)
		image.className = className;
	if (style != null){
		for (styleName in style){
			image.style[styleName] = style[styleName];
		}
	}
	if (property != null){
		for (propertyName in property){
			image[propertyName] = property[propertyName];
		}
	}
	return image;
}

function NewDiv(id, className, style, property, innerHTML){
	var styleName, propertyName;
	var div = document.createElement('div');
	if (id != null)
		div.id = id;
	if (className != null)
		div.className = className;
	if (style != null){
		for (styleName in style){
			div.style[styleName] = style[styleName];
		}
	}
	if (property != null){
		for (propertyName in property){
			div[propertyName] = property[propertyName];
		}
	}
	if (innerHTML != null)
		div.innerHTML = innerHTML;
	return div;
}


function NewElement(type, id, className, style, property, innerHTML){
	var styleName, propertyName;
	var element = document.createElement(type);
	if (id != null)
		element.id = id;
	if (className != null)
		element.className = className;
	if (style != null){
		for (styleName in style){
			element.style[styleName] = style[styleName];
		}
	}
	if (property != null){
		for (propertyName in property){
			element[propertyName] = property[propertyName];
		}
	}
	if (innerHTML != null)
		element.innerHTML = innerHTML;
	return element;
}


function GetBrowserType(){
	var browserType = '';
	switch (navigator.appName){
	case 'Microsoft Internet Explorer':
		browserType = 'IE';
		break;
	case 'Netscape':
		browserType = 'FF';
		break;
	default:
		browserType = 'Other';
		break;
	}
	return browserType;
}


function DisplayTransfer(object,id){
	var loop;
	var activePage = null;
	var objectChildren = GetChildren(object,'',true);
	//alert(objectChildren.length);
	for (loop=0;loop<objectChildren.length;loop++){
		if (objectChildren[loop].id == id){
			objectChildren[loop].style.display = 'block';
			objectChildren[loop].style.visibility = 'visible';
			activePage = objectChildren[loop];
		}else{
			objectChildren[loop].style.display = 'none';
			objectChildren[loop].style.visibility = 'hidden';
		}
	}
	/*
	for (loop=0;loop<object.childNodes.length;loop++){
		if (object.childNodes[loop].parentNode == object && object.childNodes[loop].tagName != null){
			if (object.childNodes[loop].id == id){
				object.childNodes[loop].style.display = 'block';
				object.childNodes[loop].style.visibility = 'visible';
				activePage = object.childNodes[loop];
			}else{
				object.childNodes[loop].style.display = 'none';
				object.childNodes[loop].style.visibility = 'hidden';
			}
		}
	}*/
	return activePage;
}

function GetChild(object, childID, direct){
	var child = null;
	var children = GetChildren(object, childID, direct);
	if (children.length>=1)
		child = children[0];
	return child;
}

function GetChildren(object,childID,direct){
	var loop;
	if (direct != true)
		direct = false;
	var children = [];
	for (loop=0;loop<object.childNodes.length;loop++){
		if (object.childNodes[loop].tagName != null){
			if ((childID != '' && object.childNodes[loop].id == childID) || (childID == '')){
				children.push(object.childNodes[loop]);
			}
			if (!direct){
				children = children.concat(GetChildren(object.childNodes[loop],childID,direct));
			}
		}
	}
	return children;
}

function GetChildCount(object){
	var count = 0;
	var child;
	for (child in object)
		count++;
	return count;
}

function SetVisible(layer){
	layer.style.visibility = 'visible';
	layer.style.display = 'block';
}
function SetHidden(layer){
	layer.style.visibility = 'hidden';
	layer.style.display = 'none';
}

function SetHeight(object, height){
	var nav = NavigatorType();
	if (nav == 'IE'){
		object.style.height = height;
	}else{
		object.style.minHeight = height;
		object.style.height = 'auto';
	}
}

function NavigatorType(){
	var nav = 'other';
	switch(navigator.appName){
		case 'Microsoft Internet Explorer':
			nav = 'IE';
			break;
		case 'Netscape':
			nav = 'FF';
			break;
		default:
			nav = 'Other';
	}
	return nav;
}

function DebugOutput(s){
	var text = $('DebugText');
	if (text != null){
		text.value += s + '\n';
	}
}

function RebuildArray(arr){
	var newarr = [];
	var loop, nloop;
	var exists;
	for (loop=0;loop<arr.length;loop++){
		exists = 0;
		for (nloop=0;nloop<newarr.length;nloop++){
			if (newarr[nloop] == arr[loop]){
				exists = 1
				break;
			}
		}
		if (exists == 0)
			newarr.push(arr[loop]);
	}
	return newarr;
}

function numberCheck(numberString, defaultValue){
	var v;
	v = parseInt(numberString);
	if (isNaN(v)){
		v = defaultValue;
	}
	return v;
}

var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F4217d73ccfc5134e4bc54e772655e6c9' type='text/javascript'%3E%3C/script%3E"));
