function act_tabview(count, tabnum)
{
    for(var i=1; i<count+1; i++)
    {    
        if(i == tabnum)    
        {    
            document.getElementById('side_t'+ i).className='active';
            document.getElementById('side_c'+ i).className ='on';
        }    
        else    
        {    
            document.getElementById('side_t'+ i).className='normal';
            document.getElementById('side_c' + i).className ='off';
        }    
    }    
}
var time_out = 7000;
function log_start()
{
    document.getElementById("miman").style.visibility="visible";
    window.setTimeout( "real_log_start()", time_out );
    return false;
}
function real_log_start()
{
    document.getElementById("miman").style.display="none";
}
function showDialog(obj,title,cnt,link,pic,guide)
{
    var aobj=$(obj);
    var offsettop  = aobj.offset().top+aobj.height()+"px";
    var offsetleft = aobj.offset().left+100+"px"; 
    var dobj=$('#dialog');
    dobj.css({ "top": offsettop , "left": offsetleft  }); 
    dobj.find("h3").attr('innerHTML',"<a href='"+link+"'>"+title+"</a><span>[<em>"+cnt+"</em>]</span>");
    dobj.find("#d_img_link").attr('href',link);
    dobj.find("img").attr('src',pic);
    dobj.find(".excerpt").attr('innerHTML',guide);
    dobj.show(100);
    $(document).bind("click",function(){hideDialog();});
}
function hideDialog()
{
        if($('#dialog'))$('#dialog').hide();
}
function showSharepanel(obj, art_link, art_title)
{
    //var img_domain = "http://dearmetroui.metroer.com.cn/img/";
    var img_domain = "http://dearmetro.metroerui.com/img/";
    var aobj=$(obj);
    var offsettop  = aobj.offset().top+aobj.height()+"px";
    var offsetleft = aobj.offset().left+"px";
    var dobj=$('#sharepanel');
    dobj.css({ "top": offsettop , "left": offsetleft  });
    dobj.find("h3").attr('innerHTML',"收藏");
    var str = "";
    str += "<li><a target=\"_blank\" href=\"javascript:location.href='http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(\'"+art_link+"\')+'&title='+encodeURIComponent(\'"+art_title+"\')\"><img src='"+img_domain+"ico_google.gif' border='0' style='vertical-align:middle'> Google </a></li> ";
    str += "<li> <a target=\"_blank\" href=\"javascript:location.href='http:\/\/cang.baidu.com\/do\/add?it='+encodeURIComponent(\'"+art_title+"\')+'&iu='+encodeURIComponent(\'"+art_link+"\')\"><img src=\'"+img_domain+"ico_baidu.gif\' style=\'vertical-align:middle\' border=\'0\'> Baidu <\/a> </li>";
    str += "<li> <a target=\"_blank\" href=\"javascript:location.href='http://myweb.cn.yahoo.com/popadd.html?url='+encodeURIComponent(\'"+art_link+"\')+'&title='+encodeURIComponent(\'"+art_title+"\')\"><img src='"+img_domain+"ico_yahoo.gif' style='vertical-align:middle' border='0'> Yahoo </a></li> ";
    str += "<li> <a target=\"_blank\" href=\"javascript:location.href='http://vivi.sina.com.cn/collect/icollect.php?pid=28&title='+escape(\'"+art_title+"\')+'&url='+escape(\'"+art_link+"\')\"><img src='"+img_domain+"ico_sina.gif' style='vertical-align:middle' border='0'> Sina </a> </li>";
    str += "<li><a target=\"_blank\" href=\"javascript:location.href='http://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url='+encodeURIComponent(\'"+art_link+"\')+'&title='+encodeURIComponent(\'"+art_title+"\')\"><img src='"+img_domain+"ico_winlive.gif' style='vertical-align:middle' border='0'>msn</a></li> ";
    str += "<li><a target=\"_blank\" href=\"javascript:location.href='http://www.facebook.com/sharer.php?u='+encodeURIComponent(\'"+art_link+"\')\"><img src='"+img_domain+"ico_facebook.gif' style='vertical-align:middle' border='0'> Facebook </a></li> ";
    str += "<li><a target=\"_blank\" href=\"javascript:location.href='http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(\'"+art_link+"\')+'&uri='+encodeURIComponent(\'"+art_title+"\')\" ><img src='"+img_domain+"ico_qq.gif' style='vertical-align:middle' border='0'> QQ</a></li> ";
    str += "<li><a target=\"_blank\" href=\"javascript:location.href='http://fanfou.com/sharer?u='+encodeURIComponent(\'"+art_link+"\')+'&t='+encodeURIComponent(\'"+art_title+"\')+'&d=&s=bm'\"><img src='"+img_domain+"ico_fan.jpg' style='vertical-align:middle' border='0'>fan</a></li> ";
    dobj.find("ul").attr('innerHTML', str);
    dobj.show(100);
    $(document).bind("click",function(){hideSharepanel();});
    if(typeof(Sharepanel_hideFlag)!="undefined")
    window.clearTimeout(Sharepanel_hideFlag);
    Sharepanel_hideFlag = window.setTimeout(hideSharepanel,5000);
}
function hideSharepanel()
{
    if($('#sharepanel'))$('#sharepanel').hide();
}
function showQuestionDilog()
{
    showLayer('askform',474,310);
}
layerpopmenu_stack = {};
function showLayer()
{//弹出层
    
    var elementID = arguments[0];
    var iWidth = document.documentElement.clientWidth; 
    var iHeight = document.documentElement.clientHeight;
    var popLayerParent = document.getElementById("popLayerParent");
    if(popLayerParent)
    {
        document.getElementById("popLayerParent").style.display = "block";
    }
    else
    {
        var bgObj = document.createElement("div");
        bgObj.id = "popLayerParent"; 
        bgObj.style.cssText = "display:block;position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=40);background-color:#000000;opacity:0.3;z-index:900;";
        document.body.appendChild(bgObj);
    }
    if(typeof layerpopmenu_stack[elementID] == "undefined")
    {
        var popdiv_parent = document.getElementById(elementID);
        if(popdiv_parent == null){
        document.getElementById("popLayerParent").style.display = "none";
            ;return;
        }
        popdiv_parent.style.position='absolute';
        popdiv_parent.style.zIndex = parseInt(bgObj.style.zIndex)+1;
        layerpopmenu_stack[elementID] = popdiv_parent;

    }
    else
    {
        var popdiv_parent = layerpopmenu_stack[elementID];
    }
    if(arguments.length>1)
    {
        divH=arguments[2];divW=arguments[1];
    }
    else
    {
        var divW = popdiv_parent.offsetWidth;
        var divH = popdiv_parent.offsetHeight;
    }
    var dde = document.documentElement;
    if (window.innerWidth) 
    {
        var ww = window.innerWidth;
        var wh = window.innerHeight;
        var bgX = window.pageXOffset;
        var bgY = window.pageYOffset;
    } 
    else
    {
        var ww = dde.offsetWidth;
        var wh = dde.offsetHeight;
        var bgX = dde.scrollLeft;
        var bgY = dde.scrollTop;
    }
    var t_DiglogX = (bgX + ((ww - divW)/2));
    var t_DiglogY = (bgY + ((wh - divH)/2)); 
    popdiv_parent.style.top =t_DiglogY + "px";
    popdiv_parent.style.left =t_DiglogX + "px";
    popdiv_parent.style.display = "block";
    
}

