﻿<!--
var RootName = "as0jer0j";
var Vote_Value = 0;

window.onerror=null;

function $(objName){
	if(document.getElementById){
		return document.getElementById(objName);
	}else{
		return document.all.objName;
	}
}

function TTTime(){
	document.getElementById('timestr').innerHTML=new Date().toLocaleString()+'&nbsp;星期'+'七一二三四五六'.charAt(new Date().getDay());
}

function ShowList(ObjName,ImgObj,CloseV,OpenV){
	var DivObj = document.getElementById(ObjName);
	var DivObjEX = document.getElementById(ImgObj);
	if (DivObj){
		if (DivObj.style.display=='none'){
			SetCookie(ObjName,1);
			DivObjEX.src=OpenV;
			DivObj.style.display='';
		}else{
			SetCookie(ObjName,0);
			DivObjEX.src=CloseV;
			DivObj.style.display='none';
		}
	}
}
function ShowView(ObjName,ImgObjName,CloseV,OpenV){
	if(GetCookie(ObjName)==1){
		document.getElementById(ObjName).style.display='';
		document.getElementById(ImgObjName).src=CloseV;
	}else{
		document.getElementById(ObjName).style.display='none';
		document.getElementById(ImgObjName).src=OpenV;
	}
}

function ShowTabs(ObjA,ObjB,OACNA,OACNB,STn,STz){
	for(var STi=0; STi<=STz; STi++){
		if(STi==STn){
			ObjA[STn].className = OACNA;
			ObjB[STi].style.display = "block";
		}else{
			ObjA[STi].className = OACNB;
			ObjB[STi].style.display = "none";
		}
	}
}

function Content(size){
	document.getElementById('Content').style.fontSize=size+'px'
}
function openwin(url,winName,width,height,scrolls){
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 )){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	theproperty="width="+width+",height="+height+",fullscreen=0,location=0,menubar=0,directories=0,resizable=1,scrollbars="+scrolls+",status=0,titlebar=0,toolbar=0,hotkeys=0,screenx="+xposition+",screeny="+yposition+",left="+xposition+",top="+yposition;
	window.open(url,winName,theproperty);
}
//不带框的flash
function ShowFlash(strMediaURL,obj_width,obj_height) {
	var sTag = ''
	+ '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + obj_width + '" height="' + obj_height + '">'
	+ '<param name="movie" value="' + strMediaURL + '">'
	+ '<param name="quality" value="best">'
	+ '<param name="WMode" value="Transparent">'
	+ '<embed src="' + strMediaURL + '" quality="best" WMode="Transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + obj_width + '" height="' + obj_height + '"></embed>'
	+ '</object>'
	+ '';
	document.write (sTag);
}
//显示栏目
function showsubmenu(sid){
	whichEl = eval("submenu" + sid);
	if (whichEl.style.display == "none"){
		eval("submenu" + sid + ".style.display=\"\";");
	}
	else{
		eval("submenu" + sid + ".style.display=\"none\";");
	}
}

//填充下拉框
function setSelect(objname,sSvalue){
	if(objname==null){alert("对象不存在！");}
	if(sSvalue=='Null'){
		objname.options.length = 1;
		objname.options[0].text="为空！";
		objname.options[0].value=null;
		return false;
	}else{
		sSelect = (sSvalue).split('*');
		objname.options.length = sSelect.length;
		for(var sSi = 0;sSi < sSelect.length;sSi++){
			objname.options[sSi].text=sSelect[sSi].split('^')[1];
			objname.options[sSi].value=sSelect[sSi].split('^')[0];
		}
	}
}
//批量赋值
function bq(objname,txt){
	if(objname==null) alert("对不起，当前没有记录可赋值！");
	else if(objname.length==null) objname.value=txt;
	else{
		var n=objname.length;
		for (i=0;i<n;i++) objname[i].value=txt;
	}
}
//改变多文件本框高度
function sizeChangeh(obj,size){
	var height = parseInt(obj.style.height);
	if (height+size>=50){
		obj.style.height=height+size;
	}
}
//改变多文件本框宽度
function sizeChangew(obj,size){
	var width = parseInt(obj.style.width);
	if (width+size>=50){
		obj.style.width=width+size;
	}
}

