<!--
var cookieset_mypc_history = { expires: 100, path: '/' }; //设置cookie路径的
//var domain_englishOK_url = "http://www.engok.com/";
var domain_englishOK_url = 'http://' + window.location.host + '/';

//加入到本机历史记录
var add_mypc_history = function(resource_id,action_id,resource_type,resource_name){
	try{
	if($.cookie("myPCHistory") == null){		
		var jsonStr = '[{"resource_id":' + resource_id 
			jsonStr += ',"action_id":' + action_id 
			jsonStr += ',"resource_type":' + resource_type 
			jsonStr += ',"resource_name":"' + resource_name
			jsonStr += '","view_datetime":"' + get_current_time() + '"}]'; //构造json字符串; 
		$.cookie("myPCHistory", jsonStr, cookieset_mypc_history); //如果没有这个cookie就设置他 
	}else{
		var jsonObj = eval('(' + $.cookie("myPCHistory") + ')'); //如果有，把json字符串转换成对象
        var i=0;
        for(var i=0; i < jsonObj.length; i++) {
        	if(jsonObj[i].resource_id == resource_id){
        		jsonObj.splice(i,1);
        		findResource = true;
        	}        
        }       

        if(jsonObj.length>=5){
        	//如果数量超过个，则删除最后一项
        	jsonObj.pop();
        }        
    
        var resource = {"resource_id":resource_id,"action_id":action_id,"resource_type":resource_type,"resource_name":resource_name,"view_datetime":get_current_time()}
        jsonObj.unshift(resource);//最前面加一条记录      
        
        //保存到Cookie中
        $.cookie("myPCHistory",JSON.stringify(jsonObj),cookieset_mypc_history);         
	}
	}catch(e){
	}
};

var add_music_mypc_history = function(resource_id,action_id,resource_type,resource_name){
	if($.cookie("myPCHistory_music") == null){		
		var jsonStr = "[{'resource_id':" + resource_id 
			jsonStr += ",'action_id':" + action_id 
			jsonStr += ",'resource_type':" + resource_type 
			jsonStr += ",'resource_name':'" + resource_name 
			jsonStr += "','view_datetime':'" + get_current_time() + "'}]"; //构造json字符串; 
		$.cookie("myPCHistory_music", jsonStr, cookieset_mypc_history); //如果没有这个cookie就设置他 
	}else{
		var jsonObj = eval('(' + $.cookie("myPCHistory_music") + ')'); //如果有，把json字符串转换成对象
        var i=0;
        for(var i=0; i < jsonObj.length; i++) {
        	if(jsonObj[i].resource_id == resource_id){
        		jsonObj.splice(i,1);
        		findResource = true;
        	}        
        }       

        if(jsonObj.length>=5){
        	//如果数量超过个，则删除最后一项
        	jsonObj.pop();
        }
        var resource = {'resource_id':resource_id,'action_id':action_id,'resource_type':resource_type,'resource_name':resource_name,'view_datetime':get_current_time()}
        jsonObj.unshift(resource);//最前面加一条记录      
        
        //保存到Cookie中
        $.cookie("myPCHistory_music",JSON.stringify(jsonObj),cookieset_mypc_history);         
	}
}

var add_article_mypc_history = function(resource_id,action_id,resource_type,resource_name){
	if($.cookie("myPCHistory_article") == null){		
		var jsonStr = "[{'resource_id':" + resource_id 
			jsonStr += ",'action_id':" + action_id 
			jsonStr += ",'resource_type':" + resource_type 
			jsonStr += ",'resource_name':'" + resource_name 
			jsonStr += "','view_datetime':'" + get_current_time() + "'}]"; //构造json字符串; 
		$.cookie("myPCHistory_article", jsonStr, cookieset_mypc_history); //如果没有这个cookie就设置他 
	}else{
		var jsonObj = eval('(' + $.cookie("myPCHistory_article") + ')'); //如果有，把json字符串转换成对象
        var i=0;
        for(var i=0; i < jsonObj.length; i++) {
        	if(jsonObj[i].resource_id == resource_id){
        		jsonObj.splice(i,1);
        		findResource = true;
        	}        
        }       

        if(jsonObj.length>=5){
        	//如果数量超过个，则删除最后一项
        	jsonObj.pop();
        }
        var resource = {'resource_id':resource_id,'action_id':action_id,'resource_type':resource_type,'resource_name':resource_name,'view_datetime':get_current_time()}
        jsonObj.unshift(resource);//最前面加一条记录      
        
        //保存到Cookie中
        $.cookie("myPCHistory_article",JSON.stringify(jsonObj),cookieset_mypc_history);         
	}
}

