<!--
/*
 Subsite login service script 
 Version 2014.3.20
 spring @ 2013.3.20
*/
String.prototype.replaceAll2=function(s1,s2)
{
	var demo=this;
	while(demo.indexOf(s1)!=-1)
		demo=demo.replace(s1,s2);
	return demo;
}

//Enc.js

function Enc(){_keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";this.encode=function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=_utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}
output=output+
_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+
_keyStr.charAt(enc3)+_keyStr.charAt(enc4);}
output=output.replaceAll2('=','_');output=output.replaceAll2('+','.');output=output.replaceAll2('/','-');return output;}
this.decode=function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=_keyStr.indexOf(input.charAt(i++));enc2=_keyStr.indexOf(input.charAt(i++));enc3=_keyStr.indexOf(input.charAt(i++));enc4=_keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}
if(enc4!=64){output=output+String.fromCharCode(chr3);}}
output=_utf8_decode(output);return output;}
_utf8_encode=function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c);}else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;}
_utf8_decode=function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return string;}}


var _login_flag = 0; 
var BASE_URL = 'http://me.07073.com';
var SERVICE_URL = BASE_URL + '/service';

$.ajaxSetup({ 
	cache: true
}); 

var _inited = false;
var once_cylogout = 0;
function json_get_login_stauts()
{
	try {
		$.getScript(SERVICE_URL + "/jsonLoginStautsspring/", function(){
			//判断公告是否加载过，如果加载过，不重新加载
			if(userinfo.mark==1){//普通文字
				var pl=$('#ancl p').length;			
				if(pl==0){
					$("#an").attr('class','');
					$("#an").addClass('cs14_thisLaba');
					var notice_html = '<div id="anc" style="height:32px"><div id="ancl"><p><a href="'+userinfo.notice_url0+'" target="_blank">'+userinfo.notice0+'</a></p><p><a href="'+userinfo.notice_url1+'" target="_blank">'+userinfo.notice1+'</a></p>'+(userinfo.notice2 ? '<p><a href="'+userinfo.notice_url2+'" target="_blank">'+userinfo.notice2+'</a></p>':'')+'</div></div>';
					$('#an').html(notice_html);
					$('#an').show();
					announcement();
				}
			}else if(userinfo.mark==2){
				var pl=$('#an ul:first li').length;			
				if(pl==0){
					$("#an").attr('class','');
					$("#an").addClass('cs14ImgBoxing');
					$('#an').html('<ul class="ib_xs" id="ancl" style="height:32px;"><li><a href="javascript:;" onmouseover="document.getElementById(\'ib_xxl_01\').style.display=\'block\';"><img src="http://www.07073.com'+userinfo.notice0+'" /></a></li><li><a href="javascript:;" onmouseover="document.getElementById(\'ib_xxl_02\').style.display=\'block\';"><img src="http://www.07073.com'+userinfo.notice1+'" /></a></li></ul><ul class="ib_xxl" id="ib_xxl"><li id="ib_xxl_01" style="display:none" onmouseover="this.style.display=\'block\';" onmouseout="this.style.display=\'none\';"><a href="'+userinfo.notice_url0+'"  target="_blank"><img src="http://www.07073.com'+userinfo.bigpic0+'" /></a></li><li id="ib_xxl_02" style="display:none"onmouseover="this.style.display=\'block\';" onmouseout="this.style.display=\'none\';"><a href="'+userinfo.notice_url1+'"  target="_blank"><img src="http://www.07073.com'+userinfo.bigpic1+'" /></a></li></ul>');
					$('#an').show();
					announcementpic('#ancl', 'li:first', 600); 
				}
			}
			
			if(userinfo.islogin>0)
			{
				$('.cs14_di_reg').hide(); 
				$('.cs14_user_name,.cs14_di_bigUserBoxing,.cs14_user_name_mail').show();
				$('.cs14_user_name img').attr('src', userinfo.a);
				$('.cs14_user_name a').attr('href', BASE_URL).text(userinfo.username);
				if(parseInt(userinfo.m)>0)
				{
					$('.cs14_user_name_mail1').show();
					$('.cs14_user_name_mail a').attr('href', BASE_URL+'/msg/unread/');
					$('#msg_t').text(userinfo.m);
					
				}
				$('#u_l').text(userinfo.l);

				$('#uihome').attr('href', BASE_URL);
				if(userinfo.total!=-1){
					$("#total").show();
					$("#total").text(userinfo.total);
					if(userinfo.ut>0){
						$('#u_c').show();
						$('#u_c').text(userinfo.ut);
					}
					if(userinfo.signnum>0){
						$('#u_q').show();
						$('#u_q').text(userinfo.signnum);
					}
					if(userinfo.hdnum>0){
						$('#u_h').show();
						$('#u_h').text(userinfo.hdnum);
					}
				}else{
					$("#total").hide();
				}
				
				//设置隐藏
				if(userinfo.vg!=''){
				$(userinfo.vg).hide();
				}

				$('.footmark_boxMid_a a').each(function(){
					if($(this).attr('href').indexOf('http')==-1)
						$(this).attr('href',BASE_URL + $(this).attr('href'));
				});
				$('a.taska').attr('href',BASE_URL + $('a.taska').attr('href'));
				$('.cont_user2').hide(); 
				$('.cont_user1').show();
				$('#con_ava').attr('src', userinfo.i);
				$('.cont_user1 dl dt a').attr('href', BASE_URL);
				$('.cont_user1 dl dt i a').text(userinfo.username);
				$('#fav_arc').html(userinfo.favarc);
				$('#recomm_arc').html(userinfo.recfavarc);
				$('#login_form').hide();
				_login_flag = 1;
				try{
					if(!_inited){
						once_cylogout = 0;
						if(window.SOHUCS){SOHUCS.reset();}
					}
					if(funcName && typeof(eval(funcName))=="function"){
						funcName(_login_flag);
					}
				}catch(e){

				}
			}
			else
			{
				_login_flag = 0;
				$('.eixt,.cs14_user_name,.footmark').hide(); 
				$('.cs14_user_name_mail,.cs14_user_name_mail1').hide(); 
				$('.cs14_di_reg').show();
				$('.cont_user2').show(); 
				$('.cont_user1').hide();
				$('#_password').attr('value','');
				$('#ctips').css('color', 'green').text('');
				try{
					if(once_cylogout == 0){
						once_cylogout = 1;
						if(window.changyan){
							window.changyan.api.quit();
						}
					}
					//hook other functions
					if(funcName && typeof(eval(funcName))=="function"){
						funcName(_login_flag);
					}
				}catch(e){

				}
			}

		});
	} catch(e) {
		
	}
}
 
