﻿UI.toolTip=function(event, options) {
    var e=event || window.event;
    var el= e.target || e.srcElement;
    el.options={
        className:'UItoolTip',
        mousemove:UI.toolTip.mousemove
    };
    Object.extend(el.options, options);
    if(!el.UItoolTip) {
        el.stitle = el.alt || el.title || el.stitle;
        el.title = el.alt = "";
        if(!el.stitle) return;
        var d = document.createElement("DIV");		
        d.className = el.options.className;
        d.style.position="absolute";	
        UI.$('JESToolTip').appendChild(d);
        el.UItoolTip=d;
        el.UItoolTip.innerHTML=el.stitle;
    }
    var scroll = UI.getScroll();
    var x = (e.clientX+scroll.left+10) + "px";
    var y = (e.clientY+scroll.top+10) + "px";
    el.UItoolTip.style.left = x;
    el.UItoolTip.style.top =  y;
    el.UItoolTip.style.visibility="visible";
    UI.addEvent(el,'mouseout',UI.toolTip.mouseout);
    if(el.options.mousemove) UI.addEvent(document, "mousemove", el.options.mousemove);
}
document.write('<div id="JESToolTip"></div>');
UI.toolTip.seq = 1;
UI.toolTip.mousemove=function(event){
    var e=event || window.event; var el= e.target || e.srcElement;
    var scroll = UI.getScroll();
    el.UItoolTip.style.left=(e.clientX+scroll.left)+"px";
    el.UItoolTip.style.top=(e.clientY+scroll.top+20)+"px";
};
UI.toolTip.mouseout=function(event){
    var e=event || window.event; var el= e.target || e.srcElement;
    if(!el.UItoolTip) return;
    el.UItoolTip.style.visibility="hidden";
    if(el.options.mousemove) UI.delEvent(document, "mousemove",  el.options.mousemove);	
};

/*******************************************************************************
        for Font Type && Font Size
*********************************************************************************/
UI.tvpotSWF=function(src,w,h){
    width = (w)? w : 502;
    height = (h)? h : 438; 
	src=src.replace("flvPlayer","mloader");
	src+='&ver=0001&stype=m';
	var tvpot = '<object type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" align="middle" id="V000165992" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">';
	tvpot += '<param name="movie" value="'+src+'"/>';
	tvpot += '<param name="allowScriptAccess" value="always"/>';
	tvpot += '<param name="allowFullScreen" value="true"/>';
	tvpot += '<param name="loop" value="false"/>';
	tvpot += '<param name="menu" value="false"/>';
	tvpot += '<param name="wmode" value="transparent"/>';
	tvpot += '<param name="swLiveConnect" value="true"/>';
	tvpot += '<embed src="'+src+'" width="'+width+'" height="'+height+'" loop="false" menu="false" swLiveConnect="true" wmode="transparent" allowScriptAccess="always" type="application/x-shockwave-flash" allowFullScreen="true" nowow="true"/>';
	tvpot += '</object>';
	document.write(tvpot);
};

