

/* 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
function PressContentSelector( year, month, day, publication, extra ){
	//alert(year+','+month+','+day+','+publication+','+extra);
	var yyyy = year; // year available are 2005 and 2004
	var mm = month; // only occur from 1 - 12
	var dd = day; // only occur from 1 - 31 (max)
	var pub = publication; // short of the press name
	var xtra = extra; // same news in one day with the same publication
	
	var tt=0;
	//alert(thePnews.length)
	// ss = which array in thePnews[]
	// tt = which array in tempPnews[]
	for ( ss=1; ss<thePnews.length; ss++ ){
		if ( thePnews[ss]!=null ){
			//detect the same 'year'
			if ( thePnews[ss].newsdate.year == yyyy ){
				//month set to 0; not allow 
				if ( mm==0 ){
					alert("sorry, month cannot set to 0");
				}
				//month set to 1-12; it is to show selected month's news
				if ( mm>0 && mm<13 ){
					if ( thePnews[ss].newsdate.month == mm ){
						if (thePnews[ss].keyword[0] == 'press' ){
							if ( thePnews[ss].newsdate.day == dd ){
								
								if ( thePnews[ss].spublication == pub ){
									//alert(thePnews[ss].newsimage[0]);
									if ( thePnews[ss].newsimage[0] == xtra ){
										//alert( thePnews[ss].newsdate.year +', '+ thePnews[ss].newsdate.month +', '+ thePnews[ss].newsdate.day +', '+ thePnews[ss].spublication )
										tt++;
										//alert(ss+ ', ' +tt)
										tempPnews[tt]=thePnews[ss];
									}
								}
							}
						}
						
						if (thePnews[ss].keyword[0] == 'magazine' ){
							if ( thePnews[ss].spublication == pub ){
								//alert(thePnews[ss].newsimage[0]);
								if ( thePnews[ss].newsimage[0] == xtra ){
									//alert( thePnews[ss].newsdate.year +', '+ thePnews[ss].newsdate.month +', '+ thePnews[ss].newsdate.day +', '+ thePnews[ss].spublication )
									tt++;
									//alert(ss+ ', ' +tt)
									tempPnews[tt]=thePnews[ss];
								}
							}
						}
						
						/*before changes
						if ( thePnews[ss].newsdate.day == dd ){ 
							if ( thePnews[ss].spublication == pub ){
								//alert(thePnews[ss].newsimage[0]);
								if ( thePnews[ss].newsimage[0] == xtra ){
									//alert( thePnews[ss].newsdate.year +', '+ thePnews[ss].newsdate.month +', '+ thePnews[ss].newsdate.day +', '+ thePnews[ss].spublication )
									tt++;
									//alert(ss+ ', ' +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++;
		}
	}
	
	var newstype = new Array ("Press Release", "Magazine");
	var imageSourceURL = new Image();
	imageSourceURL.src = tempPnews[1].newsimagelink;
	var title_line_htm = '';
	var image_link_htm = '';
	if (tempPnews.length !=0 ){
		//Press Release | <b>Nan Yang Siang Pau (M'sia)</b> | 8 Aug 2005 |  &#26412;&#35270;&#21147;&#24904;&#21892;&#32858;&#20250; &#20026;&#27103;&#30153;&#25371;&#21327;&#20250;&#31609;&#27454;
		if ( tempPnews[1].keyword[0] == 'press' ) newstypedisplay = newstype[0];
		if ( tempPnews[1].keyword[0] == 'magazine' ) newstypedisplay = newstype[1];
		
		title_line_htm += newstypedisplay+ ' | ';
		title_line_htm += '<b> ' +tempPnews[1].publication+ ' </b>| ';
		
		if ( tempPnews[1].newsdate.day==null || tempPnews[1].newsdate.day==undefined || tempPnews[1].newsdate.day=='' ){
			title_line_htm += tempPnews[1].newsdate.month_full+ '.' +tempPnews[1].newsdate.year+ ' | ';
		}else {
			title_line_htm += tempPnews[1].newsdate.day+ '.' +tempPnews[1].newsdate.month+ '.' +tempPnews[1].newsdate.year+ ' | ';
		}
		
		title_line_htm += tempPnews[1].newstitle ;
		
		image_link_htm += "<span class=\"brownc60-bnormal-11\"></span>";
		image_link_htm += "<br><br><img src=\"" +imageSourceURL.src+  "\"><br><br>";
		//alert(tempPnews[1].newsimage)
		document.getElementById("title_line").innerHTML = title_line_htm;
		document.getElementById("image_link").innerHTML = image_link_htm;
	}
}

