﻿// JavaScript Document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function hello(){
//alert("111111111");

document.getElementById('nameText').value="";
document.getElementById('Layer11').style.visibility = "visible";
document.getElementById('Layer11').style.display = "block";
//document.getElementById("clickNum").innerText=data;

}
function hello1(){
//alert("111111111");
document.getElementById('Layer11').style.visibility = "hidden";
document.getElementById('Layer11').style.display = "none";
//document.getElementById("clickNum").innerText=data;

}
function hello11(){
//alert("111111111");
var aa=document.getElementById('nameText').value;
document.getElementById('Layer11').style.visibility = "hidden";
document.getElementById('Layer11').style.display = "none";


document.getElementById("wrty").innerText=aa;

}
//
function alltrim(str)
{
    while (str.charAt(0)==" "||str.charAt(0)=="  ")
 {
     str=str.substr(1);
 }
 while (str.charAt(str.length-1)==" "||str.charAt(0)=="  ")
 {
     str=str.substr(0,str.length-1);
 }
    return(str);
}
function focus_1(id){
	document.getElementById(id).focus();
}
//页面文本长度限制
function lengthContol(id,length,altstr){
	var str=document.getElementById(id).value;
	if(str.length>length){
		alert(altstr);
		document.getElementById(id).focus();
		document.getElementById(id).style.border="red 2px solid";
		return false;
	}else {
		return true;
	}
}
//页面文本长度限制
function lengthContol2(id,length,altstr,spanId){
	var str=document.getElementById(id).value;
	if(str.length>length){
		document.getElementById(id).focus();
		document.getElementById(id).style.border="red 2px solid";
		document.getElementById(spanId).innerText=altstr;
		return false;
	}else {
		return true;
	}
}
//页面文本空值限定
function emptyLimit(id,altstr){
	var str=document.getElementById(id).value;
	if(alltrim(str)==""){
		alert(altstr);
		document.getElementById(id).focus();
		document.getElementById(id).style.border="red 1px solid";
		return false;
	}else{
		return true;
	}
}
//页面文本空值限定
function emptyLimit2(id,altstr,spanId){
	var str=document.getElementById(id).value;
	if(alltrim(str)==""){
		
		document.getElementById(id).focus();
		document.getElementById(id).style.border="red 1px solid";
		document.getElementById(spanId).innerText=altstr;
		return false;
	}else{
		return true;
	}
}
function exit(){
	document.location.href="exit.do";
}
function sessionInvalidate(){
	  request.open("GET",basePath+"exit.do",true);
    request.setRequestHeader("Content-Type", "text/xml");
    request.onreadystatechange = getState;
    request.send(null);
}
function getState(){
	if (request.readyState == 4) {
		if (request.status == 200) {
			var responseAction = request.responseText.split(",");
			if(responseAction[0]=="suc"){
				//alert("good!");
				parent.location.href=basePath+responseAction[1];
			}
			else{
				window.location.href=window.location.href;
  			}
		}else{
			alert("Sorry,please try again!");
		}
	}
}
//初始化top.jsp
function initTop(){
	document.getElementById('urlCache').value=window.location.href;
}
//登陆
function login(){
	//alert(document.getElementById('urlCache').value);
	document.topForm.action='loadlogin.do';
	document.topForm.submit();
}
//检查文件大小
function checkSize(imgId){
	var imgHead=document.getElementById(imgId);
    var limit= parseInt(document.getElementById("limitByte").innerText) * 1024;
    if (imgHead.fileSize > limit){
    	
        //alert("too large");
        return false;
    }else
    {
    	//alert("ok");
    	return true;
        
    }
}
function preview(){
	var x = document.getElementById("upFile");
	var y = document.getElementById("imgHead");
	y.width=80;
	y.height=80;
	if(!x || !x.value) return;
	var patn = /\.jpg$|\.gif$/i;
	if(patn.test(x.value)){
		y.src = "file://localhost/" + x.value;
		y.alt='Picture proView';
		//return;
	}else{
		alert('File too big?');
		y.src=document.getElementById('imgURLOld').value;
		return;
	}
}
function checkImg(imgId){
	if(document.getElementById('upFile'.value='')){
		alert('Please chose your file');
		return;
	}
	if(checkSize(imgId)){
		document.img_form.submit();
	}else{
		alert('file size not exceed 30K');
		return;
	}
}