﻿function resizeimg(ImgD,iwidth,iheight) {  
     var image=new Image(); 
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0){ 
        if(image.width/image.height>= iwidth/iheight){ 
           if(image.width>iwidth){ 
               ImgD.width=iwidth; 
               ImgD.height=(image.height*iwidth)/image.width; 
           }else{ 
                  ImgD.width=image.width; 
                  ImgD.height=image.height; 
                } 
               ImgD.alt=image.width+"×"+image.height; 
        } 
        else{ 
                if(image.height>iheight){ 
                       ImgD.height=iheight; 
                       ImgD.width=(image.width*iheight)/image.height; 
                }else{ 
                        ImgD.width=image.width; 
                        ImgD.height=image.height; 
                     } 
                ImgD.alt=image.width+"×"+image.height; 
            } 
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针 
　　　　　//ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
　　　　　　ImgD.title = "点击图片可在新窗口打开"; 
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放 
　　　　　 { 
　　　　　　　　　//　var zoom = parseInt(this.style.zoom, 10) || 100; 
　　　　　　　　　//　zoom += event.wheelDelta / 12; 
　　　　　　　　　　//if (zoom> 0)　this.style.zoom = zoom + "%"; 
　　　　　　　　　　//return false; 
　　　　　 } 
　　　  } else { //如果不是IE 
　　　　　　　     ImgD.title = "点击图片可在新窗口打开"; 
　　　　　　   } 
    } 
}

function resizeimg_1(ImgD,iwidth,iheight) 
{ 
     var image=new Image(); 
	 var TempWidth;
     image.src=ImgD.src; 
     if(image.width>0 && image.height>0)
	 { 
	 	if(image.width<=iwidth)
		{
			ImgD.width=image.width;
			ImgD.height=iheight;
		}
		else
		{
			var k;
			k=image.width-iwidth;
			var k1;
			k1=k/image.width;
			ImgD.width=iwidth;
			ImgD.height=image.height-image.height*k1;
		}
		
	 }
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function subString(str, len) 
{ 
    var newLength = 0; 
    var newStr = ""; 
    var chineseRegex = /[^\x00-\xff]/g; 
    var singleChar = ""; 
    var strLength = str.replace(chineseRegex,"**").length; 
    for(var i = 0;i < strLength;i++) 
    { 
        singleChar = str.charAt(i).toString(); 
        if(singleChar.match(chineseRegex) != null) 
        { 
            newLength += 2; 
        }     
        else 
        { 
            newLength++; 
        } 
        if(newLength > len) 
        { 
            break; 
        } 
        newStr += singleChar; 
    } 
     
    if( strLength > len) 
    { 
        newStr += "..."; 
    } 
    return newStr; 
} 
function CtoH(obj)
{ 

var str=obj.value;
var result="";
for (var i = 0; i < str.length; i++)
{
if (str.charCodeAt(i)==12288)
{
result+= String.fromCharCode(str.charCodeAt(i)-12256);
continue;
}
if (str.charCodeAt(i)>65280 && str.charCodeAt(i)<65375)
result+= String.fromCharCode(str.charCodeAt(i)-65248);
else result+= String.fromCharCode(str.charCodeAt(i));
} 

obj.value=result;
if (JS_Test(obj.value)==false)
{
	obj.value='';
}
} 
function JS_Test(str) {
if (str != '') {
if (str.match(/[^0-9]/g,'')== null) { }
else { alert ("只能是数字");
return false;
 }
}
}

function OpenSmallWindows(strURL,width,height){showModelessDialog(strURL,'fa','dialogWidth:'+width+'px;dialogHeight:'+height+'px;status:no;help:no;scroll:no;');}

function CopyMsg(Msg,Url){ 
var clipboardcontent=''; 

clipboardcontent=Msg+'\n'+Url; 
window.clipboardData.setData("text",clipboardcontent);
alert("按Ctrl + V ,粘贴到MSN或QQ上发给你的好友们吧 ！"); 
 
} 


function resetChooseForm(FormName) {
	try {
		
	
	
		for (var i = 0; i < document.forms[FormName].elements.length; ++i) {
			var o = document.forms[FormName].elements.item(i);
			if (o.tagName.toLowerCase() == 'input' && o.type.toLowerCase() == 'text')  o.value = '';
			else if (o.tagName.toLowerCase() == 'select' ) o.options[0].selected = true;
			else if (o.tagName.toLowerCase() == 'input' && o.type.toLowerCase() == 'checkbox') o.checked = false;
			else if (o.tagName.toLowerCase() == 'input' && o.type.toLowerCase() == 'radio') o.checked = false;
			//else if (o.tagName.toLowerCase() == 'input' && o.name == 'tprop') o.value = '';
		}
		
		
		
	}catch (e) {};
	//document.forms['filterForm'].submit();
}
function Hash(Id)
{
	alert(Id);
	window.location.hash   =   Id;
}

//滚动
function intval(v)
{
v = parseInt(v);
return isNaN(v) ? 0 : v;
}
// 获取元素信息
function getPos(e)
{
var l = 0;
var t  = 0;
var w = intval(e.style.width);
var h = intval(e.style.height);
var wb = e.offsetWidth;
var hb = e.offsetHeight;
while (e.offsetParent){
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
e = e.offsetParent;
}
l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0);
t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0);
return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
}
// 获取滚动条信息
function getScroll()
{
var t, l, w, h;
if (document.documentElement && document.documentElement.scrollTop) {
t = document.documentElement.scrollTop;
l = document.documentElement.scrollLeft;
w = document.documentElement.scrollWidth;
h = document.documentElement.scrollHeight;
} else if (document.body) {
t = document.body.scrollTop;
l = document.body.scrollLeft;
w = document.body.scrollWidth;
h = document.body.scrollHeight;
}
return { t: t, l: l, w: w, h: h };
}
// 锚点(Anchor)间平滑跳转
function scroller(el, duration)
{
if(typeof el != 'object') { el = document.getElementById(el); }
if(!el) return;
var z = this;
z.el = el;
z.p = getPos(el);
z.s = getScroll();
z.clear = function(){window.clearInterval(z.timer);z.timer=null};
z.t=(new Date).getTime();
z.step = function(){
var t = (new Date).getTime();
var p = (t - z.t) / duration;
if (t >= duration + z.t) {
z.clear();
window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
} else {
st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
z.scroll(st, sl);
}
};
z.scroll = function (t, l){window.scrollTo(l, t)};
z.timer = window.setInterval(function(){z.step();},13);
}