/*******************************************************************************
        for Right TodayNews // 
*********************************************************************************/
function viewToday(){
    new viewTodayNewsP(arguments[0]);
}
viewTodayNewsP = function(el){
    var self = this;
    this._el = (el)? true : false;
    this._tit = UI.$("GS_con_tit")? UI.$("GS_con_tit").innerHTML : false; 
    if(!this._el){
         var _icon = UI.$("VTodayTit");
         var _wrap = UI.$("VTodayWrap");
        _wrap.style.display = (_wrap.style.display == 'block')? 'none' : 'block';
        _icon.className=(_wrap.style.display== 'block')? 'close':'' ;
        this._con = UI.$("todayCon");  
        this._txt = UI.$("todayTxt");  
        this._del = UI.$("todayClear");  
        this._del.onclick = function(){self.delCook();return false;}
        this._cnt = UI.$("todayCnt");  
        this._list = UI.$("todayList");  
    }
    if(this._tit) this.init();  
    else this.print();
}
viewTodayNewsP.prototype = {
    init : function(){
        this.getUrl();
        this.setCook();
    },getUrl : function(){
        this.param = location.href;
        this.url= this.param+'|'+UI.length(this._tit,31,"..");
    },makeCook : function(){
        var cnt = 0;
        this.temp = [] ;
        var cook = UI.getCookie('todayE').split('||');
        var last = (cook.length <10)? cook.length : 10;
       
		for(var i=0; i<last; i++){
          if(cnt != last){
            if(cook[i].indexOf(this.param) > -1 || cook[i].indexOf(UI.length(this._tit,31,"..")) > -1){}
            else {this.temp[cnt] = cook[i];cnt++;};
          }
        }
        return (this.temp.length>0)? '||' + this.temp.join('||') : '';
    },setCook : function(){
       var cook =  UI.getCookie('todayE');
       var value = (cook)?  this.url+this.makeCook() :  this.url;
       UI.setCookie('todayE',value,365,'/','base.cndmy.com');
       if(!this._el) this.print();
    },getCook : function(){
        var cook = UI.getCookie('todayE').split('||');
        var con = '';
        var cnt = 0;
        var last = (cook.length <10)? cook.length : 10;

        con += '<ul class="li">';
        for(var i=0; i<last; i++){
            if(i%5 == 0 && i !=0) con += '<li class="line">&nbsp;</li>';
            con += '<li><a href="'+cook[i].split('|')[0]+'">'+cook[i].split('|')[1]+'<\/a><\/li>'
        }
        con += '<\/ul>'
        if(this._list) this._list.innerHTML = con;
        if(this._cnt) this._cnt.innerHTML = '共<strong class="on">'+last+'<\/strong>篇';
        this.viewCon();
    },delCook : function(){
        this.viewTxt();
        UI.setCookie('todayE','',-1 ,'/','base.cndmy.com');
        UI.resizeIframe('TodayFrame')
    },print : function(){
        if(UI.getCookie('todayE'))  this.getCook();
        else  this.viewTxt();
        UI.resizeIframe('TodayFrame')
    },viewCon : function(){
        this._con.style.display = 'block';
        this._txt.style.display = 'none';
    },viewTxt : function(){
        this._con.style.display = 'none';
        this._txt.style.display = 'block';
    }
}

/*******************************************************************************
        for Gisa View Font
*********************************************************************************/
GS_font = function(){
    var self = this;
    this.con = UI.$('news_content')
    this.fontNo = UI.getCookie('GS_font_Name_no');
    this.chFont();
    this.getSize = parseInt(UI.getCookie('GS_font_size'));
    this.size = (this.getSize)? this.getSize : 14;
    UI.$('font_big').onclick = function(){self.big()};
    UI.$('font_small').onclick = function(){self.small()};
    this.setSize();
}
GS_font.prototype ={
    big : function(){
        if(this.size<20) this.size += 2;
        else alert("超过最大适合浏览的字号");
        this.setSize();
    },small : function(){
        if(this.size>13) this.size -= 2;
        else alert("低于最小适合浏览的字号")
        this.setSize();
    },chFont : function(){
        var font = UI.$('GS_font_type').getElementsByTagName("li");
        var oldNo = (this.fontNo)? this.fontNo : 0;
        var obj = null;
        var self= this;
        this.setFont('GS_font_Name_no', oldNo);
        font[oldNo].on = true;
        font[oldNo].className = 'on';
        for(var i=0; i<font.length; i++){
            obj = font[i];
            obj.num = i;
            obj.onclick = function(){
                font[oldNo].on = false;
                font[oldNo].className = "";
                this.on = true;
                this.className = "on"
                oldNo = this.num;
                self.setFont('GS_font_Name_no', this.num);
            }
            obj.onmouseover = function(){this.className = "on"}
            obj.onmouseout = function(){if(!this.on) this.className = ""}
        }
    },setSize : function(){
         this.con.style.fontSize  = this.size +"px"; 
         UI.setCookie('GS_font_size', this.size,365,'/','base.cndmy.com');
    },setFont : function(name, value){
         UI.$("news_content").className  = 'GS_font_' + value;
         UI.setCookie(name, value,365,'/','base.cndmy.com');
    }
}

