﻿function welcome_info() {
	var p = '';
    var j = location.href;
    if (j.indexOf("/member/login.html") > -1 || j.indexOf("/member/register.html") > -1) {
		j = ""
    }
	if (typeof(user_info) != 'undefined' && user_info && user_info[0]!=0)
	{
		p = '您好，'+ user_info[1] + '<a href="/member/logout.html">[退出]</a>';
	}
	else {
		var login_url  = '/member/login.html';
		if (j!='')
		{
			login_url += "?ret_url="+ encodeURIComponent(j)
		}
		p = "您好，欢迎您!&nbsp;";
		p += '<span id="lam_log-info"><a href="'+ login_url +'" class="org">请登录</a> | <a href="/member/register.html" class="org marginright10"> 注册</a></span>';
	}
	document.write(p);
}

function message_info() {
	var p = '';
    var j = location.href;
    if (j.indexOf("/member/login.html") > -1 || j.indexOf("/member/register.html") > -1) {
		j = ""
    }
	if (user_info && user_info[0]!=0)
	{
		p = '<ul >';
        p += '<li style="float:left;width:100px;">未读短消息(<b>'+ user_info[3] +'</b>)</li>';
        p += '<li style="float:left;width:100px;">未回复询盘(<b>'+ user_info[4] +'</b>)</li>';
        p += '</ul>';        
        p += '<span style="float: left; text-align: center; width: 170px; padding-top: 5px;">进入 <a href="/member.html" style="color:#3366CC">我的拉美通</a> 查看更多</span>';

	}
	else {
		var login_url  = '/member/login.html';
		if (j!='')
		{
			login_url += "?ret_url="+ encodeURIComponent(j)
		}
		p = '<a href="/member/register.html"><img width="97" height="36" src="http://themes.lameibiz.com/mall/cn/styles/newdefault/images/zhuce.jpg"></a> ';
		p += '<a href="'+ login_url +'"><img width="97" height="37" src="http://themes.lameibiz.com/mall/cn/styles/newdefault/images/denglu.jpg"></a>';
	}
	document.write(p);
}

function AutoScroll(obj){
		$(obj).find("ul:first").animate({
			marginTop:"-25px"
		},300,function(){
			$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
		});
}

function showlocaltime(){
	var now = new Date();
	var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var timezone= now.getTimezoneOffset()/60;
	var time = now.getTime();
	var time_offset = 0;
	if (timezone == 0)
		{ var timeValue = "格林尼治";}
	else 
		{ var timeValue = ((timezone < 0)? "  东"+(-1)*timezone : "  西"+timezone) +'区';}
	var timeValue = "";
	
	if (timezone != 0) {
		time_offset = 60 * 60 * 1000 * timezone; //格林尼治
	}

	//东6区
	var east6 = new Date(time + time_offset + 60 * 60 * 1000 * -6);
	var east6_time = "";
    east6_time  += ((east6.getHours()<10) ? "0": "") + east6.getHours();
    east6_time  += ((minutes < 10) ? ":0" : ":") + minutes;
    east6_time  += ((seconds < 10) ? ":0" : ":") + seconds+" ";
    $(".mx_time").html(east6_time);

	//东5区
	var east5 = new Date(time + time_offset + 60 * 60 * 1000 * -5);
	var east5_time = "";
    east5_time  += ((east5.getHours()<10) ? "0": "") + east5.getHours();
    east5_time  += ((minutes < 10) ? ":0" : ":") + minutes;
    east5_time  += ((seconds < 10) ? ":0" : ":") + seconds+" ";
    $(".co_time").html(east5_time);

	//东4区
	var east4 = new Date(time + time_offset + 60 * 60 * 1000 * -4);
	var east4_time = "";
    east4_time  += ((east4.getHours()<10) ? "0": "") + east4.getHours();
    east4_time  += ((minutes < 10) ? ":0" : ":") + minutes;
    east4_time  += ((seconds < 10) ? ":0" : ":") + seconds+" ";
    $(".bo_time").html(east4_time);

	//东3区
	var east3 = new Date(time + time_offset + 60 * 60 * 1000 * -3);
	var east3_time = "";
    east3_time  += ((east3.getHours()<10) ? "0": "") + east3.getHours();
    east3_time  += ((minutes < 10) ? ":0" : ":") + minutes;
    east3_time  += ((seconds < 10) ? ":0" : ":") + seconds+" ";
    $(".ar_time").html(east3_time);
	timerID = setTimeout("showlocaltime()",1000);

    timerRunning = true;

}

/*
	banner
*/
//图片名称一定是前缀和数字序号如“img3.jpg”
var tuN=0;//设置总数值
var num2; //设置数子初始值
var check=true;
function banner_turn()
{
	if(check)
	{
		tuN=$(".lam_bigshow_img").children("a").size();
		if(num2==undefined)
		{
		num2=0;
			}
		num2=num2+1;
		if(num2>=tuN)
		{
			num2=0;
		}
		//window.numTag=num2;
		$(".lam_bigshow_img").children("a").attr("class","NotBigImg");
		$(".lam_bigshow_img").children("a").eq(num2).attr("class","BigImg");
   
		$("#lam_banner_num").children("li").attr("class","NotShowSpan");
		$("#lam_banner_num").children("li").eq(num2).attr("class","ShowSpan");
	}
}

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
		ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

		function jsddm_close()
		{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

		function jsddm_timer()
		{	closetimer = window.setTimeout(jsddm_close, timeout);}

		function jsddm_canceltimer()
		{
				if(closetimer)	{
							window.clearTimeout(closetimer);
									closetimer = null;
		}
}

$(document).ready(function(){
	setInterval('AutoScroll("#lam_clock")',5000);
	setInterval('AutoScroll("#lam_first")',3000);
	showlocaltime();
/*
	$(".lam_banner")
		.mouseover(function(){
			check=true;
		})
		.mouseout(function() {
			check=false;
		});
	$("#lam_banner_num li")
		.mouseover(function(){
			//$(this).addClass("ShowSpan");
			var num = parseInt($(this).attr('id').replace("img", ""));
			num--;
			$(".lam_bigshow_img").children("a").attr("class","NotBigImg");
			$(".lam_bigshow_img").children("a").eq(num).attr("class","BigImg");
			$("#lam_banner_num").children("li").attr("class","NotShowSpan");
			$(this).attr("class","ShowSpan");
		});
	setInterval("banner_turn()",3000);
*/

	$(".tab-holder li:first").addClass("selected");
	$(".tab-panel:first").removeClass("hidden");
	$(".tab-holder li").mouseover(function(){
		$(".tab-holder li").removeClass("selected");
		$(this).addClass("selected");
		$(".tab-panel").addClass('hidden');
		var index = $.inArray(this,$(".tab-holder li"));
		index++;
		$(".tab-panel:nth-child("+ index +")").removeClass("hidden");
	});

	$('#nav > li').bind('mouseover', jsddm_open);
	$('#nav > li').bind('mouseout',  jsddm_timer);
/*
	$('.nav_list > ul').hide();
	$('.nav_list').hover(
			function(){
				$(this).find('ul').show();
			},//
			function(){
				$(this).find('ul').hide();
			}
	);
	*/
});

