 String.prototype.Trim=function(){ return  this.replace(/(^\s+)|(\s+$)/g,"");}
 String.prototype.Ltrim = function(){ return  this.replace(/(^\s+)/g,   "");}
 String.prototype.Rtrim = function() { return this.replace(/(\s+$)/g, "");}
//================= AJAX 提交表单 ====================
var http_request = true;
	function send_request(url,Temp,ref , tb) 
	 {//初始化、指定处理函数、发送请求的函数
		http_request = false;
		
		//document.domain = "yxdown.com";
		//开始初始化XMLHttpRequest对象
		if(window.XMLHttpRequest) { //Mozilla 浏览器
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {//设置MiME类别
				http_request.overrideMimeType('text/xml');
			}
		}
		else if (window.ActiveXObject) { // IE浏览器
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) { // 异常，创建对象实例失败
			window.alert("不能创建XMLHttpRequest对象实例.");
			return false;
		}
		http_request.onreadystatechange = ref; 
		
		// 确定发送请求的方式和URL以及是否同步执行下段代码
		http_request.open("Post", url, tb);
		http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http_request.send(Temp);
	}
	
	// 处理返回信息的函数
    function processRequest() {
        if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息
                alert(http_request.responseText);
            } else { //页面不正常
                // alert("您所请求的页面有异常。");
            }
        }
    }

//=================投票=====================
var isVote=false;  //是否已经投过票了
//投票BEGIN
function sEval(softid,num,din,cai,Tpye)
{
	if(isVote)
	{
		//alert('您已经投过票了,请不要重复投票,感谢您的支持!!')
		//return
	}
	var Temp="Action=0&softid="+ escape(softid) + "&num=" +escape(num)+"&type="+ Tpye; //发送的数据
	
	var RequestFunction=function() {  //返回处理函数
		if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息
					ReadMark(softid,din,cai,Tpye);
				 
				  alert('投票成功!!');
            } else { //页面不正常
			      
                // alert("您所请求的页面有异常。");
            }
        }
	 };
	send_request("../ajax.asp",Temp,RequestFunction,false);
	isVote = true;
	//alert(Temp);
}
//投票End
//读取投票数据 Begin
function ReadMark(softid,din,cai,Tpye)
{	
	var Temp="Action=1&softid="+ escape(softid)+"&type="+ Tpye; //发送的数据
	 
	var AbetNum=document.getElementById(din).getElementsByTagName("div")[0].getElementsByTagName("span")[0];
	
	var ArgueNum=document.getElementById(cai).getElementsByTagName("div")[0].getElementsByTagName("span")[0];
	
	var RequestFunction=function() {  //返回处理函数
		if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息
				var TempText=http_request.responseText;
 
				var	 TempText_1=TempText.split("|")[0];
				var  TempText_2=TempText.split("|")[1];
					
				var TempText_3= parseInt(TempText_1) + parseInt(TempText_2);
				if (TempText_3 == 0)
				{
					var a =50;
					var b=50;
				}else
				{
				var a =parseInt(parseInt(TempText_1) /TempText_3*100)
				var b= (100 - parseInt(parseInt(TempText_1) /TempText_3*100))
				}
    
				    AbetNum.innerHTML = TempText_1 ;
				    ArgueNum.innerHTML =  TempText_2 ;

				    document.getElementById("decimal_unm").innerHTML= a/10;										
					
					if(a>=90){document.getElementById("asymarkimg1").src="/skin2012/images/star/10.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>85){document.getElementById("asymarkimg1").src="/skin2012/images/star/9.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>=80){document.getElementById("asymarkimg1").src="/skin2012/images/star/8.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>65){document.getElementById("asymarkimg1").src="/skin2012/images/star/7.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>=60){document.getElementById("asymarkimg1").src="/skin2012/images/star/6.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>45){document.getElementById("asymarkimg1").src="/skin2012/images/star/5.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>=40){document.getElementById("asymarkimg1").src="/skin2012/images/star/4.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>25){document.getElementById("asymarkimg1").src="/skin2012/images/star/3.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else if(a>=5){document.getElementById("asymarkimg1").src="/skin2012/images/star/2.gif";document.getElementById("asymarkimg1").alt=a+"%";}
					else {document.getElementById("asymarkimg1").src="/skin2012/images/star/1.gif";document.getElementById("asymarkimg1").alt=a+"%";}
                
            } else { //页面不正常
                // alert("您所请求的页面有异常");
            }
        }
	 };
     
	 send_request("../ajax.asp",Temp,RequestFunction,false);
	//AbetNum.innerText="5645";	
}


