//add by Irving over
function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}
//specify whether contents should be auto copied to clipboard (memory)
//Applies only to IE 4+
//0=no, 1=yes
var copytoclip=1;
function copyToClipboard(theField,isalert) {	
	var tempval=$(theField);		
	if (navigator.appVersion.match(/\bMSIE\b/)){
		tempval.select();		
		if (copytoclip==1){
			therange=tempval.createTextRange();
			therange.execCommand("Copy");
			if(isalert!=false)alert("复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中了。");
		}
		return;
	}else{
		alert("您使用的浏览器不支持此复制功能，请使用Ctrl+C或鼠标右键。");
		tempval.select();		
	}
}
//添加元素到收藏夹
var faved = false;
var fav_process = false;
function addFav(id){
	if(faved){
		//alert('dump');
	}
	if(fav_process){
                return;
        }
	Nova.QVideo.addFav({videoId:id}, addFavCallBack);
	fav_process = true;
}

function addFavCallBack(result,callid){
	fav_process = false;
	if(result==1){
		faved = true;
		//alert('添加收藏成功');
		document.getElementById("favo").innerHTML = '<div class="reData bold">收藏成功</div>';
		updateCount('text_fav_times',1);
	}else if(result==-1){
		//if(confirm('对不起，未登录不能进行此操作。您现在登录吗？')){
			openLoginDialog(videoLogin);
		//}
	}else if(result==-2){
		//alert('该视频您已收藏');
		document.getElementById("favo").innerHTML = '<div class="reData bold">已收藏。</div>';
	}else if(result==-3){
		alert('收藏失败');
	}else if(result==-4){
		alert('您不能够收藏自己的视频');
	}
}
function encode(sStr) {
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}
//隐藏 展开
var controlType = "hidden";

function controlOrderMenu(type){
	var control = document.getElementById("menuControl");
	var objMenu = document.getElementById("orderMenu");

	if(type == "open"){
		objMenu.style.display = "block";
		control.firstChild.nodeValue = "隐藏";
		controlType = "hidden";
	}else{
		objMenu.style.display = "none";
		control.firstChild.nodeValue = "展开";
		controlType = "open"
	}
}
function commentPage(){
	window.scroll(0,675);
}

function showHide(hideID,showID){
	if(showID != null){	
		if(document.getElementById(showID).style.display == "none"){		
			document.getElementById(showID).style.display = "block";
		}else{
			document.getElementById(showID).style.display = "none";
		}
	}
	if(hideID != null){
		document.getElementById(hideID).style.display = "none";					
	}
}
