﻿function headerSetHeightlightItem(name)
{
    var ul1 = document.getElementById("HeaderNavUl");
    var atagList = ul1.getElementsByTagName("a");
    for(var i=0; i < atagList.length; i++)
    {
        var innerTxt = atagList[i].innerHTML;
        innerTxt = innerTxt.replace(/\s+/g,"");
        if(innerTxt == name)
        {
            atagList[i].className = "selected";
            atagList[i].onclick = function()
            {
                return false;
            }
        }
    }
    
    ul1 = document.getElementById("HeaderUnderNavUl");
    atagList = ul1.getElementsByTagName("a");
    for(var i=0; i < atagList.length; i++)
    {
        var innerTxt = atagList[i].innerHTML;
        innerTxt = innerTxt.replace(/\s+/g,"");
        if(innerTxt == name)
        {
            atagList[i].className = "selected";
            atagList[i].onclick = function()
            {
                return false;
            }
        }
    }
    
}

function headerSetHeightlightItemV4(name)
{
    var ul1 = document.getElementById("headerNavV4");
    var atagList = ul1.getElementsByTagName("a");
    var hasItem = false;
    for(var i=0; i < atagList.length; i++)
    {
        var innerTxt = atagList[i].innerHTML;
        innerTxt = innerTxt.replace(/\s+/g,"");
        if(innerTxt == name)
        {
            hasItem = true;
            atagList[i].parentNode.parentNode.className = "selected";
            atagList[i].onclick = function()
            {
                return false;
            }
        }
    }
    
    if(!hasItem)
    {
        var liobj = document.createElement("li");
        liobj.className = "selected";
        liobj.innerHTML = "<div class=\"leftside\"></div> <div class=\"content\"><a href=\"#\">"+name+"</a></div> <div class=\"rightside\"></div>";
        var ul1 = document.getElementById("headerNavV4");
        var litagList = ul1.getElementsByTagName("li");
        
        ul1.insertBefore(liobj,litagList[1]);
        //ul1.appendChild(liobj);
    }
    
    
    
}



var userCardIframe = null;

function gx_group(ca_id,cook_ids,food_id,id)
{
    if(window.attachEvent)
    {
        document.getElementById("guanbi").click();
    }
    else
    {
        var ev = document.createEvent('MouseEvents');
        ev.initEvent('click', false, true);
        document.getElementById("guanbi").dispatchEvent(ev);
    }
    if(!userCardIframe)
    {
        try
        {
            userCardIframe = document.createElement("<iframe frameborder=0><iframe>");
        }
        catch(e)
        {
            userCardIframe = document.createElement("iframe");
        }
        var bodyWidth = document.body.clientWidth;
        var iframeLeft = Math.floor((bodyWidth - 516)/2);
        if(!iframeLeft) iframeLeft=120;
        
        
        userCardIframe.style.position = 'absolute';
        userCardIframe.style.left = iframeLeft+"px";
        userCardIframe.style.top = (document.documentElement.scrollTop + 170)+"px";
      
        userCardIframe.style.overflow = "hidden";
        userCardIframe.scrolling='no';
       
        userCardIframe.marginwidth="0";
        userCardIframe.framespacing="0";
        userCardIframe.marginheight="0";
        //userCardIframe.style.backgroundColor = "#C1C1C1";
        userCardIframe.style.borderStyle = "none";
        userCardIframe.style.width = "526px";
        userCardIframe.style.height = '454px';
        userCardIframe.style.zIndex = "10";
        document.body.appendChild(userCardIframe);
    }
   
    if(food_id=="0")
    {
     userCardIframe.src = "group_cashbox_money.aspx?ca_id="+ca_id+"&&cook_ids="+cook_ids+"&&id="+id
    }
    if(cook_ids=="0")
    {
    userCardIframe.src = "group_cashbox_money.aspx?ca_id="+ca_id+"&&food_id="+food_id+"&&id="+id
    }
    if(food_id=="0"&&cook_ids=="0")
    {
    userCardIframe.src = "group_cashbox_money.aspx?ca_id="+ca_id+"&&id="+id
    }
   
}

function closeUserCardWindow()//关闭用户名片窗口
{
    if(userCardIframe)
    {
        if(userCardIframe.parentNode)
        {
            window.setTimeout(function()
            {
                userCardIframe.parentNode.removeChild(userCardIframe);
                userCardIframe = null;
            },1);//新启线程进行关闭，否则会产生脚本错误。
        }
    }
}



////////////////////////  活动公告  //////////////////////////////

