﻿

// <![CDATA[ 
//设为首页
function h(obj,url){obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);}


/**
* 重新设定图片大小
*
*@param picname 图片路径
*@param width_v  目标宽度
*@param height_v 目标高度
*/
function resizepic(picname,width_v,height_v){
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
var backw=width_v;
var backh=height_v;
}else
{
var backw=width_v+8;
var backh=height_v+8;
}
var i = String(Math.floor(Math.random()*10000)+1);
document.writeln("<div style='width:"+backw+"px;height:"+backh+"px;padding:3px;border:0px solid #a1a1a1;backgournd:#fff;'>");
document.writeln("<div style='width:"+width_v+"px;height:"+height_v+"px;overflow:hidden;'>");
document.writeln("<img src='"+picname+"' id='img"+i+"'/></div></div>");
var pic=document.getElementById("img"+i);
if((width_v/height_v)>(pic.offsetWidth/pic.offsetHeight)){
pic.width=width_v;
}else
{
pic.height=height_v;
}
}


/**
* 重新设定图片大小
*
*@param picname 图片路径
*@param width_v  目标宽度
*@param height_v 目标高度
*/
function resizepic2(picname,width_v,height_v){
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
var backw=width_v;
var backh=height_v;
}else
{
var backw=width_v+8;
var backh=height_v+8;
}
var i = String(Math.floor(Math.random()*10000)+1);
document.writeln("<div style='width:"+backw+"px;height:"+backh+"px;padding:3px;border:0px solid #a1a1a1;backgournd:#fff;'>");
document.writeln("<div style='width:"+width_v+"px;height:"+height_v+"px;overflow:hidden;'>");
document.writeln("<img src='"+picname+"' id='img"+i+"'/></div></div>");
var pic=document.getElementById("img"+i);
if((width_v/height_v)>(pic.offsetWidth/pic.offsetHeight)){
pic.width=width_v;
}else
{
pic.height=height_v;
}
}


function externallinks()
{ 
 if(!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) 
 { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   {
     anchor.target = "_blank"; 
   }
 } 
} 
window.onload = externallinks;


/*下拉菜单*/
function ShowFloatDiv(selfid,aa)
{
  
 if( selfid != null )
 { 
 	selfid.style.position = 'relative';
  document.getElementById(aa).style.top = CountPx(selfid.offsetTop,1);
  document.getElementById(aa).style.left = CountPx(selfid.offsetLeft/2,112);
  }
 document.getElementById(aa).style.display = 'block';

 
}
function HiddenFloatDiv(aa)
{
 	document.getElementById(aa).style.display = 'none';

}
function CountPx(PxA,PxB)
{
 	return (parseInt(PxA.toString().replace('px','')) + parseInt(PxB.toString().replace('px',''))).toString() + 'px';
}



/*下拉菜单*/
function ShowFloatDivClassHome(selfid,aa)
{
  
 if( selfid != null )
 { 
 	selfid.style.position = 'relative';
  document.getElementById(aa).style.top = CountPx(selfid.offsetTop,1);
  document.getElementById(aa).style.left = CountPx(selfid.offsetLeft,100);
  }
 document.getElementById(aa).style.display = 'block';

 
}
function HiddenFloatDivClassHome(aa)
{
 	document.getElementById(aa).style.display = 'none';

}


/*下拉菜单*/
function ShowFloatDiv2(selfid,aa)
{
  
 if( selfid != null )
 { 
 	selfid.style.position = 'relative';
  document.getElementById(aa).style.top = CountPx(selfid.offsetTop,0);
  document.getElementById(aa).style.left = CountPx(selfid.offsetLeft,25);
  }
  
  
 document.getElementById(aa).style.display = 'block';

 
}
function HiddenFloatDiv2(aa)
{
 	document.getElementById(aa).style.display = 'none';

}



/*下拉菜单*/
function ShowFloatDiv3(selfid,aa)
{
  
 if( selfid != null )
 { 
 	selfid.style.position = 'relative';
  document.getElementById(aa).style.top = CountPx(selfid.offsetTop,20);
  document.getElementById(aa).style.left = CountPx(selfid.offsetLeft,-200);
  }
  
  
 document.getElementById(aa).style.display = 'block';

 
}
function HiddenFloatDiv3(aa)
{
 	document.getElementById(aa).style.display = 'none';

}

/*百度搜索-下拉菜单*/
function ShowFloatDiv4(selfid,aa)
{
  
 if( selfid != null )
 { 
 	selfid.style.position = 'relative';
  document.getElementById(aa).style.top = CountPx(selfid.offsetTop,50);
  document.getElementById(aa).style.left = CountPx(selfid.offsetLeft,1);
  }
  
  
 document.getElementById(aa).style.display = 'block';

 
}
function HiddenFloatDiv4(aa)
{
 	document.getElementById(aa).style.display = 'none';

}




