// JavaScript Document
//需要登录
function NeedLogin(oper,value)
{art.dialog.open("/enter.aspx?"+oper+"="+encodeURIComponent(value),{title:'登录',lock:true});}
//大弹出
function ShowLay(con,type,title)
{$.dialog({width:"200px",id:"Show_Our",lock:true,icon:type,content:con,title:title,effect:true});}
//自由弹出层
function ShowHello(con,title)
{$.dialog({width:"600px",id:"Show_Our",lock:true,content:con,title:title,effect:true})}
//type 取值：操作成功：succ,失败.fail,重要提示.cuei,普通提示.cuec,问题解答.prom,搜索提示.sear,添加成功.add,邮件发送成功.mess,编辑.edit
//一般提示弹出层
function Alert(value,type,lock,title)
{if(lock=="")lock=true;var Current=$.dialog({width:"270px",height:"100px",id:"Show_Our",lock:lock,icon:type,title:title,content:value,effect:true});return  Current;}
//关闭弹出窗口
function CloseDialog(EleID)
{$("#"+EleID).live('click',function(){alert("关闭成功")})}

//通用操作
//送礼物
function SendGift(to)
{
	if(to.length>0)
		art.dialog.open("/gift.aspx?id="+to,{title:'送礼物',lock:true});
}
function SendCall(to)
{
	if(to.length>0)
		art.dialog.open("/call.aspx?id="+to,{title:'打招呼',lock:true});
}
//通用的登录
function TopLogin()
{
	var Name=$("#TopUserName").val();
	var Password=$("#TopPassword").val();
	if(Name==null||Name.length==0)
	{
		Alert("用户名不能为空!","cuei",true);
	}
	else if(Password==null||Password.length==0)
	{
		Alert("密码不能为空!","cuei",true);
	}
	else
	{
		if($("#TopType").val()=="common")
		{
		  var current=LoginTo(Name,Password);
		  var tips=new Array("用户名与密码不匹配","登录成功","输入不正确","网络链接超时","未知错误");
		  switch(current)
		  {
			  case 1:Alert(tips[1],"succ",true);location='/user.aspx';break;
			  case 0:Alert(tips[0],"cuei",true);break;
			  case -1:Alert(tips[2],"cuei",true);break;
			  case -2:Alert(tips[3],"cuei",true);break;
			  default:Alert(tips[4],"cuei",true);break;
		  }
		}
		else if($("#TopType").val()=="vip")
		{
		  var current=VipLoginTo(Name,Password);
		  var tips=new Array("用户名与密码不匹配","登录成功","账户被冻结，请联系客服人员","未知错误");
		  switch(current)
		  {
			  case 1:Alert(tips[1],"succ",true);location.reload();break;
			  case 0:Alert(tips[2],"cuei",true);break;
			  case -1:Alert(tips[0],"cuei",true);break;			  
			  default:Alert(tips[3],"cuei",true);break;
		  }
		}
	}
}
function Exit()
{
	$.ajax({cache: false,dataType: "xml",url: "/ajax/exit.ashx",timeout:5000,
		  error:function(xml){ReValue=-2;},		  
		  success:function(xml){			 
			  ReValue=0;
			  $(xml).find("value").each(function(){				
				  var bool=$(this).text();
				  if(bool=="true")
					  	Alert("退出成功!","succ",true);		
						setTimeout(function(){location.reload()},2000);
				});
			  }
	  }) 
}
//登录到服务器
//返回值：1登录成功，0，用户名与密码不匹配，-1数据验证有误,-2网络链接超时,-3未知错误
//n=帐号,p=密码
function LoginTo(n,p)
{
	n=$.trim(n);
	p=$.trim(p);
	if(n==""||p.length<6)
		return -1;
	var ReValue=-3;
	$.ajax({async:false,cache: false,type: "POST",dataType: "xml",url: "/ajax/login.ashx?resource=index",data:{name:n,password:p},timeout:5000,
		  error:function(xml){ReValue=-2;},		  
		  success:function(xml){			 
			  ReValue=0;
			  $(xml).find("user").each(function(){				
				  var bool=$(this).find("login").text();
				  if(bool=="true")
					  ReValue=1;					
				});
			  }
	  }) 
	return ReValue;	
}
//VIp会员登录
//1成功，0冻结，-1错误,-2未知错误
function VipLoginTo(n,p)
{
	n=$.trim(n);
	p=$.trim(p);
	if(n==""||p.length<6)return -2;
	var R=-2;
	$.ajax({async:false,cache: false,type: "POST",dataType: "xml",url: "/ajax/viplogin.ashx",data:{name:n,password:p},timeout:5000,error:function(xml){R=-2;},	  
		  success:function(xml){R=-1;$(xml).find("user").each(function(){ var bool=$(this).find("login").text();if(bool=="true") R=1; else if(bool=="freeze") R=0;});}
	  }) 
	return R;	
}