var cur_flag = 1;
function json_api_login_form()
{
	if($("#login_form").length>0){
		$('#login_form').remove();
	}
	
	var container = $('#top1_banner');

		container.after('<div id="login_form" class="cs14_di_loginFormBoxing wxCtrlReg330" style="z-index:100001">');

	var loginFormHtml = container.data('loginHtml');

	$('#login_form').hide();
	var nowc=$("#nowlogin").val();
	if(nowc!=1){
		$.getScript(SERVICE_URL + "/jsonLoginForm2014/", function(){
			try{
				container.data('loginHtml', loginHtml.data);
				$('#login_form').html(loginHtml.data).show();
				if($("#jihualayer").length<=0){
					showid('login_form');
				}else{
					$("#jihualayer").show();
				}
			}catch(e){};
		});
		return false;
	}
	$('#login_form').html(loginFormHtml).show();
	if($("#jihualayer").length<=0){
		showid('login_form');
	}else{
					$("#jihualayer").show();
				}
	return false;
}




var isLogining = 0;
function do_json_login()
{
	var e = new Enc();

	if(isLogining==1){
		return false;
	}
	var username = $('#_username').val();
	var password = $('#_password').val();
	if(username=='' || username=='请输入您的帐号' ||password=='')
	{
		alert('帐号和密码不能为空!');
		return false;
	}
	/*
	if(/.*[\u4e00-\u9fa5-@^|]+.*$/.test(username)) 
	{
		document.cookie = 'cookie___='+escape(username)+';domain=.07073.com;path=/';
		username = 'cookie___';
	}
	*/
	always = $("#_always").attr("checked") ? 1 : 0;
	isLogining = 1;
	//$('#login_href').hide();
	//$('#tips').css('color', 'green').text('请稍等，正在登录中……');
	//$('#ctips').css('color', 'green').text('请稍等，正在登录中……');
	//var login_result = { stauts : -1 };
	$.getScript(SERVICE_URL + "/jsonLogin_/"+e.encode(username)+"/"+e.encode(password)+"/"+always+"/r"+new Date().getMilliseconds(), function(data){
		isLogining = 0;
		if(parseInt(login_result.stauts,10)<1){
			//login failure
			$('#tips').hide();
			$('#login_href').show();
		}
		if(parseInt(login_result.stauts,10)==-1)
		{
			alert('帐号和密码不能为空!');
			return false;
		}
		if(parseInt(login_result.stauts,10)==0)
		{
			alert('帐号或密码错误!');
			return false;
		}
		
		json_get_login_stauts();
		$("#jihualayer").remove();
		return false;
	});
}