//tab选项卡效果
function switchTag(tCount,tCur,tabStr,conStr){
	for(var i=1;i<=tCount;i++){
		if (i==tCur){
			$(tabStr + i).className="selectli1";
			$(conStr + i).className="";
			SetCookie(tabStr + i,1);
			//alert(i);
		}else{
			$(tabStr + i).className="";
			$(conStr + i).className="hidecontent";
			SetCookie(tabStr + i,0);
		}
	}
}
function Taginit(tCount,tabStr,conStr){
	var curTag = 1;
	for(var i=1; i<=tCount; i++) if (GetCookie(tabStr + i) == 1) curTag = i;
	//alert(curTag);
	switchTag(tCount,curTag,tabStr,conStr);
}
//tab选项卡效果 end

function left(mainStr,lngLen) {
	return (lngLen>0) ? mainStr.substring(0,lngLen) : null;
}
function right(mainStr,lngLen) {
	return (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) ? mainStr.substring(mainStr.length-lngLen,mainStr.length) : null;
}
function mid(mainStr,starnum,endnum){
	return (mainStr.length>=0)?mainStr.substr(starnum,endnum):null;
}

function getHTTPObject(){
	var xmlhttp = false;
	if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
		if(xmlhttp.overrideMimeType){xmlhttp.overrideMimeType('text/xml');}
	}else{
		try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e){
			try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
			catch(E){ xmlhttp = false; }
		}
	}
	//xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	return xmlhttp;
}
function runCode(obj){  //定义一个运行代码的函数，
	var code=obj.value;//即要运行的代码。
	var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
	newwin.opener = null // 防止代码对论谈页面修改
	newwin.document.write(code);  //向这个打开的窗口中写入代码code，这样就实现了运行代码功能。
	newwin.document.close();
}
//用js获取地址参数
function getUrl(name){
	var paramStr=location.search;
	if(paramStr.length==0)return null;
	if(paramStr.charAt(0)!='?')return null;
	paramStr=unescape(paramStr);
	paramStr=paramStr.substring(1);
	if(paramStr.length==0)return null;
	var params=paramStr.split('&');
	for(var i=0;i<params.length;i++){
		var parts=params[i].split('=',2);
		if(parts[0]==name){
			if(parts.length<2||typeof(parts[1])=="undefined"||parts[1]=="undefined"||parts[1]=="null")return "";
			return parts[1];
		}
	}
return null;
}
function PriceAuto(PAObj,PAValue,PAOldValue){
	PAObj.value = PAValue * PAOldValue;
}

function dateSelector(){
	var myDate=new Date();
	var dSy = myDate.getYear();
	var dSm = myDate.getMonth()+1;
	var dSd = myDate.getDate();
	var dSh = myDate.getHours();
	var dSn = myDate.getMinutes();
	var dSs = myDate.getSeconds()+1;
	return dSy + '年' +  dSm + '月' + dSd + '日　' + dSh + ':' + dSn + ':' + dSs;
}

//变小写为大写
function Amount(QuondamObj,AmountObj,Mode){
	if (isNaN(QuondamObj.value)){
		alert('请输入数字！');
		var str = QuondamObj.value;
		var lenStr = str.length;
		var L_str;
		var save_str = "x";
		for(i=lenStr;i>0;--i){
			L_str = str.substr(i-1,1)
			if (!isNaN(L_str))
			save_str =L_str + save_str;
		}
		QuondamObj.value = save_str.substr(0,(save_str.length)-1) ;
	}
	///////变小写为大写///////////////////////////////
	var untilArray = "分,角,元,拾,佰,仟,万,拾万,佰万,仟万,亿,拾亿,佰亿,仟亿,万亿" ;
	var untilArrays = untilArray.split(',') ;
	var untilNumber = "零,壹,贰,叁,肆,伍,陆,柒,捌,玖" ;
	var untilNumbers = untilNumber.split(',') ;
	var moneyLittle = QuondamObj.value ;
	var moneyLittles = moneyLittle.split('.') ;
	var headNumber,trailNumber,headNumbers,trailNumbers,i ;
	var l_Number,numberStr,placeStr ;
	if (moneyLittles.length == 2){ //存在小数点的情况
		headNumber = moneyLittles[0] ;
		headNumbers = headNumber.length ;
		trailNumber = moneyLittles[1] ;
		trailNumbers = trailNumber.length ;
		numberStr = "" ;
		for (i=headNumbers;i>0;i--){ //小数点以前的转换
			l_Number = parseInt(headNumber.substr(i-1,1)) ;
			placeStr = untilArrays[headNumbers+2-i] ;
			if (headNumbers-i >12) placeStr = "" ;
			numberStr = untilNumbers[l_Number] + placeStr + numberStr ;
		}
		for (i=0;i<trailNumbers;i++){ //小数点以后的转化
			if (i >= 2) break ;
			l_Number = parseInt(trailNumber.substr(i,1)) ;
			placeStr = untilArrays[1-i] ;
			numberStr = numberStr  + untilNumbers[l_Number] + placeStr ;
		}
	}
	else{ //不存在小数点的情况
		headNumber = moneyLittles[0] ;
		headNumbers = headNumber.length ;
		numberStr = "" ;
		for (i=headNumbers;i>0;i--){
			l_Number = parseInt(headNumber.substr(i-1,1)) ;
			placeStr = untilArrays[headNumbers+2-i] ;
			if (headNumbers-i >12) placeStr = "" ;
			numberStr = untilNumbers[l_Number] + placeStr + numberStr ;
		}
		numberStr  = numberStr + "零角零分" ;
	}
	switch (Mode){
	case "input" :
		AmountObj.value  = numberStr ;
		break;
	case "div" :
		AmountObj.innerHTML  = numberStr ;
		break;
	}
}

