function fnSoFocus() {
	var val = $("#searchForm #keyword").val();
	if (val == '请在此处输入影片片名或演员名称。') {
		$("#searchForm #keyword").val('');
	}
}
function fnSoBlur() {
	var val = $("#searchForm #keyword").val();
	if (val == '') {
		$("#searchForm #keyword").val("请在此处输入影片片名或演员名称。");
	}
}
function clickCount() {
	var val = $("#searchForm #keyword").val();
	if (val == '' || val == '请在此处输入影片片名或演员名称。') {
		$("#searchForm #keyword").val("请在此处输入影片片名或演员名称。");
		return false;
	}
	return true;
}

function setCookie(name, value, ihour) {
	var iH = ihour || 1;
	var exp = new Date;
	exp.setTime(exp.getTime() + iH * 60 * 60 * 1000);
	document.cookie = name + ("=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/;");
}

function getCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
	if (arr != null) {
		return unescape(arr[2]);
	}
	return null;
}

/*
顶部展示浏览记录
*/
function ToggleRecord(){
	$("#historyContent").toggle();
	$("#headerHistoryBtn").toggleClass("headerHistorySelected");
}

//清除记录(0为清除，序号为删除指定)
function TrunRecord(Movie_i)
{
	document.getElementById('historyList').innerHTML="<ul class=\"ulHistoryList clearfix\"><div></div></ul>";
	if(Movie_i==0)
	{
	$.ajax({  
		url:"/plus/ajax.php?action=delhistory",  
		type:"get",  
		data:"name=0",  
		dataType:"jsonp",
		success:function(jsonp){
		}
	});		
	}
}


function  addPlayRecords($name,$url,$title,$movieid,$playid){
	$.ajax({  
		url:"/plus/ajax.php?action=addhistory",  
		type:"get",  
		data:"name="+$name+"&url="+$url+"&title="+$title+"&movieid="+$movieid+"&playid="+$playid,  
		dataType:"jsonp",
		success:function(jsonp){
			$data=jsonp;
		}
	});	
	
}


function  PlayRecords() {
	
	$.ajax({  
		url:"/plus/ajax.php?action=gethistory",  
		type:"get",  
		data:"t=xxx",  
		dataType:"jsonp",
		success:function(jsonp){
			$data=jsonp;
			$("#historyList").html($data.history);
		}
	});		
	
}



(function($){  
    var status = false;  
    $.fn.scrollyiyi = function(options){
        var defaults = {}
		var options=jQuery.extend(defaults,options);
		var _self = this;
		return this.each(function(){
			$("li",this).each(function(){
				$(this).css("display","none");
			})
			$("li:lt("+options.line+")",this).each(function(){
				$(this).css("display","block");
			})
			function scroll() {
				for(i=0;i<options.scrollNum;i++) {
					var start=$("li:first",_self);
					start.fadeOut("slow");
					start.css("display","none");
					start.appendTo(_self);
					$("li:eq("+(options.line-1)+")",_self).each(function(){
						$(this).fadeIn("slow");
						$(this).css("display","block");
					})
				}
			}
			var timer;
			timer = setInterval(scroll,options.scrollTime);
			_self.bind("mouseover",function(){
				clearInterval(timer);
			});
			_self.bind("mouseout",function(){
				timer = setInterval(scroll,options.scrollTime);
			});
			
		});
    }
})(jQuery); 

