﻿ (function(){
	var Dom = FG.Dom
	var Event = FG.Event;
	var Builder = FG.Builder;
	function showFlash360(){
		var container = Dom.get('flash-360');
		var objContainer = Dom.get('flash360');
		if (!container || !objContainer) {
			return false;
		}
		
		var i, len = flash360.length;
		if (len >= 1) {
			var temFrame = document.createDocumentFragment();
			var flashInfoBar = Builder.Node('div', {
				id: 'flash-infobar'
			});
			var flashIntro = Builder.Node('p', {
				id: 'flash-intro'
			}, '环视图：' + flash360[0][0]);
			var itemsList = Builder.Node('ul', {
				id: 'flash-items-list'
			});
			Dom.setStyles(itemsList, {
				width: (34 * len) + 'px',
				left: (515 - (34 * len)) + 'px'
			});
			var items = [], itemsClass = '';
			var lastItem = null;
			var chgItem = function(index){
				var Flash = new SWFObject(flash360[index][1], 'flash360Object', 480, 276, '8');
				Flash.addParam('wmode', 'transparent');
				Flash.addParam('quality', 'high');
				Flash.addParam('scale', 'noscale');
				Flash.write('flash360');
				//flashIntro.innerHTML = "<span style='font-size:14px; font-weight:bold; float:left;'>" +  flash360[index][0] + "</span>";
				flashIntro.innerHTML = "<span style='font-size:14px; font-weight:bold; float:left;'>餐厅环视图</span>";
				lastItem.className = '';
				items[index].className = 'current';
				lastItem = items[index];
			};
			temFrame.appendChild(flashInfoBar);
			temFrame.appendChild(flashIntro);
			for (i = 0; i < len; i++) {
				items.push(Builder.Node('li', {
					id: 'flash-item' + i
				}, Builder.Node('a', {
					id: 'flash-linkitem' + i,
					href: '#linkitem' + i
				}, (i + 1).toString())));
				if(len > 1 )
				{
					itemsList.appendChild(items[i]);
					Event.addEvent(items[i], 'click', function(index){
						return function(event){
							var evt = event || window.event;
							chgItem(index);
							Event.stopEvent(evt);
						}
					}(i));
				}
			}
			lastItem = items[0];
			chgItem(0);
			temFrame.appendChild(itemsList);
			container.appendChild(temFrame);
		}
		else {
			container.style.display = 'none';
		}
	};

	showFlash360();
	
})();
     
    function trim(str)
    {
        return str.replace(/(^\s*)|(\s*$)/g,"");
    }

    //更换大图片的显示
    function ChangeShowPic(clickImgObj,type,imgurl,title,httpurl,descripton,memberPic, memberUrl,membername)
    {
        //为环境时：descripton 为图片的ID
        var ishuanshi = 0;
        
        if(type == "Environment") //为环视图
        {
            $('divTabEnvironment').style.display = "block";
            if( descripton=="0")
            {
                $('sweep360Environment').style.display = "none";
                $('phCurEnvironment2').style.display = "none";
                $('divTabEnvironmentHuanShi').style.display = "block";
                ishuanshi = 1;
            }
            else
            {
                $('sweep360Environment').style.display = "block";
                $('phCurEnvironment2').style.display = "block";
                $('divTabEnvironmentHuanShi').style.display = "none";
            }
        }
        
        SetClickImgFocus(clickImgObj,type);
        if(ishuanshi == 1) return;  //只显示环视图
        
        var tempspName = "sweep360" + type;
        if($(tempspName) == null || imgurl == null ) return;
        var bigpicUrl = imgurl;
        var bigimgid = "bigImg" + type;
        var strTempHtml =  "<span class='bigImg'><a href='" + httpurl + "' target='_blank'><img width='0' height='0' src='" + bigpicUrl + "' onload='AXImg(this)'  id='"+ bigimgid + "'/></a></span>";
        if(type == "Dish" || type == "ResMenu" )
        {
            strTempHtml += "<span id='show_detail'> <h5>" + title + "</h5><p>" + descripton + "</p></span>";
        }
        $(tempspName).innerHTML = strTempHtml;
        var phCur1Obj = $("phCur" + type + '1');
        var phCur2Obj = $("phCur" + type + '2');
        if(phCur1Obj != null )
        {
            phCur1Obj.style.display = "none";
        }
        var strTitle = "";
        if(phCur2Obj != null )
        {
            if(type != "Upload" )
            {
                strTitle = title ;
            }
            else  //为网友上传时
            {
                var strTitle = title + "&nbsp;<img src='" + memberPic + "' class='touxiang' align='absmiddle' style='width:21px;height:21px' />&nbsp;<a href='" + memberUrl + "'>" + membername + "</a>&nbsp;<cite>上传</cite>";
            }    
        } 
        phCur2Obj.innerHTML = strTitle;
        
         if(type == "Dish" )
         {
            mouseTip();
         }
         
         
        var tempimgoneName = strClientId + type;
        if($(tempimgoneName) == null ) return;
        
        $(tempimgoneName).style.display = "none";
        
    }
    
    //设置选中小图片样式
    function SetClickImgFocus(clickImgObj,type)
    {
    	var divUlObj = $('divTab' + type + 'Img');
    	if(divUlObj == null ) return ;
    	var imgArr = divUlObj.getElementsByTagName('li'); //获取所有小图
		for(var i=0;i<imgArr.length;i++)
		{
			if(clickImgObj.id == imgArr[i].id )
			{
				imgArr[i].className = "current";
			}
			else
			{
				imgArr[i].className = "";
			}
		}
    }
    
    
