
//图片按比例缩小
function view_pic(obj){
	product_img.src =  obj.src;	
}
function imgWH(ImgD,w,h){
   var image=new Image();
   image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
		if(image.width/image.height>= w/h){
				 if(image.width>w){  
				 ImgD.width=w;
				 ImgD.height=(image.height*w)/image.width;
				 }else{
				 ImgD.width=image.width;  
				 ImgD.height=image.height;
				 }
		}
		else{
				 if(image.height>h){  
				 ImgD.height=h;
				 ImgD.width=(image.width*h)/image.height;     
				 }else{
				 ImgD.width=image.width;  
				 ImgD.height=image.height;
				 }
		}
	}
}

function imgzoom(o) {
	if(event.ctrlKey) {
		var zoom = parseInt(o.style.zoom, 10) || 100;
		zoom -= event.wheelDelta / 12;
		if(zoom > 0) {
			o.style.zoom = zoom + '%';
		}
		return false;
	} else {
		return true;
	}
}

function checkcompare(n){
     var el = document.getElementsByTagName("INPUT"); 
     var len = el.length;
     var e=0;
     for(var i=0; i<len; i++){
        if((el[i].type=="checkbox")&&(el[i].checked==true)){
     		e=e+1;
     	}
     }
     if(e<2){alert("至少要选择两个产品才能进行比较！"+e);return false;}
     if(e>5){alert("每次最多只能比较五个产品！");return false;}
     if(n==1){return true;}else{document.frmcompare.submit();}
}

function showmenu(strID){ 
    var i; 
    var tarObj=document.getElementById(strID+'');

	var mobj;
    for(i=0;i<=3;i++){ 
        var lay; 
        lay = document.getElementById('lay' + i); 
		mobj = document.getElementById('mlay' + i); 
        if (lay.style.display=="" && lay!=tarObj){ 
            lay.style.display = "none"; 
			mobj.className = "";

        } 
		if(lay == tarObj){
			mobj.className = "on";
			
		}
    } 
    if (tarObj.style.display=="none"){ 
        tarObj.style.display = ""; 
    }else{ 
        tarObj.style.display = "none"; 
    } 
}

	function checkform()
	{
	  if(document.form2.name.value=="" )
		{
			alert("称呼不能为空!" );
			document.form2.name.focus();
			return(false);
		}
		
	  if(document.form2.content.value=="" )
		{
			alert("内容不能为空!" );
			document.form2.content.focus();
			return(false);
		}

		return true;
	}
	
	function textCounter(field, maxlimit) { 
		if (field.value.length > maxlimit) 
			field.value = field.value.substring(0, maxlimit); 
		else 
			document.form2.remLen.value = maxlimit - field.value.length;
	}