////////////////////////////////////////////////////////
//////////////////////////// Product and the Data Array.
//////////////////////////// Main Returning :: dataEk (Total of the searching), 
///////////////////////////////////////////////////////
function nDate( dt, dd, mm, yyyy ){
	this.date = dt;
	
	if ( dd!=null ){
		this.day = dd;
	}else this.day = '-';
	
	this.month = mm;
	
	var mm_imgfold = "images/pnews/";
	var mm_imgfile;
	var mm_stxt = new Array("month in short form", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var mm_ftxt = new Array("month in full", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	this.month_mmm = mm_stxt[this.month];
	this.month_full = mm_ftxt[this.month];
	
	var tmp_y = '0';
	if ( yyyy=='2006' ){
		tmp_y = '06';
	}
	if ( yyyy=='2005' ){
		tmp_y = '05';
	}
	if ( yyyy=='2004' ){
		tmp_y = '04';
	}
	
	this.year_yy = tmp_y;
	
	var tmp_m = '0';
	if ( mm>0 && mm<13 ){
		if ( mm>0 && mm<10 ){
			tmp_m += mm;
			mm_imgfile = "plt-ec11" + tmp_y + tmp_m + ".png";
		}
		if ( mm>9 && mm<13 ){
			tmp_m = mm;
			mm_imgfile = "plt-ec11" + tmp_y + tmp_m + ".png";
		}
	}
	this.month_img = mm_imgfold + mm_imgfile;

	this.year = yyyy;
}

function PPromotionClass( ndate, npublication, ntitle, 
						nimagefile,	nsort, nlanguage, nstatus, nkeyword ){
	
	var dateEk = DataExtract(ndate,'/','/', 'theDateArryNm'); //get the total number of array
	var theDateArry = eval(theDateArryNm);
	//alert( 'ndate='  +ndate+  ', theDateArryNm.length='  +theDateArry.length + '\n' + theDateArry[1]+ ' ,'+ theDateArry[2]+ ' ,' +theDateArry[3]);
	
	this.promodate = new nDate(ndate, theDateArry[1],theDateArry[2],theDateArry[3]); //1
	
	this.promotitle = ntitle; //3
	
	this.promoimage = nimagefile; //4
	
	this.sortofnews = nsort; //5
	this.language = nlanguage; //6
	
	this.status = nstatus; //7
	this.keyword = nkeyword; //8
	
	//publication's logo assign [new] //0 is press //1 is magazine
	var plib_s = new Array();
	var plib_f = new Array();
	var plib_i = new Array();
	plib_s[0] = new Array('cp', 'gm', 'kw', 'ny', 'sc', 'tf', 'nst', 'str', 'sun', 'bh', 'utm');
	plib_f[0] = new Array('China Press', 'Guang Ming Daily', 'Kwang Wah Yit Poh', 'Nan Yang Siang Pau', 'Sin Chew Daily', 'Oriental Daily', 'New Strait Times', 'The Star', 'The Sun', 'Berita Harian', 'Utusan Malaysia' );
	plib_i[0] = new Array('pnlo-001.png', 'pnlo-002.png', 'pnlo-003.png', 'pnlo-004.png', 'pnlo-005.png', 'pnlo-006.png', 'pnlo-007.png', 'pnlo-008.png', 'pnlo-009.png', 'pnlo-010.png', 'pnlo-011.png');
	
	plib_s[1] = new Array('adv', 'ajsr', 'cb', 'fema', 'femi', 'home', 
						  'ifeel', 'intr', 'm8', 'mcla', 'mmbb', 'nicn', 
						  'nyou',  'sis', 'vmag', 'wt', 'vida', 'ceo',
						  'pptt', 'cpt', 'jasm', 'mt', 'cl', 'vmage');
	
	plib_f[1] = new Array('Adsvantage', 'Anjung Seri', 'Citta Bella', 'Female', 'Feminine', 'Home', 
						  'I-Feel', 'In Trend', 'M8','Marie Claire', 'Mommy Baby', 'New Icon', 
						  'N&uuml; You', 'Sisters', 'VMag', 'Westinable', 'Vida', 'CEO',
						  'Property Times', 'Capital', 'Jasmine', 'Malaysia Tatler', 'COOL','VMag(Eng)');
	
	plib_i[1] = new Array('pmlo-001.png', 'pmlo-002.png', 'pmlo-003.png', 'pmlo-004.png', 'pmlo-005.png', 'pmlo-006.png', 
						  'pmlo-007.png', 'pmlo-008.png', 'pmlo-009.png', 'pmlo-010.png', 'pmlo-011.png', 'pmlo-012.png', 
						  'pmlo-013.png', 'pmlo-014.png', 'pmlo-015.png', 'pmlo-016.png', 'pmlo-017.png', 'pmlo-018.png',
						  'pmlo-019.png', 'pmlo-020.png', 'pmlo-021.png', 'pmlo-022.png', 'pmlo-023.png','pmlo-024.png');

	if ( this.keyword == 'press' ){ 
		publishlib_s = plib_s[0];
		publishlib_i = plib_i[0]; 
		publishlib_f = plib_f[0]; 
	}else if ( this.keyword == 'magazine' ){ 
		publishlib_s = plib_s[1];
		publishlib_i = plib_i[1]; 
		publishlib_f = plib_f[1];
	}
	else if ( this.keyword == '--' ){
		publishlib_s = '';
		publishlib_i = '';
		publishlib_f = '';
	}
	
	var imgfold = "images/promo/";
	
	this.spublication = npublication;
	
	if ( npublication=='--' ){
		this.publication = 'Promotion'
		this.publicationlogo = '';
		this.spublication = 'Promotion';
	}else {
		for ( pl=0; pl<publishlib_s.length; pl++ ){
			if ( npublication == publishlib_s[pl] ){
				this.publication = publishlib_f[pl];  //2
				this.publicationlogo = imgfold + publishlib_i[pl]; 
			}
		}
	}
	
	
	
	
	//alert(this.publication+", "+this.publicationlogo);
	//news' address
	
	var promoRoot = "news_events/promotions/";
	var promoInsideRoot = '';
	//alert(this.keyword);
	if ( this.keyword == 'press' ){ promoInsideRoot += promoRoot + this.keyword + '/'; }
	else if ( this.keyword == 'magazine' ){ promoInsideRoot += promoRoot + this.keyword + '/'; }
	else if ( this.keyword == 'promo' ){ promoInsideRoot += promoRoot + this.keyword + '/'; }
	else { alert('Error founds in database. Please kindly report this to webmaster@pensonic.com ! Thanks !'); }

	//extra news in the same day of publication
	var got_xtra_promo = '';
	if ( this.promoimage=='0'){
		got_xtra_promo = '';
	}else{
		got_xtra_promo = '-' + this.promoimage;
	} 
	
	//final condition for news' address
	var site_addressname = '';
	if ( this.promodate.year == '2006' ) { 
		promoInsideRoot += 'y2k6/'; 
		promoRoot += promoInsideRoot;
	}
	if ( this.promodate.year == '2005' ) { 
		promoInsideRoot += 'y2k5/'; 
		promoRoot += promoInsideRoot;
	}
	if ( this.promodate.year == '2004' ) { 
		promoInsideRoot += 'y2k4/'; 
		promoRoot += promoInsideRoot;
	}

	if ( this.status!='YES' && this.status!='NO' ){
		site_addressname += promoInsideRoot;
		site_addressname += this.status;
		this.promosite = site_addressname;
	}
	
	if ( this.status=='YES' ){
		site_addressname += promoInsideRoot;
		site_addressname +='promo.htm?';
		site_addressname +='year=' + this.promodate.year + '&';
		site_addressname +='month=' + this.promodate.month + '&';
		//site_addressname +='day=' + this.promodateday + '&';
		site_addressname +='publication=' + this.spublication + '&';
		site_addressname +='extra=' + this.promoimage;
		this.promosite = site_addressname;
		//alert(this.promosite);
	}
	if ( this.status == ' 7 ' || this.status == 'NO' ){
		this.promosite = '-undefined-';
		//alert(this.promosite);
	}
	
	//news picture link
	var promoimageadd = 'http://www.pensonic.com/' + promoInsideRoot + 'images/'+ this.promodate.month_mmm + '/' + this.promodate.year + '-' + this.promodate.month + '-' + (this.promodate.day=='--'?this.promodate.day='':this.promodate.day + '-')  + npublication + got_xtra_promo + '.jpg';
	this.promoimagelink = promoimageadd.toLowerCase(); 
	//alert(this.promoimagelink);
	
	//end news' address
		
};

var promo_list = "^";
//JANUARY PROMOTIONS 2006
promo_list += "/--/1/2006/^jasm^Vote Now! Win Date with your Favorite Pensonic Friends!&#23613;&#24555;&#36194;&#21462;&#19968;&#20010;&#38590;&#24471;&#30340;&#26426;&#20250;!&#19982;Pensonic&#20043;&#21451;&#20849;&#24230;&#19968;&#20010;&#38590;&#24536;&#30340;&#32858;&#20250;!^0^contest^chinese^YES^magazine^ @ ^";
promo_list += "/--/1/2006/^vmage^Win, Meet & Greet^0^contest^english^YES^magazine^ @ ^";
promo_list += "/--/1/2006/^vmag^Pensonic with Friends&#32654;&#20029;&#32422;&#20250;^0^contest^chinese^YES^magazine^ @ ^";
promo_list += "/--/1/2006/^ifeel^&#20320;&#19982;Pensonic&#30340;&#27426;&#20048;&#26102;&#20809;&#23558;&#26377;&#26426;&#20250;&#36194;&#21462;&#20215;&#20540;RM1500 PMM 620R Pensonic Music Monster &#21809;&#26426;^0^contest^chinese^YES^magazine^ @ ^";
promo_list += "/--/1/2006/^cl^ROUGE - COOL Chinese New Year Party to WIN Pensonic 1 H/P Air Conditioner ^2^contest^chinese^YES^magazine^ @ ^";
promo_list += "/--/1/2006/^cl^&#25237;&#36873;&#20320;&#26368;&#21916;&#27426;&#30340;Pensonic&#20043;&#21451;^1^contest^chinese^YES^magazine^ @ ^";


//DECEMBER PROMOTIONS 2005
promo_list += "/--/12/2005/^--^Block Buster Month Promotion (Television)<br>1 Dec 2005 - 31 Jan 2006^0^promotion^chinese^pmo-o-001.htm^promo^ @ ^";
promo_list += "/--/12/2005/^jasm^&#21019;&#26032;&#21561;&#21457;&#39640;&#31185;&#25216; &#20813;&#25163;&#25552;&#21561;&#21457;&#26356;&#31616;&#20415; 6&#20301;&#21019;&#24847;&#20339;&#20316; &#23558;&#26377;&#26426;&#20250;&#36194;&#21462;&#20215;&#20540; RM600 &#30340; PRINCESS &#21561;&#39118;&#26426;&#22411;&#21495;5130^0^contest^chinese^YES^magazine^ @ ^";
//NOVEMBER PROMOTIONS 2005
//OCTOBER PROMOTIONS 2005
//SEPTEMBER PROMOTIONS 2005
promo_list += "/--/9/2005/^adv^Recipe Contest<br>Win a Pensonic Juice Extractor Today !^0^contest^english^YES^magazine^ @ ^";
//promo_list += "/--/9/2005/^--^Twin Rewards Promotion (Water Heater)<br>16 Sep - 15 Nov 2005^0^contest^chinese^pmo-o-001.htm^promo^ @ ^";
//AUGUST PROMOTIONS 2005
promo_list += "/--/8/2005/^vmag^V MAG &#35835;&#32773;&#38382;&#21367;&#35843;&#26597;2005^0^survey^chinese^YES^magazine^ @ ^";
//JULY PROMOTIONS 2005
promo_list += "/--/7/2005/^adv^Recipe Contest<br>Win a Pensonic Stand Mixer Today !^1^contest^english^YES^magazine^ @ ^";
promo_list += "/--/7/2005/^adv^Subsribe to Adsvantage today and get a Pensonic Coffee Maker^2^give away^english^YES^magazine^ @ ^";
//JUNE PROMOTIONS 2005
promo_list += "/--/6/2005/^adv^Recipe Contest<br>Win the lastest Pensonic Multi-cooker worth RM200 !^0^contest^english^YES^magazine^ @ ^";
//MAY PROMOTIONS 2005
promo_list += "/--/5/2005/^adv^Subsribe to Adsvantage today and get a Pensonic PSI-860 Dry Iron with spray worth RM 55.00^0^give away^english^YES^magazine^ @ ^";
//APRIL PROMOTIONS 2005
//MARCH PROMOTIONS 2005
promo_list += "/--/3/2005/^ajsr^Menangi Barangan Elektrik Pensonic^0^contest^malay^YES^magazine^ @ ^";
//FEBRUARY PROMOTIONS 2005
//JANUARY PROMOTIONS 2005




//get the value from the current page to compare the name as below
/*
var theTypeofPublicNm = new Array('press', 'magazine');

if (theNewsGroup!=''){ 
	for ( ag=0; ag<theTypeofPublicNm.length; ag++ ){
		if ( theNewsGroup == theTypeofPublicNm[ag] ){
			theListNm = eval(theTypeofPublicNm[ag]+'_list');
			theArryNm = theTypeofPublicNm[ag]+'_array';
		}
	}
}
*/
theListNm = eval('promo_list');
theArryNm = 'promo_array';
//


//Extraction of string variable to a total BIG array
var dataEk = DataExtract(theListNm,'^','^', theArryNm); //get the total number of array
var theArray = eval(theArryNm);
var theStep = 9;

//Division process
var PROMO_CLASS = new Array();
var PROMO_ARRAY = new Array();
var nexArr=0;


for ( ii=1; ii<dataEk; ii+=theStep ){
	
	if ( ii%theStep ){ nexArr++ }
	PROMO_CLASS[nexArr] = new PPromotionClass( theArray[ii], theArray[ii+1], theArray[ii+2], theArray[ii+3], theArray[ii+4],
	theArray[ii+5], theArray[ii+6], theArray[ii+7], theArray[ii+8] );
	PROMO_ARRAY[nexArr] = new Array( theArray[ii], theArray[ii+1], theArray[ii+2], theArray[ii+3], theArray[ii+4],
	theArray[ii+5], theArray[ii+6], theArray[ii+7], theArray[ii+8] );
}

/*
//-------------------------------------------------------------------------------------------------------------------
//List all for checking
//-------------------------------------------------------------------------------------------------------------------

var theDesTitle = new Array ();
for(i=0;i<theStep;i++){
	theDesTitle[i] = i+1;
}

theDocumentWrt="";
theDocumentWrt += "<table border=1 cellpadding=0 cellspacing=0 class=grey999-normal-10>";

//list out title
for (g=0;g<PROMO_ARRAY[1].length;g++){
	if (g==0) { theDocumentWrt+="<tr>" };
	if (theDesTitle[g]== null){ theDesTitle[g]=' . '; }
	theDocumentWrt += "<td>" + theDesTitle[g] + "</td>";
	if (g==PROMO_ARRAY[1].length-1) { theDocumentWrt+="</tr>" };
}

//list out the all 
for (j=1;j<PROMO_ARRAY.length;j++){
	theDocumentWrt += "<tr>";
	for (k=0;k<PROMO_ARRAY[j].length;k++){
		theDocumentWrt += "<td>" + PROMO_ARRAY[j][k] + "</td>";
	}
	theDocumentWrt += "</tr>";
} 

theDocumentWrt += "</table>";

document.write(theDocumentWrt);
*/