function randomOrder(targetArray)
{
    var arrayLength = targetArray.length
    var tempArray1 = new Array();
    for (var i = 0; i < arrayLength; i ++)
    {
        tempArray1 [i] = i
    }
    var tempArray2 = new Array();
    for (var i = 0; i < arrayLength; i ++)
    {
        tempArray2 [i] = tempArray1.splice (Math.floor (Math.random () * tempArray1.length) , 1)
    }
    var tempArray3 = new Array();
    for (var i = 0; i < arrayLength; i ++)
    {
        tempArray3 [i] = targetArray[tempArray2[i]]
    }
    return tempArray3
}
function Rmingxing(_type) {
	var arrlist = new Array()
	arrlist=["孙红雷","谢霆锋","黄晓明","刘烨","韩庚","文章","张东健","冯绍峰","范冰冰","章子怡","秋瓷炫","董璇","赵薇","杨幂","高圆圆","刘亦菲","周星驰","古天乐","林永健","黄渤","葛优","范伟","郭德纲","郭涛","梁朝伟","周润发","刘德华","陈奕迅","吴奇隆","陈建斌","林志颖","周星驰","林青霞","金喜善","吕丽萍","刘晓庆","蒋雯丽","舒淇","海清","周迅","李连杰","甄子丹","章子怡","李小龙","李冰冰","林青霞","成龙","吴京","林正英","张国荣","刘青云","李冰冰","徐静蕾","陈道明","姚晨","姜文","章子怡","霍思燕","范冰冰","林志玲","苍井空","巩新亮","舒淇","郝蕾","田朴珺","潘粤明","张馨予","周杰伦","林依晨","陈柏霖","李晨","董洁","吴奇隆","林峰","刘恺威","文章","冯绍峰","胡歌","林志颖","黄宗泽","刘诗诗","杨幂","李小璐","马苏","马伊琍","孙俪","范冰冰","苗圃","吴秀波","张嘉译","孙红雷","王志文","陈建斌","于荣光","张国立","尤勇","袁莉","蔡少芬","林心如","宋慧乔","金喜善","高圆圆","秦海璐","殷桃","赵本山","pong","宋丹丹","刘雪华","张铁林","刘佩琦","刘晓庆","王姬"];
	var ShowHtml="";
	var NewArrlist = new Array();
	NewArrlist=randomOrder(arrlist);
	var maxNum=9;
	if(_type==1||_type==2)
	{
		maxNum=12;
	}
	for(var i=0;i<maxNum;i++)
	{
		if(_type==1||_type==2)
		{
			ShowHtml+="<a href=\"http://"+(_type==1?"/search/":"/search/")+"?keyword="+NewArrlist[i]+"\" target=\"_blank\" title=\""+NewArrlist[i]+"\">"+NewArrlist[i]+"</a>";
			ShowHtml+="<em>|</em>";
		}
		else{
			ShowHtml+="<span><a href=\"/search/?keyword="+NewArrlist[i]+"\" target=\"_blank\" title=\""+NewArrlist[i]+"\">"+NewArrlist[i]+"</a></span>";
		}
	}
	if(_type==1||_type==2)
	{
		$('.filter_select_con #mingxing').html(ShowHtml+"<a href=\"javascript:Rmingxing(1);\">换一换</a>");
	}
	else
	{
		$('#mingxing dd').html(ShowHtml);
	}
}
function desc(a, b, c) {
				if (c.className.indexOf('_on') == -1) {
					if (a == 0) {
						document.getElementById('desc_' + b).className = 'desc';
						c.className = 'asc asc_on';
					} else {
						document.getElementById('asc_' + b).className = 'asc';
						c.className = 'desc desc_on';
					}
					document.getElementById('play_' + b).innerHTML = '<ul'+(b=="999"?" class=\"Dlist\"":"")+'>' + document.getElementById('play_' + b).getElementsByTagName('ul')[0].innerHTML.toLowerCase().split('</li>').reverse().join('</li>').substring(5) + '</li></ul>';
				}
}

function getPageGoUrl(maxPage,pageDiv,type,listpagename){
	var str,goUrl
	var url=location.href
	pageNum=$(".page input:input").val();
	if (pageNum.length==0||isNaN(pageNum)){alert('输入页码非法');return false;}
	if(pageNum>maxPage){pageNum=maxPage;}
	if(pageNum<1){pageNum=1;}
	if(url.lastIndexOf("/")==(url.length-1)){url+=listpagename}
	str=(pageNum==1)?'':pageNum;
   var urlstr=window.location.href; 
   var pagetype='index';
   if(urlstr.indexOf('index')){  pagetype='index'; }
   else if(urlstr.indexOf('top')){  pagetype='top'; }	
   else {  pagetype='index'; } 
   if(pageNum>1){
   pagetype=pagetype+'_';
   }
   
	goUrl=regexpSplice(url,/(http:\/\/\S+?)[\d]*(\.html|\.htm|\.shtml|\.shtm|\.asp)/,str);
	location.href=pagetype+pageNum+'.html';
}

