﻿var _json_base = eval(Ext.get('hidden_json_base').dom.value);
Ext.onReady(function(){
    Ext.BLANK_IMAGE_URL = _json_base.ExtBlankUrl;
});
//**************************
var myp2c_win_current = null;
function myp2c_OpenDlg(btn, sTitle, w, h, sUrl)
{//为Url打开对话框
    var sId = 'id_iframe_'+new Date().getTime();
    myp2c_win_current = new Ext.Window({
        title:sTitle,
        border:true,
        closable:true,
        maximizable:true,
        resizable:true,
        width:w,
        height:h,
        html:'<iframe id=\''+sId+'\' style=\'width:100%;height:100%;border:0px;margin:0px;padding:0px;\' frameborder=\'0\' src=\'\'></iframe>',
        listeners:{show:function(){document.getElementById(sId).src = sUrl}}
    });
    myp2c_win_current.show(btn);
}
function myp2c_CloseDlg()
{//关闭当前对话框
    if(myp2c_win_current)
    {
        myp2c_win_current.close();
    }
}
//***********************
function myp2c_ToHome2(sUrl)
{
    var sId = 'id_iframe_'+new Date().getTime();
    myp2c_ShowHome2('<iframe id=\''+sId+'\' style=\'width:100%;height:600px;border:0px;margin:0px;padding:0px;\' frameborder=\'0\' src=\'\'></iframe>');
    document.getElementById(sId).src = sUrl;
}
function myp2c_ShowHome2(sHtml)
{//显示home2
    var home2 = document.getElementById('myp2c_id_main_home2');
    home2.innerHTML = '<div class=\'div_more\' href=\'javascript:void(0);\' onclick=\'myp2c_ShowHome1();\'><a>&gt;&gt;返回&nbsp;</a></div>'+sHtml;
    home2.style.display = 'block';
    document.getElementById('myp2c_id_main_home1').style.display = 'none';
}
function myp2c_ShowHome1()
{//返回home1
    var home2 = document.getElementById('myp2c_id_main_home2');
    home2.innerHTML = '';
    home2.style.display = 'none';
    document.getElementById('myp2c_id_main_home1').style.display = 'block';
}

//***********************
function myp2c_LoadAd()
{
    myp2c_LoadAdHtml('domain');
    myp2c_LoadAdHtml('app');
}
function myp2c_LoadAdHtml(sAdType)
{
    Ext.Ajax.request({
        url:_json_base.SourcePath+'/index_pc_ajax.ashx',
        params:{
            action:'GetAdHtml',
            AppId:_json_base.AppId,
            AdType:sAdType
        },
        method:'POST',
        success:function(rp, rq){
            if(rp.responseText != '')
            {
                var div = null;
                if(sAdType == 'domain')
                {
                    div = document.getElementById('myp2c_id_main_ad_domain');
                }
                else if(sAdType == 'app')
                {
                    div = document.getElementById('myp2c_id_main_ad_app');
                }
                if(div)
                {
                    div.style.display='block';
                    div.innerHTML = rp.responseText;
                }
            }
        }
    });
}
//*********************
function myp2c_DoAppStat()
{
    Ext.Ajax.request({
        url:_json_base.SourcePath+'/index_pc_ajax.ashx',
        params:{
            action:'DoAppStat',
            AppId:_json_base.AppId
        },
        method:'POST',
        success:function(rp, rq){
            //
        }
    });
}
//*********************
/*双击滚动阅读*/
var myp2c_scroll_pos,myp2c_scroll_timer; 
function myp2c_scroll_begin() 
{ 
    myp2c_scroll_timer= setInterval(myp2c_scroll_do,50);
} 
function myp2c_scroll_do() 
{ 
    myp2c_scroll_pos = Ext.getBody().getScroll().top +2;
    window.scroll(0,myp2c_scroll_pos); 
    if (myp2c_scroll_pos != Ext.getBody().getScroll().top)
    { 
        myp2c_scroll_clear();
    }
} 
function myp2c_scroll_clear()
{
    clearInterval(myp2c_scroll_timer);
}
