//修复ie6 css背景图cache晃动问题
/*@cc_on
if (document && document.execCommand) {
	try { document.execCommand("BackgroundImageCache",false,true); }
	catch (e) { }
}
@*/




//$
function $(obj){return document.getElementById(obj)}










function fitimgsize(obj, size, addlink, cName) {//元素，宽度，是否加原图链接，对应class的图片
   if(document.getElementById(obj)) {
      var obj2 = document.getElementById(obj).getElementsByTagName("IMG"); 
      var size = size; 
      for (var i = 0; i < obj2.length ; i++ ) {
         if (obj2[i].className == cName) {
            obj2[i].removeAttribute('width'); 
            obj2[i].removeAttribute('height'); 
            var width = obj2[i].naturalWidth || obj2[i].width; 
            var height = obj2[i].naturalHeight || obj2[i].height; 
            //if (height>width) {
            //if (height>size) {
            //obj2[i].title="'点击本图片放大'";
            //obj2[i].onclick=new Function("window.open(this.src);");
            //obj2[i].style.cursor="pointer";
            //width = width * size / height;
            //height = size;
            //};
            //} else {
            if (width > size) {
               if(addlink == "addlink") {
                  obj2[i].title = "点击本图片放大"; 
                  obj2[i].onclick = new Function("window.open(this.src);"); 
                  obj2[i].style.cursor = "pointer"; 
                  }
               height = height * size / width; 
               width = size; 
               }; 
            //};
            //obj2[i].height = height;
            obj2[i].width = width; 
            obj2[i].style.width = width; 
            obj2[i].style.height = ""; 
            }
         }
      }
   }
//window.onload = function() {
//   fitimgsize("product_img", 200, "nolink", "photoList1");//产品列表的细图
//   fitimgsize("product_show_small", 200, "nolink", "");//产品内页的细图  
//   fitimgsize("product_show_big", 600, "addlink", "");//产品内页的大图  
//   }
 







//ajax
function echo(obj,html)
{
	try{
		$(obj).innerHTML=html;
	}catch(er){}
}


function createxmlhttp()
{
	var xmlhttp=false;
	try	{
  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} 
	catch (e) {
  		try {
   			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} 
		catch (e) {
   			xmlhttp = false;
 		}
 	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  		xmlhttp = new XMLHttpRequest();
				if (xmlhttp.overrideMimeType) {//设置MiME类别
			xmlhttp.overrideMimeType('text/xml');
		}
	}	

	return xmlhttp;	
}
function getdata(url,obj1,obj2,method)
{
	
		url=url+'&rnd='+ Math.random()
		var xmlhttp=createxmlhttp();
		if(!xmlhttp)
		{
			alert("你的浏览器不支持XMLHTTP！！");
			return;
		}
		if(obj1!=""){
			echo(obj1,"读取资料中,请等候......");
		}
		xmlhttp.onreadystatechange=requestdata;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		function requestdata(){
				if(xmlhttp.readyState==4)
				{	
					if(method==-1)alert(xmlhttp.responseText);
					if(xmlhttp.status==200)
					{
						echo(obj2,xmlhttp.responseText);
//						$j('.lightBox a').lightbox();			
	$j(".lightBox a").colorbox({transition:"fade"});
					}
				}
			
		}
}





