window.onerror=function(){ return true; };

$A = function(em) {
	if (document.getElementById){ return document.getElementById(em); }
	else if (document.all){ return document.all[em]; }
	else if (document.layers){ return document.layers[em]; }
	else{ return null; }
};

$F = function(em){	return document.getElementById(em).value;	};

function get_cookie(_name){
	var Res=eval('/'+_name+'=([^;]+)/').exec(document.cookie); return Res==null?'':unescape(Res[1]);
};

function SetCookie(name, value){
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))+((secure == true) ? "; secure" : "");
};

function set_history(_url, _name, _id){
	var current_str = _id + "#" + _name + "#" + _url + "*ylmv*";
	var cookie_info = get_cookie("ylmvHistory");
	var deal_cookie="";
	if( "" != cookie_info){
		cookie_info = cookie_info.split("*ylmv*");
		var N = (cookie_info.length > 18) ? 18 : cookie_info.length - 1;
		for(var i=0; i<N; i++){
			if(current_str != cookie_info[i] + "*ylmv*" && '' != cookie_info[i]) deal_cookie += (cookie_info[i] + "*ylmv*");
		}
	}
	current_str = ('' == deal_cookie) ? current_str : current_str + deal_cookie;
	SetCookie("ylmvHistory", current_str, 48 * 3600, "/", DomainUrl, false);
};

function show_select(_title, _options, _input){
	option_obj = $(_options);
	option_obj.style.display = (option_obj.style.display == '') ? 'none' : '';
	option_obj.onblur = function() { option_obj.style.display = 'none'; };
	option_obj.focus();
	for (var i = 0; i < option_obj.childNodes.length; i++){
		option_obj.childNodes[i].onmouseover = function(){ this.className = 'options_over pointer'; };
		option_obj.childNodes[i].onmouseout = function(){ this.className = 'options_out pointer'; };
		option_obj.childNodes[i].onclick = function(){
			$A(_title).innerHTML = this.innerHTML;
			$A(_input).value = this.id;
			option_obj.blur();
			option_obj.style.display = 'none';
		}
	}
};

function get_tags(parentobj, tag){
	if (typeof parentobj.getElementsByTagName != 'undefined'){ return parentobj.getElementsByTagName(tag);
	}else if (parentobj.all && parentobj.all.tags){ return parentobj.all.tags(tag);
	}else{ return new Array(); }
};

function clk(_act, _id) {
	var v = [];
	var a = get_tags($A(_id), 'input');

	for (var i = 0; i < a.length; i++) {
		if (_act == 'all' ) {a[i].checked = true;}
		else if (_act == 'un' ) { a[i].checked = (a[i].checked) ? false : true; }
		else { if (0 < a[i].value && a[i].checked){ v.push(a[i].value); } }
	}

	if ( 'play' == _act ) {
         if (3 > v.length){asyncbox.tips("至少选择三首歌曲以上才能进行连播！", "alert", 1500);return;}
		window.open(''+web_url+'include/lplayer.php?id=' + v.join(','));
	}
};