﻿/////////////////////////////////////////////////////////////////////
//  C8pano.js
//  Created on:      2008-07-09 17:00:00
//  Original author: chris
//  Copyright www.jietusoft.com
////////////////////////////////////////////////////////////////////
//----------------------------Global PARAMS----------------------------------------------
var JsReady = false;


function pageInit()
{
	JsReady = true;
};
function isJsReady()
{
    return JsReady;
};

function C8PlayAPI(func,params)
{
	var id = params.split(",").shift();
	var len = C8Pano.instance.length;
	for(var i=0;i<len;i++)
	{
		var panoitem = C8Pano.instance[i];
		if(panoitem.id==id)
		{
			var arr = panoitem.events;
			var eventlen = panoitem.events.length;
			for(var j=0;j<eventlen;j++)
			{
				var o = arr[j];
				if(o.event==func)
				{
					o.func(params);
				}
			}
		}
		
	}
	
	
};
//----------------------------PanoOption Start--------------------------------
function PanoOption()
{
	var domain=window.location.host;

	this.staticType = "PanoOption";//readOnly
	this.flashID = "";
	this.filePath = "City8Beta4.swf";
	this.floorPanelUrl = "/swf/floorPanel.swf";
	this.searchUiUrl = "/swf/searchUi.swf";
	this.advPath = "";
	this.wmode = "transparent";
	this.c8PanoKey = "";
	this.url = "city8.com";
	this.src = "";
	this.endDate = "";
	this.allowFullScreen = true;
	this.cityCode = "";
	//this.domain = "http://www.buynowmall.com.cn/";
	this.ajaxDomain = "../ajax/";
	if(domain=="www.buynowmall.com.cn")
	{
		this.panoLibDomain="http://pic.buynowmall.com.cn/panolib/";
		this.previewDomain="http://pic.buynowmall.com.cn/preview/";
		this.rootUrl = "http://www.buynowmall.com.cn/";
	}
	else
	{
		this.panoLibDomain="http://pic1.buynowmall.com.cn/panolib/";
		this.previewDomain="http://pic1.buynowmall.com.cn/preview/";
		this.rootUrl = "http://www1.buynowmall.com.cn/";
	}
	///add by clyde
	this.roadFlatUrl = "../AjaxHander/AdminAjaxHander.aspx";
	//////////
	
	var arrowUrl=document.location.href;
    var data=/AdminEditArrow/gi;
    if(data.test(arrowUrl))
    {
       this.enableModifyFoot = true;
    }
    else
    {
      this.enableModifyFoot = false;
    }
        
	
	
	
	
	this.helpInfoUrl = "../AjaxHander/AjaxHander.aspx?action=roam";
	this.businessServiceUrl = "../AjaxHander/AjaxHander.aspx?action=businessservice";
	this.panoID = "";
	this.singlePoiid = "100165_5yLB";
	this.lat = "12.023";
	this.lng = "129.03";
	this.latlngMode = "MAPABC";
	this.language = "jp";
	this.initPan = 0;
	this.initTilt= 0;
	this.initFov =90;
	this.customPlug = false;
	this.plugs = "";
	this.poiFile = "poi_info.txt";
	this.POI_MANAGER ="Admin/AdminAjaxHander.aspx";
	this.poiPage = "../AjaxHander/AdminAjaxHander.aspx";
	this.mapInitUrl = "../AjaxHander/AjaxHander.aspx?action=mapinit";
	
	
    this.poiPanoUrl = "../AjaxHander/AdminAjaxHander.aspx?action=pois";
    this.searchUrl = "../AjaxHander/AjaxHander.aspx?action=search";
    this.topImg = "";
    this.bottomImg = "";
    this.topURL = "";
	this.bottomURL = "";
};
PanoOption.prototype.addPlug = function(plug)
{
	if(plug==null||plug.staticType!="C8PlugObject")
	{
		alert("PLUG ERROR");
		return;
	}
	var plugstr = plug.name+","+plug.url+","+plug.link+","+plug.position.join("~");
	this.plugs+=plugstr+"|";
};
//---------------------------- PanoOption End ----------------------------------

