

/* reference of product class
nDate ::
	this.date //date
	this.day = day;
	this.month = month;
	this.year = year;

PNewsClass ::
	
	this.newsdate //.date .day .month .year
	this.publication //which publication
	this.publicationlogo //the publication logo
	this.newstitle //the news title
	
	this.newsimage[0]
	this.newsimage[1]
	this.newsimage[2]
	this.newsimage[3]

	this.sortofnews // kind of news
	this.language // english, maly, chinese ?
	
	this.status // unknown 
	this.keyword[0]
	this.keyword[1]
	this.keyword[2]
};

*/

var thePnews = eval(PNEWS_CLASS);
var tempPnews = new Array; 
var blankPnews = new Array; 
var minus_length = 0;

var pnImgRoot = 'images/pnews/';
var pnLargeRoot = 'images/pnews/plarge/';
var pnLhumbRoot = 'images/pnews/pthumb/';

//var plt_cat_img1 = "images/pproducts/plt-epb-prc11.png";
//var plt_cat_img2 = "images/pproducts/plt-epb-prc12.png";

/////////////////////////ChangePnewsContent() -> to switch between different section
//Testing on the function
var currentYear = oServerTime.getFullYear();

function PnewsContentSelector( yyyy, mm ){
	var year = yyyy;
	var month = mm; //0 = all; 1-12 = months

	var tt=0;
	//alert(thePnews.length)
	for ( ss=1; ss<thePnews.length; ss++ ){
		if ( thePnews[ss]!=null ){
			if ( thePnews[ss].newsdate.year == year ){
				//month set to 0; it is to show all month's news
				if ( mm==0 ){
					tt++;
					tempPnews[tt]=thePnews[ss];
				}
				//month set to 1-12; it is to show selected month's news
				if ( mm>0 && mm<13 ){
					if ( thePnews[ss].newsdate.month == mm ){
						tt++;
						tempPnews[tt]=thePnews[ss];
					}
				}
			}
		}
	}
	
	//to make the unmatch data to be taken out.
	for ( st=1; st<tempPnews.length; st++ ){
		if (tempPnews[st]!=null){
			if (tempPnews[st].newsdate.year!=year){
				//alert(st+', year not same'+ tempPnews[st].newsdate.year);
				tempPnews[st]=null;
			}
		}
		if (tempPnews[st]==null){
			minus_length++;
		}
	}
	//alert(tempPnews[8].newsdate.year);
	document.getElementById("PnewsList").innerHTML = pnewslist(year, tempPnews[1].keyword[0]);
}

