
var light_on = true;
var page_height = $(document.body).height() + 2000; //
function openCloseLight(){
	if(light_on==true){
		//light is open, now start to close light
		$(".content_video_player").css('z-index', '10');
		
		$("#light_back").css("height", page_height);
		$("select").hide();
		$("#light_back").show();
		window.light_on = false;
	}else{
		//light is closed, now start to open light
		$(".content_video_player").css('z-index', '10');		
		$("#light_back").css("height", page_height);
		$("select").show();
		$("#light_back").hide();
		window.light_on = true;
	}
}
/*  
*
*  now start to define functions about page shown
*
*/
function copyToClipboard(txt) {
      if(window.clipboardData) {
              window.clipboardData.clearData();
              window.clipboardData.setData("Text", "推荐一个视频给你："+t+"("+txt+")");
      } else if(navigator.userAgent.indexOf("Opera") != -1) {
           window.location = txt;
      } else if (window.netscape) {
           try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
           } catch (e) {
                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
           }
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
           if (!clip)
                return;
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
           if (!trans)
                return;
           trans.addDataFlavor('text/unicode');
           var str = new Object();
           var len = new Object();
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
           var copytext = txt;
           str.data = copytext;
           trans.setTransferData("text/unicode",str,copytext.length*2);
           var clipid = Components.interfaces.nsIClipboard;
           if (!clip)
                return false;
           clip.setData(trans,null,clipid.kGlobalClipboard);
		   
      }
	  alert("视频地址和标题已复制，你可以粘贴到QQ\\MSN或通过其它方式发给你的朋友！");
}

function addfavorite(){
   if (document.all){
      window.external.addFavorite(document.URL,'法治中国传媒.网络电视-'+t);
   }
   else if (window.sidebar){
      window.sidebar.addPanel('法治中国传媒.网络电视-'+t, document.URL, "");
   }
} 
//显示举报窗口
function showhiderep(){
	var a=document.getElementById("jubao_container");
	if(a.style.display=="block"){
	   a.style.display="none";
	}else{
	  a.style.display="block";
	  a.style.top = '80%';
	  a.style.left = '70%';
	}
}

function showhiderep_world(){
	var a=document.getElementById("jubao_container");
	if(a.style.display=="block"){
	   a.style.display="none";
	}else{
	  a.style.display="block";
	  a.style.top = '70%';
	  a.style.left = '70%';
	}
}
function doReport(){

	/*if(!checkRadio("tRadio")){

	   alert("请选择投诉类型！");	

	   return false;

	}*/

	if(document.reportform.tContent.value.length == 0){

	    alert("投诉内容不能为空！");

		document.reportform.tContent.focus();

	    return false;

	}else{

		alert("举报信息已成功提交到管理员！\n谢谢您对法治中国传媒的支持！");
	    document.getElementById("tTitle").value=t;
	    document.getElementById("turl").value = document.URL; 
		reportform.submit();	
		document.reportform.tContent.value="";
		document.getElementById("jubao_container").style.display="none"; 

	}
}


function icon_digg(method){
	/*
	method = up/down  / @
	*/

	var url_get= 'http://www.lawtv.com.cn/app/affiliate/index.php?ac=digg&method='+method;
	$.ajax({
	  type: "GET",
	  url: url_get+'&a_id='+artist_id+'&web_ref='+web_ref+ajax_rand(),
		dataType: '',
		timeout: 500000,
		error: function(data){			
			alert('服务器无反应！请联系管理员！');
			return false;
		},
	  success: function(data) {
			//alert(data);
			
			var json = json_get(data);
			if(json[0]['result'] == 'failed'){
				alert('服务器响应失败！请联系管理员！谢谢！');
				return false;
			}else if(json[0]['result'] == 'timelimit'){
				alert('您的操作太频繁！休息一下哦@_@！');
				return false;
			}else{
				if(method!=='up'){
					var msg = '恭喜！成功踩了一下！';
				}else{
					var msg = '恭喜！成功顶了一下！';
				}
				alert(msg);
				var times = $("#icon_digg_"+method+"_times").html();
				times = parseInt(times) +1;
				$("#icon_digg_"+method+"_times").html(times);
			}
	  } // end success
	}); 
	
}

function get_article_affiliate(){
	/*
	a_id, web_ref,

	*/
	var url_get= 'http://www.lawtv.com.cn/app/affiliate/index.php?ac=get';
	$.ajax({
	  type: "GET",
	  url: url_get+'&a_id='+artist_id+'&web_ref='+web_ref+ajax_rand(),
		dataType: '',
		timeout: 500000,
		error: function(data){
			//alert(data);
			alert('服务器无反应！请联系管理员！');
			return false;
		},
	  success: function(data) {
			//alert(data);
			var json = json_get(data);
			$("#icon_digg_up_times").html(json[0]['digg_up']);
			$("#icon_digg_down_times").html(json[0]['digg_down']);
			$("#icon_hits_times").html(json[0]['hits']);			
	  } // end success
	}); 


}

function ajax_rand(){
	return '&rand='+new Date().getTime();
}
function json_get(data){
	return eval("["+data+"]");
}
