//window.onerror=function(){return true;}
var isIE=(navigator.appName).indexOf("Microsoft")!=-1;if(window.Event&&!isIE){function SearchEvent(){var func=SearchEvent.caller;while(func!=null){var arg=func.arguments[0];if(arg){if(String(arg.constructor).indexOf('Event')>-1){return arg}}func=func.caller}return null};window.constructor.prototype.__defineGetter__("event",function(){return SearchEvent()});Event.prototype.__defineSetter__("returnValue",function(bool){if(!bool){this.preventDefault()}return bool});Event.prototype.__defineSetter__("cancelBubble",function(bool){if(bool){this.stopPropagation()}return bool});Event.prototype.__defineGetter__("clientX",function(){return this.pageX});Event.prototype.__defineGetter__("clientY",function(){return this.pageY});Event.prototype.__defineGetter__("keyCode",function(){return this.which});Event.prototype.__defineGetter__("button",function(){return this.which});Event.prototype.__defineGetter__("srcElement",function(){var n=this.target;while(n.nodeType!=1){n=n.parentNode}return n});Event.prototype.__defineGetter__("offsetX",function(){return this.layerX});Event.prototype.__defineGetter__("offsetY",function(){return this.layerY});Event.prototype.attachEvent=function(type,handler){this.addEventListener(type.substring(2),handler,true)};Event.prototype.detachEvent=function(type,handler){this.removeEventListener(type.substring(2),handler,true)};window.constructor.prototype.attachEvent=function(type,handler){this.addEventListener(type.substring(2),handler,true)};window.constructor.prototype.detachEvent=function(type,handler){this.removeEventListener(type.substring(2),handler,true)};document.constructor.prototype.attachEvent=function(type,handler){this.addEventListener(type.substring(2),handler,true)};document.constructor.prototype.detachEvent=function(type,handler){this.removeEventListener(type.substring(2),handler,true)};Element.prototype.attachEvent=function(type,handler){this.addEventListener(type.substring(2),handler,true)};Element.prototype.detachEvent=function(type,handler){this.removeEventListener(type.substring(2),handler,true)};HTMLElement.prototype.attachEvent=function(type,handler){this.addEventListener(type.substring(2),handler,true)};HTMLElement.prototype.detachEvent=function(type,handler){this.removeEventListener(type.substring(2),handler,true)}}
function $(s){return document.getElementById(s);}function $P(child,parent){return parent?parent.appendChild(child):document.body.appendChild(child);}function $C(s){return document.createElement(s);};function $R(child,parent){return parent?parent.removeChild(child):document.body.removeChild(child);};var E=new Object;E.add=function(o,t,f){if(o.addEventListener){o.addEventListener(t,f,false)}else if(o.attachEvent){o.attachEvent("on"+t,f)}else{o["on"+t]=f}};E.remove=function(o,t,f){if(o.removeEventListener){o.removeEventListener(t,f,false)}else if(o.detachEvent){o.detachEvent("on"+t,f)}else{o["on"+t]=null}};E.formatEvent=function(e){if(isIE&&isWin){e.charCode=(e.type=="keypress")?e.keyCode:0;e.eventPhase=2;e.isChar=(e.charCode>0);e.pageX=e.clientX+document.body.scrollLeft;e.pageY=e.clientY+document.body.scrollTop;e.preventDefault=function(){this.returnValue=false};if(e.type=="mouseout"){e.relatedTarget=e.toElement}else if(e.type=="mouseover"){e.relatedTarget=e.fromElement}e.stopPropagation=function(){this.cancelBubble=true};e.target=e.srcElement;e.time=(new Date).getTime()}return e};E.get=function(){if(window.event){return this.formatEvent(window.event)}else{return E.get.caller.arguments[0]}};function GetDataByIframe(url,cbf,err,para){if((cbf[0]&&typeof(cbf[0])!='function')||typeof(cbf)!='function'){return alert('cbf function is in error!')}if(url instanceof Array){for(var i=0;i<arr_url.length;i++){doWork(url[i],cbf[i],para[i])}}else if(typeof(url)=='string'){doWork(url,cbf,para)}function doWork(u,cb,p){var idp=$C('iframe');idp.style.display='none';idp.src=u;E.add(idp,'load',icb);function icb(){E.remove(idp,'load',icb);var json=idp.contentWindow.jsonObj;if(!json){if(typeof(err)=='function'){$R(idp);return err();}else{$R(idp);return;}}$R(idp);cb(json,p)}$P(idp)}};
var B=BigNews={
	current:0,
	next:0,
	scrollInterval:0,
	autoScroller:0,
	smallpic:"SwitchSmaPic"
};
BigNews.turn=function(index,obj){
	clearInterval(BigNews.autoScroller);
	BigNews.scroll(index,obj);
}
BigNews.scroll=function(index,obj){
	if(obj.smallpic==null || obj.smallpic==""){
		clearInterval(BigNews.autoScroller);
		return;
	}
	var count=0;
	var step=obj.step;
	var duration=16;
	var b=BigNews;
	b.next=index;
	
	if(index==b.current){
		return;
	}

	if(index < SmallNews.current){
		SmallNews.go(SmallNews, index);
	} else if (index - 3 >= SmallNews.current) {
		SmallNews.go(SmallNews, index - 3);
	}

	clearInterval(b.scrollInterval);
	for(var i=0;i<obj.totalcount;i++){
		$(obj.smallpic+"_"+i).className='';
		if(obj.pictxt!=null && obj.pictxt!="")		
			$(obj.pictxt+"_"+i).style.display = "none" ;
	}
	$(obj.smallpic+"_"+index).className=obj.selectstyle;
	if(obj.pictxt!=null && obj.pictxt!="")	
		$(obj.pictxt+"_"+index).style.display = "block" ;
	var span=index-b.current;
	var begin_value=$(obj.bigpic).scrollTop;
	var chang_in_value=span*step+(b.current*step-begin_value);
	b.scrollInterval=setInterval(function(){doit(begin_value,chang_in_value)},10);
	function doit(b,c){
		$(obj.bigpic).scrollTop=cpu(count,b,c,duration);
		count++;
		if(count==duration){
			clearInterval(BigNews.scrollInterval);
			scrollInterval=0;
			count=0;
			$(obj.bigpic).scrollTop=b+c;
			BigNews.current=index;
		}
	}
	function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}