var notification = function(){}
//-------------- 显示活动公告 ---------------
notification.show = function(htmlStr)
{
	var notiEl = document.createElement("div");
	notiEl.innerHTML = "<div style=\"width:279px; height:47px;"+notification.getTransBgStyle("images/notification_t.png")+";position:raletive;\"><div style=\"position:absolute; left:249px; top:10px; width:13px; height:13px;\" onclick=\"notification.close()\"><img src=\"images/notification_close.gif\" /></div></div>"+
	"<div style=\"width:279px;" + notification.getTransBgStyle("images/notification_m.png") + "\"><div style='padding:20px; color:#737476; line-height:22px; text-indent:2em;font-size:14px;'>"+htmlStr+"</div></div>"+
	"<div style=\"width:279px; height:16px;" + notification.getTransBgStyle("images/notification_b.png") + "\"></div>";
	notiEl.style.position = "absolute";
	notiEl.style.zIndex = "3"
	notiEl.style.left = (document.documentElement.clientWidth - 285)+"px";
	notiEl.style.top = (document.documentElement.clientHeight + document.documentElement.scrollTop) + "px";
	notiEl.id = "notifyContainer";
	document.body.appendChild(notiEl);
	window.showNotifyTimer = window.setInterval(notification.showAnimation , 35);

	
	notiEl.style.height="1px";
	notiEl.style.overflow = "hidden";
	if(window.attachEvent)
	{
		window.attachEvent("onscroll",notification.onScrollHandler);
		window.attachEvent("onresize",notification.onResizeHandler);
	}
	else
	{
		window.addEventListener("scroll",notification.onScrollHandler,false);
		window.addEventListener("resize",notification.onResizeHandler,false);
	}
}
notification.showAnimation = function()
{
	var nEl = document.getElementById("notifyContainer");
	if(nEl.clientHeight < (nEl.scrollHeight-10))
	{
		nEl.style.height = (nEl.clientHeight + 6) + "px";
		//nEl.style.top = (nEl.offsetTop - 6) + "px";
		nEl.style.top = ((document.documentElement.clientHeight + document.documentElement.scrollTop) - nEl.clientHeight ) + "px";
		
	}
	else
	{
		nEl.style.height = (nEl.scrollHeight-10) + "px";
		window.clearInterval(window.showNotifyTimer);
		
	}
	
}
notification.onScrollHandler = function()
{
	var nEl = document.getElementById("notifyContainer");
	if(!nEl) return;
	nEl.style.top = ((document.documentElement.clientHeight + document.documentElement.scrollTop) - nEl.clientHeight ) + "px";
}
notification.onResizeHandler = function()
{
	var nEl = document.getElementById("notifyContainer");
	if(!nEl) return;
	nEl.style.top = ((document.documentElement.clientHeight + document.documentElement.scrollTop) - nEl.clientHeight ) + "px";
	nEl.style.left = (document.documentElement.clientWidth - 285)+"px";
}
notification.getTransBgStyle = function(imgurl)
{
	if(/msie\s*6/i.test(window.navigator.appVersion + ""))
	{
		return "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='" + imgurl + "');";
	}
	else
	{
		return "background-image:url("+imgurl+")";
	}
}
notification.close = function()
{
	notification.closeSpeed = 3;
	window.clearInterval(window.showNotifyTimer);
	window.showNotifyTimer = setInterval(notification.closeAnimation,35)
}
notification.closeSpeed = 3;
notification.closeAnimation = function()
{
	notification.closeSpeed+=3;
	var nEl = document.getElementById("notifyContainer");
	if(nEl.clientHeight > notification.closeSpeed)
	{
		nEl.style.height = (nEl.clientHeight - notification.closeSpeed) + "px";
		nEl.style.top = ((document.documentElement.clientHeight + document.documentElement.scrollTop) - nEl.clientHeight ) + "px";
		
	}
	else
	{
		document.body.removeChild(nEl);
		window.clearInterval(window.showNotifyTimer);
	}
}

if(window.attachEvent){
    window.attachEvent("onload",function(){window.setTimeout(function(){notification.show('时值年底，个人和餐厅各种活动频繁。餐厅进入最为繁忙的时间段，难以保证品尝活动的进行。因此，“王老吉空中美食城”的品尝活动由2011年12月23日起暂停，年后将重启活动，请留意趁热网相关公告。')},300);});  
} else {
    window.addEventListener("load", function(){ window.setTimeout(function(){notification.show('时值年底，个人和餐厅各种活动频繁。餐厅进入最为繁忙的时间段，难以保证品尝活动的进行。因此，“王老吉空中美食城”的品尝活动由2011年12月23日起暂停，年后将重启活动，请留意趁热网相关公告。')},300);},false);  
}  

function YaoQing()
{
        var windowElement = document.getElementById("show_yaoq_box2");
        var shadowObj1 = new boxShadow(new boderTemplate(),true,true);
        var windowWidth = document.documentElement.clientWidth;   
        var windowHeight = document.documentElement.clientHeight;   
        var popupHeight =200;   
        var popupWidth =300;   
        windowElement.style.position="absolute";
        windowElement.style.top=((windowHeight-300)/2)+document.documentElement.scrollTop+document.body.scrollTop+"px";
        windowElement.style.left=windowWidth/2-popupWidth/2-100+"px";
        windowElement.style.display="block";
        windowElement.style.zIndex=900;
        shadowObj1.bind(windowElement);
        shadowObj1.setCloseButton(document.getElementById("btn_close_div2"));
}

window.isMouseOnMenu = false;
function menuSwitch(obj,showObj)
{
    document.getElementById('HeaderUnderNavUl2').style.display='none';
    document.getElementById('HeaderUnderNavUl').style.display='none';
    document.getElementById('HeaderUnderNavUl3').style.display='none';
    document.getElementById('HeaderUnderNavUl4').style.display='none';
    
    document.getElementById('Cr3Header1_A14').style.backgroundColor='';
    document.getElementById('Cr3Header1_A10').style.backgroundColor='';
    document.getElementById('Cr3Header1_A4999').style.backgroundColor='';
    document.getElementById('Cr3Header1_A21').style.backgroundColor='';
    window.isMouseOnMenu = true;
    if(obj)
    {
        obj.style.backgroundColor='#6E8213';
    }
    if(showObj)
    {
        showObj.style.display='inline';
    }
}

function moseOverSubMenu()
{
    window.isMouseOnMenu = true;
}

function mouseOutMenu()
{
    window.isMouseOnMenu = false;
    setTimeout(
        function()
        {
            if(window.isMouseOnMenu) return;
             menuSwitch(null,null);
        }
        ,200
    )
}
