function popDestination(){

}
popDestination.prototype={
	createdBy:"vincentLi",
	locateObj:document.getElementById('destinationKey'),
	popLayer:null,
	getPopLayer:function(){
        if(window.parent){
            return window.parent.popLayer;
        }
        else{return window.popLayer;}
        },
	locateWhere:function()
	{
        var obj=document.getElementById('destinationKey');
        if(obj!=null)
        {
        	var left= obj.offsetLeft;
            var top = obj.offsetTop;
            while (obj=obj.offsetParent) 
            {	
            	left+=obj.offsetLeft;
            	top+= obj.offsetTop;
            }
		var  popLayer=document.getElementById('popLayer');
        popLayer.style.left=left+"px";
        popLayer.style.display="block";
        popLayer.style.top=top+document.getElementById('destinationKey').clientHeight+5+"px";
        this.loadDestination();
        }
        this.setIFrameAutoHeight();
    },
     setIFrameAutoHeight:function() 
     { 
		var ifm= document.getElementById("popLayer"); 
		var subWin = document.frames?document.frames["popLayer"].document:ifm.contentDocument; 
		if(ifm !=null&&subWin!= null) 
			ifm.height = subWin.body.scrollHeight; 
	},
	
	loadDestination:function()
	{
		var cssStr="<style type=\"text/css\">";
        cssStr+='*{ margin:0px; padding:0px;}\r\n';
		cssStr+='body{background:#fff;font-size:12px;margin:0px;padding:0px;}\r\n';
		cssStr+='.clear{ clear:both;}\r\n';
		cssStr+='.destina { color:#4B4B4B; border:1px solid #5AAEE7; background:white; width:340px; padding:10px 12px;}\r\n';
		cssStr+='.destina h1 { font-size:12px; font-weight:normal; border-bottom:1px dashed #BBB; padding-bottom:10px; width:340px;}\r\n';
		cssStr+='.destina h1 a {  width:8px; height:8px; float:right;}\r\n';
		cssStr+='.destina .txt1 { padding:8px 0; width:340px;}\r\n';
		cssStr+='.destina .txt2 { border-bottom:1px solid #DDD; height:19px; width:340px;}\r\n';
		cssStr+='.destina .txt2 span { cursor:pointer; text-decoration:none; color:#223C6A; border-top:1px solid #DDD; border-left:1px solid #DDD; border-right:1px solid #DDD; width:40px; height:18px; line-height:18px; text-align:center; margin-right:8px; float:left;}\r\n';
		cssStr+='.destina .txt2 .sele { color:#223C6A; border-top:1px solid #DDD; border-left:1px solid #DDD; border-right:1px solid #DDD; width:40px; height:18px; line-height:18px; text-align:center; background:#DDF5FF; margin-right:8px; float:left;}\r\n';
		cssStr+='.destina ul {}\r\n';
		cssStr+='.destina li { line-height:24px; float:left; cursor:pointer; text-align:center; width:60px; margin-left:4px; white-space:nowrap;word-break:keep-all;overflow:hidden;}';
		cssStr+="</style>";		
		var javascriptStr="<script type='text/javascript'>var oldIndex=0;function closePop(){ var ifm= window.parent.document.getElementById('popLayer');if((ifm.style.display=='' || ifm.style.display=='block')){ifm.style.display='none';}  }";
		javascriptStr+="function changeDestTab(index){if(index==oldIndex)return false;if(document.getElementsByName('arearadiobutton')[1].checked==true) index=index+5;"
		javascriptStr+="document.getElementById('destina').getElementsByTagName('ul')[index].style.display=''; ";
		javascriptStr+="document.getElementById('destinaP').getElementsByTagName('span')[index%5].className='sele'; ";
		javascriptStr+="document.getElementById('destina').getElementsByTagName('ul')[oldIndex].style.display='none'; ";
		javascriptStr+="document.getElementById('destinaP').getElementsByTagName('span')[oldIndex%5].className='';oldIndex=index;setIFrameAutoHeight();}";
		javascriptStr+="function changeAreaType(){if(document.getElementsByName('arearadiobutton')[1].checked==true){if(oldIndex>=5)return false;document.getElementById('destina').getElementsByTagName('ul')[oldIndex%5+5].style.display=''; document.getElementById('destina').getElementsByTagName('ul')[oldIndex].style.display='none';oldIndex=oldIndex+5;}else{if(oldIndex<5)return false;document.getElementById('destina').getElementsByTagName('ul')[oldIndex].style.display='none'; document.getElementById('destina').getElementsByTagName('ul')[oldIndex%5].style.display='';oldIndex=oldIndex%5;}setIFrameAutoHeight();}";
		javascriptStr+="function setDestName(obj,destName){window.parent.document.getElementById(destName).value=obj.innerHTML;closePop();}";
		javascriptStr+="function setIFrameAutoHeight() { var ifm= window.parent.document.getElementById(\"popLayer\"); var subWin = window.parent.document.frames?window.parent.document.frames[\"popLayer\"].document:ifm.contentDocument;if(ifm !=null&&subWin!= null) ifm.height = subWin.body.scrollHeight; if(!document.all){ifm.height =subWin.childNodes[0].clientHeight;}}</script>";
        this.getPopLayer().document.writeln('<html>'+cssStr+javascriptStr+'<body><div>'+document.getElementById('nestDestDIV').innerHTML+'</div></body></html>');
        this.getPopLayer().document.close();
	},
	closeSelf:function(){
            var ifm= document.getElementById("popLayer");
            if((ifm.style.display=="" || ifm.style.display=="block")){
                ifm.style.display="none";
            }
        }
}

document.writeln('<iframe id="popLayer" name="popLayer" frameborder="0" scrolling="no" width="366" style="position:absolute;width:366px;z-index:9999;display:none;"></iframe>');
var MyPopDestination=new popDestination();