//
function high(which2){
	theobject=which2
	highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
	clearInterval(highlighting)
	which2.filters.alpha.opacity=70
}

function highlightit(cur2){
	if (cur2.filters.alpha.opacity < 100)
		cur2.filters.alpha.opacity += 8
	else if (window.highlighting)
		clearInterval(highlighting)
}
function changeamount(index){
	var mytr = document.getElementById("txt"+index);
	var mycheckbox = document.getElementById(index);
	var mytext = document.getElementById("text"+index);
	if(mycheckbox.checked == true){
		mytext.disabled = false;
		if(mytext.value == "0" || mytext.value == ""){
			mytext.value = "1";
		}
		mytr.style.backgroundColor = '#EEEEEE';
	}
	else{
		mytr.style.backgroundColor = '';
	}

	if(mycheckbox.checked == false){
		mytext.disabled = true;
	}
}

/*以下是Cookie操作*/
function CheckCookie(){
	var cookieEnabled=(navigator.cookieEnabled)? true : false;
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
		document.cookie="ttcookie";
		cookieEnabled=(document.cookie=="ttcookie")? true : false;
		document.cookie="";
	}
	if(!cookieEnabled){
		window.alert("您好，您的浏览器设置禁止使用cookie。您选中了“增强安全性”选项，该选项要求浏览器启用cookie设置。\n\n您可以选择以下的其中一个方法：\n1：设置您的浏览器，启用cookie设置，再重新操作。\n2：或者操作时取消选中“增强安全性”选项，但是您的操作安全性将会降低。");
		return false;
	}
	return true;
}
function GetCookie (name) {
	var arg = RootName + name + "=";
	var alen = arg.length;
	var clen = window.document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (window.document.cookie.substring(i, j) == arg)	return getCookieVal (j);
		i = window.document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal (offset) {
	var endstr = window.document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = window.document.cookie.length;
	return unescape(window.document.cookie.substring(offset, endstr));
}
function SetCookie (name, value) {
	var exp = new Date();
	exp.setTime(exp.getTime() + (30*24*60*60*1000));
	window.document.cookie = RootName + name + "=" + escape (value) + "; expires=" + exp.toGMTString()+";path=/";
}
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (RootName + name);
	window.document.cookie = RootName + name + "=" + cval + "; expires=" + exp.toGMTString()+";path=/";
}

/*以下是验证操作*/
//是否为空
function IsNull(text){
	if (text == "") return false;
	return true;
}
//校验是否全由数字组成
function IsNumber(text){
	var patrn = /^[0-9]{1,20}$/;
	if (!patrn.exec(text)) return false;
	return true;
}
//校验EMail正确
function IsMail(text){
	var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if (!patrn.exec(text)) return false;
	return true;
}

//下拉
function subop(obj,toObj){
	var tLeft = obj.offsetLeft;
	var tTop = obj.offsetTop + 20;
	while(obj=obj.offsetParent) {
		tLeft+=obj.offsetLeft;
		tTop+=obj.offsetTop;
	}
	if($(toObj).style.display == 'none'){
		$(toObj).style.cssText = 'display:block;position:absolute;left:' + tLeft + 'px; top:' + tTop + 'px;';
	}else{
		$(toObj).style.cssText = 'display:none;';
	}
}
function subopHide(){
}


