function emailFocus(){
    if(document.getElementById("email").value==document.getElementById("EmailInitialValue").value)document.getElementById("email").value="";
}   

         
function emailBlur(){
    if(document.getElementById("email").value=="")document.getElementById("email").value=document.getElementById("EmailInitialValue").value;
}


function emailKkeydown(e)
{
var theEvent=window.event||e;var keyNum=theEvent.keyCode||theEvent.which;
if(keyNum==13)subscibe_email_do();
}


function subscibe_email_do()
{
var value=document.getElementById("email").value;if(value==""||value.indexOf("输入")!=-1)return;
var emailReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; if (!emailReg.test(value)){alert("请输入正确的电子邮箱！");return;}
ajax("post","/tuan/do.aspx?act=tuan_email&rd="+Math.random(),"value="+value,OnHandler);
function OnHandler(){if(xmlHttp.readyState == 4){OnHandler_(xmlHttp.responseText);}}
function OnHandler_(par1){if(par1=="ok"){document.getElementById("email").value="";alert("订阅成功！");}else alert(par1);}
}


function subscibe_sms_do(type)
{
var value=document.getElementById("sms").value;if(value=="")return;
var telReg=/^[0-9]{11,11}$/;  if (!telReg.test(value)){alert("请输入正确的手机号码！");return;}
ajax("post","/tuan/do.aspx?act=tuan_sms&rd="+Math.random(),"type="+type+"&value="+value,OnHandler);
function OnHandler(){if(xmlHttp.readyState == 4){OnHandler_(xmlHttp.responseText);}}
function OnHandler_(par1){if(par1=="ok1"){alert("订阅成功！");TINY.box.hide();}else if(par1=="ok2"){alert("取消订阅成功！");TINY.box.hide();}else alert(par1);}
}

function subscibe_sms_do_(type)
{
TINY.box.show("/tuan/input_sms.aspx?type="+type+"&rd="+Math.random(),1,310,62,1,0);
}


function tuan_copy_url(domain,par1){
function copyToClipboard(txt){if(window.clipboardData){window.clipboardData.clearData();window.clipboardData.setData("Text", txt);alert("复制成功，您可以通过QQ、邮件或微博发送给您的好友！");}else alert("浏览器拒绝该功能！");}
if(par1=="")copyToClipboard(domain+"/tuan/?city");else copyToClipboard(domain+"/tuan/?uid="+par1);
}


function TgState(id){
if(parseInt(document.getElementById("id"+id+"_buy").innerHTML)>=parseInt(document.getElementById("id"+id+"_lowestbuy").innerHTML))
{
    document.getElementById("id"+id+"_tgstate1").innerHTML="团购已成功";
    document.getElementById("id"+id+"_tgstate2").innerHTML="还可以继续购买…";
}
else
{
    document.getElementById("id"+id+"_tgstate1").innerHTML="团购正在进行";
    document.getElementById("id"+id+"_tgstate2").innerHTML="请抓紧时间购买…";
}
}


function TgStateCheck(id,type){
if(type=="nostart"){
    document.getElementById("id"+id+"_tgstate1").innerHTML="团购尚未开始";
    document.getElementById("id"+id+"_tgstate2").innerHTML="请您耐心等候…";
    document.getElementById("id"+id+"_tgstate1").className="chil1_nostart";
    document.getElementById("surplustime"+id).innerHTML="离开团还有"; 
    document.getElementById("buybtn"+id).href="javascript:alert('团购尚未开始')";  
}
else if(type=="over"){
    document.getElementById("id"+id+"_tgstate1").innerHTML="团购已结束";
    document.getElementById("id"+id+"_tgstate2").innerHTML="请留意下次团购…";
    document.getElementById("id"+id+"_tgstate1").className="chil1_over";
    document.getElementById("surplustime"+id).parentNode.innerHTML="<strong class=\"block\" style=\"padding-top:15px;\">本次团购活动已结束</strong>";//document.getElementById("surplustime"+id).innerHTML="已过期时间";
    document.getElementById("buybtn"+id).href="javascript:alert('团购已结束')";  
}
}



var tms = [];var day = [];var hour = [];var minute = [];var second = [];
function takeCount(){
setTimeout("takeCount()", 1000);
for (var i = 0, j = tms.length; i < j; i++){
//
tms[i] -= 1000;
//
var days = Math.floor(tms[i] / (1000 * 60 * 60 * 24));var hours = Math.floor(tms[i] / (1000 * 60 * 60)) % 24;var minutes = Math.floor(tms[i] / (1000 * 60)) % 60;var seconds = Math.floor(tms[i] / 1000) % 60;
if (days < 0)days = 0;if (hours < 0)hours = 0;if (minutes < 0)minutes = 0;if (seconds < 0)seconds = 0;
//
if(document.getElementById(day[i])){
document.getElementById(day[i]).innerHTML = days;document.getElementById(hour[i]).innerHTML = hours;document.getElementById(minute[i]).innerHTML = minutes;document.getElementById(second[i]).innerHTML = seconds;
}
}
}
setTimeout("takeCount()", 1000);