function $(objName){return(document.getElementById(objName));}  //转换ID
//提交时提交按钮变灰，避免二次提交开始
function CheckInput(button)
{
	document.getElementById( button ).disabled = true;
}
//弹出提示后进入页面开始
function confirmdel_yes(url,title)
{
	if (confirm(title)) 
	{
		//window.location.href=url
		document.write("<form name='hrefform1' method='post' action='"+ url +"'></form>")
		hrefform1.submit()
	}
}
//弹出提示后进入页面结束

//添加管理员
function adminadd(str)
{
	if(form1.adminname.value=="")
	{
		alert("用户名不能为空")
		return false;
	}
	CheckInput(str)
}

//加载页面时间等待
function admin_load()
{
	fh = '"';
	Height = (document.body.scrollHeight+15);
	if(Height<document.body.clientHeight){Height="100%";}
	adminLoad.innerHTML = "<div id='_adminloadalpha' style='position: absolute;top: 0;left: 0;z-index: 1;width: 100%;height:"+ Height +";background-color: #000;filter:alpha(opacity=0);'></div><div style='position: absolute;top: 0;left: "+ (document.body.scrollWidth-180) +";z-index: 2;'><table width='180' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='30' align='center' bgcolor='#FFFFFF' style='font-size:12px;color:#000000;' id='ymzrz'><img src='/Qc.inc/images/loading_16x16.gif' width='16' height='16'>&nbsp;页面载入中...</td></tr></table></div><iframe src='' style="+ fh +"position:absolute; visibility:inherit;top:0px; left:0px; width:100%; height:"+ Height +"; z-index:3; filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';"+  fh+"></iframe>";
	adminloadalpha();
	setTimeout("admin_load_ymzrz()","500")
}

//加载页提示语
var _admin_load_ymzrz = 1
function admin_load_ymzrz()
{
	if(_admin_load_ymzrz==1)
	{
		ymzrz.innerHTML = "<img src='/Qc.inc/images/loading_16x16.gif' width='16' height='16'>&nbsp;页面载入中.&nbsp;&nbsp;";
		_admin_load_ymzrz = _admin_load_ymzrz + 1;
	}
	else if(_admin_load_ymzrz==2)
	{
		ymzrz.innerHTML = "<img src='/Qc.inc/images/loading_16x16.gif' width='16' height='16'>&nbsp;页面载入中..&nbsp;";
		_admin_load_ymzrz = _admin_load_ymzrz + 1;
	}
	else if(_admin_load_ymzrz==3)
	{
		ymzrz.innerHTML = "<img src='/Qc.inc/images/loading_16x16.gif' width='16' height='16'>&nbsp;页面载入中...";
		_admin_load_ymzrz = 1;
	}
	setTimeout("admin_load_ymzrz()","500")
}

//加载页面层渐变.
var _adminloadalpha_i = 0;
function adminloadalpha()
{
	_adminloadalpha_i = (_adminloadalpha_i+5)
	eval("_adminloadalpha").filters.alpha.opacity=_adminloadalpha_i;
	if(_adminloadalpha_i<40)
	{
		setTimeout("adminloadalpha()","1")
	}
}