//==========投票方案 Begin=================
function ngsEval(id,goodid,badid,verid,type)
{
	var objgood = $(goodid);
	var objbad = $(badid);
 
	objgood.css({cursor:"pointer"});
	
	 ngSendEval(id,goodid,badid,verid,0,type);
	 
	objgood.click(function (){ ngSendEval(id,goodid,badid,verid,1,type) ; isVote=true; });
	objbad.click(function (){ ngSendEval(id,goodid,badid,verid,2,type); isVote=true; });
}

function ngSendEval(id,goodid,badid,verid,num,type)
{
   if(isVote && num>0)
	{
		 alert('您已经投过票了,请不要重复投票,感谢您的支持!!')
		 return true;
	}
	
 var url="action=3&id="+id+"&num="+num+"&type="+type;
  $.ajax({
   type: "POST",
   url: "/ajax.asp",
   data: url,
   success: function(msg){
      ListEval(goodid,badid,verid,msg);
   }
});
}

function ListEval(goodid,badid,verid,msg){
	var objgoodimg = $(goodid + " img");
	var objgoodem = $(goodid + " em");

	var objgoodb = $(goodid + " b");
 
	
	var objbadimg = $(badid + " img");
	var objbadem = $(badid + " em");

	var objbadb = $(badid + " b");
	
	
	var objver = $(verid);
	
	var dataObj=eval("("+msg+")");//转换为json对象
	
	
	objgoodimg.eq(0).animate({width: "1%"},200);
	objgoodimg.eq(0).animate({width: +dataObj.Percentage[0]+ "%"},"slow");
	
	objbadimg.eq(0).animate({width: "1%"},200);
	objbadimg.eq(0).animate({width: +dataObj.Percentage[1]+ "%"},"slow");
	
	objgoodem.eq(0).html(dataObj.Percentage[0]+ "%" + "("+ dataObj.Num[0] +")");
	objbadem.eq(0).html(dataObj.Percentage[1]+ "%"+ "("+ dataObj.Num[1] +")");
	
	objgoodb.eq(0).html(dataObj.Num[0] );
	objbadb.eq(0).html(dataObj.Num[1] );
	
	objver.html(dataObj.Very[0])	
	 
	
}
//==========投票方案 End=================

//支持效果 lj
//评论页读取顶
function BindDing(objtext,id,CommentTpye)
{
    var obj=$(objtext)
    //var sobj = obj..$("a")
    
    if (obj.length==0) return false;
      //alert(obj.length) 
     for (var i=0 ;i<obj.length;i++)
     {
      var sobj = obj.eq(i).find("a").first();
      //alert(sobj.length)  

      sobj.click(function (){ 
                           SendDing($(this).parent().attr("id"));
                           
                           var  spanobj = $(this).parent().find("span")
                           spanobj.html(parseInt(spanobj.html())+1);
						   spanobj.css({"color":"#999"});
						   
						   var emobj = $(this).parent().find("em");
						   emobj.css({"color":"#999"});
						   
                            $(this).unbind();                            
                            $(this).attr("title","您已经顶过了").css({"cursor":"default","color":"#999"});														
							                            
                           })
     }
    ReadDing(objtext,id,CommentTpye)    
}

function SendDing(id)//发送顶
{
    //alert(id)
    var url="action=19&id="+id
   $.ajax({
   type: "POST",
   url: "/ajax.asp",
   data: url,
   success: function(msg){
     // alert(msg)  ;
   }
});
}

function ReadDing(objtext,id,CommentTpye)
{
    var obj=$(objtext)
    var sendid=""
    for (var i=0 ;i<obj.length;i++)
    {
        sendid+=obj.eq(i).attr("id");
        if (i<(obj.length-1)) sendid+=",";
    }
  var url="action=18&id="+id+"&CommentTpye="+CommentTpye+"&sendid="+escape(sendid)+""
 //alert(url)
  $.ajax({
   type: "POST",
   url: "/ajax.asp",
   data: url,
   success: function(msg){
      ListDing(objtext,msg);
   }
}); 
}

function ListDing(objtext,msg) //显示顶的数据
{
    //alert(msg)
    var obj=$(objtext)
    var dataObj=eval("("+msg+")");//转换为json对象
     for (var i=0 ;i<obj.length;i++)
     { 
       var spanobj = obj.eq(i).find("span")
       var sid = obj.eq(i).attr("id");
       for (var y=0;y < dataObj.ID.length;y++)
       {
           if (sid == dataObj.ID[y])
           {
             spanobj.html(dataObj.Ding[y]);
             break;
           }
       }
    }   
}

