﻿<!--
function killErrors(){return true;}
window.onerror=killErrors;

function $(id){
	if(document.getElementById){
		return document.getElementById(id);
	}else if(document.all){
		return document.all[id];
	}else if(document.layers){
		return document.layers[id];
	}
}

function checkSearch(){
	if ($('keyword').value.length<2 || $('keyword').value.length>100){
		$('searchsubmit').disabled=true;
		$('keyword').focus();
	}else{
		$('searchsubmit').className='goOver'
		$('searchsubmit').disabled='';
	}
}

function documentFalse(){
	document.oncontextmenu=new Function("event.returnValue=false;");
	//document.onselectstart=new Function("event.returnValue=false;");
}

function documentSelf(){
	if (top.location !=self.location)top.location=self.location;
}

function changeDIV(divcount,olddivall,newdiv,newdivclass,olddivclass,listdiv,listdivall){
	for(var p=0;p<divcount;p++){
		document.getElementById(olddivall+p).className=newdivclass;
		document.getElementById(listdivall+p).style.display='none';
	}
	document.getElementById(newdiv).className=olddivclass;
	document.getElementById(listdiv).style.display='block';
}

function CheckBrowser(){
    var app=navigator.appName;
    var verStr=navigator.appVersion;
    if (app.indexOf('Netscape') !=-1){
        alert("Ocenaia友情提示：\n你使用的是Netscape浏览器，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
    } else if (app.indexOf('Microsoft') !=-1){
        if (verStr.indexOf("MSIE 3.0") !=-1 || verStr.indexOf("MSIE 4.0") !=-1 || verStr.indexOf("MSIE 5.0") !=-1 || verStr.indexOf("MSIE 5.1") !=-1) alert("Ocenaia友情提示：\n    您的浏览器版本太低，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。");
    }
}

function SetFocus(){
    if (document.Login.UserName.value=="") document.Login.UserName.focus();
    else document.Login.UserName.select();
}

function doZoom(size){
	var page_content = $('tdContent');
	if(!page_content){
	return;
	}
	var page_contentChild = page_content.childNodes;
	page_content.style.fontSize = size + 'px';
	for(var i = 0; i < page_contentChild.length; i++){
		if(page_contentChild[i].nodeType == 1){
		page_contentChild[i].style.fontSize = size + 'px';
		}
	}
}

//检测会员表单信息，多种提示
function checkMember(theform,thefunc){
    var e=theform.elements;
	var strMinLen=2;
    for (var i=0,lngLeng=e.length; i < lngLeng; i++){
        if (e[i].disabled) continue;
        if (e[i].leixing==null) continue;
        if (e[i].chulibz=='R') continue
        var themsg='_'+e[i].name;
        var strValue, strMaxLen;
        strValue=e[i].value.replace(/^\s+|\s+$/, "");
        e[i].value=strValue;
		
        if (strValue==""){
            if (e[i].allowNull==null){
                if (e[i].chulibz=='M'){
                    _goInfo(e[i], thefunc, themsg, "该项目不能为空！");
					return false
                }
                continue
            }
            if (e[i].allowNull=='Y'){
				$(themsg).className='label';
				e[i].className='feedbackInput';
                continue
            }
            if (e[i].chulibz=='M'){
                _goInfo(e[i], thefunc, themsg, "该项目不能为空！");
				return false
            }
            switch (e[i].leixing){
            case "C":
                continue
            default:
                _goInfo(e[i], thefunc, themsg, "该项目不能为空！");
				return false
            }
        }      
		
        if (e[i].value.length > e[i].maxlength && (e[i].tagName=='TEXTAREA')){
            alert(e[i].parentElement.previousSibling.innerText + "长度过长应该小于" + e[i].maxlength);
            e[i].focus();
            return (false);
        }

        switch (e[i].leixing){
        //日期格式1999-10-10
        case 'D':
            {
                var filter=/^(?:(?!0000)[0-9]{4}([-/.]?)(?:(?:0?[1-9]|1[0-2])([-/.]?)(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])([-/.]?)(?:29|30)|(?:0?[13578]|1[02])([-/.]?)31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2([-/.]?)29)$/;
                if (! (filter.test(strValue))){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的时间格式！例：1999-09-09");
                    return false;
                }
            }
            break;
        //数字
        case 'I':
            {
                var filter=/^((\d+),)*(\d+)$/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的数字格式！");
                    return false;
                }
            }
            break;
		//年份
        case 'YEAR':
            {
                var filter=/((19|20)\d{2})/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的年份！");
                    return false;
                }
				
				//范围
				if (strValue<1949 || strValue>2015){
					_goInfo(e[i], thefunc, themsg, "请输入1949到2015之间的年份！");
                    return false;
				}
            }		
            break;
        //时间格式例:12:20
        case 'N':
            {
                var filter=/^(([0-1][0-9])|([2][0-3])|[0-9]):(([0][0-9]|([1-5][0-9]|[0-9])))$/;
                if (! (filter.test(strValue))){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的时间格式！例：12:30");
                    return false;
                }
            }
            break;
        //邮件
        case 'MAIL':
            {
                var filter=/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的电子邮件格式！");
                    return false;
                }
            }
            break;
        //网址
        case 'HTTP':
            {
                var filter=/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的网址格式！");
                    return false;
                }
            }
            break;
        //电话号码
        case 'TEL':
            {
                var filter=/(\d{3}-\d{8}|\d{4}-\d{8}|\d{4}-\d{7}|\d{3}-\d{7})(-\d{2,8})?/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的电话或传真号码，例：021-88886666！");
                    return false;
                }
            }
            break;
		//手机
        case 'MOBILE':
            {
                var filter=/[1][3,5][0-9]{9}/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的手机号码格式！");
                    return false;
                }
            }
            break;
        //邮编
        case 'ZIP':
            {
                var filter=/^[1-9]\d{5}$/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的邮政编码格式！");
                    return false;
                }
            }
            break;
        //QQ号
        case 'QQ':
            {
                var filter=/[1-9][0-9]{4,8}/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的QQ号格式！");
                    return false;
                }
            }
            break;
        //IP地址
        case 'IP':
            {
                var filter=/[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}.[0-5]{1,3}/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的IP地址格式！");
                    return false;
                }
            }
            break;
        //匹配由数字和26个英文字母组成的字符串
        case 'A9':
            {
                var filter=/^[A-Za-z0-9]+$/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的字母或数字格式！");
                    return false;
                }
            }
            break;
        //匹配由26个英文字母组成的字符串
        case 'AZ':
            {
                var filter=/^[A-Za-z]+$/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的字母格式！");
                    return false;
                }
            }
            break;
        //汉字
        case 'HZ':
            {
                var filter=/[^\x00-\xff]/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的汉字格式！");
                    return false;
                }
            }
            break;
        //身高
        case 'SG':
            {
                var filter=/[1,2]\d*\.\d*|[1,2]\d*/;
                if (!filter.test(strValue)){
                    _goInfo(e[i], thefunc, themsg, "请输入正确的身高格式！");
                    return false;
                }
            }
            break;
        }
		
		//文本框为空，文本区域判断
        if (e[i].maxLength !=null){
            strMaxLen=e[i].maxLength;
        }else if (e[i].tagName=='TEXTAREA'){
			strMinLen=2;
            strMaxLen=1000;
			if (strLength(e[i].value)<strMinLen || strLength(e[i].value)>strMaxLen){
				_goInfo(e[i], thefunc, themsg, '请输入'+ strMinLen +'到'+ strMaxLen +'个字符，1个汉字等于个2字符！');
				return false;
			}
        } else {
			strMaxLen=e[i].maxLength;
        }
		//显示提示信息
		if (strLength(e[i].value) < strMinLen || strLength(e[i].value) > strMaxLen){
			$(themsg).className='label1';
			e[i].className='feedbackInputOver';
			$(themsg).innerHTML='<font color="red">请输入长度为'+ strMinLen +'到' + strMaxLen + '位字符，1个汉字等于个2字符！</font>';
			e[i].focus();
            return false
        }
		$(themsg).className='label';
		e[i].className='feedbackInput';
        //未使用
		//e[i].parentElement.previousSibling.style.color='';
    }
    return true
}
//会员提示
function _goInfo(e, thefunc, themsg, s){
	$(themsg).className='label1';
	if (e.tagName=='TEXTAREA'){
		e.className='feedbackInputOver';
	}else{
		e.className='feedbackInputOver';
	}	
	if (s!=null){
		$(themsg).innerHTML='<font color="red">'+ s +'</font>';
	}else{
		$(themsg).innerHTML='<font color="red">该项目类型错误！</font>';
	}
	
	//未使用
	if (thefunc!=null){
		thefunc(e)
	}else{
		e.focus();
		return false
	}
}

