function checksel(obj){
	var checksign = false;
	if(obj == null){
		alert("没有可用记录！");
		return checksign;
	}
	if(obj.length > 1){
		for(var i = 0;i < obj.length;i++){
			if(obj[i].checked){
				checksign = true;
				break;
			}
		}
	}else{
		if(obj.checked){
			checksign = true;
		}
	}
	if(!checksign){
		alert("请选中一条记录！");
	}
	return checksign;
}
function checkEmail1(obj){
	var checksign = true;
	var emailvalue = obj.value;
	if(emailvalue == null || emailvalue.length == 0){
		checksign = false;
	}else if(emailvalue.indexOf(' ') != -1){
		checksign = false;
		}else if(emailvalue.indexOf('@') == -1 || emailvalue.indexOf('.') == -1){
				checksign = false;
			}else if(emailvalue.substring(0,emailvalue.indexOf('@')).length == 0 || emailvalue.substring(emailvalue.indexOf('@') + 1).length == 0){
				checksign = false;
				}else if(emailvalue.substring(emailvalue.indexOf('.') + 1).length == 0){
					checksign = false;
					}else if(emailvalue.indexOf('@') > emailvalue.indexOf('.')){
						checksign = false;
						}
	if(!checksign){
		alert("您输入的Email格式不对！");
		obj.focus();
		obj.select();
	}
	return checksign;
}
function checkisnull(obj,msg){
	var checksign = true;
	if(obj.value.length == 0){
		alert(msg + "不能为空！")
		obj.focus();
		checksign = false;
	}
	return checksign;
}
function checkisselected(obj,msg){
	var checksign = true;
	if(obj.selectedIndex == 0){
		alert("请选择" + msg)
		obj.focus();
		checksign = false;
	}
	return checksign;
}
function gopagep(gocur)
{
   var x=document.nextpage;
   if(x.KHcurRow!="undefined")
      {x.KHcurRow.value=gocur;
       x.submit();
      }
}

function del(alias,alarm){
 var r=document.nextpage.prodno;
 var clk=false; 	
 var a = 0;         	            
 	if (isNaN(parseInt(r.length))){
 	  clk=r.checked;
 	}else{  
 	  for(i=0;i<r.length;i++){if (r[i].checked){clk=true;i=r.length;}}
 	}
 	if (clk==true){
 	  if(confirm("是否真要删除?")) {
 	  document.nextpage.TASK_ALIAS.value = alias;  
 	  document.nextpage.submit();
 	  }
 	}else{
 	  alert(alarm);
 	}	
 }

function check_tmp(shopper,theform,flag,rowcount){
theform.KHcurRow.name="curRow";
var f=0;
if (rowcount>1){	
	for (i=0;i<rowcount;i++){
		if (khGetElementsValueByName(prodno,i,check)==true)
		{
		f=1;
		i=rowcount;
		}
	}
}else{
	if (khGetElementsValueByName(prodno,0,check)==true){
		f=1;
	}
}
if (f==1){
	if (shopper!=null && shopper!=""){	
		if (rowcount>1){
			var i=0;
			if (flag==1){
				khGetElementsValueByName(TASK_ALIAS,0)="shopcart";
				for (i=0;i<rowcount;i++){
					if (khGetElementsValueByName(prodno,i,check)==true){
						theform.vent[i].name="prvent";
					}else{
						theform.vent[i].name="vent";
					}
				}
			}else if (flag==2){
				theform.TASK_ALIAS.value="collect";
				for (i=0;i<rowcount;i++){
					theform.prodno[i].name="colprodno";
				}
			}
			theform.submit();
		}else{
			if (flag==1){
				theform.vent.name="prvent";
				theform.TASK_ALIAS.value="shopcart";
			}else if (flag==2){
				theform.TASK_ALIAS.value="collect";
				theform.prodno.name="colprodno";
			}
			theform.submit();
		}
	}else{
		newwin=self.open("/bookmall/login_sm.htm","login","width=320 height=150 resizable=no");
		newwin.focus();
	}
}else{
	if (flag==1){
		alert('请选择要购买的书籍！');
	}else{
		alert('请选择要收藏的书籍！');
	}
}
}

function checklog(shopper){
	if (shopper!=null && shopper!=""){
		return true;
	}else{
		newwin=open("/bookmall/login_sm.htm","login","width=320 height=150 resizable=no");
		newwin.focus();
		return false;
	}
}

function checklog_new(shopper,prodnosel){
	if (shopper!=null && shopper!=""){
		return true;
	}else{
		newwin=open("/bookmall/servlet/cn.com.kehwa.KHMTServlet?TASK_ALIAS=testlogin_sm&prodno="+prodnosel,"login","");
		newwin.focus();
		return false;
	}
}