//收藏
function AddFavorite(){
	if ( window.sidebar && "object" == typeof( window.sidebar ) && "function" == typeof( window.sidebar.addPanel ) ){window.sidebar.addPanel( '芦珊婚恋集团_交友_征婚_婚介_中国权威婚恋机构', 'http://www.ls53.com/', '');	}
	else if ( document.all && "object" == typeof( window.external ) ){window.external.addFavorite( 'http://www.ls53.com/', '芦珊婚恋集团_交友_征婚_婚介_中国权威婚恋机构' );}
}

//点击我的主页
function OpenLogin(flag){if(flag=="1"){Alert("&nbsp;&nbsp;&nbsp;&nbsp;亲爱的用户，您还没登录。请在页面顶部登录，如果您还没注册，请您先注册，记得查看短信，我们的登录密码将发到您的手机中。谢谢。","fail");return false;}}


function SetHome(obj,vrl){
vrl='http://www.ls53.com/default.aspx'
try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);}
catch(e){
if(window.netscape) {
try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
catch (e) {alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);prefs.setCharPref('browser.startup.homepage',vrl);}}
}



//首页的图片切换
function SwitchImgs(acol,con,width,time)
{
	  if(time==null) time=10000;var C=$(con);var Acol=$(acol);var count=C.find("img").size();var TempHtml="";
	  for(i=0;i<count;i++) TempHtml+="<a href='#image'>"+(i+1)+"</a>";
	  Acol.html(TempHtml);var A=$(acol+" a");A.first().addClass("on");
	  if(width==null) width=C.find("img").first().width();	
	  C.css("width",width*count);
	  A.click(function(){var number=A.index($(this));ImgMove(number,width,C,A);})
	  setInterval(function(){var c=A.index($(acol).find(".on"));if(c==null||c<0||c==count-1) c=0;else c=c+1;ImgMove(c,width,C,A);},time);
	  function ImgMove(n,w,C,A){A.removeClass("on");A.eq(n).addClass("on");C.animate({left:'-'+w*n},"slow");}
}
//匹配
function Match(id){art.dialog.open('match.aspx?id='+encodeURIComponent(id), {title: '看一下您的信息是否与我匹配！',width:540,height:560});}
//首页会员切换
function ShowMember(name,number,count)
{
	var i=0;
	for(i=0;i<=count;i++)
	{
		document.getElementById(name+"_"+i).style.display="none";
		document.getElementById(name+i).className="def";		
	}
	document.getElementById(name+"_"+number).style.display="";
	document.getElementById(name+number).className="on";
	if(number==2)
		document.getElementById("IndexMore").href="member.aspx?thesex=female"
	else
		document.getElementById("IndexMore").href="member.aspx?thesex=male"
}

//标签切换
function Tabs(TabA,TabCon,Once)
{
	
	var Tab=$(TabA);//$("#myTabs a");//标签
	var Con=$(TabCon);//$("div.ShowRoom");//切换的层
	var OnceCss=Once;
	Tab.first().addClass("on");Con.hide();Con.first().show();
	Tab.click(function(){Tab.removeClass(OnceCss);$(this).addClass(OnceCss);var flag=Tab.index($(this));Con.hide();Con.eq(Tab.index($(this))).show();})
}
//首页最新会员滚动
function MoveMember(l,a,t)//宽度,数量,时间
{
	var Roll=$("#RollMember");
	var count=$("#RollMember div").size();
	var allwidth=count*l;
	var ow=0//偏移量
	var maxow=allwidth-a*l;//最大偏移量
	Roll.width(allwidth);
	if(count>a)//数量大于临界值则开始滚动
	{setInterval(function(){M(Roll,l)},t)}
	function M(c,w)
	{		
		ow=ow+w;
		if(ow<=maxow) c.animate({left:-ow},"slow")		
		else {c.animate({left:0},"fast");ow=0;}
	}
}

//公交车跳转
function busgo(e){
	str = encodeURI(e);
	window.open("http://www.bjbus.com/home/map_section.php?uTab=1&uType=3&uKeyword="+str);
}
