
/******************************
 *used for:      Upcoming Games
 *Version:       1.0.0(2009-8-27)
 *Website:       http://
 *Author:        S.S.L
*******************************/

function GamlistForArray(){
	
	this.gamelist = function( arr ){
		if( arr == null ) return;
		var inbeta = arr;
		
		var str = '';

		str += '<div class="mmo_column2">';
		str += '  <h3>Upcoming Games</h3>';
		str += '  <div class="mmo_column2_con">';
		str += '	<ul class="main_left_list">';

		for( var i = 0; i < inbeta.length; i++ ){
			str += '	  <li><span class="main_left_title o_1" ><a  href="' + inbeta[i]['gae_url'] + '" >' + inbeta[i]['name'] + '</a></span>';
			str += '		<div class="o_2">' + inbeta[i]['beta_type'] + '-' + inbeta[i]['beta_date'] + '</div>';
			str += '		<div class="o_3">Area: <a  href="' + inbeta[i]['area_url'] + '" >' + inbeta[i]['area'] + '</a></div>';
			if( inbeta[i]['get_key'] == "" )
				str += '';
			else
				str += '		<div class="o_4"><a href="' + inbeta[i]['get_key'] + '">Get Key</a></div>';
				
			str += '	  </li>'
		}
		str += '	</ul>';
		str += '	<div class="mmo_more"><a href="http://feature.mmosite.com/upcoming_onlinegame/">more?</a></div>';
		str += '  </div>';
		str += '</div>';
		
		document.write( str );
	}
}
var gaml_o = new GamlistForArray();

function NewsDisplayForID(){
	
	function doNull( param ){
		return (param == null || param == undefined)? "": param;
	}
	
	//help them
	this.download = function( arr ){
		
		if( arr == null ) return;
		
		var down_mmoar = arr;
		
		var str = '';
		
		str += '<a href="' + down_mmoar[0]['gurl']  + '"><img src="http://images.mmosite.com/news/images/2009v2/download.jpg" width="311" height="50" /></a>';
		
		document.write( str );
	}
	
		//help them
	this.helpThem = function( arr ){
		
		if( arr == null || arr.list.length == 0 )return;
		
		var answers = arr.list;     
		var answerscatalog = arr.catalog;

		var str = '';
		
		str += '<div class="column4">';
		str += '  <h3>Help Them</h3>';
		str += '  <div class="column4_con">';
		str += '    <div class="help">';
		
		str += '		<table width="100%" border="0">';
		
		for( var i = 0; i < answers.length; i++ ){
        	str +=   '<tr>';
        	str +=    	'<td><a href="' + doNull(answers[i].aurl) + '" title="' + doNull(answers[i].title) + '">' + doNull(answers[i].title) + '</a></td>';
        	str +=      '<td><span>' + doNull(answers[i].score) + '</span></td>';
        	str +=   '</tr>';
		}
		
		str +=  '		</table>';
		str += '    </div>';
		str += '    <div class="more more2"><a href="' + doNull(answerscatalog.curl) + '">more</a></div>';
		str += '  </div>';
		str += '</div>';
		
		document.write( str );
	}
	
	//MMOsiter Soapbox
		this.mmositerSoapbox = function( arr1,arr2 ){
		
		if( arr1 == null || arr2 == null || ( arr1.length == 0 && arr2.length == 0 ) ) return;
		
		var forum = arr1,blog = arr2;
		
		var str = '';
		
		str += ' <div class="column4">';
		str += '  <h3>MMOsiter Soapbox</h3>';
		str += '  <div class="column4_con special">';
		str += '	<table class="fix">';
		
		for( var i = 0; i < forum.length; i++ ){
			str += '  <tr>';
			str += '	<td class="td1">';
			str += '		<img src="http://images.mmosite.com/news/images/2009v2/fh1.gif"/>';
			str += '		<a href="' + forum[i]['url'] + '" title="' + forum[i]['title'] + '">' + forum[i]['title'] + '</a>';
			str += '		<img src="http://images.mmosite.com/news/images/2009v2/fh2.gif"/><br />';
			str += '	  	Posted ' + forum[i]['date'] + ' by <a href="' + forum[i]['author_url'] + '" class="c1">' + forum[i]['author_nickname'] + '</a><br /> ';
			str += '	  	<span class="c1">' + forum[i]['reply'] + ' Comments</span></td>';
			str += '	<td class="td2"><a href="' + forum[i]['author_url'] + '"><img src="' + forum[i]['author_avatar'] + '" width="64" height="64"/></a></td>';
			str += '  </tr>';
		}
		
		for( var i = 0; i < blog.length; i++ ){
			str += '  <tr>';
			str += '	<td class="td1">';
			str += '		<img src="http://images.mmosite.com/news/images/2009v2/fh1.gif"/>';
			str += '		<a href="' + blog[i]['article_url'] + '" title="' + blog[i]['subject'] + '">' + blog[i]['subject'] + '</a>';
			str += '		<img src="http://images.mmosite.com/news/images/2009v2/fh2.gif"/><br />';
			str += '	  	Posted ' + blog[i]['postdate'] + ' by <a href="' + blog[i]['author_url']  + '" class="c1">' + blog[i]['author'] + '</a><br /> ';
			str += '	  	<span class="c1">' + blog[i]['comment_num'] + ' Comments</span></td>';
			str += '	<td class="td2"><a href="' + blog[i]['author_url'] + '"><img src="' + blog[i]['author_img'] + '" width="64" height="64"/></a></td>';
			str += '  </tr>';
		}
		
		str += '</table>';
str += '	<div class="more more2"><a href="http://my.mmosite.com/">more</a></div>';
		str += '  </div>';
		str += ' </div>';
		
		document.write( str );
	}
	
	//Video
	this.video = function( arr ){
		
		if( arr == null || arr.length == 0 ) return;
		
		var video_mmoar = arr;
		
		var str = '';
		
        str += '<div class="column4">';
		str += '  <h3>Related Videos</h3>';
		str += '  <div class="column4_con special">';
		
		str += '<table class="fix">';
		
		for( var i = 0; i < video_mmoar.length; i++ ){
        	str += '	<tr>';
        	str += '		<td><a href="' + video_mmoar[i]['url'] + '" title="' + video_mmoar[i]['title'] + '">' + video_mmoar[i]['title'] + '</a><br />';
        	str += '            ' + video_mmoar[i]['time'] + '</td>';
        	str += '        <td class="videophoto"><a href="' + video_mmoar[i]['url'] + '" title="Play"> <span></span><img src="' + video_mmoar[i]['picture'] + '" width="60" height="45"/></a></td>';
        	str += '    </tr>';
		}
        
		str += '      </table>';
		str += '    <div class="more more2"><a href="' + video_mmoar[0]['gameurl']  + '">more</a></div>';
		str += '  </div>';
		str += '</div>';
		
		document.write( str );
	}
}