//图片比例显示
function DownImage(ImgD,MaxWidth,MaxHeight)
{
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		var rate = (image.width > image.height)?MaxWidth/image.width:MaxHeight/image.height;

		if(rate <= 1)
		{
			ImgD.width=image.width*rate;
			ImgD.height=image.height*rate;
		}
		else
		{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
	//tp2.innerHTML=rate;
}

//转换
function index_sqzh(id1,id2,num,class1,class2)
{
	for(i=1;i<=num;i++)
	{
		$("sqzh_"+ id1 +"_"+ i +"_1").className = class1;
		$("sqzh_"+ id1 +"_"+ i +"_2").style.display = "none";
	}
	$("sqzh_"+ id1 +"_"+ id2 +"_1").className = class2;
	$("sqzh_"+ id1 +"_"+ id2 +"_2").style.display = "";
}

//转换2
function index_sqzh_2(id1,id2,num,class1,class2)
{
	for(i=1;i<=num;i++)
	{
		$("sqzh_"+ id1 +"_"+ i +"_1_1").className = class1 + "_1";
		$("sqzh_"+ id1 +"_"+ i +"_1_2").className = class1 + "_2";
		$("sqzh_"+ id1 +"_"+ i +"_1_3").className = class1 + "_3";
		$("sqzh_"+ id1 +"_"+ i +"_2_1").style.display = "none";
	}
	$("sqzh_"+ id1 +"_"+ id2 +"_1_1").className = class2 + "_1";
	$("sqzh_"+ id1 +"_"+ id2 +"_1_2").className = class2 + "_2";
	$("sqzh_"+ id1 +"_"+ id2 +"_1_3").className = class2 + "_3";
	$("sqzh_"+ id1 +"_"+ id2 +"_2_1").style.display = "";
}

//添加行类别
function addUserkindStr()
{
	if(Form1.SKind_IdStr.value=="" || Form1.SSKind_IdStr.value=="")
	{
		alert("请选择行业！")
		return false;
	}
	if((Form1.UserKind.value.split("|").length-1)>6)
	{
		alert("行业最多可选6个！")
		return false;
	}
	Form1.UserKind.value = Form1.UserKind.value.replace("|,skindid:"+ Form1.SKind_IdStr.value +",sskindid:"+ Form1.SSKind_IdStr.value +",|","|") + ",skindid:" + Form1.SKind_IdStr.value + ",sskindid:"+ Form1.SSKind_IdStr.value +",|"
}

//删除行业类别
function delUserkindStr()
{
	if(Form1.UserSKindStr.value=="")
	{
		alert("请选择行业！")
		return false;
	}
	Form1.UserKind.value = Form1.UserKind.value.replace(Form1.UserSKindStr.value,"|")
}

function product_db(product_Id,product_skind_id)
{
	if($("product_id_"+ product_Id +"").checked)
	{
		var HttpAjax = CreateAjaxObject();
		HttpAjax.open("GET","product_db_js.asp?p=add&product_Id="+ product_Id +"&product_skind_id="+ product_skind_id +"&t="+ Math.random() +"",false)
		HttpAjax.send(null)
		if(HttpAjax.readyState == 4 && HttpAjax.status == 200)
		{
			if(HttpAjax.responseText != "")
			{
				alert("最多可同时对比 "+ HttpAjax.responseText +" 条数据")
				$("product_id_"+ product_Id +"").checked = false;
			}
			else
			{
				product_db_list()
			}
		}
	}
	else
	{
		var HttpAjax = CreateAjaxObject();
		HttpAjax.open("GET","product_db_js.asp?p=del&product_Id="+ product_Id +"&product_skind_id="+ product_skind_id +"&t="+ Math.random() +"",false)
		HttpAjax.send(null)
		if(HttpAjax.readyState == 4 && HttpAjax.status == 200)
		{
			product_db_list()
		}
	}
}

function product_db_del()
{
		var HttpAjax = CreateAjaxObject();
		HttpAjax.open("GET","product_db_js.asp?p=alldel&t="+ Math.random() +"",false)
		HttpAjax.send(null)
		if(HttpAjax.readyState == 4 && HttpAjax.status == 200)
		{
			product_db_list()
		}
}

function product_db_list()
{
		var HttpAjax = CreateAjaxObject();
		HttpAjax.open("GET","product_db_list_js.asp?p="+ Math.random() +"",false)
		HttpAjax.send(null)
		if(HttpAjax.readyState == 4 && HttpAjax.status == 200)
		{
			str = HttpAjax.responseText;
			$("ad1").innerHTML = "";
			document.getElementById('ad1').innerHTML = str;
			$('ad_right_lsw_gb').style.display=''
			indexadgd()
		}
}

function CreateAjaxObject()
{
	http_request = false;
	//建立对象 FF
	if(window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
	}
	//IE
	if(!http_request){
		if(window.ActiveXObject)
		{
			try
			{
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	}
	return http_request;

//    var ajax=false;
//   try { 
//    ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
//   } catch (e) { 
//   try { 
//    ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
//    } catch (E) { 
//    ajax = false;
//    } 
//    } 
//    if (!ajax && typeof XMLHttpRequest!='undefined') { 
//    ajax = new XMLHttpRequest(); 
//    } 
//    return ajax;
}


//当前元素具顶端距离
function body_top(element)
{
	var anchor = document.getElementById(element);
	var top_i;
	//top_i = anchor.offsetTop;
	top_i = 0
	if (anchor.offsetParent)
	{
		while (anchor.offsetParent)
		{ 
			top_i += anchor.offsetTop; 
			anchor = anchor.offsetParent;
		}
	}
	return top_i;
}

//当前元素具左边距离
function body_left(element)
{
	var anchor = document.getElementById(element);
	var left_i;
	//left_i = anchor.offsetLeft;	
	left_i = 0;
	if (anchor.offsetParent)
	{
		while (anchor.offsetParent)
		{ 
			left_i += anchor.offsetLeft; 
			anchor = anchor.offsetParent;
		}
	}
	return left_i;
}




