jQuery.extend(
{init_news:function(option){option=$.extend({
firstname:"",secondname:"",thirdname:"",fourthname:"",playingtitle:"Now Playing:",nexttitle:"Next News:",prevtitle:"Prev News:",newsspeed:6000,effectis:0,mouseover:true,effectspeed:600,imagedir:"",newscountname:"",isauto:true,disablenewscount:false},option);
var firstname=option.firstname;
var secondname=option.secondname;
var thirdname=option.thirdname;
var fourthname=option.fourthname;
var newsspeed=option.newsspeed;
var effectis=option.effectis;
var isopacity = true

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	if(ie55 || ie6){
		isopacity = false
	}
	
var playingtitle=option.playingtitle;
var nexttitle=option.nexttitle;
var prevtitle=option.prevtitle;
var mouseover=option.mouseover;
var effectspeed=option.effectspeed;
var imagedir=option.imagedir;
var newscountname=option.newscountname;
var isauto=option.isauto;
var disablenewscount=option.disablenewscount;
if(newscountname){var news_sp=1}
if(disablenewscount===true){var news_dis=1}effectis=parseInt(effectis,10);effectspeed=parseInt(effectspeed,10);
var myprevimg=$('#story_prev').attr('src');if(!myprevimg){myprevimg=imagedir+'prev.gif'}
var mynextimg=$('#story_next').attr('src');if(!mynextimg){mynextimg=imagedir+'next.gif'}
var mypauseimg=$('#story_pause').attr('src');if(!mypauseimg){mypauseimg=imagedir+'pause.gif'}
var myprevimg0=$('#story_prev0').attr('src');if(!myprevimg0){myprevimg0=imagedir+'prev0.gif'}
var mynextimg0=$('#story_next0').attr('src');if(!mynextimg0){mynextimg0=imagedir+'next0.gif'}
var mypauseimg0=$('#story_pause0').attr('src');if(!mypauseimg0){mypauseimg0=imagedir+'pause0.gif'}
var activechk,activechkmore,mysize,myfirst,myfirst_explain,active,timer,splaynum;
mysize=$('#'+firstname+' .sequences').size();myfirst=$('#'+firstname+' .sequences').eq(0).html();
myfirst_explain=$('#'+firstname+' .sequences').eq(1).attr('rel');active=0;
$('#'+secondname).append(myfirst);if(news_sp===1&&news_dis!=1){$('#'+newscountname).html('1/'+mysize)}
if(news_sp!=1&&news_dis!=1){$('#'+thirdname).html(playingtitle+'1/'+mysize+'')}
$('#'+thirdname).append(nexttitle+myfirst_explain);
$('#'+fourthname+' #story_next').click(function(){clearTimeout(timer);isauto=true;$(this).attr({src:mynextimg0});
$('#'+fourthname+' #story_prev').attr({src:myprevimg});
$('#'+fourthname+' #story_pause').attr({src:mypauseimg});
active=active+1;if(active==mysize){active=0}var mynum=active+1;
var mynow=$('#'+firstname+' .sequences').eq(active).html();
var nextnum=mynum;if(nextnum==mysize){nextnum=0}
var mynow_explain=$('#'+firstname+' .sequences').eq(nextnum).attr('rel');
switch(effectis){

case 2:
if(isopacity==true){
$('#'+secondname).animate({width:"0px",opacity:0.33},effectspeed,function(){$('#'+secondname).empty();
$('#'+secondname).html(mynow);
$('#'+secondname).animate({width:"100%",opacity:1},effectspeed,function(){if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(nexttitle+mynow_explain)}
																																										 
if(news_sp!=1&&news_dis!=1){
$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
$('#'+thirdname).append(nexttitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(nexttitle+mynow_explain)}})});
}
else{
$('#'+secondname).animate({width:"0px"},effectspeed,function(){$('#'+secondname).empty();
$('#'+secondname).html(mynow);
$('#'+secondname).animate({width:"100%"},effectspeed,function(){if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(nexttitle+mynow_explain)}
																																										 
if(news_sp!=1&&news_dis!=1){
$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
$('#'+thirdname).append(nexttitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(nexttitle+mynow_explain)}})});
}
if(mysize==mynum){
	isauto =false;
	$('#'+fourthname+' #story_next').attr({src:mynextimg});
	$('#'+fourthname+' #story_pause').attr({src:mypauseimg0});

}
break;
default:$('#'+secondname).fadeOut(effectspeed,function(){$('#'+secondname).empty();$('#'+secondname).html(mynow);if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(nexttitle+mynow_explain)}if(news_sp!=1&&news_dis!=1){$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
$('#'+thirdname).append(nexttitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(nexttitle+mynow_explain)}$('#'+secondname).fadeIn(effectspeed)});
if(mysize==mynum){
	isauto =false;
	$('#'+fourthname+' #story_next').attr({src:mynextimg});
	$('#'+fourthname+' #story_pause').attr({src:mypauseimg0});

}
break}if(isauto===true){timer=setTimeout(autonext,newsspeed,active)}});$('#'+fourthname+' #story_prev').click(function(){clearTimeout(timer);isauto=true;$(this).attr({src:myprevimg0});$('#'+fourthname+' #story_next').attr({src:mynextimg});$('#'+fourthname+' #story_pause').attr({src:mypauseimg});active=active-1;if(active<0){active=mysize-1}var mynum=active+1;var myprevnum=mynum-2;if(myprevnum<0){myprevnum=mysize-1}var mynow=$('#'+firstname+' .sequences').eq(active).html();var mynow_explain=$('#'+firstname+' .sequences').eq(myprevnum).attr('rel');


switch(effectis){

case 2:
if(isopacity==true){
$('#'+secondname).animate({width:"0px",opacity:0.33},effectspeed,function(){$('#'+secondname).empty();$('#'+secondname).html(mynow);$('#'+secondname).animate({width:"100%",opacity:1},effectspeed,function(){if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(prevtitle+mynow_explain)}if(news_sp!=1&&news_dis!=1){$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
$('#'+thirdname).append(prevtitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(prevtitle+mynow_explain)}})});
}
else{
$('#'+secondname).animate({width:"0px"},effectspeed,function(){$('#'+secondname).empty();$('#'+secondname).html(mynow);$('#'+secondname).animate({width:"100%"},effectspeed,function(){if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(prevtitle+mynow_explain)}if(news_sp!=1&&news_dis!=1){$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
$('#'+thirdname).append(prevtitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(prevtitle+mynow_explain)}})});
}
if(1==mynum){
	isauto =false;
	$('#'+fourthname+' #story_prev').attr({src:myprevimg});
	$('#'+fourthname+' #story_pause').attr({src:mypauseimg0});

}
break;

default:$('#'+secondname).fadeOut(effectspeed,function(){
		$('#'+secondname).empty();$('#'+secondname).html(mynow);if(news_sp===1&&news_dis!=1){$('#'+newscountname).html(mynum+'/'+mysize);$('#'+thirdname).html(nexttitle+mynow_explain)}if(news_sp!=1&&news_dis!=1){$('#'+thirdname).empty().html(playingtitle+''+mynum+'/'+mysize+'');
		$('#'+thirdname).append(prevtitle+mynow_explain)}if(news_dis===1){$('#'+thirdname).html(prevtitle+mynow_explain)}$('#'+secondname).fadeIn(effectspeed)});
if(1==mynum){
	isauto =false;
	$('#'+fourthname+' #story_prev').attr({src:myprevimg});
	$('#'+fourthname+' #story_pause').attr({src:mypauseimg0});

}
		break}if(isauto===true){timer=setTimeout(autoprev,newsspeed,active)}});$('#'+fourthname+' #story_pause').click(function(){$(this).attr({src:mypauseimg0});$('#'+fourthname+' #story_next').attr({src:mynextimg});$('#'+fourthname+' #story_prev').attr({src:myprevimg});clearTimeout(timer)});if(mouseover===true){$('#'+secondname).hover(function(){clearTimeout(timer);activechk=$('#'+fourthname+' #story_next').attr('src');activechkmore=$('#'+fourthname+' #story_prev').attr('src');$('#'+fourthname+' #story_pause').attr({src:mypauseimg0});$('#'+fourthname+' #story_next').attr({src:mynextimg});$('#'+fourthname+' #story_prev').attr({src:myprevimg})},function(){$('#'+fourthname+' #story_pause').attr({src:mypauseimg});if(activechk==mynextimg&&activechkmore==myprevimg){if(isauto===true){timer=setTimeout(autonext,100,active)}}if(activechk===mynextimg0&&isauto===true){timer=setTimeout(autonext,100,active)}if(activechk===mynextimg&&activechkmore===myprevimg0&&isauto===true){timer=setTimeout(autoprev,100,active)}})}var _st=window.setTimeout;window.setTimeout=function(fRef,mDelay){if(typeof fRef=='function'){var argu=Array.prototype.slice.call(arguments,2);var f=(function(){fRef.apply(null,argu)});return _st(f,mDelay)}return _st(fRef,mDelay)};function autonext(q){if(!q){q=0}myend=$('#'+firstname+' .news_hide_style').size();myend=myend-1;if(q>=myend){q=0}$('#'+fourthname+' #story_next').eq(q).click();q=q+1}function autoprev(q){if(!q){q=0}myend=$(".news_hide_style").size();myend=myend-1;if(q>=myend){q=0}$('#'+fourthname+' #story_prev').eq(q).click();q=q+1}if(isauto===true){timer=setTimeout(autonext,newsspeed,1)}}});