BigNews.auto=function(obj){
	clearInterval(BigNews.autoScroller);
	BigNews.autoScroller=setInterval(function(){
		BigNews.scroll(BigNews.current==(obj.totalcount-1)?0:BigNews.current+1,obj);
	},obj.autotimeintval);
}
BigNews.pauseSwitch = function() {	
	//clearTimeout(BigNews.autoScroller);
	clearInterval(BigNews.autoScroller);
}
BigNews.init=function(obj){
	$(obj.bigpic).onmouseover = new Function("BigNews.pauseSwitch();") ;		
	$(obj.bigpic).onmouseout = new Function("BigNews.auto("+obj.objname+");") ;	
	for (i=0;i<obj.totalcount;i++) {	
		if(obj.smallpic!=null && obj.smallpic!="") {
		 $(obj.smallpic+"_"+i).onmouseover = new Function("BigNews.turn("+i+","+obj.objname+");BigNews.pauseSwitch();") ;		
		 $(obj.smallpic+"_"+i).onmouseout = new Function("BigNews.auto("+obj.objname+");") ;	
		}
	}
	BigNews.smallpic = obj.smallpic;
	BigNews.auto(obj);
}



var SmallNews = {
	current:0,
	step:0,
	totalcount:0,
	a_pre:"",
	a_next:"",
	ul:'',
	clickflag:0
};
SmallNews.init=function(obj) {
	SmallNews.step = obj.step;
	SmallNews.totalcount = obj.totalcount;
	SmallNews.a_pre = obj.a_pre;
	SmallNews.a_next = obj.a_next;
	SmallNews.ul = obj.ul;
}
SmallNews.pre=function(){
	if(SmallNews.current<=0){
		return;
	}else{
		var index = SmallNews.current - 1;
		if(BigNews.current > index + 3) {
			$(BigNews.smallpic+"_"+ (index + 3)).onmouseover();
			$(BigNews.smallpic+"_"+ (index + 3)).onmouseout();
		}
		SmallNews.go(SmallNews,SmallNews.current-1);
	}
}
SmallNews.next=function(){
	if(SmallNews.current>=SmallNews.totalcount - 4){
		return;
	}else{
		var index = SmallNews.current + 1;
		if (BigNews.current < index) {
			$(BigNews.smallpic+"_"+index).onmouseover();
			$(BigNews.smallpic+"_"+index).onmouseout();
		} 
			SmallNews.go(SmallNews,SmallNews.current+1);
		
		
	}
}
SmallNews.go=function(obj,index){
	if(obj.current==index){return;}
	var span=-index+obj.current;
	if(obj.clickflag > 0){return;}
	obj.clickflag=1;
	if(obj.step>0)
		ScrollCrossUp.scroll($(obj.ul),obj.step,span,parseInt($(obj.ul).style.marginTop)||0,cb,10);
	else{
		cb();	
	}
	function cb(){
		obj.current=index;
		if(obj.current == 0) {
			$(obj.a_pre).className = "no-pre";
			$(obj.a_next).className = "next";
		}else if(obj.current > 0 && obj.current < obj.totalcount - 4) {
			$(obj.a_pre).className = "pre";
			$(obj.a_next).className = "next";
		}else if(obj.current == obj.totalcount - 4) {
			$(obj.a_pre).className = "pre";
			$(obj.a_next).className = "no-next";
		}
		obj.clickflag=0;
	}
}

