

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

PPromotionsClass ::
	
	this.promodate //.date .day .month .year
	this.publication //which publication
	this.publicationlogo //the publication logo
	
	this.promotitle //the news title
	
	this.promoimage //the images status
	
	this.sortofpromo // sorts of promotion
	this.language // language la
	
	this.status // status of promo
	this.keyword // keyword to regconize the publishcation or else
};

*/

var thePromo = eval(PROMO_CLASS);
var tempPromo = new Array; 
var blankPromo = 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 PromoContentSelector( yyyy, mm, ppp, ext ){
	var year = yyyy;
	var month = mm; //0 = all; 1-12 = months
	var publication = ppp;
	var extra = ext;

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

/////////////////////////pnewslist() -> id=PnewsList
function promolist(yyyy, newsType) {
	var theHtm = '';
	var layoutHtm = '';
	var the_HREF = '';
	var bgcolorGroup = new Array('', '#c69', '#c33', '#ffea43', '#fc0', '#f90', '#3cc', '#c2dc21', '#3cf', '#96c', '#963', '#933', '#f66');
	for ( pr=1; pr<tempPromo.length; pr++ ){
		//alert(oServerTime.getMonth())
		//detect for within 3 months promo
		//alert(oServerTime.getFullYear());
		if ( tempPromo[pr].promodate.month>= (oServerTime.getMonth()+1)-3  && tempPromo[pr].promodate.year==currentYear ){
			if ( pr==1 ){
				layoutHtm += "<table border=0 cellpadding=0 cellspacing=0>";
				layoutHtm += "<tr>";
				layoutHtm += "<td><a href=\"javascript://\" onClick=\"displayMorePromo(tempPromo)\" style=\"text-decoration:none;\"><span class=grey666-bo-12><u>Promotion Archives </u> : </span></a></td>";
				layoutHtm += "</tr>";
				
				layoutHtm += "<tr><td>";
				layoutHtm += "<div id=promoColumn>" ;
				layoutHtm += "<div class=columnBox>"
				layoutHtm += "	<div style=\"width:180px; height:20px; background-color:"+ bgcolorGroup[tempPromo[pr].promodate.month] +"; padding:0; text-align:center;\">";
				layoutHtm += "		<p class=white-bo-11 style=\"padding:.2em; margin:0; \">"+ tempPromo[pr].promodate.month_full +"</p>";
				layoutHtm += "	</div>";
				layoutHtm += "	<ul>";
				layoutHtm += "		<u><strong>" + tempPromo[pr].publication + "</strong></u>";
				layoutHtm += "		<li>";
				
				//promo links
				layoutHtm += "		<a target=_parent ";
					if ( tempPromo[pr].promosite != '-undefine-' ){
						the_HREF = " href=\"" +tempPromo[pr].promosite+ "\"";
					}else {
						the_HREF = "";
					}
				layoutHtm += the_HREF + ">";
				layoutHtm +="<strong>&gt;&gt;</strong>" + tempPromo[pr].promotitle +"</a></li>";
				
				layoutHtm += "	</ul>";
				if( tempPromo[pr+1]!=null ){
					if ( tempPromo[pr].promodate.month != tempPromo[pr+1].promodate.month ){
						layoutHtm += "</div>";
					}
				}
				
			}
	//		alert(tempPromo.length);
			if ( tempPromo[pr-1]!=null ){
				//alert(pr+", tempPromo[pr-1]!=null")
				if ( tempPromo[pr].promodate.month != tempPromo[pr-1].promodate.month ){
					//alert(pr);
					layoutHtm += "<div class=columnBox>"
					layoutHtm += "	<div style=\"width:180px; height:20px; background-color:"+ bgcolorGroup[tempPromo[pr].promodate.month] +"; padding:0; text-align:center;\">";
					layoutHtm += "		<p class=white-bo-11 style=\"padding:.2em; margin:0; \">"+ tempPromo[pr].promodate.month_full +"</p>";
					layoutHtm += "	</div>";
				}
				layoutHtm += "	<ul>";
				layoutHtm += "		<u><strong>" + tempPromo[pr].publication + "</strong></u>";
				layoutHtm += "		<li>" ;
				
				//promo links
				layoutHtm += "		<a target=_parent ";
					if ( tempPromo[pr].promosite != '-undefine-' ){
						the_HREF = " href=\"" +tempPromo[pr].promosite+ "\"";
					}else {
						the_HREF = "";
					}
				layoutHtm += the_HREF + ">";
				layoutHtm +="<strong>&gt;&gt;</strong>" + tempPromo[pr].promotitle +"</a></li>";
				
				layoutHtm += "	</ul>";
				
				if( tempPromo[pr+1]!=null ){
					if ( tempPromo[pr].promodate.month != tempPromo[pr+1].promodate.month ){
						layoutHtm += "</div>";
					}
				}
			}
			if ( pr==tempPromo.length-1 ){	
				layoutHtm += "</div>" ; 
				layoutHtm += "</td>";
				layoutHtm += "</tr>";
				layoutHtm += "</table>";
			}
		}
	}
	//alert(layoutHtm);
	theHtm = layoutHtm;
	return theHtm;
}

function displayMorePromo( oPromoClass ) {
	
	var htmlCode = '';
	var title = "Promotions Archive";
	var w = 400;
	var h = 500;

	var bgcolorGroup = new Array('', '#c69', '#c33', '#ffea43', '#fc0', '#f90', '#3cc', '#c2dc21', '#3cf', '#96c', '#963', '#933', '#f66');
	for ( pr=1; pr<tempPromo.length; pr++ ){
		if ( pr==1 ){
			htmlCode += "<!--this script is programmed and developed by oechai-->";
			htmlCode += "<html>";
			htmlCode += "<head>";
			htmlCode += "<title>... PENSONIC : About us  ...</title>";
			htmlCode += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
			htmlCode += "</head>";

			htmlCode += "<link rel=stylesheet href=\"ppromo-popup-style.css\">";
			htmlCode += "<link rel=stylesheet href=\"style.css\">";
			
			htmlCode += "<body leftmargin=0 topmargin=0 background=\"images/bgcolor.gif\">";
			htmlCode += "<table border=0 cellpadding=0 cellspacing=0 style=\"padding-left:15px; padding-top:15px;\">";
			htmlCode += "<tr>";
			htmlCode += "<td><span class=grey666-bo-12><u>Promotion Archives </u> : </span></td>";
			htmlCode += "</tr>";
			
			htmlCode += "<tr><td>"
			htmlCode += "<div id=promoColumn>" ;
			htmlCode += "<div class=columnBox>"
			htmlCode += "	<div style=\"width:180px; height:20px; background-color:"+ bgcolorGroup[oPromoClass[pr].promodate.month] +"; padding:0; text-align:center;\">";
			htmlCode += "		<p class=white-bo-11 style=\"padding:.2em; margin:0; \">"+ oPromoClass[pr].promodate.month_full +"</p>";
			htmlCode += "	</div>";
			htmlCode += "	<ul>";
			htmlCode += "		<u><strong>" + oPromoClass[pr].publication + "</strong></u>";
			htmlCode += "		<li>";
			
			//promo links
			htmlCode += "		<a target=_blank ";
				if ( tempPromo[pr].promosite != '-undefine-' ){
					the_HREF = " href=\"" +tempPromo[pr].promosite+ "\"";
				}else {
					the_HREF = "";
				}
			htmlCode += the_HREF + ">";
			htmlCode +="<strong>&gt;&gt;</strong>" + tempPromo[pr].promotitle +"</a></li>";
			htmlCode += "	</ul>";
			
			htmlCode += "	</ul>";
			if( oPromoClass[pr+1]!=null ){
				if ( oPromoClass[pr].promodate.month != oPromoClass[pr+1].promodate.month ){
					htmlCode += "</div>";
				}
			}
		}
//		alert(oPromoClass.length);
		if ( oPromoClass[pr-1]!=null ){
			//alert(pr+", oPromoClass[pr-1]!=null")
			if ( oPromoClass[pr].promodate.month != oPromoClass[pr-1].promodate.month ){
				//alert(pr);
				htmlCode += "<div class=columnBox>"
				htmlCode += "	<div style=\"width:180px; height:20px; background-color:"+ bgcolorGroup[oPromoClass[pr].promodate.month] +"; padding:0; text-align:center;\">";
				htmlCode += "		<p class=white-bo-11 style=\"padding:.2em; margin:0; \">"+ oPromoClass[pr].promodate.month_full +"</p>";
				htmlCode += "	</div>";
			}
			htmlCode += "	<ul>";
			htmlCode += "		<u><strong>" + oPromoClass[pr].publication + "</strong></u>";
			htmlCode += "		<li>" ;
			
			//promo links
			htmlCode += "		<a target=_blank ";
				if ( tempPromo[pr].promosite != '-undefine-' ){
					the_HREF = " href=\"" +tempPromo[pr].promosite+ "\"";
				}else {
					the_HREF = "";
				}
			htmlCode += the_HREF + ">";
			htmlCode +="<strong>&gt;&gt;</strong>" + tempPromo[pr].promotitle +"</a></li>";
			htmlCode += "	</ul>";

			
			if( oPromoClass[pr+1]!=null ){
				if ( oPromoClass[pr].promodate.month != oPromoClass[pr+1].promodate.month ){
					htmlCode += "</div>";
				}
			}
		}
		if ( pr==oPromoClass.length-1 ){	
			htmlCode += "</div>" ;
			htmlCode += "</td>";
			htmlCode += "</tr>";
			htmlCode += "</table></body></html>";
		}
	}
	//alert(htmlCode);
	
	createWindow( 'width='+w+',height='+h+',scrollbars=1,resizeable=1', htmlCode );
};
