
(function($){
$.fn.extend({
	div_src:function(num,speed,stime){
		var q_this=this;
		var q_height=$('.pro_r_01_in01_li:last').height();
		var downHeight=num*q_height;
		scrollUp=function(){
			q_this.animate({marginTop:downHeight},speed,function(){$('.pro_r_01_in01_li').eq(13).hide();$('.pro_r_01_in01_li').eq(12).hide();$('.pro_r_01_in01_li').eq(13).prependTo(q_this);$('.pro_r_01_in01_li').eq(12).prependTo(q_this);q_this.css({marginTop:0});$('.pro_r_01_in01_li').eq(0).fadeIn('600');$('.pro_r_01_in01_li').eq(1).fadeIn('600')})			
			}
			
		q_this.hover(function(){
			clearInterval(setT);
		},function(){
			setT=setInterval("scrollUp()",stime);
		}).mouseout();
	}			
})
})(jQuery)

$().ready(function(){	   
	tab("index_tuijian_top_js","index_tuijian_in","index_tuijian_a");
	tab("index_zx_top_js","index_zx_in01","index_tuijian_a");
	tab("index_zx_top_js1","index_zx_in02","index_tuijian_a");
	
	
	//检测注册帐号
	$("#reg_check").click(function(){
		var val=$("#reg_username").val().replace(/[ ]/g,"");
		if(val=="" || val.length<6 || val.length>16){
			$("#ts_user").html("<font color=#cc0000><b>×</b> 注册名为空或长度不对</font>");
		}else{
			$("#ts_user").html("检测中...").load("../checkuser.aspx?user="+val);	
		}
	})
	//注册地址选择
		$("#reg_adds1").attr("disabled","disabled");							
		$("#reg_adds2").attr("disabled","disabled");							
		$("#reg_adds3").attr("disabled","disabled");							
		$("#reg_add2").attr("disabled","disabled").css("background","#eee");							
	$("#reg_r1").click(function(){
		$("#reg_add1").attr("disabled","").css("background","#fff");							
		$("#reg_adds1").attr("disabled","disabled");							
		$("#reg_adds2").attr("disabled","disabled");							
		$("#reg_adds3").attr("disabled","disabled");							
		$("#reg_add2").attr("disabled","disabled").css("background","#eee");							
	});
	$("#reg_r2").click(function(){
		$("#reg_adds1").attr("disabled","");							
		$("#reg_adds2").attr("disabled","");							
		$("#reg_adds3").attr("disabled","");							
		$("#reg_add2").attr("disabled","").css("background","#fff");							
		$("#reg_add1").attr("disabled","disabled").css("background","#eee");							
	});
})

function gofy(){
	location.href=$("#fy_go").attr("vv")+$("#fy_num").val();
}

function login(){
	$('<div id="public_mark"></div><div id="public_login"><div class="public_login_in"><iframe width="100%" height="200px"  marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" name="iframe_dl" id="iframe_dl" src="public_dl.aspx"></iframe></div></div>').appendTo("body");
	$("#public_mark").css({height:$(document).height()});
	$("#iframe_dl").focus();
}

function login_pro(){
	$('<div id="public_mark"></div><div id="public_login"><div class="public_login_in"><iframe width="100%" height="200px"  marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" name="iframe_dl" id="iframe_dl" src="../public_dl.aspx"></iframe></div></div>').appendTo("body");
	$("#public_mark").css({height:$(document).height()});
	$("#iframe_dl").focus();
}

function RemoveLogin(){
	$('#public_mark',window.parent.document).remove();
	$('#public_login',window.parent.document).remove();
}

function login_out(){
$.ajax({
  url: "login_out.aspx?action=del",
  cache: false,
  success: function(){
	parent.location.replace(parent.location.href);
  }
});   
}
function login_out_pro(){
$.ajax({
  url: "../login_out.aspx?action=del",
  cache: false,
  success: function(){
	parent.location.replace(parent.location.href);
  }
});   
}