function json_logout()
{
	$.getScript(SERVICE_URL + "/jsonLogout/r"+new Date().getMilliseconds(), function(){
		$('div.foot').find('div').eq(0).html('<div class="clear"></div>');
		$('.footmark_boxMid_2').html('');
		$('div[rel="game"],div[rel="flash"],div[rel="comic"],div[rel="animation"]').removeData('fp');
		$('div[rel="game"]').css('display','block').siblings('.foot').css('display','none');
		$('ul.footmark_boxMid_nav li').eq(0).addClass('new_show').siblings('li').removeClass('new_show');
		if($('#login_form').length>0)
		{
			$("#login_form").remove();
		}
		json_get_login_stauts();
	});
	return false;
}

function json_api_reg_form(){
	document.cookie = "from_url="+ escape (location.href)+';domain=.07073.com;path=/';
	document.cookie = "from_url_flag=0;domain=.07073.com;path=/";
	window.location.href = BASE_URL + '/center/register/';
}

function json_api_reg()
{
	document.cookie = "from_url="+ escape (location.href)+';domain=.07073.com;path=/';
	document.cookie = "from_url_flag=1;domain=.07073.com;path=/";
	window.location.href = BASE_URL + '/center/register/';
}
$(document).ready(function(){
	json_get_login_stauts();
});


function announcement() {
	var ann = new Object();
	ann.anndelay = 3000;
	ann.annst = 0;
	ann.annstop = 0;
	ann.annrowcount = 0;
	ann.anncount = 0;

	ann.annlis = document.getElementById('anc').getElementsByTagName("p");
	ann.annrows = new Array();
	ann.announcementScroll = function() {
	if (this.annstop) {
	this.annst = setTimeout(function() {
	ann.announcementScroll();
	},
	this.anndelay);
	return;
	}
	if (!this.annst) {
	var lasttop = -1;
	for (i = 0; i < this.annlis.length; i++) {
	if (lasttop != this.annlis[i].offsetTop) {
	if (lasttop == -1) lasttop = 0;
	this.annrows[this.annrowcount] = this.annlis[i].offsetTop - lasttop;
	this.annrowcount++;
	}
	lasttop = this.annlis[i].offsetTop;
	}
	if (this.annrows.length == 1) {
	document.getElementById('an').onmouseover = document.getElementById('an').onmouseout = null;
	} else {
	this.annrows[this.annrowcount] = this.annrows[1];

	document.getElementById('ancl').innerHTML += document.getElementById('ancl').innerHTML;

	this.annst = setTimeout(function() {
	ann.announcementScroll();
	},
	this.anndelay);
	document.getElementById('an').onmouseover = function() {
	ann.annstop = 1;
	};
	document.getElementById('an').onmouseout = function() {
	ann.annstop = 0;
	};
	}
	this.annrowcount = 1;
	return;
	}
	if (this.annrowcount >= this.annrows.length) {
	document.getElementById('anc').scrollTop = 0;
	this.annrowcount = 1;
	this.annst = setTimeout(function() {
	ann.announcementScroll();
	},
	this.anndelay);
	} else {
	this.anncount = 0;
	this.announcementScrollnext(this.annrows[this.annrowcount]);
	}
	};
	ann.announcementScrollnext = function(time) {
	document.getElementById('anc').scrollTop++;
	this.anncount++;
	if (this.anncount != time) {
	this.annst = setTimeout(function() {
	ann.announcementScrollnext(time);
	},
	10);
	} else {
	this.annrowcount++;
	this.annst = setTimeout(function() {
	ann.announcementScroll();
	},
	this.anndelay);
	}
	};
	ann.announcementScroll();
} 
//图片滚动