function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function ceowenajax(cid) {
    http.open('get','/user/message/updatestate?id='+cid);
    http.send(null);
}



/*********************************************************************
*CEOWEN图片加载类
*功能：避免了在img 里直接判断宽高造成屏幕的闪烁
*参数：
*url:图片url
*id:图片img的id,如果查找不到这个id，将创建一个img，并添加到网页尾部
*maxWidth:最大宽度，可不设置
*maxHeight:最大高度，可不设置
*作者：闻青
*日期：2007-10-17 18:26:16
*Copyright (c) 2007 CEOWEN Corporation.
**********************************************************************/
  ImageLoader=function(url,id,maxWidth,maxHeight){
  this.imgObj=new Image();
  this.imgObj.tries=0;
  this.imgObj.src=url;
  this.imgObj.uid=id;
  this.imgObj.maxWidth=maxWidth;
  this.imgObj.maxHeight=maxHeight;
  
  if (!window.ImageLoaders)
    window.ImageLoaders={};
  	window.ImageLoaders[id]=this.imgObj;
  if (!document.all)
    window.addEventListener('load',function(){document.readyState='complete'},false)
  	window.ImageComplete=function(i){
    var obj=window.ImageLoaders[i];
    clearInterval(obj.timer);
    var mw=obj.maxWidth;
    var mh=obj.maxHeight;
    var id=obj.uid;

    if (!document.getElementById(id)){
    		//alert("创建img")
        var img=document.createElement("img");
        img.setAttribute("id",id);
        img.alt='图像';
        document.body.appendChild(img);
    }
    var img=document.getElementById(id);

    if (obj.width>obj.height){
      if (mw>0){
        if (obj.width>mw)
          img.width=mw;
      }
    }
    else{
      if (mh>0){
        if (obj.height>mh)
          img.height=mh;
      }
    }
    img.src=obj.src;
    img.style.display='';
   // document.getElementById('ceowen-loadinfo').innerHTML = '';
   // document.getElementById('ceowen-loadinfo').style.display = 'none';
    window.ImageLoaders[i]=null;
  }

  this.imgObj.onload=function(){
  	document.getElementById('ts').style.width = document.getElementById('ceowenimage').style.width;
    window.ImageLoaders[this.uid].timer=setInterval("if (document.readyState=='complete'){window.ImageComplete('"+this.uid+"');}",500);
  }
  this.imgObj.onerror=function(){window.status='加载'+this.src+'失败';document.getElementById('ceowen-loadinfo').innerHTML = '<b style=\"color:#ff0000;\">图片加载失败</b>';document.getElementById('ceowen-loadinfo').style.display = 'block';}
}



function CEOWEN_OpenURL(URL)
{
	window.location.href = URL;
}



//读取图片预览数据200x200px
function ceowen_getviewimage(imgurl,divname){
	var xmlhttpobj = CEOWEN_CreateXmlHttp();
	if(xmlhttpobj){//如果创建对象xmlhttpobj成功
		document.getElementById(divname).innerHTML="<img src='/i/ceowen_ajax2010red.gif' alt='' style='margin-right:5px;' align='absmiddle'><span style='color:#666;'>正在加载预览图片...</span><img src='/i/ceowen_ajax2010blue.gif' alt='' style='margin-right:5px;' align='absmiddle'>";
		xmlhttpobj.open("get","/ajax/ceowen_priviewimage/?img="+ imgurl,true);//get方法 加个随机数。
		xmlhttpobj.send(null);
		xmlhttpobj.onreadystatechange=function(){//客户端监控函数
			if(xmlhttpobj.readyState==4){//服务器处理请求完成
				if(xmlhttpobj.status==200){
					//alert('ok');
					document.getElementById(divname).innerHTML="<img src='/i/ceowen_ajax2010red.gif' alt='' style='margin-right:5px;' align='absmiddle'>正在加载预览图片...<img src='/i/ceowen_ajax2010blue.gif' alt='' style='margin-right:5px;' align='absmiddle'>";//服务器处理中
					var html = xmlhttpobj.responseText;//获得返回值
					//alert(html);
					document.getElementById(divname).innerHTML=html;
				
				}else{
					document.getElementById(divname).innerHTML="服务器忙，请您稍后重试！";
				}
			}else{
				document.getElementById(divname).innerHTML="<img src='/i/ceowen_ajax2010red.gif' alt='' style='margin-right:5px;' align='absmiddle'>正在加载预览图片...<img src='/i/ceowen_ajax2010blue.gif' alt='' style='margin-right:5px;' align='absmiddle'>";//服务器处理中				
			}
		}	
	}
}

// ]]>