function tab(id,cls,cls2){
	var t_li=$("#"+id+" span");
	var cls=$("."+cls+"");
	for (var i=0;i<cls.length;i++){
	  (function(i){
		t_li.eq(i).mouseover(function(){
			t_li.attr("class","");
			$(this).attr("class",cls2);
			cls.css("display","none");
			cls.eq(i).css("display","inline");
		});
	  })(i);
	}
}
	
var F={
	id:$("#pro_in_js"),//ID
	hnum:7,//每次滚动的横排数 横排  如竖排滚动，设为1即可
	snum:7,//行数   竖排  如横排滚动，设为与 hnum 相同
	gaonum:1,//滚动行数高度   如竖排滚动,设与 hnum 相同，如横排，看需要
	topnum:4,//每次滚动的距离
	height:4,//兼容IE和FF ID边框问题，如ID无边框，设置为 0 即可
	top:0,
	mtime:20,//滚动动画时间
	mtime_num:2,//动画时间倍数（兼容横排数多时IE动画效果比FF慢）
	ttime:6000,//滚动停顿时间
	set:null,//Interval参数1
	gd:null,//Interval参数2
	marquee:function(){
		F.top=F.top+F.topnum;
		for(var i=0;i<F.hnum;i++){
			F.id.find("li").eq(i).css({marginTop:-F.top});
		}
		if(F.top>=(F.id.find("li:first").height()+F.height)*F.gaonum){
			clearInterval(F.set);
			for(var i=0;i<F.snum;i++){
				F.id.find("li:first").css({marginTop:0}).appendTo(F.id);
			}
			F.top=0;
		}
	},
	start:function(){
		F.id.hover(function(){clearInterval(F.gd)},function(){F.gd=setInterval(function(){F.set=setInterval(F.marquee,$.browser.msie?F.mtime/2:F.mtime);},F.ttime)}).mouseout();
	}		
}