function check_old(shopper,theform,flag,rowcount){
theform.KHcurRow.name="curRow";
var f=0;
if (rowcount>1){	
	for (i=0;i<rowcount;i++){
		if (theform.prodno[i].checked==true)
		{
		f=1;
		i=rowcount;
		}
	}
}else{
	if (theform.prodno.checked==true){
		f=1;
	}
}
if (f==1){
	if (checklog(shopper)){	
		if (rowcount>1){
			var i=0;
			if (flag==1){
				theform.TASK_ALIAS.value="shopcart";
				for (i=0;i<rowcount;i++){
					if (theform.prodno[i].checked==true){
						theform.vent[i].name="prvent";
					}else{
						theform.vent[i].name="vent";
					}
				}
			}else if (flag==2){
				theform.TASK_ALIAS.value="collect";
				for (i=0;i<rowcount;i++){
					theform.prodno[i].name="colprodno";
				}
			}
			theform.submit();
		}else{
			if (flag==1){
				theform.vent.name="prvent";
				theform.TASK_ALIAS.value="shopcart";
			}else if (flag==2){
				theform.TASK_ALIAS.value="collect";
				theform.prodno.name="colprodno";
			}
			theform.submit();
		}
	}
}else{
	if (flag==1){
		alert('请选择要购买的书籍！');
	}else{
		alert('请选择要收藏的书籍！');
	}
}
}

function check(shopper,theform,flag,rowcount){
var alias=theform.TASK_ALIAS.value;
var prodnosel = "";
for (var j=0;j<document.getElementsByName("prodno").length;j++){
	if (document.getElementsByName("prodno")[j].checked==true)
		{prodnosel=document.getElementsByName("prodno")[j].value;}
}
if (checklog_new(shopper,prodnosel)){
	if (rowcount>1){
		var i=0;
		var f=0;
		for (i=0;i<rowcount;i++){
			if (theform.prodno[i].checked==true)
				{f=1;}
		}
		if (f==0){
			if (flag==1){
				alert('请选择要购买的商品！');
			}else{
				alert('请选择要收藏的商品！');
			}
		}else{
			if (flag==1){
				for (i=0;i<rowcount;i++){
					if (theform.prodno[i].checked==true){
						theform.vent[i].name="prvent";
					}else{
						theform.vent[i].name="vent";
					}
				}
				newwin=open("/loading.htm","shoplist","");
				theform.TASK_ALIAS.value="shopcart";
				theform.target="shoplist";
				newwin.focus();
			}else if (flag==2){
				//theform.target="_self";
				theform.TASK_ALIAS.value="collect";
				for (i=0;i<rowcount;i++){
					theform.prodno[i].name="colprodno";
				}
			}
			theform.submit();
		}
	}else{
		if (theform.prodno.checked==true){
			if (flag==1){
				theform.vent.name="prvent";
				newwin=open("/loading.htm","shoplist","");
				theform.TASK_ALIAS.value="shopcart";
				theform.target="shoplist";
				newwin.focus();
				
			}else if (flag==2){
				theform.TASK_ALIAS.value="collect";
				theform.prodno.name="colprodno";
			}
			theform.submit();
		}else{
			if (flag==1){
				alert('请选择要购买的书籍！');
			}else{
				alert('请选择要收藏的书籍！');
			}
		}
	}
}
theform.TASK_ALIAS.value=alias;
//theform.target="_self";
}
function imgchange(){
	setTimeout("imgchange1();",10000);
	}
function imgchange1(n){
 if (n==null) n="coverImg";
for(var i=1;i<=khGetElementsCountByName(n);i++){
  if(khGetElementsByName(n,i).readyState=="uninitialized") khGetElementsByName(n,i).src="/images/jpg/no.jpg";
}
}


function changedivcx(thediv,num,beginnum)
{
	var i=0;
	for(i=0;i<3;i++){
		var nownum = i + beginnum;
		if(document.getElementById("showdiv" + parseInt(nownum)) ){
			if( parseInt(nownum) == parseInt(num)){
				document.getElementById("showdiv" + parseInt(num)).style.backgroundColor="#ffc342";
				document.getElementById("showdiv_content" + parseInt(num)).style.display="";	
				document.getElementById("showdiv_content"+parseInt(num)).backgroundColor="#ffc342";
			}else{
				document.getElementById("showdiv" + parseInt(nownum)).style.backgroundColor="#FAEFDE";
				document.getElementById("showdiv_content"+parseInt(nownum)).style.display="none";
			}
		}else{
			break;
		}
	}
}