/////////////////////////pnewslist() -> id=PnewsList
function pnewslist(yyyy, newsType) {
	
	var theHtm = '';
	//currentYear = 2010;
	imgTabNext = "plt-ea-1a"+ ( (yyyy==currentYear)?1:0 ) + ".png";
	imgTab2010 = "plt-ea-16"+ ( (yyyy==2010)?1:0 ) + ".png";
	imgTab2009 = "plt-ea-15"+ ( (yyyy==2009)?1:0 ) + ".png";
	imgTab2008 = "plt-ea-14"+ ( (yyyy==2008)?1:0 ) + ".png";
	imgTab2007 = "plt-ea-13"+ ( (yyyy==2007)?1:0 ) + ".png";
	imgTab2006 = "plt-ea-12"+ ( (yyyy==2006)?1:0 ) + ".png";
	imgTab2005 = "plt-ea-11"+ ( (yyyy==2005)?1:0 ) + ".png";
	imgTab2004 = "plt-ea-10"+ ( (yyyy==2004)?1:0 ) + ".png";
	
	var layoutHtm = '';
	//the Year of Archives
	layoutHtm += "<table width=744 border=0 cellpadding=0 cellspacing=0 bgcolor=#ffffff>";
	layoutHtm += "<tr><!--ea-->";
	layoutHtm += "<td colspan=9 height=34 background=\"images/bgcolor.gif\">"
	layoutHtm += "<table width=744 height=34 cellpadding=0 cellspacing=0>";
	layoutHtm += "<tr>";
	
	if ( currentYear>=2010 ){
		layoutHtm += "<td valign=bottom><a href=\"pnews.htm?year=2010&newsgroup="+newsType+"\">";
		layoutHtm += "<img src=\"images/pnews/" + imgTab2010 + "\" border=0\">";
		layoutHtm += "</td></a>";
		layoutHtm += "<td width=5></td>";
	}
	if ( currentYear>=2009 ){
		layoutHtm += "<td valign=bottom><a href=\"pnews.htm?year=2009&newsgroup="+newsType+"\">";
		layoutHtm += "<img src=\"images/pnews/" + imgTab2009 + "\" border=0\">";
		layoutHtm += "</td></a>";
		layoutHtm += "<td width=5></td>";
	}
	if ( currentYear>=2008 ){
		layoutHtm += "<td valign=bottom><a href=\"pnews.htm?year=2008&newsgroup="+newsType+"\">";
		layoutHtm += "<img src=\"images/pnews/" + imgTab2008 + "\" border=0\">";
		layoutHtm += "</td></a>";
		layoutHtm += "<td width=5></td>";
	}
	if ( currentYear>=2007 ){
		layoutHtm += "<td valign=bottom><a href=\"pnews.htm?year=2007&newsgroup="+newsType+"\">";
		layoutHtm += "<img src=\"images/pnews/" + imgTab2007 + "\" border=0\">";
		layoutHtm += "</td></a>";
		layoutHtm += "<td width=5></td>";
	}
	if ( currentYear>=2006 ){
		layoutHtm += "<td valign=bottom><a href=\"pnews.htm?year=2006&newsgroup="+newsType+"\">";
		layoutHtm += "<img src=\"images/pnews/" + imgTab2006 + "\" border=0\">";
		layoutHtm += "</td></a>";
		layoutHtm += "<td width=5></td>";
	}

	layoutHtm += "</tr>";
	layoutHtm += "</table>";
	layoutHtm += "</td>";
	layoutHtm += "<!--/ea--></tr>";
	//
	//the Title of menu
	layoutHtm += "<tr><!--eb-->";
	layoutHtm += "<td colspan=2 width=126><img src=\"images/pnews/plt-eb11.png\" width=126 height=34></td>";
	layoutHtm += "<td width=2><img src=\"images/pnews/plt-eb10.png\" width=2 height=34></td>";
	layoutHtm += "<td width=128><img src=\"images/pnews/plt-eb12.png\" width=128 height=34></td>";
	layoutHtm += "<td width=2><img src=\"images/pnews/plt-eb10.png\" width=2 height=34></td>";
	layoutHtm += "<td width=400><img src=\"images/pnews/plt-eb13.png\" width=400 height=34></td>";
	layoutHtm += "<td width=2><img src=\"images/pnews/plt-eb10.png\" width=2 height=34></td>";
	layoutHtm += "<td colspan=2 width=84><img src=\"images/pnews/plt-eb14.png\" width=84 height=34></td>";
	layoutHtm += "<!--/eb--></tr>";
	//
	
	d_totalpn = (tempPnews.length-1)-minus_length;
	minus_length=0;
	d_step = 7;
	
	//Here's the main Programming
	layoutHtm+= "<tr><!--ec1-->"; 
	layoutHtm+= "<td width=100 height=1 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=26 background=\"images/pnews/plt-ec12.png\" align=center></td>";

	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=128 background=\"images/pnews/plt-ec12.png\" align=center></td>";

	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=400 background=\"images/pnews/plt-ec12.png\"><a class=\"green996-normal-11\">";

	layoutHtm+= '' +   "</a></td>";
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";

	layoutHtm+= "<td width=82 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>"; 
	layoutHtm+= "<!--/ec1--></tr>";
	
/*	layoutHtm+= "<tr><!--ec1-->"; 
	layoutHtm+= "<td width=100 height=22><img src=\""   + 'april' +   "\" width=100 height=22></td>";
	layoutHtm+= "<td width=26 align=center><font class=\"green996-bo-12\">"  + '11' +  "</font></td>";
										
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=128 align=center><img src=\""   + 'publication logo' +   "\" width=100 height=20></td>";
			
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
	layoutHtm+= "<td width=400><a class=\"green996-normal-11\">";
			
	layoutHtm+= 'title' +   "</a></td>";
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
			
	layoutHtm+= "<td width=82></td>";
	layoutHtm+= "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>"; 
	layoutHtm+= "<!--/ec1--></tr>";
*/	
	var innerLayHtm = new Array();
	var nmonth= '';
	//var month_bg_img = '';
	
	for ( ne=1; ne<d_totalpn+1; ne++ ){
		if ( tempPnews[ne].newsdate.month>0 && tempPnews[ne].newsdate.month<10 ){
			nmonth = '0' + tempPnews[ne].newsdate.month;
		}else if ( tempPnews[ne].newsdate.month>9 ){ 
			nmonth = tempPnews[ne].newsdate.month; 
		}
		//month bg condition
		if ( tempPnews[ne-1]!=null){
			if ( tempPnews[ne].newsdate.month != tempPnews[ne-1].newsdate.month ){
				month_img = tempPnews[ne].newsdate.month_img;
			}
			if ( tempPnews[ne].newsdate.month == tempPnews[ne-1].newsdate.month ){
				//if ( tempPnews[ne].newsdate.month>0 && tempPnews[ne].newsdate.month<10 ){
				//	nmonth = '0' + tempPnews[ne].newsdate.month;
				//}else if ( tempPnews[ne].newsdate.month>9 ){ 
				//	nmonth = tempPnews[ne].newsdate.month; 
				//}
				month_img = pnImgRoot + 'plt-ec21' + nmonth + '.png';
			}
		}else if ( tempPnews[ne-1]==null){ //toppest
			month_img = tempPnews[ne].newsdate.month_img;
		}
		
		month_bg_img =  pnImgRoot + 'plt-ec21' + nmonth + '.png';
		//
		
		var the_HREF ="";
		//rendering the ouput
	  	if( tempPnews[ne]!=null ){
			innerLayHtm[ne] = '';
			innerLayHtm[ne] += "<tr style=\"background:#ffffff;\" onMouseOver=\"this.style.background='#e7e7c7'\" ";
			innerLayHtm[ne] +=     " onMouseOut=\"this.style.background='#ffffff'\"><!--ec1-->";
			
			innerLayHtm[ne] += "<td width=100 height=22 valign=bottom background=\""  +month_bg_img+   "\"><img src=\""   +month_img;
			innerLayHtm[ne] += "\" width=100 height=22 alt=\""   +tempPnews[ne].newsdate.month+    "\"></td>";
			innerLayHtm[ne] += "<td width=26 align=center><font class=\"green996-bo-12\">"  +tempPnews[ne].newsdate.day+  "</font></td>";

			innerLayHtm[ne] += "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
			innerLayHtm[ne] += "<td width=128 align=center>";
			
			innerLayHtm[ne] += "<img src=\""   +tempPnews[ne].publicationlogo+   "\" alt=\""   +tempPnews[ne].publication+   "\" width=100 height=20></td>";
			
			innerLayHtm[ne] += "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
			innerLayHtm[ne] += "<td width=400><p class=\"green996-normal-11\" style=\"margin-left:12px;\">";
			innerLayHtm[ne] += "<a class=\"green996-normal-11\" target=\"_parent\" ";
			
			if ( tempPnews[ne].newssite != '-undefined-' || tempPnews[ne].newssite != '' ){
				the_HREF = " href=\""   +tempPnews[ne].newssite+  "\"";
			}else {
				the_HREF = "";
			}
			innerLayHtm[ne] += the_HREF + ">";

			innerLayHtm[ne] += tempPnews[ne].newstitle+   "</a></p></td>";
			innerLayHtm[ne] += "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>";
	
			innerLayHtm[ne] += "<td width=82 class=\"green996-normal-11\" align=center>";
			innerLayHtm[ne]	+= tempPnews[ne].sortofnews+   "</td>";
			innerLayHtm[ne] += "<td width=2 background=\"images/pnews/plt-ec12.png\"></td>"; 
	
			innerLayHtm[ne] += "<!--/ec1--></tr>";
			layoutHtm+=innerLayHtm[ne];
		}
		//
	}
	
	//
	//the Bottom and the End of Table
	layoutHtm += "<tr><!--ed-->";
	layoutHtm += "<td colspan=2 width=126 height=35><img src=\"images/pnews/plt-ed11.png\" width=126 height=35></td>";
	layoutHtm += "<td colspan=7 width=618 height=35 background=\"images/pnews/plt-ed12-bg.png\">";
	layoutHtm += "<select class=\"brownc60-bo-11\" size=1 style=\"width:150px; position:relative; left:0px;\">";
		layoutHtm += "<option selected>by Year</option>";
		layoutHtm += "<option value='2004'>2004</option>";
		layoutHtm += "<option value='2005'>2005</option>";
		layoutHtm += "<option value='2006'>2006</option>";
		layoutHtm += "<option value='2007'>2007</option>";
		layoutHtm += "<option value='2008'>2008</option>";
		layoutHtm += "<option value='2009'>2009</option>";
		layoutHtm += "<option value='2010'>2010</option>";

	layoutHtm += "</select>";
	layoutHtm += "<select class=\"brownc96-bo-11\" size=1 style=\"width:150px; position:relative; left:25px;\">";
		layoutHtm += "<option selected>by Month</option>";
		layoutHtm += "<option value='0'>Show All</option>";
		layoutHtm += "<option value='1'>January</option>";
		layoutHtm += "<option value='2'>February</option>";
		layoutHtm += "<option value='3'>March</option>";
		layoutHtm += "<option value='4'>April</option>";
		layoutHtm += "<option value='5'>May</option>";
		layoutHtm += "<option value='6'>June</option>";
		layoutHtm += "<option value='7'>July</option>";
		layoutHtm += "<option value='8'>August</option>";
		layoutHtm += "<option value='9'>September</option>";
		layoutHtm += "<option value='10'>October</option>";
		layoutHtm += "<option value='11'>November</option>";
		layoutHtm += "<option value='12'>December</option>";
	layoutHtm += "</select>";
	layoutHtm += "</td>";
	layoutHtm += "<!--/ed--></tr>";
	layoutHtm += "</table>"; 
	//
	
	theHtm = layoutHtm;

	return theHtm;

}