/*
	JC.append('图片地址','链接URL','标题文字')
	JC.width=图片宽度
	JC.height=图片高度
	JC.time=毫秒
	JC.start()
*/
var JC={
		width:228,
		height:150,
		time:4000,
		data:[],
		opacity:100,
		now:null,
		next:null,
		interval:null,
		blank:'_blank',
		first:0,//从第几个开始播放；
		$:function(){return document.getElementById(arguments[0])},
		dw:function(){return document.write(arguments[0])},
		_open:function(url){window.open(url);},
		setAlpha:!-[1,]?function(opacity){JC.$('jc_picup').style.filter="alpha(opacity="+opacity+")";}:function(opacity){JC.$('jc_picup').style.opacity=opacity/100;},
		append:function(){
			 var jc_d=[];
			 for(var i=0,l=arguments.length;i<l;i++){
			 	jc_d.push(arguments[i]=undefined?'':arguments[i].replace('"','\"'));
			 }
			 JC.data.push(jc_d);			 
		},
		setAnimate:function(){
			if(JC.opacity>0){
				var step = Math.ceil((100-JC.opacity+1)/5);
				if(JC.opacity<step)step=JC.opacity;
				JC.opacity -= step;
				JC.setAlpha(JC.opacity);
				setTimeout("JC.setAnimate()",10);
			}else{
				JC.$('jc_picup').innerHTML = JC.$('jc_picdown').innerHTML;
				JC.setAlpha(JC.opacity);
				JC.now=JC.next;
				JC.opacity = 100;
			}
		},
		setLunhuan:function(num){
			if(num==undefined){	
				num=JC.now+1;
			}else{
				if(JC.now==num){return};
			}
			JC.next=num;
			if(JC.next==JC.data.length){JC.next=0;}	
			JC.$('jc_picdown').innerHTML="<a href='"+JC.data[JC.next][2]+"' target='"+JC.blank+"'><img src='"+JC.data[JC.next][0]+"'/></a>";
			JC.autoEnd();
			JC.$('jc_picdown').getElementsByTagName('IMG')[0].onload=function(){				
				JC.setStyle();
				JC.setAnimate();
				JC.autoBegin();
				//JC.echo();
			}
			
		},
		start:function(){
			if(!JC.data.length){
				JC.dw('没有任何信息可展示！');return;
			}
			var updiv=document.createElement('DIV');
			var downdiv=updiv.cloneNode(false);
			JC.dw('\
				<style type="text/css">\
				.jc_all{width:'+JC.width+'px;float:left;}\
				.jc_all img{border:0;width:'+JC.width+'px;height:'+JC.height+'px;}\
				#jc_pic{width:'+JC.width+'px;overflow:hidden;cursor:pointer;height:'+JC.height+'px;}\
				#jc_picup{width:'+JC.width+'px;position:absolute;overflow:hidden;cursor:pointer;height:'+JC.height+'px;}\
				#jc_picdown{width:'+JC.width+'px;overflow:hidden;cursor:pointer;height:'+JC.height+'px;}\
				#jc_pictitle{height:20px;position:absolute;margin:-22px 0px 0px 118px;}\
				.jc_bt{width:20px;margin:0px 2px;background:#fff;float:left;line-height:18px;border:#ddd 1px solid;color:#333;text-align:center;cursor:pointer;font-family:Verdana, Arial}\
				.jc_bt1{width:20px;margin:0px 2px;background:#ff7d05;float:left;line-height:18px; border:#ddd 1px solid;color:#fff;text-align:center;cursor:pointer;font-family:Verdana, Arial}\
				</style>\
			')
			JC.now=JC.first;
			JC.dw("<div class='jc_all'>");
			JC.dw("<div id='jc_pic'></div>");
			updiv.innerHTML="<a href='"+JC.data[JC.now][2]+"' target='"+JC.blank+"'><img src='"+JC.data[JC.now][0]+"'/></a>"
			updiv.id='jc_picup';
			downdiv.id='jc_picdown';
			JC.$('jc_pic').appendChild(updiv);
			JC.$('jc_pic').appendChild(downdiv);
			JC.dw("<div id='jc_pictitle'>");
			for(var i=0,l=JC.data.length;i<l;i++){JC.dw("<div class='jc_bt' onclick=JC._open('"+JC.data[i][2]+"') onmouseover='JC.setLunhuan("+i+")'>"+JC.data[i][1]+"</div>");}
			JC.dw("</div></div>");
			JC.$('jc_picdown').onmouseover=JC.autoEnd;
			JC.$('jc_picdown').onmouseout=JC.autoBegin;
			JC.setStyle(true);
			JC.$('jc_picup').getElementsByTagName('IMG')[0].onload=function(){
				JC.autoBegin();
			}			
		},
		setStyle:function(t){
			var list=JC.$('jc_pictitle').getElementsByTagName('DIV');
			if(t){
				list[JC.now].className='jc_bt1';
			}else{
				for(var i=0,l=JC.data.length;i<l;i++){
					list[i].className='jc_bt';
				}
				list[JC.next].className='jc_bt1';
			}
		},
		autoBegin:function(){
			if(!JC.interval){JC.interval=setInterval("JC.setLunhuan()",JC.time);}
		},
		autoEnd:function(){
			if(JC.interval){clearInterval(JC.interval);JC.interval=undefined;}
		}
		
}


