﻿// HI/LO switch for Sidebox (used in Top Page and some other)

function bg_in(obj, typ) {
	obj.style.cursor='pointer';
	if ( typ == '1' ){
		obj.style.backgroundImage='url(img/page_top/back_sidebox1_HI.gif)';
	} else {
		obj.style.backgroundImage='url(img/page_top/back_sidebox2_HI.gif)';
	}
}

function bg_out(obj, typ) {
	obj.style.cursor='default';
	if ( typ == '1' ){
		obj.style.backgroundImage='url(img/page_top/back_sidebox1_LO.gif)';
	} else {
		obj.style.backgroundImage='url(img/page_top/back_sidebox2_LO.gif)';
	}
}


// Content on/off switch for Centerbox (used in Top Page and some other)
function centerbox(id) {
	document.getElementById('centermenu1').src='img/page_top/logo_topcenter1_LO.gif';
	document.getElementById('centermenu2').src='img/page_top/logo_topcenter2_LO.gif';
	document.getElementById('centermenu3').src='img/page_top/logo_topcenter3_LO.gif';
	document.getElementById('centermenu4').src='img/page_top/logo_topcenter4_LO.gif';

	document.getElementById('centerdoc1').style.display = "none";
	document.getElementById('centerdoc2').style.display = "none";
	document.getElementById('centerdoc3').style.display = "none";
	document.getElementById('centerdoc4').style.display = "none";
	
	if ( id == '1' ){
		document.getElementById('centermenu1').src='img/page_top/logo_topcenter1_HI.gif';
		document.getElementById('centerdoc1').style.display = "";
	}
	else if ( id == '2' ){
		document.getElementById('centermenu2').src='img/page_top/logo_topcenter2_HI.gif';
		document.getElementById('centerdoc2').style.display = "";
	}
	else if ( id == '3' ){
		document.getElementById('centermenu3').src='img/page_top/logo_topcenter3_HI.gif';
		document.getElementById('centerdoc3').style.display = "";
	}
	else if ( id == '4' ){
		document.getElementById('centermenu4').src='img/page_top/logo_topcenter4_HI.gif';
		document.getElementById('centerdoc4').style.display = "";
	}
}


// Content on/off switch for NewsBox (used in NewsList Page)
function newsbox(id) {
	document.getElementById('newsmenu0').src='img/page_news/logo_select0_LO.gif';
	document.getElementById('newsmenu1').src='img/page_news/logo_select1_LO.gif';
	document.getElementById('newsmenu2').src='img/page_news/logo_select2_LO.gif';
	document.getElementById('newsmenu3').src='img/page_news/logo_select3_LO.gif';
	document.getElementById('newsmenu4').src='img/page_news/logo_select4_LO.gif';

	switch (id) {
		case '0': document.getElementById('newsmenu0').src='img/page_news/logo_select0_HI.gif'; break;
		case '1': document.getElementById('newsmenu1').src='img/page_news/logo_select1_HI.gif'; break;
		case '2': document.getElementById('newsmenu2').src='img/page_news/logo_select2_HI.gif'; break;
		case '3': document.getElementById('newsmenu3').src='img/page_news/logo_select3_HI.gif'; break;
		case '4': document.getElementById('newsmenu4').src='img/page_news/logo_select4_HI.gif'; break;
	}

	var elements = document.getElementsByTagName('div');
	for (var i=0; i<elements.length; i++){
		if (elements[i].className == 'news_gossip'
		  || elements[i].className == 'news_action'
		  || elements[i].className == 'news_topics'
		  || elements[i].className == 'news_trend' )
		{
			var onoff = 0;
			elements[i].style.display = "none";
			
			switch (id) {
				case '0': onoff=1; break;
				case '1': if (elements[i].className == 'news_gossip') onoff=1; break;
				case '2': if (elements[i].className == 'news_action') onoff=1; break;
				case '3': if (elements[i].className == 'news_topics') onoff=1; break;
				case '4': if (elements[i].className == 'news_trend') onoff=1; break;
			}
			
			if (onoff == 0){
				elements[i].style.display = "none";
			} else {
				elements[i].style.display = "";
			}
		}
	}
}