//---------------------------- C8Pano Begin ------------------------------------
C8Pano.EVENT_FLASH_INITIALIZED = "onFlashInited";
C8Pano.EVENT_PANO_PTZ_CHANGED = "onPanoPTZChanged";
C8Pano.EVENT_PANO_PANOID_CHANGED = "onPanoPanoIDChanged";
C8Pano.EVENT_PANO_CLOSED = "onPanoClosed";
C8Pano.EVENT_PANO_ALERT = "onPanoAlert";
C8Pano.EVENT_PANO_PANCHANGE = "onPanoPanChange";
C8Pano.EVENT_SCENE_CHANGE = "OnSceneChange";
C8Pano.instance = new Array();
//containerId ：the pano container id
//options     ：PanoOption

function C8Pano(containerId, options)
{  
    if(containerId==null||options==null||options.staticType!="PanoOption")
	{
		alert("OPTIONS ERROR");
		return;
	}
	this.initialized = false;
	this.flashProxy = null;
	this.events = new Array();
    this.container = containerId;
	
	this.id = "pano" + C8Pano.instance.length;
	C8Pano.instance.push(this);
	options.flashID = this.id;
    var c8swfso = new SWFObject(options.filePath, this.id, "100%", "100%", 
        "9.0.28", "#FFFFFF");
	c8swfso.addParam("wmode",options.wmode);
    c8swfso.addParam("allowScriptAccess", value = "always");
	c8swfso.addParam("allowNetworking" , value = "all");
	if(options && options.allowFullScreen == false)
	{
		c8swfso.addParam("allowFullScreen", false);
	}
	else
	{
		c8swfso.addParam("allowFullScreen", true);
	}
    for (var prop in options)
	{
		if(prop=="addPlug")
		{
			continue;
		}
		c8swfso.addVariable(prop, options[prop]);
	}
    c8swfso.write(containerId);
    this.flashProxy = document.getElementById(this.id);
    //see http://www.4nothing.net/blog/?p=128
    eval("window." + this.id + "=this.flashProxy");
	this.addEventListener(C8Pano.EVENT_FLASH_INITIALIZED, this.innerPanoInited,this);
	this.addEventListener(C8Pano.EVENT_PANO_CLOSED, this.closePano,this);
	this.addEventListener(C8Pano.EVENT_PANO_ALERT, this.panoAlert,this);
	this.addEventListener(C8Pano.EVENT_PANO_PANCHANGE, this.panChange,this);
	this.addEventListener(C8Pano.EVENT_SCENE_CHANGE, this.OnSceneChange,this);
};
C8Pano.prototype.addEventListener = function(type,func,owner)
{
	var obj = new Object();
	obj.event = type;
	obj.func = func;
	obj.owner = owner;
	this.events.push(obj);
};
//EVENTS
C8Pano.prototype.innerPanoInited = function(event)
{
	this.owner.initialized = true;
	return true;
};
C8Pano.prototype.closePano = function(event)
{
	var id = this.owner.container;
	document.getElementById(id).style.display = 'none';
	return true;
};

/////////
//add by clyde
C8Pano.prototype.showThisFoot= function(curPid, roadPid, bShow)
{
	if (!this.initialized)
    {
        return ;
    }
   
    return this.flashProxy.C8PanoAPI("showThisFoot", curPid, roadPid, bShow);
};

/////////


C8Pano.prototype.panChange = function(event)
{
		var info = event.split(",");
		map.ChangeRadarAngle(info.slice(1,info.length));
};

C8Pano.prototype.OnSceneChange = function(event)
{
		var info = event.split(",");
		map.UpdateRadarPos(info[1], info[2]);
};
C8Pano.prototype.panoAlert= function(event)
{
	var info = event.split(",");
   alert(info.slice(1,info.length));
   return true;
};
//APIs
C8Pano.prototype.isInitialized = function()
{
	return this.initialized;
};

C8Pano.prototype.toPanID = function(p1, p2, p3, p4)
{
	if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("toPanID", p1, p2, p3, p4);
}