/*******************************************************************************
        for Gisa View image Zoom
*********************************************************************************/
function GS_zoom(){
    this.img = UI.$("news_content").getElementsByTagName("img"); 
    this.table = UI.$("news_content").getElementsByTagName("table");
    var obj = null;
    var objT = null;
    if(this.table.length != 0){
        for(var j=0; j<this.table.length; j++){
             objT = this.table[j];
             if(parseInt(objT.style.width) > 568 ) objT.style.width = 568+'px';
        }
    }
    if(this.img.length != 0) {
        if(this.img[this.img.length-1].complete == false) {setTimeout('GS_zoom()',10); return false;}
        for(var i=0; i<this.img.length; i++){
            obj = this.img[i];
            obj.w = obj.width;
            obj.h = obj.height;
            if(obj.w >= 568 ) {
                obj.width = 568;
                obj.style.cursor = 'pointer';
                obj.zoom = obj.nextSibling;
                obj.onmouseover = function(){
                    var self=this;
                    this.zoom.style.left = (this.width-106)/2+"px";
                    this.zoom.style.top = (this.height-75)/2+"px";
                    this.zoom.style.display="block";
                    this.zoom.onmouseover = function(){this.style.display="block"}
                    this.zoom.onclick = function(){self.onclick();}
                }
                obj.onmouseout = function(){this.zoom.style.display="none"}
                obj.onclick = function() {
                    var w = 568;
                    var h = (this.h >= 650 )? 650 : this.h;
                    var s = (this.h >= 500 )? 'yes' : 'no';
                    if(s == 'yes') w = w+17;
                    var url = '/IncluedFile/media/popup/imgpopup.html?src='+this.src+'&w='+this.width+'&h='+this.height;

                   window.open(url,'pop',"width="+w +",height="+h+", status=0, resizable=0, scrollbars="+s+" ,resizable=yes, status=no");
                }
            }
        }
     }
}
function GS_zoom_pop(){
    var param = UI.parseQuery();
    if(param['w'] == 568){
        var w = (UI.$('popimg').width <1000)? UI.$('popimg').width - 568 : Math.abs(1000 -UI.$('popimg').width);
        window.resizeBy(w,0);
        var h = (UI.$('popimg').height <700)?  UI.$('popimg').height - param['h'] : Math.abs(700 - param['h']);
        window.resizeBy(0,h);
    }
}
function GS_con(){
    new GS_font();
    GS_zoom();
}

/*******************************************************************************
        for Gisa View WHO
*********************************************************************************/
UI.GModal=function(url){
    if(!UI.$('UIModalB')) UI.GModal.print();
    UI.$('WTS').style.display = 'none'; //for Mac FF
    UI.GModal.setB();
    UI.GModal.center(UI.$('UIModalL'));
    UI.$('UIModalF').innerHTML = '<iframe name="whoFrame" id="whoFrame" src="'+url+'" width="901" height="590" frameborder="0" scrolling="no" style="display:none; "><\/iframe>';
    UI.addEvent(UI.$('whoFrame'), 'load', UI.GModal.onload);
    UI.addEvent(UI.$('UIModalB'), 'click', UI.GModal.reset);
    UI.addEvent(window,'resize', UI.GModal.onresize);
}
UI.GModal.print=function(){
    var d=document.createElement('div');
    var s='';
    s+='<div id="UIModalB" style="z-index:99998; position:absolute; width:100%; height:100%; display:none; background:#000;"><\/div>';
    s+='<div id="UIModalF" style="z-index:99999; position:absolute; display:none; text-align:center;"><\/div>';
    s+='<div id="UIModalL" style="z-index:99999; position:absolute; width:901px; height:590px; background:#000; text-align:center;"><img src="/images/media/who/loading.gif" width="119" height="119" style="margin-top:230px;" /><\/div>';
    d.innerHTML=s;
    document.getElementsByTagName('body')[0].appendChild(d);
};
UI.GModal.setB=function(){
    var w=UI.$('UIModalB');
    var h =  document.body.scrollHeight 
    UI.setOpacity(w,30);
    w.style.top=0;
    w.style.left=0;
    w.style.height = h+'px';
    w.style.display='block'	
};
UI.GModal.onload=function(){
    UI.$('whoFrame').style.display='block';
    UI.GModal.center(UI.$('UIModalF'));
    UI.$('UIModalL').style.display='none';
};
UI.GModal.center=function(el){
    el.style.display='block';
    var pos=UI.getScroll();
    el.style.left=pos.width/2-el.offsetWidth/2+pos.left+'px';
    var h =  (UI.getBrowser().opera)? window.innerHeight : document.documentElement.clientHeight; //(UI.getBrowser().opera)? window.innerHeight :
    el.style.top=h/2-el.offsetHeight/2+pos.top+'px';
};
UI.GModal.reset=function(){
    UI.$('WTS').style.display = 'block'; //for Mac FF
    UI.$('UIModalF').innerHTML='';
    UI.$('UIModalB').style.display='none';
    UI.$('UIModalF').style.display='none';
    UI.$('UIModalL').style.display='none';
};
UI.GModal.change=function(){
    UI.GModal.center(UI.$('UIModalF'));
    UI.GModal.center(UI.$('UIModalL'));
};
UI.GModal.onresize=function(){
    UI.GModal.center(UI.$('UIModalF'));
	UI.GModal.setB();
};

