﻿function UrlEncode(str){ 
  var ret=""; 
  var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%"; 
  var tt= "";

  for(var i=0;i<str.length;i++){ 
   var chr = str.charAt(i); 
    var c=str2asc(chr); 
    tt += chr+":"+c+"n"; 
    if(parseInt("0x"+c) > 0x7f){ 
      ret+="%"+c.slice(0,2)+"%"+c.slice(-2); 
    }else{ 
      if(chr==" ") 
        ret+="+"; 
      else if(strSpecial.indexOf(chr)!=-1) 
        ret+="%"+c.toString(16); 
      else 
        ret+=chr; 
    } 
  } 
  return ret; 
} 

function UrlDecode(str){ 
  var ret=""; 
  for(var i=0;i<str.length;i++){ 
   var chr = str.charAt(i); 
    if(chr == "+"){ 
      ret+=" "; 
    }else if(chr=="%"){ 
     var asc = str.substring(i+1,i+3); 
     if(parseInt("0x"+asc)>0x7f){ 
      ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6))); 
      i+=5; 
     }else{ 
      ret+=asc2str(parseInt("0x"+asc)); 
      i+=2; 
     } 
    }else{ 
      ret+= chr; 
    } 
  } 
  return ret; 
} 

function copySend(){
	var _title=document.title;
	var _url=document.location.href;
	if( document.all ) {
		var _text=_title+' - '+ _url;
		clipboardData.setData('Text',_text);
		document.getElementById("copySendBtn").innerHTML="<span style='color:red'>请用 <strong>Ctrl+V</strong> 粘贴</span>";
}}



function G(id){return document.getElementById(id);}

function changeTab(tabUL, n, cntID){
var ul = G(tabUL);
var lis = ul.getElementsByTagName('li');
for(var i=0; i<lis.length; i++){
lis[i].className = lis[i].className.replace(/\s*focus/, '');
G(cntID + '_' + i).style.display = 'none';
}
lis[n].className = lis[n].className ? lis[n].className + ' focus' : 'focus';
G(cntID + '_' + n).style.display = '';
}


function loaded(myimg,mywidth,myheight){
var tmp_img = new Image();
tmp_img.src=myimg.src;
image_x=tmp_img.width;
image_y=tmp_img.height;
	if(image_x>mywidth){
	tmp_img.height=image_y * mywidth / image_x;
	tmp_img.width=mywidth;
		if(tmp_img.height>myheight){
			tmp_img.width=tmp_img.width * myheight / tmp_img.height;
			tmp_img.height=myheight;
			}
	}else if(image_y > myheight)
	{
	tmp_img.width=image_x * myheight / image_y;
	tmp_img.height=myheight;
		if(tmp_img.width>mywidth)
		{
			tmp_img.height=tmp_img.height * mywidth / tmp_img.width;
			tmp_img.width=mywidth;
			}
	}
	myimg.width=tmp_img.width;
	myimg.height=tmp_img.height;

}

function SwitchList(id)
{
	for (var i = 1; i <= 11;  i++ )
	{	
		G("index"+i).style.display='none';
		G("show"+i).className='show';
	}
	G("index"+id).style.display='block';
	G("show"+id).className='tab';	
}


//下载打分部分


jQuery.Assess = function(id,type)
{
	$.ajax({
		url: 'Assess.aspx?id='+id+'&type='+type,
		dataType:'text', 
		type:'get',
		error: function(text){ 
			alert('评论-获取远程file出错...'); 
		}, 	
		success: function(text){
			var str = text.split("|");
			var pj1 = parseInt(str[0]);
			var pj2 = parseInt(str[1]);
			$("#s1").html(pj1);
			$("#s2").html(pj2);
			var pj = pj1+pj2;
			var pp1 = parseInt((pj1/pj)*100);
			var pp2 = 100-pp1;
			
			$("#sp1").html(pp1+"%");
			$("#sp2").html(pp2+"%");
			
			var px1 = parseInt((pj1/pj)*55);
			var px2 = 55-px1;
			$("#eimg1").html("<div style=\"width:"+px1+"px\"></div>");
			$("#eimg2").html("<div style=\"width:"+px2+"px\"></div>");
		}
	});	
	
}