function reg1_check(){
//alert(111);
if($("#reg_username").val()=="" || $("#reg_username").val().length >16 || $("#reg_username").val().length <6 ){$("#ts_user").html("<font color=#cc0000><b>×</b> 注册名为空或长度不对</font>");$("#reg_username").focus();return false;}
if($("#reg_password").val()=="" || $("#reg_password").val().length >16 || $("#reg_password").val().length <6 ){$("#ts_psw").html("<font color=#cc0000><b>×</b> 密码格式不正确</font>");$("#reg_password").focus();return false; }else{$("#ts_psw").html("<b>√</b>");}
if($("#reg_pswcf").val()=="" || $("#reg_pswcf").val()!=$("#reg_password").val() || $("#reg_pswcf").val().length >16 || $("#reg_pswcf").val().length <6 ){$("#ts_pswcf").html("<font color=#cc0000><b>×</b>两次密码不一样</font>");$("#reg_pswcf").focus();return false; }else{$("#ts_pswcf").html("<b>√</b>");}
if($("#reg_code").val().length!=4){$("#ts_code").html("<font color=#cc0000><b>×</b> 验证码格式不正确</font>");$("#reg_code").focus();return false;}else{$("#ts_code").html("<b>√</b>");}
//if($("#reg_name").val()=="" ){alert("请填写注册人姓名！");$("#reg_name").focus();return false; }
//if($("#reg_tel").val()=="" ){alert("请填写座机电话！");$("#reg_tel").focus();return false; }
//if($("#reg_mobil").val()=="" ){alert("请填写手机号码！");$("#reg_mobil").focus();return false; }
//if($("#reg_mail").val()=="" ){alert("请填写邮箱地址！");$("#reg_mail").focus();return false; }
//if($("#reg_qs").val()=="" ){alert("请填写提示问题！");$("#reg_qs").focus();return false; }
//if($("#reg_answer").val()=="" ){alert("请填写答案！");$("#reg_answer").focus();return false; }
//if($("#reg_comname").val()=="" ){alert("请填写公司名称！");$("#reg_comname").focus();return false; }
//if($("#reg_hy").val()==0 ){alert("请选择主营行业！");$("#reg_hy").focus();return false; }
//if($("#reg_pro").val()==0 ){alert("请选择主要产品，最少一个！");$("#reg_pro").focus();return false; }
}