var dis_o = new NewsDisplayForID();

/******************************
 *picture roll
*******************************/

var Speed = 10; 
var Space = 5; 
var PageWidth = 390; 
var fill = 0; 
var MoveLock = false; 
var MoveTimeObj; 
var Comp = 0; 
var AutoPlayObj = null; 
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}} 

function playReady(){
GetObj("List2").innerHTML = GetObj("List1").innerHTML; 
GetObj('ISL_Cont').scrollLeft = fill; 
GetObj("ISL_Cont").onmouseover = function(){clearInterval(AutoPlayObj);} 
GetObj("ISL_Cont").onmouseout = function(){AutoPlay();} }
AutoPlay(); 

function AutoPlay(){  
 clearInterval(AutoPlayObj); 
 AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();',5000); 
} 
function ISL_GoUp(){ 
 if(MoveLock) return; 
 clearInterval(AutoPlayObj); 
 MoveLock = true; 
 MoveTimeObj = setInterval('ISL_ScrUp();',Speed); 
} 
function ISL_StopUp(){ 
 clearInterval(MoveTimeObj); 
 if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0){ 
  Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth); 
  CompScr(); 
 }else{ 
  MoveLock = false; 
 } 
 AutoPlay(); 
} 
function ISL_ScrUp(){  
 if(GetObj('ISL_Cont').scrollLeft <= 0){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth} 
 GetObj('ISL_Cont').scrollLeft -= Space ; 
} 
function ISL_GoDown(){ 
 clearInterval(MoveTimeObj); 
 if(MoveLock) return; 
 clearInterval(AutoPlayObj); 
 MoveLock = true; 
 ISL_ScrDown(); 
 MoveTimeObj = setInterval('ISL_ScrDown()',Speed); 
} 
function ISL_StopDown(){  
 clearInterval(MoveTimeObj); 
 if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 ){ 
  Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill; 
  CompScr(); 
 }else{ 
  MoveLock = false; 
 } 
 AutoPlay(); 
} 
function ISL_ScrDown(){ 
 if(GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth;} 
 GetObj('ISL_Cont').scrollLeft += Space ; 
} 
function CompScr(){ 
 var num; 
 if(Comp == 0){MoveLock = false;return;} 
 if(Comp < 0){ 
  if(Comp < -Space){ 
   Comp += Space; 
   num = Space; 
  }else{ 
   num = -Comp; 
   Comp = 0; 
  } 
  GetObj('ISL_Cont').scrollLeft -= num; 
  setTimeout('CompScr()',Speed); 
 }else{ //???? 
  if(Comp > Space){ 
   Comp -= Space; 
   num = Space; 
  }else{ 
   num = Comp; 
   Comp = 0; 
  } 
  GetObj('ISL_Cont').scrollLeft += num; 
  setTimeout('CompScr()',Speed); 
 } 
} 