C8Pano.prototype.changepan = function(p)
{
	 if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("changepan", p);
}
C8Pano.prototype.showPanobyTheodolite = function(lat, lng,e)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("showPanobyTheodolite", lat, lng,e);
}

C8Pano.prototype.addPoi = function(n)
{
   if (!this.initialized)
    {
        return ;
    }
    var poi = new Object();
    poi.name = n;
     poi.ispublic = false;
     return this.flashProxy.C8PanoAPI("addPoi",poi);
}
C8Pano.prototype.GetNewPOIInfo = function()
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("GetNewPOIInfo");
}
C8Pano.prototype.showSinglePoiByName = function(n)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("showSinglePoi" ,n);
}

C8Pano.prototype.RefreshPOI = function()
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("RefreshPOI");
}
C8Pano.prototype.CenterPOI = function(poiID)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("CenterPOI", poiID);
}

C8Pano.prototype.ShowPanoByPanoID = function(pano, pan, tilt, fov, poiid)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("ShowPanoByPanoID", pano, pan, tilt, fov, poiid);
}


C8Pano.prototype.setPanFromRadar = function(p)
{
  if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("changepan", p);
}

C8Pano.prototype.ShowMovieRectangle = function()
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("ShowMovieRectangle");
}

C8Pano.prototype.lockMovieRectangle = function()
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("LockCurrentMovieRectangle");
}
C8Pano.prototype.EditMovieRectangle = function(panoid, poiid, beditable)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("EditMovieRectangle", panoid, poiid, beditable);
}

C8Pano.prototype.onAreaCodeChanged = function(code)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("onAreaCodeChanged", code);
};

//function MovieRectangle(ev)
//{
//	//ev.tr.x ,ev.tr.y, ev.tl.x, ev.tl.y, ev.bl.x, ev.bl.y, ev.br.x, ev.br.y	
//};

C8Pano.prototype.showPanoByPOI = function(p)
{
	 if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("showPanoByPOI", p);
}

C8Pano.prototype.Mp_setRadarAngle = function(ang)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("Mp_setRadarAngle",ang);
};

C8Pano.prototype.Mp_setRadarbyTheodolite = function(lng, lat)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("Mp_setRadarbyTheodolite",lng, lat);
};



C8Pano.prototype.MP_onRadarMoved = function(lng, lat)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("MP_onRadarMoved",lng, lat);
};

C8Pano.prototype.Mp_setFov = function(val)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("Mp_setFov", val);
};

C8Pano.prototype.Mp_fullScreen = function(bFull)
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("Mp_fullScreen", bFull);
};

C8Pano.prototype.Mp_centerRadar = function()
{
	if (this.flashProxy=="undefined")
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("Mp_centerRadar");
};

C8Pano.prototype.setFloor= function(floor)
{
	if (!this.initialized)
    {
        return ;
    }
    return this.flashProxy.C8PanoAPI("setFloor", floor);
};


C8Pano.prototype.setAutoDrive = function (list,frameDelay,autoDrive)
{
	if (!this.initialized)
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("setAutoDrive",list,frameDelay,autoDrive);
};
C8Pano.prototype.playDrive = function ()
{
	if (!this.initialized)
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("playDrive");
};
C8Pano.prototype.pauseDrive = function ()
{
	if (!this.initialized)
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("pauseDrive");
};
C8Pano.prototype.stopDrive = function ()
{
	if (!this.initialized)
    {
        return;
    }
	return this.flashProxy.C8PanoAPI("stopDrive");
};
C8Pano.prototype.setTopBottomImg = function(top, bottom)
{
   if (!this.initialized)
    {
        return ;
    }
     return this.flashProxy.C8PanoAPI("setTopBottomImg", top, bottom);
}
//---------------------------- C8Pano End ----------------------------------------

//---------------------------- C8PLUG START --------------------------------------
function C8PlugObject()
{
};
C8PlugObject.prototype.staticType = "C8PlugObject";//readOnly
C8PlugObject.prototype.link = false;//use LocalConnection
C8PlugObject.prototype.name = ""; //plug name
C8PlugObject.prototype.url = "";	//file path
C8PlugObject.prototype.position = [0,0,0];//
//---------------------------- C8PLUG END --------------------------------------