//菜单
function startList(){
	if (document.all && document.getElementById) {
		var dropmenuRoot = $("nav");
		var node;
		for (i=0; i<dropmenuRoot.childNodes.length; i++) {
			node = dropmenuRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}


//计算字符数，一个中文2个字符
function fLen(Obj){
	var nCNLenth = 0;
	var nLenth = Obj.length;
	for (var i=0; i<nLenth; i++){
		if(Obj.charCodeAt(i)>255){
			nCNLenth += 2;
		}else{
			nCNLenth++;
		}
	}
	return nCNLenth;
}

/* 表单操作 */
var ttForm = function(){
	var bgcolor = '#FFFFD8';
	return{
		//选择全部
		//复选框数组,值
		selectAll:function(objs,cValue,rowColor){
			if(rowColor == null) rowColor = bgcolor;
			if(objs == null) alert("对不起，当前没有记录可选择！");
			else if(objs.length == null) objs.checked=cValue;
			else{
				var n = objs.length;
				if(cValue != true) rowColor = '';
				for (var i = 0;i < n;i++){
					objs[i].checked = cValue;
					if ($('txt'+objs[i].value)) $('txt'+objs[i].value).style.backgroundColor = rowColor;
				}
			}
		},

		//数据视图中，选中行并改变行背景颜色
		//行中复选框，行对象，值
		exchange:function(obj,txts,cValue){
			var objRow = $(txts);
			var objA = $('exa');
			var objB = $('exb');
			if(obj.checked==true) objRow.style.backgroundColor = bgcolor;
			else objRow.style.backgroundColor = '';
			if (objA){
				if(objA.value=='') objA.value=cValue;
				else{
					if(objA.value==cValue) objA.value='';
					else objB.value=cValue;
				}
			}
		},

		Over:function(img){
			//
		}
	}
}();

var ttTime = function(){
	return{
		DateDiff:function(sDate1, sDate2) {
			var aDate, oDate1, oDate2, iDays;
			aDate = sDate1.split("-");
			oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
			aDate = sDate2.split("-");
			oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);
			iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24);
			return iDays;
		},

		Over:function(){
			//
		}
	}
}();

/* 数据验证 */
var ttVal = function(){
	return{
		isNull:function(string){
			if(string=="" || string==null)return 0;
			else return 1;
		},

		isNumber:function(string){
			if(string=="")return 0;
			else if(! /^\d+$/.test( string )) return -1;
			return 1;
		},

		isUsername:function(string){
			if(string=="") {return 0;}	//用户名不能为空
			else if( /^\d.*$/.test( string ) ){return -1;}	//用户名不能以数字开头
			else if(fLen( string )<6 || fLen( string )>18 ){return -2;}	//合法长度为6-18个字符
			else if(! /^\w+$/.test( string ) ){return -3;}	//用户名只能包含_,英文字母，数字
			else if(! /^([a-z]|[A-Z])[0-9a-zA-Z_]+$/.test( string ) ){return -4;}	//用户名只能英文字母开头
			else if(!(/[0-9a-zA-Z]+$/.test( string ))){return -5;}	//用户名只能英文字母或数字结尾
			return 1;
		},

		isPassword:function(string){
			if(string=="") return 0;
			else if(string.length<6 || string.length>16 ){return -1;}//合法长度为6-20个字符
			return 1;
		},

		isChinese:function(string){
			if(string=="")return 0;
			else if(! /^[\u0391-\uFFE5]+$/.test( string )) return -1;
			return 1;
		},

		isMail:function (string){//邮箱
			if(string=="")return 0;
			else if(! /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test( string )) return -1;
			return 1;
		},

		isZipCode:function (string){//邮编
			if(string=="")return 0;
			else if(! /^[1-9]\d{5}$/.test( string )) return -1;
			return 1;
		},

		isMobile:function (string){
			if(string=="") return 0;
			if(/^13\d{9}$/.test( string ) | /^15\d{9}$/.test( string ) | /^18\d{9}$/.test( string ))
			return 1;
			return -1;
		}

	}
}();


function loaded(myimg,mywidth,myheight)
{
 var tmp_img = new Image();
 tmp_img.src = myimg.src;
 image_x = tmp_img.width;
 image_y=tmp_img.height;

 if(image_x > mywidth)
 {
  tmp_img.height = image_y * mywidth / image_x;
  tmp_img.width = mywidth;

  if(tmp_img.height > myheight)
  {
   tmp_img.width = tmp_img.width * myheight / tmp_img.height;
   tmp_img.height=myheight;
  }
 }
 else if(image_y > myheight)
 {
  tmp_img.width = image_x * myheight / image_y;
  tmp_img.height=myheight;
  
  if(tmp_img.width > mywidth)
  {
   tmp_img.height = tmp_img.height * mywidth / tmp_img.width;
   tmp_img.width=mywidth;
  }
 }
  
 myimg.width = tmp_img.width;
 myimg.height = tmp_img.height;
}
//-->