//向上滚动
ScrollCrossUp={interval:0,count:0,duration:0,step:0,srcObj:null,callback:null};
ScrollCrossUp.doit=function(obj,b,c,d){
	var s=ScrollCrossUp;
	obj.style.marginTop=cpu(s.count,b,c,d)+'px';
	s.count++;
	if(s.count>=d){
		clearInterval(s.interval);
		s.count=0;
		obj.style.marginTop=b+c+'px';
		s.callback();
	}
	function cpu(t,b,c,d) {return c*((t=t/d-1)*t*t+1)+b;};
}
ScrollCrossUp.scroll=function(obj,step,span,beign,callback,duration){
	var s=ScrollCrossUp;
	s.duration=duration;
	s.callback=callback;
	s.interval=setInterval(function(){s.doit(obj,beign,step*span,duration)},10);

}




var D=Detail={};
Detail.show=function(info_id){
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="/ajax.php";
url=url+"?info_id="+info_id+"&type=info_show";
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=result_show;
xmlHttp.open("GET",url,true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
	var p=KK.position(event.srcElement);
	var tip=$('movie_info');
	tip.style.display='';
	tip.style.top=p.Top+'px';
	tip.style.left=p.Left+108+'px';
}

function result_show()
{
if (xmlHttp.readyState==4){
$("div_tip_detail").innerHTML=xmlHttp.responseText;
}
}

Detail.actor=function (str,len,spliter){
	spliter=spliter||'|';
	var arr=str.split(spliter);
	var temp='';
	for(var i=0;i<arr.length;i++){
		temp+=arr[i]+'&nbsp;';
		if(D.len(temp)<len){
			str=temp;
		}else{
			break;
		}
	}
	return str;
}
Detail.ac_search=function (str,len,spliter){
	spliter=spliter||'|';
	var arr=str.split(spliter);
	var temp=html='';
	var l=Math.min(2,arr.length);
	for(var i=0;i<l;i++){
		temp=arr[i]+'&nbsp;';
		html+='<a style="color:#007EBC" href="http://video.gougou.com/search?s='+arr[i]+'&id=35&fr=2" title="'+arr[i]+'" target="_blank">'+arr[i]+'</a>'+'&nbsp;';
		if(D.len(temp)<30){
			str=html;
		}else{
			break;
		}
	}
	return str;
}
Detail.hide=function (){
	$('movie_info').style.display='none';
}
Detail.len=function (str){
	var l=0;
	var sl=str.length
	for(var i=0;i<sl;i++){
		l++;
   		if (str.charCodeAt(i)>256) l++;
	}
	return l;
}
var KK={};
KK.position=function(o){
	var p={Top:0,Left:0};
	while(!!o){
		p.Top+=o.offsetTop;
		p.Left+=o.offsetLeft;
		o=o.offsetParent;
	}
	return p;
}
