
//设置XMLHTTP对象
	function getAjax()
	{
		var XmlHttp;	
		//Creating object of XMLHTTP in IE
		try
		{
			XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				XmlHttp = null;
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
		{
			XmlHttp = new XMLHttpRequest();
		}
		return XmlHttp;
	}
	
	
	function checkPicture()
	{
		var filePathAndName;
		var allItem = document.getElementsByTagName("Img");
		var formatwidth = 65;  //设定格式化宽度
		var formatheight = 65; //设定格式化高度
		var outwidth;          //输出宽度
		var outheight;         //输出高度
		var width;             //原图片宽度
		var height;            //原图片高度

		for(i=0;i<allItem.length;i++)
		{
			if(allItem[i].getAttribute("Id")=="productpicture")
			{
				if(allItem[i].getAttribute("filename")!="" && allItem[i].getAttribute("filename").toLowerCase()!="detail_no_pic.gif")
				{
				    	filePathAndName = "http://www.cnledcn.com/UploadPicture/ProductPicture/" + allItem[i].getAttribute("filename");
				//	filePathAndName = "http://www.cnledcn.com/UploadPicture/S_ProductPicture/F_" + allItem[i].getAttribute("filename");
				//	filePathAndName2 = "http://www.cnledcn.com/UploadPicture/S_ProductPicture2/F_" + allItem[i].getAttribute("filename");
					
				//	var oreq = getAjax();
				//	oreq.open("Get",filePathAndName,false);
				//	oreq.send();
				//	if(oreq.status == 404)
				//	{
				//		filePathAndName = filePathAndName2;
				//	}
				}
				else
				{
					if(allItem[i].getAttribute("biztype")=="1")
					{
						filePathAndName = "http://www.cnledcn.com/images/wutup.jpg";
					}
					else
					{
						filePathAndName = "http://www.cnledcn.com/images/wutup_qiugou.jpg";
					}
				}
				allItem[i].setAttribute("src",filePathAndName);
				showerrorimg(allItem[i].getAttribute("biztype"),i);
			}
				
		}
	}
	
	function IsExistsPicture(picFile)
	{
		var oreq = getAjax();
		oreq.open("Get",picFile,false);
		oreq.send();
		alert(oreq.status)
		if(oreq.status==404)
		{
			alert('不存在');
		}
		else
		{
			alert("存在")
		}
	}

	
	//缩放多张图片
	function ZoomAllPicture(setformatwidth,setformatheight)
	{
		var filePathAndName;
		var allItem = document.getElementsByTagName("Img");
		var formatwidth = Number(setformatwidth);  //设定格式化宽度
		var formatheight = Number(setformatheight); //设定格式化高度
		var outwidth;          //输出宽度
		var outheight;         //输出高度
		var width;             //原图片宽度
		var height;            //原图片高度

		for(var i=0;i<allItem.length;i++)
		{
			if(allItem[i].getAttribute("Id")=="productpicture")
			{
				if(allItem[i].getAttribute("filename")!="" && allItem[i].getAttribute("filename")!="detail_no_pic.gif")
				{
					filePathAndName = "http://www.cnledcn.com/UploadPicture/ProductPicture/" + allItem[i].getAttribute("filename");
				}
				else
				{
					if(allItem[i].getAttribute("biztype")=="1")
					{
						filePathAndName = "http://www.cnledcn.com/images/wutup.jpg";
					}
					else
					{
						filePathAndName = "http://www.cnledcn.com/images/wutup_qiugou.jpg";
					}
				}
				allItem[i].setAttribute("src",filePathAndName);
				
				width = Number(allItem[i].width);
				height = Number(allItem[i].height);
				if(width>height)
				{
					outwidth = formatwidth;
					outheight = Number(height*(formatwidth/width));
				}
		
				if(height>width)
				{
					outheight = formatheight;
					outwidth = Number(width*(formatheight/height));
				}
		
				if(height==width)
				{
					outwidth = formatwidth;
					outheight = formatheight;
				}
				
				allItem[i].setAttribute("width",outwidth);
				allItem[i].setAttribute("height",outheight);
			}
			
			showerrorimg(allItem[i].getAttribute("biztype"),i);
		}
	}
	
	//缩放单张图片
	function ZoomPicture(pictureid,formatwidth,formatheight)
	{
		var outwidth;          //输出宽度
		var outheight;         //输出高度
		var width;             //原图片宽度
		var height;            //原图片高度
		
		var obj = document.getElementById(pictureid);
		width = parseFloat(obj.width);
		height = parseFloat(obj.height);

		if(width>height)
		{
			if(width>parseFloat(formatwidth))
			{
				outwidth = parseFloat(formatwidth);
			}
			else
			{
				outwidth = width;
			}
			outheight = parseFloat(height*(outwidth/width));
		}
		
		if(height>width)
		{
			if(height>parseFloat(formatheight))
			{
				outheight = parseFloat(formatheight);
			}
			else
			{
				outheight = height;
			}
			outwidth = parseFloat(width*(outheight/height));
		}
		
		if(height==width)
		{
			if(width>parseFloat(formatwidth))
			{
				outwidth = parseFloat(formatwidth);
			}
			else
			{
				outwidth = width;
			}
			if(height>parseFloat(formatheight))
			{
				outheight = parseFloat(formatheight);
			}
			else
			{
				outheight = height;
			}
		}

		document.getElementById(pictureid).onerror = function()
		{
			obj.setAttribute("src","http://www.cnledcn.com/UploadPicture/ProductPicture/detail_no_pic.gif");
		}
				
		obj.setAttribute("width",parseFloat(outwidth));
		obj.setAttribute("heigth",parseFloat(outheight));
		//obj.height = parseFloat(outheight);
		
	}
	
	//显示错误图片
	function showerrorimg(biztype,pictureid)
	{
	
		var allItem = document.getElementsByTagName("Img");
		allItem[pictureid].onerror = function()
		{
			if(biztype=="2")
			{
				allItem[pictureid].setAttribute("src","http://www.cnledcn.com/images/wutup_qiugou.jpg");
			}
			else if(biztype=="")
			{
				allItem[pictureid].setAttribute("src","http://www.cnledcn.com/UploadPicture/ProductPicture/detail_no_pic.gif");
			}
			else
			{
				allItem[pictureid].setAttribute("src","http://www.cnledcn.com/images/wutup.jpg");
			}
		}
	}
	
	