function announcementpic(main_cont, scroll_cont, speed){
var _wrap=$(main_cont);//定义滚动区域
var _interval=3000;//定义滚动间隙时间
var _moving;//需要清除的动画
_wrap.hover(function(){
clearInterval(_moving);//当鼠标在滚动区域中时,停止滚动
},function(){
_moving=setInterval(function(){
var _field=_wrap.find(scroll_cont);
var _h=_field.height();
_field.animate({marginTop:-_h+'px'},speed,function(){
_field.css('marginTop',0).appendTo(_wrap);
})
},_interval)
}).trigger('mouseleave');
} 

function AddFavorite(sURL, sTitle){
    try { window.external.addFavorite(sURL, sTitle);}
    catch (e) 
    { 
        try { window.sidebar.addPanel(sTitle, sURL, ""); } 
        catch (e) { alert("加入收藏失败，请使用Ctrl+D进行添加"); } 
    } 
    return false;
} 

function showid(idname) {
var isIE = (document.all) ? true : false;
var isIE6 = isIE && (navigator.appVersion.indexOf("MSIE 6")>-1);
var newbox = document.getElementById(idname);
newbox.style.display = "block"
newbox.style.position = !isIE6 ? "fixed" : "absolute";
newbox.style.top = newbox.style.left = "50%";
newbox.style.marginTop = -newbox.offsetHeight / 2 + "px";
newbox.style.marginLeft = -newbox.offsetWidth / 2 + "px";
var jihualayer = document.createElement("div");
jihualayer.id = "jihualayer";
jihualayer.style.width = jihualayer.style.height = "100%";
jihualayer.style.position = !isIE6 ? "fixed" : "absolute";
jihualayer.style.top = jihualayer.style.left = 0;
jihualayer.style.backgroundColor = "#000";
jihualayer.style.zIndex = "100000";
jihualayer.style.opacity = "0.6";
document.body.appendChild(jihualayer);
var sel = document.getElementsByTagName("select");
for (var i = 0; i < sel.length; i++) {
sel[i].style.visibility = "hidden";
}
function jihualayer_iestyle() {
jihualayer.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)
+ "px";
jihualayer.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +
"px";
}
function newbox_iestyle() {
newbox.style.marginTop = document.documentElement.scrollTop - newbox.offsetHeight / 2 + "px";
newbox.style.marginLeft = document.documentElement.scrollLeft - newbox.offsetWidth / 2 + "px";
}
if (isIE) { jihualayer.style.filter = "alpha(opacity=60)"; }
if (isIE6) {
jihualayer_iestyle()
newbox_iestyle();
window.attachEvent("onscroll", function () {
newbox_iestyle();
})
window.attachEvent("onresize", jihualayer_iestyle)
}
jihualayer.onclick = function () {


for (var i = 0; i < sel.length; i++) {
sel[i].style.visibility = "visible";
}
}
}


//绑定三处点击消失
function disapper(v){
	if(!isNaN(v)){
		$.getScript(SERVICE_URL + "/vgcookie/"+v, function(){
			$(".vg"+v).hide();
			//获取状态
			//json_get_login_stauts();
			
			if(vg_result.stauts == 2 || vg_result_.status==-1){
				$('#total').hide();
			}
		})
	}else{
		return false;
	}
}

$("#vg1").bind('click',function(){
	disapper(1);
})

$("#vg2").bind('click',function(){
	disapper(2);
})

$("#vg4").bind('click',function(){
	disapper(4);
})

$("#ib_xxl li").bind('click',function(){
	$(this).hide();
})
//-->