// Content on/off switch for Specials Pickup List
function spbox(obj, tgt) {
	// clear BG, hide contents
	var elements = document.getElementsByTagName('div');
	for (var i=0; i<elements.length; i++){
		if (elements[i].className == 'specials_listbox'){
			elements[i].style.backgroundColor = "f0ffd0";
		}
		if (elements[i].className == 'specials_dispbox'){
			elements[i].style.display = "none";
		}
	}
	
	// set BG & display content
	obj.style.backgroundColor = "#aaffaa";
	document.getElementById(tgt).style.display = "";
	
	// jump to top
	document.body.scrollTop=0;
}


// Content hover coloring for Specials Pickup List / Specials List
function spbox_in(obj) {
	var colorcode = obj.style.backgroundColor;
	obj.style.backgroundColor = "#aaffaa";
	if( colorcode != obj.style.backgroundColor ){
		obj.style.backgroundColor = "#ccffee";
	}
	obj.style.cursor='pointer';
}
function spbox_out(obj) {
	var colorcode = obj.style.backgroundColor;
	obj.style.backgroundColor = "#aaffaa";
	if( colorcode != obj.style.backgroundColor ){
		obj.style.backgroundColor = "#f0ffd0";
	}
	obj.style.cursor='default';
}


// News List content creator
function set_newslist(param_category, param_country, param_title, param_date, param_source, param_summary, param_url)
{
	document.write("<div class='news_"+param_category+"'>");
		document.write("<div style='float:left; width:60px; text-align:center;'>");
			document.write("<img src='img/flags/icon_flag_"+param_country+".gif' />");
		document.write("</div>");
		document.write("<div style='float:left; width:610px'>");
			document.write("<div class='newslist_title'>");
				document.write("<a href='"+param_url+"' target='_blank'>"+param_title+"</a>");
			document.write("</div>");
			document.write("<div class='newslist_source'>( "+param_date+" / "+param_source+" ) </div>");
			document.write("<div class='newslist'>"+param_summary+"</div>");
		document.write("</div>");
		document.write("<div style='clear:both'></div>");
	document.write("</div>");
}

// News List jump link setting
function set_newsmark(param_mark)
{
	document.write("<a name='"+param_mark+"'></a>");
}



// Specials Pickup List content creator
function set_specials_picklist(topflag, param_target, param_title, param_date, param_pic)
{
	var bgsetting;
	
	if (topflag==1) {
		bgsetting = "background-color: #aaffaa;";
	} else {
		bgsetting = "background-color: #f0ffd0;";
	}

	document.write("<div class='specials_listbox' style='height:86px; border:1px solid black; border-top:none; "+bgsetting+"' onclick=spbox(this,'"+param_target+"') onmouseover=spbox_in(this) onmouseout=spbox_out(this) >");
	document.write("<div style='float:left; width:110px; height:78px; margin-top:4px; margin-left:4px; text-align:center; border-right:1px solid #aaaaaa;'>");
	document.write("<img src='"+param_pic+"' onload='resize_img(this,105,76)' />");
	document.write("</div>");
	document.write("<div class='specials_list' style='float:left; width:215px; margin-top:4px; margin-left:10px; '>"+param_title+"<br />( "+param_date+" )");
	document.write("</div>");
	document.write("<div style='clear:both;'></div>");
	document.write("</div>");
}



// Specials List content creator
function set_specialslist(param_title, param_date, param_pic, param_article)
{
	document.write("<div style='height:86px; border:1px solid black; border-top:none; background-color: #f0ffd0;' onclick=\"window.open('article_"+param_article+".htm','_self')\" onmouseover=spbox_in(this) onmouseout=spbox_out(this) >");
	document.write("<div style='float:left; width:110px; height:78px; margin-top:4px; margin-left:4px; text-align:center; border-right:1px solid #aaaaaa;'>");
	document.write("<img src='"+param_pic+"' onload='resize_img(this,105,76)' />");
	document.write("</div>");
	document.write("<div class='specials_list' style='float:left; width:215px; margin-top:4px; margin-left:10px; '>"+param_title+"<br />( "+param_date+" )");
	document.write("</div>");
	document.write("<div style='clear:both;'></div>");
	document.write("</div>");
}



// IMG resizer
function resize_img(obj, max_width, max_height)
{
	if (obj.width > max_width || obj.height > max_height)
	{
		var pct_w = max_width / obj.width;
		var pct_h = max_height / obj.height;
		
		if (pct_h < pct_w) {
			obj.style.height = max_height+"px";
		}
		else {
			obj.style.width = max_width+"px";
		}
	}
}


