﻿//新窗口打开
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;

//支持firefox的加入收藏
function addfav(favName,favUrl)
{
   if (document.all)
   {
      window.external.addFavorite(favUrl,favName);
   }
   else if (window.sidebar)
   {
      window.sidebar.addPanel(favName, favUrl, "");
   }
} 


//检验电子邮件是否有效
function check_mail(myint)
{
  var checkOK = "@";
  var checkStr = myint;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
if(checkStr.length == 0) return(false);
if(checkStr.charAt(0)=='@') return(false);
if(checkStr.charAt(checkStr.length-1)=='@')
return(false);
if(checkStr.charAt(checkStr.length-1)=='.')
return(false);
a_valid=0; a_count=0;
d_valid=0;
 for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    if (ch == '@')   {a_valid=1; a_count++;  }
    if (ch == '.')   {d_valid=1;  }
  }
   if(a_count>1) return(false);
   if(a_valid==1 && d_valid==1) return(true); else return(false);
}

//转化为小写
function strLow(inputString)
{
  return inputString.toLowerCase();
}

//判断sV是否由sR组成
function fIsNumber (sV,sR){
var sTmp;
if(sV.length==0){ return (false);}
for (var i=0; i < sV.length; i++){
sTmp= sV.substring (i, i+1);
if (sR.indexOf (sTmp, 0)==-1) {return (false);}
}
return (true);
}

//text文本转化为html显示
function txt2html(strtxt){
	strtxt2 = strtxt;
	strtxt2=strtxt2.replace('\n','<br>');
	strtxt2=strtxt2.replace('&','&amp;');
	strtxt2=strtxt2.replace('<','&lt;');
	strtxt2=strtxt2.replace('>','&gt;');
	strtxt2=strtxt2.replace(' ','&nbsp;');
}

//下一页
function GoToPage(pid){													
document.location='?ipage=' + pid  
}

//控制图片长宽srcobj:ID  
function DrawImage(srcobj,maxWidth,maxHeight)
{
    var OImg=new Image();
    OImg.src=srcobj.src;
    var scale=OImg.width>OImg.height?(OImg.width>maxWidth?OImg.width/maxWidth:1):(OImg.height>maxHeight?OImg.height/maxHeight:1);
    srcobj.width=OImg.width/scale;
    srcobj.Height=OImg.height/scale;     
}
function loadjscssfile(filename, filetype, charset, title, callbackfunction){ 
	if (filetype=="js"){ //js
	  var fileref=document.createElement('script')
	  fileref.setAttribute("type","text/javascript")
	  fileref.setAttribute("src", filename)
	  if(charset) fileref.setAttribute("charset", charset)
	  if(title) fileref.setAttribute("title", title)  
	} 
	else if (filetype=="css"){ //css 
	  var fileref=document.createElement("link") 
	  fileref.setAttribute("rel", "stylesheet") 
	  fileref.setAttribute("type", "text/css")  
	  if(charset) fileref.setAttribute("charset", charset)
	  if(title) fileref.setAttribute("title", title) 
	} 
	if (typeof fileref!="undefined") 
	  document.getElementsByTagName("head")[0].appendChild(fileref) 
	if(document.all&&filetype=="js"){ 
		fileref.onreadystatechange=function(){     
			if(/(complete|loaded)/.test(fileref.readyState)){ 
				//alert(typeof(callbackfunction)=="function");
				if(typeof(callbackfunction)=="function")callbackfunction(); 
			}     
		} 
	}else{ 
		fileref.onload=function(){  
		if(typeof(callbackfunction)=="function")callbackfunction(); 
		} 
	} 
}  
var ___filesadded="" 
function loadjscss(filename, filetype, charset, title, callbackfunction){ 
if (___filesadded.indexOf("["+filename+"]")==-1){
  loadjscssfile(filename, filetype, charset, title, callbackfunction) 
  ___filesadded+="["+filename+"]"
} 
} 

//JS  输出Flash
function flash(ur,w,h){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"> ');
  document.write('<param name="movie" value="' + ur + '">');
  document.write('<param name="quality" value="high"> ');
  document.write('<param name="wmode" value="transparent"> ');
  document.write('<param name="menu" value="false"> ');
  document.write('<embed src="' + ur + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="'+w+'" height="'+h+'"></embed> ');
  document.write('</object> ');
} 