//半角转全角
function conv(s){
	s=s.replace(/[ ]/g,"")
	s=s.replace(/!/gi,"！");
	s=s.replace(/</gi,"＜");
	s=s.replace(/>/gi,"＞");
	s=s.replace(/\(/gi,"（");
	s=s.replace(/\)/gi,"）");
	s=s.replace(/'/gi,"＇");
	s=s.replace(/"/gi,"＂");
	s=s.replace(/:/gi,"：");
	s=s.replace(/;/gi,"；");
	s=s.replace(/~/gi,"～");
	s=s.replace(/\^/gi,"＾");
	s=s.replace("<font color=#cc0000>","")
	s=s.replace("</font>","")
	return s;
}


function favourite(id,user){
	if($("#pro_check_login").length>0){
		alert("请登录后再操作，如没有帐号，请先注册！")
	}else{
		if(confirm("确定关注吗？")){
			$.ajax({
			  url: "pro_manage.aspx?type=1&id="+id+"&adduser="+user,
			  cache: false,
			  success: function(data){
				alert(data);
			  }
			});   
		}
	}
}

function xiadan(id,user,cname){
	var num=$("#probuy_num").val();
	var reg=/^[1-9]\d*$/gi;
	if(!reg.test(num)){
		alert("请输入数字！")
	}else{
		$.ajax({
		  url:"pro_manage.aspx",
		  data:"type=2&id="+id+"&adduser="+user+"&cname="+cname+"&num="+num,
		  cache: false,
		  success: function(data){
			var backdata=data.substring(data.length-1,data.length)
			if(backdata==1){
				alert(data.substring(0,data.length-1));
			}else{
				alert(data.substring(0,data.length-1));
				proli_remove();				
			}
		  }
		});  
	}
}

function message(id,user,cname){
	var ly=conv($("#probuy_liuyan").val());
	var code=conv($("#probuy_code").val());
	//var reg_code=/^([a-zA-Z0-9]){4}$/gi;
	if(ly.length>140 || ly.length<1 || code.length!=4){
		alert("内容长度不对或不正确的验证码！");
	}else{
		$("#proly_ts").show();
		$.ajax({
		  url:"pro_manage.aspx",
		  data:"type=3&id="+id+"&adduser="+user+"&cname="+cname+"&ly="+ly+"&code="+code,
		  cache: false,
		  success: function(data){
			var backdata=data.substring(data.length-1,data.length)
			if(backdata==1){
				$("#proly_ts").hide();
				alert(data.substring(0,data.length-1));
			}else{
				$("#proly_ts").hide();
				alert(data.substring(0,data.length-1));
				proli_remove();				
			}
		  }
		});  			
	}
}

function proli_remove(){
	$("#pro_xiadan").remove();	
	$("#pro_liuyan").remove();
}

function ly_shuzi(){
	$("#probuy_zishu").html($("#probuy_liuyan").val().length);
	if($("#probuy_liuyan").val().length>139){
		alert("请注意，最多输入 140 个字符！多余部分将被删除！");	
	}
}

function proli_manage(type,x,id,name,cname){
	proli_remove();
	name=conv(name);
	cname=conv(cname);
	if($("#pro_check_login").length>0){
		alert("请登录后再操作，如没有帐号，请先注册！")
	}else{
		if(type==1){
			$('<div id="pro_xiadan"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="28" colspan="2">产品：<span id="probuy_cname">产品名称</span></td></tr><tr><td width="44%" height="28">数量：<input type="text" id="probuy_num" size="6" style="border:#99cccc 1px solid; padding:2px;" maxlength="20"/>&nbsp;&nbsp;<span style="color:#666;">数字：50</span></td><td width="56%"><input type="button" ID="probuy_btn" title="下订单" onclick=xiadan('+id+',"'+name+'","'+cname+'") /></td></tr></table><div onclick="proli_remove()" id="probuy_hide">关闭</div></div>').appendTo(x);
		}else{
			$('<div id="pro_liuyan"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td height="30" colspan="4">产品：<span id="probuy_cname">产品名称</span></td></tr><tr><td colspan="4"><textarea onkeyup="ly_shuzi()" id="probuy_liuyan"></textarea></td></tr><tr><td height="38" width="18%"><input type="text" maxlength="4" id="probuy_code" size="6" style="border:#ff9933 1px solid; padding:3px;" maxlength="20"/></td><td width="27%"><img src="Imgcode.aspx" title="验证码看不清,点击换一张! " id="BValidImg" style="cursor:pointer;" onClick=javascript:this.src="Imgcode.aspx?r="+Math.random() width="50" height="18"></td><td class="probuy_tishi" width="29%" aglin="right"><b><span id="probuy_zishu">0</span> / 140</b> 字</td><td aglin="left"><input type="button" ID="probuy_btn_ly" onclick=message('+id+',"'+name+'","'+cname+'") /></td></tr></table><div style="margin:-164px 9px 0px 0px;cursor:pointer;float:right;"><img src="images/ly_close.gif" title="关闭" onclick="proli_remove()" /></div><div style="float:right;margin-top:8px;line-height:30px;display:none;" id="proly_ts"><img src="images/1-12.gif"/> 留言提交中......</div></div>').appendTo(x);
		}
		$("#probuy_cname").html(cname);
	}
}

function pro_ly_zishu(){
	if(conv($("#pro_con_pl").val()).length>200){
		alert("字数过多,请删减!");
	}
	$("#pro_ly_zishu").html(200-conv($("#pro_con_pl").val()).length);
}

function procon_ly(){
	var ly=conv($("#pro_con_pl").val());
	var code=conv($("#pro_code").val());
	var cname=conv($("#pro_cname").html());
	var id=conv($("#bianhao").html());
	var user=conv($("#pro_adduser").html());
	if(conv($("#pro_con_pl").val())=="" || conv($("#pro_con_pl").val()).length>200 || conv($("#pro_code").val()).length!=4){
		alert("请输入200字内的留言内容和正确的验证码!");	
	}else{
		$.ajax({
		  url:"../pro_manage.aspx",
		  data:"type=4&id="+id+"&adduser="+user+"&cname="+cname+"&ly="+ly+"&code="+code,
		  cache: false,
		  success: function(data){
			  alert(data);
			  $("#pro_con_pl").val("");
			  $("#pro_code").val("");	
			  pl_page();
		  }
		});  			
	}
}

function pl_page(){
	var id=conv($("#bianhao").html());
	$.ajax({
	  url:"../pro_pinglun.aspx",
	  data:"id="+id,
	  cache: false,
	  success: function(data){
		  $("#get_plcon").html(data);
	  }
	});  			
}

function pl_jubao(id){
	$.ajax({
	  url:"../pro_manage.aspx",
	  data:"type=5&id="+id,
	  cache: false,
	  success: function(data){
		  alert(data);
	  }
	});  			
}




