global_tt=1;
//document.oncontextmenu=function (){return false;};
DisableViewSource=true;

function setHome(obj,aa){//设为首页
	obj.style.behavior='url(#default#homepage)';
	if(!aa) aa=document.URL;
	obj.setHomePage(aa);
}
function copy(aa){//复制当前页URL
	if(!aa) aa=document.URL; 
	window.clipboardData.setData('text',aa);
}
function AddFavorite(text,url){//添加到收藏夹
	if(!text) text = document.title;
	if(!url) url = document.location.href;
	if ( window.sidebar && "object" == typeof( window.sidebar ) && "function" == typeof( window.sidebar.addPanel) )
		window.sidebar.addPanel(text, url, "");
	else if ( document.all && "object" == typeof( window.external ) ){
		window.external.addFavorite(url,text);
	}
}
function check_email(email){
	var result=1;
	var pos1=email.indexOf("@");
	var pos2=email.lastIndexOf(".");
	if(pos1==-1 || pos2==-1 || pos1==0 || pos2==0 || pos2<=pos1+1 || pos2==email.length-1 || pos1==email.length-1){
		result=-1;
	} 
	return result;
}
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function getSubcode(code1){
var result="";
var code=String(code1);
if(code.length==1) {result="00" + code;}
else if(code.length==2) {result="0" + code;}
else {result=code;}
return result;
}

function compareDate(start,end){
pos1=start.indexOf("-");
pos2=start.lastIndexOf("-");
year1=eval(start.substring(0,pos1));
month1=eval(start.substring(pos1+1,pos2));
day1=eval(start.substring(pos2+1,start.length));

pos1=end.indexOf("-");
pos2=end.lastIndexOf("-");
year2=eval(end.substring(0,pos1));
month2=eval(end.substring(pos1+1,pos2));
day2=eval(end.substring(pos2+1,end.length));

if(year1>year2) {return false;}
else if(month1>month2 && year1==year2 && month1.length==month2.length) {return false;}
else if(month1.length>month2.length && year1==year2) {return false;}
else if(day1>day2 && month1==month2 && year1==year2 && day1.length==day2.length) {return false;}
else if(day1.length>day2.length && month1==month2 && year1==year2) {return false;}
else {return true;}
}

function isNumerical(num){
var float_expression = /^-?\d+(\.\d+)?$/g;
if(num.match(float_expression)){
	return true;
}
else {
	return false;
}
}
function isInteger(num){
var positiveInteger_expression = /^\d+$/g;	
if(num.match(positiveInteger_expression) ){
	return true;
}
else {
	return false;
}
}
function CheckInteger(num){
if(num==""){
return false;
}	
else {
	leap=true;
	s=num.substring(0,1);
	if(s=="-") {num=num.substring(1,num.length);}
	
	return isInteger(s);
}
}

function IsDate(DateString , Dilimeter) 
{ 
  if (DateString==null) return false; 
  if (Dilimeter=='' || Dilimeter==null) Dilimeter = '-'; 
  var tempy=''; 
  var tempm=''; 
  var tempd=''; 
  var tempArray; 
  if (DateString.length<8 && DateString.length>10) return false;    
  tempArray = DateString.split(Dilimeter); 
  if (tempArray.length!=3) return false; 
  if(isInteger(tempArray[0])==false || isInteger(tempArray[1])==false || isInteger(tempArray[2])==false) return false;
  tempy = eval(tempArray[0]); 
  tempm = eval(tempArray[1]);
  tempd = eval(tempArray[2]); 

  
  if(String(tempArray[0]).length<4 || String(tempArray[0]).length>4 ) return false;  
  var tDateString = tempy + '/'+tempm + '/'+tempd+' 8:0:0';//加八小时是因为我们处于东八区 
  var tempDate = new Date(tDateString); 
 
 if (isNaN(tempDate)) return false;
 
 if (((tempDate.getUTCFullYear()).toString()==tempy) && (tempDate.getMonth()==parseInt(tempm)-1) && (tempDate.getDate()==parseInt(tempd))) 
  { 
   return true; 
  } 
  else 
  { 
   return false; 
  } 
} 

function ShowFloat(num,len){
	if(num.indexOf('.')!=-1){
		var pos=num.indexOf('.');
		var first=num.substring(0,pos);
		var end=num.substring(pos+1,num.length);
		if(end.length>len){
			var top_num=end.substring(0,len);
			var end_num=end.substring(len,len+1);
			//alert(end_num);
			if(eval(end_num)>=5){top_num=(eval(top_num)+1).toString();}
			num=first+"." + top_num;
		}
	}
	return num;
}

