﻿// JScript File

$(document).ready(function(){
    chatControl.init();
});

function showBorder (name)
{
    var tip = document.getElementById(name); 
    if (tip != null)    tip.style.border = '1px solid #FA9E47';
}


function hideBorder (name)
{
    var tip = document.getElementById(name); 
    if (tip != null) tip.style.border = '';
}


function showBlock(name)
{
    var block = document.getElementById(name); 
    if (block != null)
    {
        block.style.display = "block";
    }
}

function hideBlock(name)
{
    var block = document.getElementById(name); 
    if (block != null)
    {
        block.style.display = "none";
    }
}



//This function is used by the daily content rendering module to get the selected day's content
function getDailyContent(name, day)
{
    var dayControl = document.getElementById(name);
    dayControl.value=day;
     __doPostBack(name.replace(/_/g,'$'),'');  
}

//This function is used by the daily content rendering module to get the selected page's content
function getDailyContentByPage(name, page)
{
    
    var pageControl = document.getElementById(name);
    pageControl.value=page;
    __doPostBack(name.replace(/_/g,'$'),'');  
    
}

function showAllObjective()
{

	document.getElementById("ct_school_objective_detail").style.display = "block";
	document.getElementById("ct_school_objectvie_link").href="javascript:hideObjective();";
	document.getElementById("ct_school_objective_icon").src="/chinesetime/resources/images/school/closeup.jpg";


}

function hideObjective()
{
	document.getElementById("ct_school_objective_detail").style.display = "none";
	document.getElementById("ct_school_objectvie_link").href="javascript:showAllObjective();";
	document.getElementById("ct_school_objective_icon").src="/chinesetime/resources/images/school/opendown.jpg";

}

function ViewMovie()
{
    var width = 366;
    var height = 300;
    var windowFeatures = "toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, height=" + height + ", width=" + width + ", top=" + ((screen.height - height)/2).toString()+",left="+((screen.width - width)/2).toString();
    var vw = window.open ("/chinesetime/pages/shared/movie.aspx?id=" + ViewMovie.arguments[0] , "ChineseTime_Movie", windowFeatures);
    //vw.focuse();
}

/*write by jmd 2010-12-30*/
function blinkColor(id,interval,toggleColor1,toggleColor2){
    this.obj=document.getElementById(id);
    this.interval=interval;
    this.toggleColor1=toggleColor1;
    this.toggleColor2=toggleColor2==null?this.obj.style.color:toggleColor2;
    this.status=0;
    this.blink=function(){
        if(this.obj!=null){
            var self=this;            
            setInterval(function(){
                    timerTick(self,self.obj);
                },this.interval);
        }
    }
    
    function timerTick(obj,node){                
        if(obj.status==0){            
            node.style.color=obj.toggleColor1;
        }else{            
            node.style.color=obj.toggleColor2;
        }
        obj.status=obj.status==0?1:0;
    }    
}

/*Chat JS*/
var chatControl={
    btnMin:null,
    btnOpenChat:null,
    titleWrap:null,
    chatWrap:null,
    popupContent:null,
    
    init:function(){
        $this=this;
        this.chatWrap=$(".chat_wrap");
        if(!this.chatWrap.length){
            return false;
        }
        
        if ($.browser.msie && $.browser.version == "6.0"){        
            this.chatWrap.floatingWidget();
        }
        
        
        this.btnMin=$("#charPopupMin");
        this.btnOpenChat=$("#openChat");
        this.titleWrap=$(".chat_popup .popup_title");
        this.popupContent=$(".chat_wrap .popup_content");
        
        this.btnMin.click(function(){
            $this.togglePopup();
        });
        
        this.btnOpenChat.click(function(){
            return $this.openChat();
        });
    },
    
    togglePopup:function(){
        var isVisiable=!this.popupContent.is(":hidden");
        if(isVisiable){
            this.popupContent.hide();            
            this.titleWrap.addClass("popup_title_min");
        }else{
            this.popupContent.show();            
            this.titleWrap.removeClass("popup_title_min");
        }
    },
    
    openChat:function(){        
        this.openWin(this.btnOpenChat.attr("href"));
        return false; 
    },
    
    openWin:function(url){
        var width = 350;
        var height = 450;
        var windowFeatures = "toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, height=" + height + ", width=" + width + ", top=" + ((screen.height - height)/2).toString()+",left="+((screen.width - width)/2).toString();
        window.open (url , "cr_member_detail", windowFeatures);
    }
};
/*End Chat JS*/