/******************************
 *show popular news today
*******************************/
function showByPopularToday(){
var url = '';
var title = '';
var nums = '';
for(i=0;i<10;i++) {
	url = urlList[i];
	title = titleList[i];
	nums = numsList[i];
	document.writeln("<ul>");
	document.writeln("<li class=\"rank_digg\"><a href=\""+url+"\" title=\"Digg it!\" target=\"_blank\">"+nums+"<\/a><\/li>");
	document.writeln("<li class=\"rank_title\"><a href=\""+url+"\" title=\""+title+"\" target=\"_blank\">"+title+"<\/a><\/li>");
	document.writeln("<\/ul>");
}
}

/******************************
 *show flalsh
*******************************/

function playFlash(flashid){
	var flink =document.getElementById(flashid).getElementsByTagName("a");
	var fsimag =document.getElementById(flashid).getElementsByTagName("span");
	var ftitle =document.getElementById(flashid).getElementsByTagName("dt");
	var ftext =document.getElementById(flashid).getElementsByTagName("dd");
	var pic_width="622"; 
    var pic_height="268";
	//var button_pos=fpic.length;
	var stop_time=6000;
	var show_text=0; 
	var txtcolor="dddddd";
	var bgcolor="000000";

//alert(fsimag[0].firstChild.src); 小图
//alert(flink[0].firstChild.src); 大图
//alert(ftitle[0].firstChild.nodeValue); 标题
//alert(ftext[0].firstChild.nodeValue); 内容
//alert(flink[0].href) 链接

	var flashUrl = 'http://images.mmosite.com/news/flash/flash620268.swf';

	var flashvar="";
	for(var i=0; i<flink.length; i++){	
	
		if( i == flink.length - 1){
		flashvar = flashvar +( flink[i].firstChild.src +"#"+ fsimag[i].firstChild.src +"#"+ ftitle[i].firstChild.nodeValue +"#"+ ftext[i].firstChild.nodeValue +"#"+ flink[i].href);
		}else{
		flashvar = flashvar +( flink[i].firstChild.src +"#"+ fsimag[i].firstChild.src +"#"+ ftitle[i].firstChild.nodeValue +"#"+ ftext[i].firstChild.nodeValue +"#"+ flink[i].href  +"|");	
		}
	}
	
	var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ pic_width +'" height="' + pic_height +'" width="'+ pic_width +'" /><param name="allowScriptAccess" value="always" />';
	flash = flash + '<param name="movie" value="'+ flashUrl +'" />';
	flash = flash + '<param name="quality" value="high" />';
	flash = flash + '<param name="menu" value="false" />';
	flash = flash + '<param name="FlashVars" value="mypiclink='+flashvar+'">';
    flash = flash + '<param name="wmode" value="transparent" />';
	flash = flash + '<embed wmode="transparent" src="' + flashUrl + '" FlashVars="mypiclink='+flashvar+'" height="'+ pic_height +'" width="'+ pic_width +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"allowScriptAccess="always"  />';
	flash = flash + '</object>';
	document.writeln(flash); 
}