//   -----------------------------------------------------------------------------------   
  //1本函数用于对sString字符串进行前空格截除   
  //   -----------------------------------------------------------------------------------   
  function   JHshLTrim(sString)   
  {     
  var   sStr,i,iStart,sResult   =   "";   
    
  sStr   =   sString.split("");   
  iStart   =   -1   ;   
  for   (i   =   0   ;   i   <   sStr.length   ;   i++)   
  {   
  if   (sStr[i]   !=   "   ")     
  {   
  iStart   =   i;   
  break;   
  }   
  }   
  if   (iStart   ==   -1)   {   return   ""   ;}         //表示sString中的所有字符均是空格,则返回空串   
  else   {   return   sString.substring(iStart)   ;}   
  }   
      
    
  //   -----------------------------------------------------------------------------------   
  //2   本函数用于对sString字符串进行后空格截除   
  //   -----------------------------------------------------------------------------------   
  function   JHshRTrim(sString)   
  {     
  var   sStr,i,sResult   =   "",sTemp   =   ""   ;   
    
  //   if   (sString.length   ==   0)   {   return   ""   ;}   //   参数sString是空串   
    
  sStr   =   sString.split("");   
  for   (i   =   sStr.length   -   1   ;   i   >=   0   ;   i   --)     //   将字符串进行倒序   
  {     
  sResult   =   sResult   +   sStr[i];     
  }   
  sTemp   =   JHshLTrim(sResult)   ;   //   进行字符串前空格截除   
    
  if   (sTemp   ==   "")   {   return   ""   ;   }   
    
  sStr   =   sTemp.split("");   
  sResult   =   ""   ;   
  for   (i   =   sStr.length   -   1   ;   i   >=   0   ;   i--)   //   将经处理后的字符串再进行倒序   
  {   
  sResult   =   sResult   +   sStr[i];   
  }   
  return   sResult   ;   
  }     
  //   -----------------------------------------------------------------------------------   
  //3本函数用于对sString字符串进行前后空格截除   
  //     
  function   JHshTrim(sString)   
  {   
  var   strTmp   ;   
    
  strTmp   =   JHshRTrim(JHshLTrim(sString))   ;   
    
  return   strTmp   ;   
  }
  
  
  function isalbum(s)
{
     var r,re;
     re = "^http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?s$";
     r = s.match(re);
     return (r == s) ? true : false;
}

// Copyright: hc360.com
// Author: Dakular
// Useage: HCmarquee(滚动对象id, 可见范围宽度, 可见范围高度, 滚动条数, 可见条数, 滚动速度, 停留时间, 方向); 方向有left和up两种
function HCmarquee(id,mw,mh,mr,sr,ms,pause){
	
	var obj=document.getElementById(id);
	obj.ss=false; //stop tag
	obj.mr=mr; //marquee rows
	obj.sr=sr; //marquee display rows
	obj.mw=mw; //marquee width
	obj.mh=mh; //marquee height
	obj.ms=ms; //marquee speed
	obj.pause=pause; //pause time
	obj.pt=0; //pre top
	obj.st=0; //stop time
	obj.mul=1;
	obj.con="";
	with(obj){
		style.width=mw+"px";
		style.height=mh+"px";
		noWrap=false;
		onmouseover=stopm;
		onmouseout=startm;
		scrollTop=0+"px";
		scrollLeft=0+"px";
	}

	if(obj.mr!=1){
				obj.tt=mh*mr/sr;
				obj.ct=mh; //current top
				obj.innerHTML+=obj.innerHTML;
				setInterval(scrollUp,obj.ms);
	}
	function scrollUp(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mh+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==(obj.pause*obj.mul)){
				obj.ct=0; obj.st=0;
				if(obj.mul==1) obj.mul = 1;
				else obj.mul = 1;
			}
		}else {
			obj.pt=(++obj.scrollTop);
			if(obj.pt==obj.tt){obj.scrollTop=0;}
		}
	}

	function stopm(){obj.ss=true;}
	function startm(){obj.ss=false;}
	
}