//发送报错信息
function senderror(id,obj)
{
	var Content= document.getElementById(obj);
	var CommentTpyeId = 3
	
	if (Content.value.Trim().length<1) 
	{
		alert("请提供报错信息谢谢!!")
		return false;
	}
	
	var Url="content=" + escape(Content.value) + "&SoftID=" +  escape(id) + "&Action=2&CommentTpye="+CommentTpyeId;
	
	  var ref=function()//处理返回数据
	 	{
		  if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息
				var requestText=http_request.responseText;
                 if(requestText=="OK") 
				 {
					alert("你的报错信息已经提交感谢您的支持。");
					Content.value="";
					
				 }else
				 {//alert(requestText);
				   alert("你的报错信息已经提交感谢您的支持。");
				 }
            } else { //页面不正常
                 alert("写数据出错了！！"); 
            }
        }
	}
   
      send_request("/ajax.asp",Url,ref,true);
	  
	 //alert(Url)
	
	return true;
	
}
/*分享按钮*/
var sharev = ['0','0','0'];

function bbsCode(softid){		
bbsAjax(1,softid);
bbsAjax(2,softid);

}

function bbsAjax(x,softid){
	
		if(sharev[x]=="0"){
			$.ajax({
				   type: "POST",
				   url: "/ajax.asp",
				   data: "action=10&id="+softid+"&x="+x,
				   success:function(msg){
					   sharev[x] = msg;
					   $("#shid_"+x).text(msg);
					   
					   },
				   error:function (XMLHttpRequest, textStatus, errorThrown) { /*alert(textStatus)*/}
				   });
			
		}	
	
}

function copyText(theField,type)
{
	
 var clipBoardContent;

 if(type == 'id'){
	
	var copyObj=document.getElementById(theField);
	clipBoardContent = copyObj.innerHTML;
	//copyObj.select();

  } else if(type == 'text') {
	  
	  clipBoardContent = theField;
}

  if(clipBoardContent){	  
	  window.clipboardData.setData("Text",clipBoardContent); 
	  alert("相关信息已复制到剪贴板");
	  }

}

function copytofriend(){
	
	var txt = '名称：' + document.getElementById('softtitle').innerHTML;
	txt += '\n'
	txt += '地址：'  + window.location;
	
	copyText(txt,'text');
	
}

function inputDefault(obj){
	  var $obj = $(obj);
	  var defaultVal = $obj.val();
	  $obj.focus(function(){
			 var iptval = $(this).val();
			 if(!this.defaultValue){
				  this.defaultValue = defaultVal;
			 };
			 if(iptval==this.defaultValue){
				  $(this).val("");
			 }
	  });
	  $obj.blur(function(){
			 var iptval = $(this).val();
			 if(iptval==""){
				  $(this).val(this.defaultValue);
				  $(this).addClass("grey9");
			 }
	  });
};

//tags
function colorTags(id){	
	var BLACK = 1- 0.618, //黑色的比例, 取值0-1
		COLOR = '#f00,#090,#00f,#f60,#09f,#f0f',
		FONTSIZE = ['16px','14px','12px'],
		cp = [],
		colors = [],
		current = '',
		tags = document.getElementById(id).getElementsByTagName('a'),
		length = tags.length,
		black_count = 0,
		black_total = Math.ceil(BLACK*(length - 1));
	//按比例生成数组
	for(var i = 0 ; i < length; i++){
		cp[i] =  i > black_total ? 	'color' :  'black';
	}	
	//乱序
	cp.sort(function(a,b){
		return Math.random()>.5 ? -1 : 1;				  
	});
	for(var i = 0 ; i < length; i++){
		if( cp[i] == 'color'){
			colors  = COLOR.replace( new RegExp(current + ',?'),'').split(',');
			current = colors[ Math.floor(Math.random()*(colors.length-1))];
			tags[i].style.color = current;
		} else {
			current = '#333';	
		}
			tags[i].style.fontSize =  FONTSIZE[ Math.floor( Math.random()*3 ) ];
	}		
	id == "tags_list_left_bot" && splitTags(id,20)	
}
function splitTags(id,num){	
	var wrap = document.getElementById(id),
		tags = wrap .getElementsByTagName('a'),
		br = document.createElement('div');	
	br.className = 'tag_br';
	for(var i = 1; i< tags.length; i++){
		if(i % num == 0){
				wrap.insertBefore(br.cloneNode(false),tags[i]);
		}  
	}	
}

