var callBackFun;
var containerDiv=null;
function dialog(popWidth,popHeight,innerHTML,callBack){	
	var height=document.body.scrollHeight
	var width=document.body.scrollWidth;
	var o=$("mask")
	o.style.height=(height)+"px";
	o.style.width=(width)+"px";
	addClass(o,"displayTrue");	
	if(ie)addClass(document.body,"masked");		
	var body = document.getElementsByTagName('body')[0];
	var newLocation;	
	containerDiv =$('popupcontainer') ? $('popupcontainer') : createElement(body, 'div');
	containerDiv.id = "popupcontainer";
	containerDiv.style.width = popWidth+'px';
	containerDiv.style.height = popHeight+'px';
	var win = windowSize();
	var wid=containerDiv.style.width
	var hei=containerDiv.style.height
	newLocation = { left : (win.width +document.body.scrollLeft -(wid.substring(0,wid.length -2)*1)) / 2,
					 top : (win.height +document.body.scrollTop-(hei.substring(0,hei.length -2)*1)) / 2 } ;
	if(newLocation.top<0)newLocation.top=0;
	containerDiv.style.left = (newLocation.left) + 'px';
	containerDiv.style.top = (newLocation.top) + 'px';

	var str='<div class="popTitle"><div style="float:right;margin:5px 5px 0px 0px;"><a href="#" class="closeButton" onclick="return dismissEditPopup()"></a></div></div>'+
		'<div id="myPopDiv"></div>';
	containerDiv.innerHTML=str;
	$("myPopDiv").innerHTML=innerHTML;
	
	callBackFun=callBack;
}
var uploadPhotoTitle="";
function photoEditPop(objDesc,objUrl,objAction,standardType,callBack,isTwoDomain,retType,mark){//isTwoDomain:0不跨域
	var twoDomain='1';
	var inT='1';
	mark=mark || "";
	if(retType)inT=retType;
	if(isTwoDomain)twoDomain=isTwoDomain;
	uploadPhotoTitle=objDesc;
	var frm = dialog(760,520,'<iframe style="float:left;width:760px;height:500px;border:0px;" src="/comm/photoUpload.html?myactions=editPhoto&isTwoDomain='+twoDomain+'&int='+inT+'&mark='+mark+'&url='+objUrl+'&zpc='+standardType+'&uaction='+objAction+'" frameborder="0" SCROLLING="no"></iframe>',callBack);
}
function photoEditMPop(objId,objDesc,objUrl,objMain,objAction,standardType,callBack,isTwoDomain){//isTwoDomain:0不跨域
	var twoDomain='1';
	if(isTwoDomain)twoDomain=isTwoDomain;
	uploadPhotoTitle=objDesc;
	var frm = dialog(760,670,'<iframe style="float:left;width:760px;height:600px;border:0px;" src="/comm/photoUpload.html?myactions=editPhoto&max=-1&isTwoDomain='+twoDomain+'&cid='+objId+'&objMain='+objMain+'&url='+objUrl+'&zpc='+standardType+'&uaction='+objAction+'" frameborder="0" SCROLLING="no"></iframe>',callBack);
}
function popIframe(width,height,src,callback){
	dialog(width,height+20,'<iframe src="'+src+'" style="float:left;width:'+width+'px;height:'+height+'px;border:0px;" SCROLLING="no"></iframe>',callBack);
}
function quitPop(){
	dismissEditPopup();
}
function test(val){
	alert(val.length+"===="+val[0]+val[0].objDesc+val[0].objUrl+val[0].updateFlag);
}
function callBack(){
	if(callBackFun)callBackFun(arguments);	
	callBackFun=null;
	dismissEditPopup();
	return false;
}
function getCity(obj){
	popReturn=obj.getAttribute("ca")
	if(callBackFun){
		callBackFun(obj.getAttribute("ca"),obj.getAttribute("da"),obj.innerHTML);	
		dismissEditPopup();
		return false;
	}
	callBackFun=null;
	return true;
}
function getCityUnion(obj){
	popReturn=obj.getAttribute("ca")
	if(callBackFun){
		callBackFun(obj.getAttribute("ca"),obj.getAttribute("da"),obj.innerHTML,obj.getAttribute("fw"));	
		dismissEditPopup();
		return false;
	}
	callBackFun=null;
	return true;
}
function closePopup(){
	removeClass($("mask"),"displayTrue");
	if(ie)removeClass(document.body,"masked");
}
function dismissEditPopup() {
	if (self.ct) ct.tickerPause(false);
	if (containerDiv) {
		containerDiv.style.visibility="hidden";
		var pObj=containerDiv.parentElement ? containerDiv.parentElement : document.getElementsByTagName('body')[0];
		pObj.removeChild(containerDiv);
		containerDiv = null;
	}
	closePopup();
	return false;
}
function popTest(value){
alert(value)
}
function changeCity(location,callBack){
	dismissEditPopup();
	if (navigator.vendor == "Apple Computer, Inc.") {
		document.location = "/test";
		return false;
	}
	var sp=cityHtmlStr;
	var frm = dialog(775,700,sp,callBack);
	
	var serverResponse = createElement(frm, "div");
	serverResponse.id = "cityDiv"
	serverResponse.className="cityborder";
	
	return false;
}
function doReload() {
	//document.location.reload(true);
}

var popupMessage = function(message) {
	dismissEditPopup();
	var frm = makeEditPopup(null, "", null);
	createText(frm, message);
	bt = createInput(frm, "submit");
	bt.value = "OK";
	bt.className = "buttonInput";
	bt.onclick = dismissEditPopup;
	return false;
}
function getObjUrlBF(url){
	if(url==null) return url;	
	var fold;
	var fName;
	var pos = url.lastIndexOf("/");
	if(pos>0){
		fold=url.substring(0,pos+1);
		fName=url.substring(pos+1);
		pos=fName.indexOf("-");
		if(pos>=0 & pos<fName.length)fName=fName.substring(pos+1);
	}else return url;	
	return fold+fName;
}