$("#img_ask_go").click(function(){
var s = document.getElementById('askcontent').value;
if(s == ''){
alert("Please enter the content");
return false;
}
document.askform.submit();
})

/*
*如果登录用户,显示"欢迎,用户名"
*/
var auth = getcookie('auth');
if(auth != null)
{

$('#sign_show').hide();
$('#login_info').show();
$.ajax({	   
url: "/member/chpage.php",
type: "post",
dataType: "json",
data: {
username : getcookie('username')			
},

success: function(data){
if(!data) return;
//			var s = "您好, " + data['username'] + "!<br />欢迎回来." + "<br />" + data['name'] + "<br />" + data['lastlogintime'] + "<br />" + data['logintimes'];
$('#mem_name').html(data['username']);
$('#mem_type').html(data['name']);
$('#last_login').html(data['lastlogintime']);
$('#login_time').html(data['logintimes']);

var s ="<font color='#F18819'>" + data['username'] + "</font>" + "<font color='#F18819'>,</font>Welcome back to ETCN!";
$('#hearcontent').html(s);
}
})

}
else
{
var s ="<span style='color:#eb8001'>Welcome</span>!Want to export to China?  <a href='http://www.e-to-china.com/member/register.php' style='text-decoration:underline;'>Start from here</a>!";
$('#hearcontent').html(s);
}
$.getJSON('/ask/chpage.php?num=8', function(json){
$('#ask_content').html(json);
})

function ScrollText(content,btnPrevious,btnNext,autoStart,timeout,isSmoothScroll)
{
    this.Speed = 10;
    this.Timeout = timeout;
this.stopscroll =false;//是否停止滚动的标志位
this.isSmoothScroll= isSmoothScroll;//是否平滑连续滚动
    this.LineHeight = 20;//默认高度。可以在外部根据需要设置
    this.NextButton = this.$(btnNext);
    this.PreviousButton = this.$(btnPrevious);
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;//为了平滑滚动再加一遍

if(this.PreviousButton)
{
this.PreviousButton.onclick = this.GetFunction(this,"Previous"); 
this.PreviousButton.onmouseover = this.GetFunction(this,"MouseOver");
this.PreviousButton.onmouseout = this.GetFunction(this,"MouseOut");
}
if(this.NextButton){
this.NextButton.onclick = this.GetFunction(this,"Next");
this.NextButton.onmouseover = this.GetFunction(this,"MouseOver");
this.NextButton.onmouseout = this.GetFunction(this,"MouseOut");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"MouseOver");
    this.ScrollContent.onmouseout = this.GetFunction(this,"MouseOut");

    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype = {

$:function(element)
{
return document.getElementById(element);
},
Previous:function()
{
this.stopscroll = true;
this.Scroll("up");
},
Next:function()
{
this.stopscroll = true;
this.Scroll("down");
},
Start:function()
{
if(this.isSmoothScroll)
{
this.AutoScrollTimer = setInterval(this.GetFunction(this,"SmoothScroll"), this.Timeout);
}
else
{		
this.AutoScrollTimer = setInterval(this.GetFunction(this,"AutoScroll"), this.Timeout);
}
},
Stop:function()
{
clearTimeout(this.AutoScrollTimer);
this.DelayTimerStop = 0;
},
MouseOver:function()
{	
this.stopscroll = true;
},
MouseOut:function()
{
this.stopscroll = false;
},
AutoScroll:function()
{
if(this.stopscroll) 
{
return;
}
this.ScrollContent.scrollTop++;
if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
{
this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Speed);
}
else
{
if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
{
this.ScrollContent.scrollTop = 0;
}
clearTimeout(this.ScrollTimer);
//this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
}
},
SmoothScroll:function()
{
if(this.stopscroll) 
{
return;
}
this.ScrollContent.scrollTop++;
if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
{
this.ScrollContent.scrollTop = 0;
}
},
Scroll:function(direction)
{

if(direction=="up")
{
this.ScrollContent.scrollTop--;
}
else
{
this.ScrollContent.scrollTop++;
}

if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
{
this.ScrollContent.scrollTop = 0;
}
else if(parseInt(this.ScrollContent.scrollTop)<=0)
{
this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
}

if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
{
this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Speed);
}
},
GetFunction:function(variable,method,param)
{
return function()
{
variable[method](param);
}
},
debug :function(){
alert('Top: '+this.ScrollContent.scrollTop + ' Height: ' + this.ScrollContent.scrollHeight)
}
}

//add by qiangb at 2010-01-05 #for ask模块的文字滚动显示
var k = 0;
setInterval(picStart, 2000);
function picStart()
{
k++;
if(k != 1) return;
var scroll2 = new ScrollText("ask_content","pre2","next2",true,8000,false);
scroll2.LineHeight = 164;
}

function ignoreError() {
  return true;
}
window.onerror = ignoreError; 

//$("#alert_img").click(function(){
//	var email = $("#alert_email").val();
//    if( email == 'E-main Please!')
//    {
//    	alert("Please input you email!");
//    	return false;
//    }
//    var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
//	if(!pattern.test(email))
//	{
//	   alert("Please input right email");
//	   return false;
//	}
//	
//	//document.location.href="restrict.php?code="+resdata;
//	document.location.href="http://alert.e-to-china.com/alert/nosubscription_view.html?email="+email;
//})
//