//显示本机历史记录
var display_mypc_history = function(resource_type){
	var jsonObj;
	var ulHistoryObj = $("#ulMyPCHistory");
	var txt = "";
	var cookie_name="myPCHistory";
	//从Cookie中取得记录，并转化为JSON对象．
	/*
	switch(resource_type){		
		case 10:
			cookie_name = "myPCHistory_music";
			break;
		case 30:
			cookie_name = "myPCHistory_article";
			break;
		default:
			cookie_name = "myPCHistory";
			break;
	}
	*/
	if($.cookie(cookie_name) != null){		
		jsonObj = eval('(' + $.cookie(cookie_name) + ')'); //如果有，把json字符串转换成对象
	}
	 
	if(jsonObj != null && jsonObj.length>0){
		var resource_name;
		var view_datetime;
		var url="";
		for(var i=0; i < jsonObj.length; i++) {
			url = "";
			switch(jsonObj[i].resource_type){
				case 10:
					url = "music/showMusicDetails-" + jsonObj[i].resource_id + ".html";
					break;
				case 11:
					url = "music/ksongDetail-" + jsonObj[i].resource_id + ".html";
					break;
				case 30:
					url = "article/showSayDetails-" + jsonObj[i].resource_id + ".html";
					break;
				case 31:
					url = "article/readAloudDetail-" + jsonObj[i].resource_id + ".html";
					break;
				default:
					break;
			}
			url = domain_englishOK_url + url;
			resource_name = decodeURI(jsonObj[i].resource_name);
			view_datetime = jsonObj[i].view_datetime;
			
			//<li><span class="myPcHistoryTitle"><a href="#">Yesterday once more once more...</a></span><span class="myPcHistoryTime">3分钟前</span></li>
	      	txt += "<li><span class='myPcHistoryTitle'><a target='_blank' title='"+resource_name+"' href='"+url+"'>"
	      	if(ULength(resource_name)>22){
	      		txt	+= get_fix_ustring(resource_name,20);
	      		txt += "…";
	      	}else{
	      		txt	+= resource_name;
	      	}
	      	txt += "</a></span><span class='myPcHistoryTime'>"+get_display_time(view_datetime)+"</span></li>"
	    }
    }else{
    	//暂时没有任何足迹记录
    	txt = "<span style='font-size:13px;color:#999999'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;暂时没有任何足迹记录。</span>"
    	
    }    
    ulHistoryObj.html(txt);
}

//清除本机历史记录
var clear_mypc_history = function(resource_type){
	var cookie_name = "myPCHistory";
	/*
	switch(resource_type){		
		case 10:
			cookie_name = "myPCHistory_music";
			break;
		case 30:
			cookie_name = "myPCHistory_article";
			break;
		default:
			cookie_name = "myPCHistory";
			break;
	}
	*/

	$.cookie(cookie_name,null,cookieset_mypc_history);
}

//获取当前时间
var get_current_time = function(){
	var intYear,intMonth,intDay,intHours,intMinutes,intSeconds;
	var today;
	var txt = "";
	today=new Date();
	intYear=today.getFullYear();
	intMonth=today.getMonth()+1;
	intDay=today.getDate();
	intHours=today.getHours();
	intMinutes=today.getMinutes();
	intSeconds=today.getSeconds();
	txt = intYear + '/' + intMonth + '/' + intDay + ' ' + intHours + ':' + intMinutes + ':' + intSeconds;
	return txt;
}

var get_display_time = function(time){	
	var today=new Date();
	var old_day = new Date(time);
	var n=(today.getTime()-old_day.getTime())/1000;
	if(n<0) n=0;
	var txt="";
	if(n<60){
		txt += "1分钟内";
	}else if(n<(60*60)){
		txt += parseInt(n/60)  + "分钟前";
	}else if(n<(60*60*24)){
		txt += parseInt(n/60/60) + "小时前";
	}else if(n<(60*60*24*30)){
		txt += parseInt(n/60/60/24) + "天以前";
	}else if(n<(60*60*24*30*365)){
		txt += parseInt(n/60/60/24/30) + "个月前";
	}else{
		txt += parseInt(n/60/60/24/30/365) + "年以前";
	}

	return txt;	
}

//以下为cookie插件代码
jQuery.cookie = function(name, value, options) { 
    if (typeof value != 'undefined') { // name and value given, set cookie 
        options = options || {}; 
        if (value === null) { 
            value = ''; 
            options.expires = -1;
        } 
        
        var expires = ''; 
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 
            var date; 
            if (typeof options.expires == 'number') { 
                date = new Date(); 
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); 
            } else { 
                date = options.expires; 
            } 
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE 
        } 
        var path = options.path ? '; path=' + options.path : ''; 
        var domain = options.domain ? '; domain=' + options.domain : ''; 
        var secure = options.secure ? '; secure' : ''; 
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); 
    } else { // only name given, get cookie 
        var cookieValue = null; 
        if (document.cookie && document.cookie != '') { 
            var cookies = document.cookie.split(';'); 
            for (var i = 0; i < cookies.length; i++) { 
                var cookie = jQuery.trim(cookies[i]); 
                // Does this cookie string begin with the name we want? 
                if (cookie.substring(0, name.length + 1) == (name + '=')) { 
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 
                    break; 
                } 
            } 
        } 
        return cookieValue; 
    } 
};


//-->

