﻿// JavaScript Document
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var is_safari = (userAgent.indexOf('webkit') != -1 || userAgent.indexOf('safari') != -1);
var note_step = 0;
var note_oldtitle = document.title;
var note_timer;

//iframe包含
if (top.location != location) {
	top.location.href = location.href;
}

function $(id) {
	return document.getElementById(id);
}

function change(srcObj,tid,zid)
{
    for(var i=0;i<zid;i++){
		document.getElementById("so_"+(i+1)).className= 's2';
        document.getElementById("search_"+(i+1)).style.display = 'none';
    }
    document.getElementById("so_"+tid).className ='s1';
    document.getElementById("search_"+tid).style.display ='block';
    return false;
}


function change2(srcObj,tid,zid)
{
    for(var i=0;i<zid;i++){
		document.getElementById("m"+(i+1)).className= '';
        document.getElementById("mz"+(i+1)).style.display = 'none';
    }
    document.getElementById("m"+tid).className ='on';
    document.getElementById("mz"+tid).style.display ='block';
    return false;
}

function setintro(type) {
var intro = '';
var bPosition = '';
if(type == 'doing') {
intro = '用一句话记录自己生活中的点点滴滴';
bPosition = '0';
} else if(type == 'mtag') {
intro = '创建自己的小圈子，与大家交流感兴趣的话题';
bPosition = '175px';
} else if(type == 'pic') {
intro = '上传照片，分享生活中的精彩瞬间';
bPosition = '55px';
} else if(type == 'app') {
intro = '与好友一起玩转游戏和游戏，增加好友感情';
bPosition = '118px';
} else {
intro = '马上注册，与好友分享日志、照片，一起玩转游戏';
bPosition = '0';
}
$('guest_intro').innerHTML = intro + '......';
$('guest_intro').style.backgroundPosition = bPosition + ' 100%'
}
function scrollPic(e, LN, Width, Price, Speed) {
id = e.id;
if(LN == 'Last'){ scrollNum = Width; } else if(LN == 'Next'){ scrollNum = 0 - Width; }
scrollStart = parseInt(e.style.marginLeft, 10);
scrollEnd = parseInt(e.style.marginLeft, 10) + scrollNum;

MaxIndex = (e.getElementsByTagName('li').length / Price).toFixed(0);
sPicMaxScroll = 0 - Width * MaxIndex;

if(scrollStart == 0 && scrollEnd == Width){
scrollEnd = -1806;
e.style.marginLeft = parseInt(e.style.marginLeft, 10) - Speed + 'px';
} else if(scrollStart == sPicMaxScroll + Width && scrollEnd == sPicMaxScroll){
scrollEnd = 0;
e.style.marginLeft = parseInt(e.style.marginLeft, 10) + Speed + 'px';
}
scrollShowPic = setInterval(scrollShow, 1);

function scrollShow() {
if(scrollStart > scrollEnd) {
if(parseInt(e.style.marginLeft, 10) > scrollEnd) {
$(id + '_last').onclick = function(){ return false; };
$(id + '_next').onclick = function(){ return false; };
e.style.marginLeft = parseInt(e.style.marginLeft, 10) - Speed + 'px';
} else {
clearInterval(scrollShowPic);
$(id + '_last').onclick = function(){ scrollPic(e, 'Last', Width, Price, Speed);return false; };
$(id + '_next').onclick = function(){ scrollPic(e, 'Next', Width, Price, Speed);return false; };
}
} else {
if(parseInt(e.style.marginLeft, 10) < scrollEnd) {
$(id + '_last').onclick = function(){ return false; };
$(id + '_next').onclick = function(){ return false; };
e.style.marginLeft = parseInt(e.style.marginLeft, 10) + Speed + 'px';
} else {
clearInterval(scrollShowPic);
$(id + '_last').onclick = function(){ scrollPic(e, 'Last', Width, Price, Speed);return false; };
$(id + '_next').onclick = function(){ scrollPic(e, 'Next', Width, Price, Speed);return false; };
}					
}
}
}
function scrollShowNav(e, Width, Price, Speed) {
id = e.id;
$(id + '_last').onclick = function(){ scrollPic(e, 'Last', Width, Price, Speed);return false; };
$(id + '_next').onclick = function(){ scrollPic(e, 'Next', Width, Price, Speed);return false; };

}
function getUserTip(obj) {
var tipBox = $('usertip_box');
tipBox.childNodes[0].innerHTML = '<strong>' + obj.rel + ':<\/strong> ' + obj.rev + '...';

var showLeft;
if(obj.parentNode.offsetLeft > 730) {
showLeft = $('showuser').offsetLeft + obj.parentNode.offsetLeft - 148;
tipBox.childNodes[0].style.right = 0;
} else {
tipBox.childNodes[0].style.right = 'auto';
showLeft = $('showuser').offsetLeft + obj.parentNode.offsetLeft;
}
tipBox.style.left = showLeft + 'px';

var showTop; 
if(obj.className == 'uonline') {
showTop = $('showuser').offsetTop + obj.parentNode.offsetTop - tipBox.childNodes[0].clientHeight;
} else {
showTop = $('showuser').offsetTop + obj.parentNode.offsetTop + 48;
}
tipBox.style.top = showTop + 'px';

tipBox.style.visibility = 'visible';
}
