/**
 * @fileoverview 为应用页面的helper库
 * v1.0
 * @author scorr
 */

try{
	document.domain = "qq.com";
} catch(err) {
	//not qq.com page
	throw (new Error("Qzone:not *.qq.com"));
}

var fnMap = [
	"getBitMapFlag",
	"setBitMapFlag",
	"getLoginUserBitMap",
	"getSecondaryBitMapFlag",
	"setSecondaryBitMapFlag",
	"getNickname",
	"getGender",
	"getAge",
	"getCity",
	"getQzonename",
	"getDescription",
	"getVipStatus",
	"getQzoneConfig",
	"appendPopupFn",
	"appendFullscreenFn",
	"popupDialog",
	"resizePopupDialog",
	"closePopup",
	"fullscreenDialog",
	"closeFullScreenDialog",
	"showLoginBox",
	"addFriend",
	"showMsgbox",
	"hideMsgbox",
	"showBubble",
	"hideBubble",
	"showVerifyBox",
	"sendGift",
	"sendMessage",
	"getScrollTop",
	"setScrollTop",
	"showTips",
	"hideTips",
	"getCurrentAppWindow",
	"getPortraitList",
	"getRemarkList",
	"confirm",
	"getVIPLevel",
	"getSvrTime",
	"getAppWindowPosition",
	"toggleDisplay",
	"toApp",
	"appInvite",
	"setPageAnchor",
	"regClickStream",
	"dataSave",
	"dataLoad",
	"dataDelete"
];

var OFP_fnMap = [
	"updateAppList",
	"refreshAppList"
];

var APP_fnMap = [
	"ifAppInstalled"
];

if(typeof(window.QZONE)=='undefined'){
	window.QZONE = {};
}

QZONE.FP=(function(){
	var _fp=window,found=0;
	try{
		do{
			_fp=_fp.parent;
			if(_fp.QZONE && _fp.QZONE.FrontPage && _fp.g_iUin){
				found=5;
				break;
			}

		}while(_fp!=top);
	}catch(err){
		found=0;
	}

	if(found < 5){
		return {_t : _fp};
	}

	var res={},tmp,t;
	t=_fp.QZONE.FrontPage;
	
	for(;fnMap.length>0;){
		tmp=fnMap.pop();
		if(typeof(t[tmp])=='function'){
			res[tmp]=t[tmp];
		}
	}
	var t2 = _fp.QZONE.OFP;
	if(typeof(t2)!="undefined"){//先检查存不存在OFP
		//映射个人中心提供的接口
		for(;OFP_fnMap.length>0;){
			tmp=OFP_fnMap.pop();
			if(typeof(t2[tmp])=='function'){
				res[tmp]=t2[tmp];
			}
		}
	}
	
	
	var t3 = _fp.QZONE.appPlatform,
		apRes = {};
	if(typeof(t3)!="undefined"){
		//映射应用平台提供的接口
		for(;APP_fnMap.length>0;){
			tmp=APP_fnMap.pop();
			if(typeof(t3[tmp])=='function'){
				apRes[tmp]=t3[tmp];
			}
		}
	}
	
	//应用平台接口个命名空间
	QZONE.AP = apRes;
	
	res._t = _fp; //首页window对象支持
	
	res.activateOFPIframe = function(){
		if(frameElement){
			if(typeof(frameElement.activate)=="function"){
				frameElement.activate();
			}
		}
	};
	
	return res;
})();

/*  |xGv00|d0c7b0e9c6c665fe5e9104631c483c44 */