//计算长度
function strLength(str){
    var getSubjectLen=str.length;
    var n=getSubjectLen;
    for (var i=0; i < getSubjectLen; i++){
        if (str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255) n++
    }
    return n;
}

//判断输入的字符串数
function changeHints(subject,strlen){
	var getSubjectLen=strLength(subject.value)
	if (getSubjectLen<=strlen){
		var templen=strlen-getSubjectLen
		if (strlen-templen <=3){
			$(subject.name).focus();
		}else{
			if (document.all!=null){
				$('_'+subject.name).className='label1';
				$('_'+subject.name).innerHTML='<font color="green">已经输入<font color="red">'+ getSubjectLen +'</font>字符，还可以输入'+ templen +'字符<font>';
			}
		}
	}else{
		if (document.all!=null){
			$('_'+subject.name).innerHTML='输入字符超出'+ [parseInt(getSubjectLen)-parseInt(strlen)] +'字符';
		}
	}
	return true
}


//图片按比例缩放
//调用：<img src="图片" onload="javascript:DrawImage(this,100,100)">
var imgflag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    imgflag=true;
	
	if(image.width/image.height<= iwidth/iheight){
	if(image.width>iwidth){  
        ImgD.width=iwidth;
        ImgD.height=(image.height*iwidth)/image.width;
        }
		else{
        ImgD.width=image.width;  
        ImgD.height=image.height;
		ImgD.style.width=image.width; 
		ImgD.style.height=image.height; 
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//ImgD.style.margin-top=(200-image.height)/2; 
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
        ImgD.height=iheight;
        ImgD.width=(image.width*iheight)/image.height;        
        }
		else{
        ImgD.width=image.width;
        ImgD.height=image.height;
		ImgD.style.width=image.width;
		ImgD.style.height=image.height;
		//ImgD.style.padding=""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"; 
		//alert(""+(200-image.height)/2+"px "+(300-image.width)/2+"px "+(200-image.height)/2+"px "+(300-image.width)/2+"px"); 
        }
        //ImgD.alt=image.width+"×"+image.height;
        }
		
		
    }
} 



//-->