function mod(x,y){
	for(var i=x;i>=y;i-=y);
	return i;
}

function change_div(type){
	if(type==1){
		var row=top.document.getElementById("progress_bar");
		if(row) {
			row.style.top=(window.top.document.body.clientHeight-parseInt(row.offsetHeight))/2+window.top.document.body.scrollTop;
			row.style.display="block";
			//setTimeout('change_div(-1)',5000);
		}
	}
	else {
		var row=top.document.getElementById("progress_bar");
		if(row) row.style.display="none";
	}
}
function replaceAll(strChk, strFind, strReplace) {
  var strOut = strChk;
  while (strOut.indexOf(strFind) > -1) {
    strOut = strOut.replace(strFind, strReplace);
  }
  return strOut;
}

String.prototype.ReplaceAll = stringReplaceAll; 
function  stringReplaceAll(AFindText,ARepText){
  raRegExp = new RegExp(AFindText,"g");
  return this.replace(raRegExp,ARepText)
}
function copy_link(src){
    window.clipboardData.setData('text',src);
}
function isLegal(s,name){
	if(s){
		var illegal=["'",'"','\\'];
		var sign=-1;
		for(var i=0;i<illegal.length && sign==-1;i++){
			if(s.indexOf(illegal[i])!=-1){
				sign=1;
				alert(name+"不能包含非法字符  "+illegal[i]+"  ！");
			}
		}
		if(sign==1){
			return false;
		}else {
			return true;
		}
	}
}
function textarea(obj,maxlength){
	if(obj.value.length>maxlength){
		obj.value=obj.value.substring(0,maxlength);
	}
}


function open_blog(seq){
	window.open("/user/" + seq,"","top=0,left=0,toolbar=yes,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+(screen.availwidth)+",height="+(screen.availheight-20));
}
function checkImgFile(obj){
   if(obj!=""){
	   var pos=obj.lastIndexOf(".");
	   var valid_sign=1;
	   if(pos!=-1){
	  		var s=obj.substring(pos+1,obj.length);
	  		
		 		if(s.toLowerCase()!="gif"&&s.toLowerCase()!="jpg"&&s.toLowerCase()!="jpeg"&&s.toLowerCase()!="bmp"&&s.toLowerCase()!="png"){
					valid_sign=-1;
				}	
		}
		else {
			valid_sign=-1;
		}
		if(valid_sign==-1){
			
			return false;
		}
		else {return true;}
	}
	return true;
}
function checkFlashFile(obj){
   if(obj!=""){
	   var pos=obj.lastIndexOf(".");
	   var valid_sign=1;
	   if(pos!=-1){
	  		var s=obj.substring(pos+1,obj.length);
		 		
		 		if(s.toLowerCase()!="swf"){
					valid_sign=-1;
				}	
		}
		else {
			valid_sign=-1;
		}
		if(valid_sign==-1){
			
			return false;
		}
		else {return true;}
	}

}
function enterprise_button_mousemove(obj){
	if(obj.className.indexOf("focus")!=-1){
		obj.className=obj.className.substring(0,obj.className.indexOf("focus")-1);
	}else{
		obj.className+="-focus";
	}
}
//验证邮箱
function isEmail(strEmail) { 
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) 
		return true; 
	else 
		return false;
}

//计算锁定图片纵横比后的图片的宽和高
function change_img_size(now_width,now_height,obj_id){
	now_width=parseInt(now_width);
	now_height=parseInt(now_height);
	var obj=document.getElementById(obj_id);
	if(obj){
		obj.style.visibility = "visible";
		var img_width=obj.offsetWidth; 
		var img_height=obj.offsetHeight;
	 if(img_width <now_width && img_height <now_height) 
	  { 
	      //如果比预定义的宽高小，原图显示。 
	      obj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = "image"; 
	      return;         
	  } 
	  else 
	  { 
	      //如果大的化，要把 sizingMethod改成scale 如果属性是image,不管怎么改div的宽高，都不起作用 
	      obj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = "scale"; 
	  } 
		
		var scale1=now_width/img_width;
		var scale2=now_height/img_height;
		var scale=scale1;
		if(scale2<scale1) scale=scale2;
		if(scale>1) scale=1;
		obj.style.width=img_width*scale;
		obj.style.height=img_height*scale;
	}
}