/*******************************************************************************
        for goMail, Print, Scrap, Favorait
*********************************************************************************/
function popReport(id) {//
    UI.popUp('/service/report/cs_report?newsid='+id,'popReport','730','470');
}
function popMail(id){// 
    UI.popUp('/service/mail/mailform?newsid='+id,'popMail','730','470');
}
function popPrint(id) {//print
    UI.popUp('/service/print/form?newsid='+id,'popPrint','690','550',0,0,0,1);
}

/*******************************************************************************
        for Gisa View Slide
*********************************************************************************/
UI.GSlide = function(el){ 
    var self = this;
    this.obj = UI.$(el.id);
    this.w = el.width;
    if(el.on) UI.MouseOver(this.obj);
    this.x = (el.dir == 'prev')?  2 * this.w : 0; // 2 * this.w : 0;
    this.set();
    clearInterval(this.timer)
    this.timer = setInterval(function(){self.sliding()},20);
}
UI.GSlide.prototype = {
    sliding : function(){
        var self = this;
        this.x += (this.w-this.x) * 0.3;
        this.set();
        if(Math.round(this.x) == this.w){clearInterval(this.timer)};
    },set : function(){
       this.obj.style.left = -Math.round(this.x)+"px"
    }
}
UI.GSmove = function(el){
    this.obj = UI.$(el.id);
    this.w = el.width;
    this.on = (el.on)? true : false;
}
UI.GSmove.prototype = {
    start : function(pos){
        var self = this;
        if(this.on) UI.MouseOver(this.obj);

        if(arguments[1]){
            this.x =  (pos == 'prev' || pos == '')? this.w/3 : -this.w/3; 
            this.target = (pos == 'prev')?  0 : 0;
        }else{
            this.x =  (pos == 'prev' || pos == '')? this.w : 0; 
            this.target = (pos == 'prev')?  0 : this.w;
       }
        this.set();
        if(this.playing) return;
        this.timer = setInterval(function(){self.sliding()},10);
    },sliding : function(){
        var self = this;
        this.x += (this.target-this.x) * 0.3;
        this.set();

        if(Math.round(this.x) == this.w){clearInterval(this.timer); this.playing=false;}; 
    },set : function(){
       this.obj.style.left = -Math.round(this.x)+"px"
    }
}
UI.MouseOver = function(id){
    this.obj = (typeof id == "object")? id.getElementsByTagName("li") : UI.$(id).getElementsByTagName("li"); 
    for(i=0; i<this.obj.length; i++){
        this.obj[i].cname = (this.obj[i].className=="on" || this.obj[i].className=="fir_plus_on")? true : false;
        this.obj[i].onmouseover = function(){if(!this.cname) this.className=(this.className=="fir_plus")? "fir_plus_on" : "on"; }
        this.obj[i].onmouseout = function(){if(!this.cname) this.className=(this.className=="fir_plus_on")? "fir_plus" :""}
    }
}
function ADgeneral(){}
function ADclix(){}

function goSearch(){
	frm = document.searchfrm;
	site = frm.q.value;
    if(site==""){
		alert("请输入要搜索的内容")
		return false;

	}
	frm.action = "/Search/home";
	frm.target = "_parent";
	frm.submit();
	return false;
}
