/**
set_div_content() is used to set up the content of DIV tag
!!!Need to have an <div></div> with the correct id in document!!!
**/

function set_div_content(div_name,content) {
	var obj;
	var value_str;
	obj = document.getElementById(div_name);
	value_str = '<img name="index_r41_c18" src="images/index_r41_c18.jpg" width="626" height="48" border="0" usemap="#m_index_r41_c18" alt="">'	
	obj.setAttribute("innerHTML", content)	
}	

/**
popup_win() is used to open a new window with some parameters (e.g. path,height,width,status,toolbar,menubar,location)
Sample:
You want to pop up a new window with the following conditions,
	1. this  (Must be added!! it used to define the parent window)
	2. Path? popup.htm
	3. Height? 400
	4. Width? 200
	5. Status Bar? Yes
	6. Tool Bar? No
	7. Menu Bar? No
	8. Location? No

You need to call,
	popup_win(this,"popup.htm","200","400","yes","no","no","no")
**/

function popup_win(win,win_path,win_h,win_w,win_status,win_toolbar,win_menubar,win_location) {
	var feature='';
	
	feature = addFeature(feature,"height",win_h);
	feature = addFeature(feature,"width",win_w);
	feature = addFeature(feature,"status",win_status);
	feature = addFeature(feature,"toolbar",win_toolbar);
	feature = addFeature(feature,"menubar",win_menubar);
	feature = addFeature(feature,"location",win_location);
	win.open(win_path,null,feature);	
}	

/**
addFeature() is used to concatenate the feature parameter of window.open
**/
function addFeature(str,w_name,fea_value) {
	if (str != '') {
		str += ',';
	}
	str = str + w_name + '=' + fea_value;
	return str;
}		

/**
setStatus() is used set the value in window status bar
**/	
function setStatus(win,win_status) {
	win.status = win_status
}	

/**
setTitle() is used set the value in window title bar
**/	
function setTitle(win,win_title) {
	win.document.title = win_title
}

/**
set_content_src() is used to assign the source file for each pages in IEDMR Web 
with some parameters (e.g. frame_name, source file, frame_height, frame_width, scroll_bar, frame_border)
Sample:
You want to set up the content frame with the following conditions,
	1. Frame Name? content_frame 
	2. Path? popup.htm
	3. Height? 400
	4. Width? 200
	5. Scroll Bar? Yes
	6. Frame Border? 0

You need to call,
	set_content_src("content_frame","sitemap.htm","653","621","no","0")
**/

function set_content_src(frame_name,frame_src,frame_h,frame_w,frame_scrollbar,frame_border) {
	var obj;
	obj = document.getElementById(frame_name);
	obj.setAttribute("FRAMEBORDER", frame_border)
	obj.setAttribute("width", frame_w)
	obj.setAttribute("HEIGHT", frame_h)
	obj.setAttribute("SRC", frame_src.toString().toLowerCase(), 0)
	obj.setAttribute("SCROLLING", frame_scrollbar)
}	

/**
pageName(str) is used to return the html file name of the current web page
**/
function pageName(str)
{
	//"[0-9]{4,4}\/{1,1}[0-1]{1,1}[0-9]{1,1}\/{1,1}[0-3]{1,1}[0-9]{1,1}" // format of "yyyy/mm/dd";
	var format = "\/[a-z0-9_-]+\\.htm";
	var regObj = new RegExp(format,"ig");
	var rtn = regObj.exec(str)
	
	if (rtn == null) {
		return "index.htm";
	} else {	
		rtn = rtn.toString().substr(1,rtn.toString().length)
		return rtn.toString().toLowerCase();
	}
	
}

/**
toLCase(str) is used to return lower case letter
**/
function toLCase(str)
{
	return str.toString().toLowerCase();
}


/**
Pull down menu in content page
**/
function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