$(function(){
  $('.summary .sum li:last').css({"border-bottom":"none"});
  //mTab
  $('.mTab li').eq(0).click(function(){
	$(this).addClass('cur');
	$(this).siblings().removeClass('cur');
	$('#introWrap').show();
	$('#addressWrap').show();
	$('#commentWrap').show();
  });
  $('.mTab li').eq(1).click(function(){
	$(this).addClass('cur');
	$(this).siblings().removeClass('cur');
	$('#introWrap').hide();
	$('#addressWrap').show();
	$('#commentWrap').show();
  });
  $('.mTab li').eq(2).click(function(){
	$(this).addClass('cur');
	$(this).siblings().removeClass('cur');
	$('#introWrap').hide();
	$('#addressWrap').hide();
	$('#commentWrap').show();
  });
  $('.mTab li').eq(3).click(function(){
	$(this).addClass('cur');
	$(this).siblings().removeClass('cur');
	$('#introWrap').hide();
	$('#addressWrap').hide();
	$('#commentWrap').hide();
  });
  
  colorTags('hottags');
  
  inputDefault("#cmtMsg");
  inputDefault("#userName");
  $("#cmtMsg").click(function(){                
     if($("#cmtMsg").val() == 0 || $("#cmtMsg").val() == "..."){
        $("#cmtMsg").focus();$("#cmtMsg").removeClass("grey9");
        return false;}
  }); 

//ad
//下载头部信息下的通栏广告
var dAdtl1=document.getElementById("dAdtl1");    
 if (dAdtl1!=null)
 {
	//dAdtl1.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#FAFEFF' scrolling=no src='/skin2012/js/html/dAdtl1.html' width=990 height=90></iframe>"
	//$(dAdtl1).css({"margin-top":"10px"});
 }
//下载头部信息同类人气下文字广告
var txtAd1=document.getElementById("txtAd1");    
 if (txtAd1!=null)
 {
	//txtAd1.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/txtAd1.html' width=280 height=30></iframe>"
 }
//下载头部信息右侧广告300*300
var dAdtopLeft=document.getElementById("dAdtopLeft");    
 if (dAdtopLeft!=null)
 {
	//dAdtopLeft.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdtopLeft.html' width=300 height=300></iframe>"
	//$(dAdtopLeft).css({"position":"absolute","left":"680px","top":"9px"});
 }
//下载地址上部广告  
var dAdleft1=document.getElementById("dAdleft1");    
 if (dAdleft1!=null)
 {
	//dAdleft1.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdleft1.html' width=662 height=60></iframe>"
	//$(dAdleft1).css({"margin-top":"10px"});
 }
//下载地址右侧广告  
var dAdleftBlock=document.getElementById("dAdleftBlock");    
 if (dAdleftBlock!=null)
 {
	//dAdleftBlock.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdleftBlock.html' width=325 height=80></iframe>"
	//$(dAdleftBlock).css({"float":"left","display":"inline","margin-left":"12px"});
 }
//相关下载上部广告  
var dAdleft2=document.getElementById("dAdleft2");    
 if (dAdleft2!=null)
 {
	//dAdleft2.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdleft2.html' width=662 height=90></iframe>"
	//$(dAdleft2).css({"margin-top":"10px"});
 }
//评论上部广告  
var dAdleft3=document.getElementById("dAdleft3");    
 if (dAdleft3!=null)
 {
	//dAdleft3.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdleft3.html' width=662 height=90></iframe>"
	//$(dAdleft3).css({"margin-top":"10px"});
 }
//猜你喜欢上部广告  
var dAdleft4=document.getElementById("dAdleft4");
 if (dAdleft4!=null)
 {
	//dAdleft4.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#ffffff' scrolling=no src='/skin2012/js/html/dAdleft4.html' width=662 height=90></iframe>"
	//$(dAdleft4).css({"margin-top":"10px"});
 }
//右侧标签下部广告  
var dAdright1=document.getElementById("dAdright1");
 if (dAdright1!=null)
 {
	//dAdright1.innerHTML="<iframe marginwidth=0 marginheight=0 frameborder=0 bordercolor='#FAFEFF' scrolling=no src='/skin2012/js/html/dAdright1.html' width=280 height=300></iframe>"
	//$(dAdright1).css({"margin-top":"10px"});
 }
});       
