

//表格选项卡
function setTab(idTags,currentTags,totalTags){
	for(i=1;i<=totalTags;i++){
		var obj = document.getElementById(idTags+i);
		var obj2 = document.getElementById(idTags+"_"+i);
		if(i==currentTags){
			obj.className = "active";
			obj2.style.display = "block"; 
		}else{
			obj.className = "normal";
			obj2.style.display = "none"; 
		}
	}
}



var loadingicon= "<div style='text-align:center'><img src='/images/loading_16x16.gif'></div>";

function Addme(){ 
	url = "http://www.china-nme.com/";
	title = "中国有色设备网";
	window.external.AddFavorite(url,title); 
}

//添加收藏夹
function toFav(title,iurl){
	window.external.AddFavorite(iurl,title); 
}
//打印
function PrintPage(){
$("#myPrintArea").printArea();
}
//复制
function toFriend(title){
	window.clipboardData.setData("text",location.href); 
	window.alert("【"+title+"】地址已复制到您的剪切栏，可直接粘贴(CTRL+V)发送给您的好友!");
}
/**
 * 按钮页面跳转
 */
function href_onClick(url){
	alert(url);
	window.location.href = url;
}



//等比例缩放图片
function imgadapter(obj,width,height){
	var max_height = height-6; 
	var max_width = width-6;      
	var real_height = obj.height;
	var real_width = obj.width;
	var img_pdding;
	if(obj.height>max_height)
	{
	   obj.height = max_height;
	   obj.width = Math.round(obj.height*(real_width/real_height));
	}
	if(obj.width>max_width)
	{
	   obj.width = max_width;
	   obj.height = Math.round(obj.width*(real_height/real_width));
	}

	if(obj.height<max_height)
	{
	   img_padding = Math.round((max_height-obj.height)/2);
	   obj.style.paddingTop=img_padding;
	   obj.style.paddingBottom=img_padding;
	}
	if(obj.width<max_width)
	{
	   img_padding = Math.round((max_width-obj.width)/2);
	   obj.style.paddingLeft=img_padding;
	   obj.style.paddingRight=img_padding;
	}
	obj.style.visibility ='visible' ;
}

function onClick_doLogin(submit_url){
	if($("#mmid").val()==""){
		alert("请输入会员名！");
		sform.mmid.focus();
		return false;
	}
	if($("#mmpwd").val()==""){
		alert("请输入密码！");	
		sform.mmpwd.focus();
		return false;
	}
	sform.action = submit_url;
	sform.submit();
}

function clearInput(){
	$("#advice_email").val("");
}


//本网建议
function onClick_doAdvicePost(){
	var _advice_content = encodeURI(encodeURI($("#advice_content").val()));
	var _advice_email = encodeURI($("#advice_email").val());
	if(_advice_content==""){
		alert("请输入留言内容");
		return;
	}
	if (_advice_email.length > 0 && !_advice_email.match( /^.+@.+$/ ) ) {
		alert("您输入的E-mail格式不正确！");
		return;
	}	
	$.ajax({
		type:"POST",
		url:"/advice/save.do",
		timeout: 20000,
		data: "advice_content="+_advice_content+"&advice_email="+_advice_email,
		error: function(){alert('提交失败，您提交的地址不存在！');},
		success:function(data){
			alert("感谢您的建议，我们会尽快改善！");
		}}
	);
}

//求购信息发布
function check_so_data(obj){
	if($("#m_password").val()!=$("#re_m_password").val()){
		alert("两次输入的密码不同，请重新输入");
		$("#m_password").focus();
		return false;
	}
	if(Validator.Validate(obj,2)){
		obj.submit();
	}
}

function href_doFavInfo(_mId,_from_mId,_pId,_msgType,_msgFree){
	$.get("/ajax/doFavInfo.do",{mId:_mId,from_mId:_from_mId,pId:_pId,msgType:_msgType,msgFree:_msgFree},
		function(data){
			if(data=="0"){
				alert("您还没有注册，请注册后使用本功能，谢谢！");
			}else{
				alert("操作成功，感谢您的使用！");
			}
		}
	);
}
//收藏公司、产品对比结果	mid:,msgType:,mids:,pids:
function save_compare_result(_mid,_msgType,_mids,_pids){
	$.get("/ajax/save_compare_result.do",{mid:_mid,msgType:_msgType,mids:_mids,pids:_pids},
		function(data){
			if(data=="0"){
				alert("您还没有注册，请注册后使用本功能，谢谢！");
			}else{
				alert("结果已保存，请登陆后台管理\"信息反馈\"收藏夹，查看收藏结果");
			}
		}
	);
}


//留言信息验证
function check_msg_data(obj){
	if($("#jrcode_value").val()==""){
		alert("请输入验证码！");
		$("#jrcode_value").focus();
		return false;
	}
	if(Validator.Validate(obj,2)){
		obj.submit();
	}
}