function hideLayer()
{
    var popLayerParent = document.getElementById("popLayerParent");
    if(popLayerParent)popLayerParent.style.display = "none";
    if(layerpopmenu_stack)
    {
        for(x in layerpopmenu_stack){layerpopmenu_stack[x].style.display = "none";}
    }
}
function vilidateQform(form)
{
    
    var username = '';//form.nickname.value;
    var email = '';//form.email.value;
    var content = form.content.value;
    var title = form.title.value;
    if(!document.login_status)
    {
        username = form.nickname.value;
        email = form.email.value;
        if(username.length < 1 || username.length > 50) 
        {   
            alert("请正确填写昵称");
            return;
        }   
        if(email.length < 1 || email.length > 100)
        {   
            alert("请正确填写Email");
            return;
        }
    }
    if(title.length<1 || form.title.value==form.title.getAttribute('defaultvalue')) 
    {
        alert("请正确填写标题");
        return;
    }
    if(title.length > 50) 
    {   
        alert("标题不能多于50个字！");
        return;
    }
    if(content.length < 1)  
    {   
        alert("请正确填写评论");
        return;
    }   
    $.post('http://'+document.domain+'/include/deal_data.php',{'username': username,'email': email,'content':content,'title':title,'type' : 'question_submit'}, function(data) {
    if(data == '1')
    {   
            alert("提交成功！");window.location.reload();
    }
    else if(data == '0' || data=='2')alert("提交失败！");
    else alert(data);
    return false;
}); 
}
function vilidateCommentform(form)
{
    
    var username = '';//form.comment_nickname.value;
    var email = '';//form.comment_email.value;
    var content = form.comment_content.value;
    var sexqa_id=form.sexqa_id.value;
    if(!document.login_status)
    {
        username = form.comment_nickname.value;
        email = form.comment_email.value;
        if(username.length < 1 || username.length > 50) 
        {   
            alert("请正确填写昵称");
            return;
        }   
        if(email.length < 1 || email.length > 100)
        {   
            alert("请正确填写Email");
            return;
        }
    }
    if(content.length < 1)  
    {   
        alert("请正确填写评论");
        return;
    }
   $.post('http://'+document.domain+'/include/deal_data.php',{'username': username,'email': email,'content':content,'type' : 'qacomment_submit','sexqa_id':sexqa_id}, function(data) {
    if(data == '1')
    {   
        alert("提交成功！");
        $(form).find("INPUT[type='text']").val('');$(form).find("TEXTAREA").val('');
        window.location.reload();
    }
    else if(data == '0' || data=='2')alert("提交失败！");
    else alert(data);
    return false;
}); 
}
function getCarStyle()
{
    var brand = document.getElementById('brand').value;
    //document.getElementById('car_style_div').style.display = 'block';
    $.post('http://'+document.domain+'/include/deal_data.php',{'brand': brand,'type' : 'get_brandstyle'}, function(data) {
     eval(data);
     return false;
     }); 
}
function doSlide(s)
{
    car_body= document.getElementById('famedcar_body');
    car_body_left = parseInt(car_body.style.marginLeft);
    car_body_left = isNaN(car_body_left)?0:car_body_left;
    
    car_timers= new Array();
    car_offset =200;
    var car_body_children = car_body.getElementsByTagName('div');
    if(car_body_children.length>0)
    {   
        if(s>0){
            if(car_body_left==0)
            {
                car_body.innerHTML +=car_body.innerHTML
                car_body.style.width = car_offset*car_body_children.length+'px';
                car_body_left = car_body.style.marginLeft = (car_offset*car_body_children.length*(-1)/2)+'px';
                doSlide(s);
            }
                //car_body_left = (car_body_children.length)*car_offset*-1
                    //return;
        }   
        else{ 
            if(car_body_left <=(car_body_children.length-1)*car_offset*-1)
            {
                car_body.innerHTML +=car_body.innerHTML
                car_body.style.width = car_offset*2*car_body_children.length+'px';
            }
            //car_body_left = 0;
            //  return;
        }   
    } 
    /*
       if(car_body_children.length>0)
       {   
       if(s>0){if(car_body_left==0)return;}
       else{ if(car_body_left <=(car_body_children.length-1)*car_offset*-1)return;}
       }   
       else return;
     */
    for(var i=0;i<car_offset;i++)
    {   
        (function(){
         if(car_timers[i]) clearTimeout(car_timers[i]);
         car_timers[i]=setTimeout(function(){car_body_left+=s;car_body.style.marginLeft = car_body_left+'px';},i%(Math.floor(car_offset/2))*8);
         })();
    }   
}