function regexpSplice(url,pattern,spanstr) {
   pattern.exec(url);
   return (RegExp.$1+spanstr+ RegExp.$2);
}
function closesearchsuggest(){$("#suggest").hide(200)}var suggest=function(a){function m(a,c){if(0!=a.length){for(var d=a.split("|"),f=0,g=[],h=0;d.length>h;){var i=d[h++],j=d[h++],k=d[h++],m=(d[h++],d[h++]),n=d[h++];d[h++],g.push('<li id="ret'+i+'" rel="'+i+'" title="'+k+'" onclick=\'window.location.href="'+m+"\"' >");var p='<a href="'+n+'">'+j+"</a>",q='<a href="'+m+'">'+k.replace(RegExp("("+c+")","gi"),"<strong>$1</strong>")+"</a>";1==b.shortLi?(g.push(q),g.push(" <span>["),g.push(p),g.push("]</span> ")):(g.push("<span>\u66f4\u65b0\u81f3\uff1a"),g.push(p),g.push("</span>"),g.push(q)),g.push("</li>"),f++}return g.join("")}}function n(){var a=$.trim($("#"+b.key).val());return""==a?(window.alert("\u8bf7\u8f93\u5165\u8981\u4f60\u8981\u641c\u7d22\u5185\u5bb9"),!1):(document.getElementById("search_form").submit(),void 0)}function o(){$("#"+b.result).show(200)}function p(){$("#"+b.result).hide(200)}function q(a){j[a]?r(j[a],a):$.ajax({type:"GET",url:b.url,data:"key="+escape(a),dataType:"text",success:function(b){r(b,a)}})}function r(a,d){c=-1,$("#"+b.result).html("<ul>"+m(a,d)+"</ul><div><a href='javascript:void(0);' onclick='closesearchsuggest()'>\u00d7\u5173\u95ed</a>"),$("#"+b.result+" li").mouseover(function(){$("#"+b.result+" li").removeClass("selected"),$(this).addClass("selected"),c=$(this).attr("id").replace("ret","")}),a.length>0?o():p(),e=$("#"+b.result+" li").length,j[d]=a,j.length>8&&j.pop()}function s(){h&&clearTimeout(h),h=window.setTimeout(function(){var a=$.trim($("#"+b.key).val());i!=a&&(i=a,""!=a?q(a):(c=-1,e=0,p(),$("#"+b.result).html("")))},b.delay)}function t(a){a?k--:k++,$("#"+b.result+" li").removeClass("selected"),countlinum=$("#"+b.result+" li").length,k>9&&(k=0),k>countlinum&&(k=0),0>k&&(k=countlinum-1);var c=$("#"+b.result+" ul li:eq("+k+")");$kal=c.attr("title"),$("#"+b.key).val($kal),c.addClass("selected")}var b={url:"/plus/ajax_search.php",key:"keyword",result:"suggest",button:"searchbutton",delay:200,shortLi:0};$.extend(b,a||{});var h,i,c=-1,e=0,g=!1,j=[],k=-1,l={appended:!1,append:function(){1==g&&0==this.appended&&($("#"+b.result).append('<iframe class="suggest_bg" id="suggest_bg" frameborder="0" scrolling="no"></iframe>'),this.appended=!0)},show:function(){1==g&&$("#suggest_bg").height($("#"+b.result).height()+10).show()},hide:function(){1==g&&$("#suggest_bg").hide()}};this.bind=function(){$("#"+b.key).keyup(function(a){if(a.stopPropagation(),13==a.keyCode)n();else{var d="none"!=document.getElementById(b.result).style.display;if(d)switch(a.keyCode){case 27:-1!=c?(c=-1,f()):p();break;case 38:isup=!0,t(isup);break;case 40:isup=!1,t(isup);break;default:s()}else switch(a.keyCode){case 38:isup=!0,t(isup);break;case 40:isup=!1,t(isup);break;default:s()}}}),$("#"+b.key).blur(function(){setTimeout(function(){p()},300)}),$("#"+b.key).focus(function(){l.append(),e>0&&o()})}};$().ready(function(){var a=new suggest;a.bind()});