function see_article_from_date(f, p_index_of_from_date, p_menuid, p_parent_menuid, p_subject){
	v_date_value = eval("f.from_date_" + p_index_of_from_date + ".value");
	if (v_date_value!="")
	{
		window.location = "index.asp?menuid=" + p_menuid + "&parent_menuid=" + p_parent_menuid + "&fuseaction=" + p_subject + "&from_date=" + euro_us(v_date_value) + "&show_date=1" ;
	}
}
function check_keypress(f,p_fuseaction){
	key = event.keyCode;
	if (key==13){
		search_onclick(f,p_fuseaction);
	}	
}
function search_onclick(f,p_fuseaction)
{
	if (f.txt_search.value!="" && f.txt_search.value.length>1)
	{
		go_url = "index.asp?text=" + f.txt_search.value + "&fuseaction=" + p_fuseaction;
		window.location =  go_url ;
	}	
}

function search_onclick_frame(f,p_fuseaction)
{
	if (f.txt_search.value!="" && f.txt_search.value.length>1)
	{
		s = new String(window.parent.location);
		go_url = s.substring(0, s.lastIndexOf("index.asp")) + "index.asp?text=" + f.txt_search.value + "&fuseaction=" + p_fuseaction;
		//alert(go_url);
		window.parent.location =  go_url ;
	}	
}

function counter(f,p_fuseaction)
{
	selected=0;
	for (i=0;i<f.opt_answer.length;i++)
	{
		if (f.opt_answer(i).checked)
		{
			selected=1;
			break;
		}	
	}
	if (selected==1)
	{
		go_url = "index.asp?type=COUNTER&fuseaction=" + p_fuseaction + "&answer_id=" + f.opt_answer(i).value;
		window.location =  go_url ;
	}	
}

function display_result(p_question_id)
{
	go_url = "Counter/dsp_counter_result.asp?question_id=" + p_question_id
	window.open(go_url,null,"top=10,left=10,height=370,width=680,status=no,toolbar=no,scrollbars=yes,menubar=yes,location=no,directories=0,fullscreen:yes;");
}

function goto_url(p_url,p_open_new_win)
{
	if (p_open_new_win==1)
		open_me(p_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
	else{
		//document.parentWindow.location = p_url;	
		//alert (document.location);
		window.top.location = p_url;
	}
}

function goto_url_frame(p_url,p_open_new_win)
{
	if (p_open_new_win==1)
		open_me(p_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
	else
		window.parent.location = p_url;	
}

function onchange_link(f)
{
	if (f.sele_link.value=="-2")
		return;
	for (i=0; i<f.sele_link.length; i++) 
	{
		if (f.sele_link.options[i].selected) 
		{
			if (f.sele_link.options[i].new_win=="1")
				open_me(f.sele_link.options[i].goto_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
			else
				window.parent.location = f.sele_link.options[i].goto_url;
			return;
		}		
	}
}	
function onchange_eservice(f)
{
	if (f.sele_eservice.value=="")
		return;
	for (i=0; i<f.sele_eservice.length; i++) 
	{
		if (f.sele_eservice.options[i].selected) 
		{
			if (f.sele_eservice.options[i].new_win=="1")
				open_me(f.sele_eservice.options[i].goto_url, 0, 1, 1, 1, 1, 0, 1, 1, 300, 450, 0, 0);
			else
				window.parent.location = f.sele_eservice.options[i].goto_url;
			return;
		}		
	}
}
// open new window with some value
function open_me(url, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vHeight, vWidth, vTop, vLeft)	 
{
	winDef = '';
	winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('height=').concat(vHeight).concat(',');
	winDef = winDef.concat('width=').concat(vWidth).concat(',');

	if (vCentered)	{
		winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	}
	else	{
		winDef = winDef.concat('top=').concat(vTop).concat(',');
		winDef = winDef.concat('left=').concat(vLeft);
	}
	open(url, '_blank', winDef);
}

/*function to read doc of the article */
function read_doc(doc_id){
	var url="../../2007en/en/article/dsp_file_content.asp?id=" + doc_id;
	var the_window;
	the_window=window.open(url,null,"");
	the_window.focus();
}

function btn_save_idea_onclick(f,fuse){
	if (!verify(f))
		return false;
	f.action = "index.asp?type=QA&fuseaction=" + fuse ;
	f.submit();
}
//	Function set_selected set the i option to be checked if its value equals p_value
function set_selected(p_obj,p_value)
{
	for (i=0;i<p_obj.options.length;i++)
	{
		if (p_obj.options[i].value==p_value)
		{
			p_obj.options[i].selected = true;
			break;
		}	
	}
}
function DoCal(elTarget){
  if (showModalDialog)
  {
    var sRtn;
    sRtn = showModalDialog("../lib/calendar.htm","","dialogWidth=210pt;dialogHeight=180pt;status=no;scroll=no");
    if (sRtn!="")
      elTarget.value = sRtn;
  }
}  
function euro_us(theDate){
	strSeparator = ""
	if (theDate.indexOf("/")!=-1) strSeparator = "/";
	if (theDate.indexOf("-")!=-1) strSeparator = "-";
	if (theDate.indexOf(".")!=-1) strSeparator = ".";
	if (strSeparator == "")
		return "";
	parts=theDate.split(strSeparator);
	day=parts[0];
	month=parts[1];
	year=parts[2];
	return month + strSeparator + day + strSeparator + year.substr(0,4);
}

function resizeImageWithLink(max_width, width, height, objImage) {
	if (width > max_width)	{
		//alert (objImage.width + "||" + objImage.height);
		//objImage.realHeight = objImage.height;
		//objImage.realWidth = objImage.width;
		objImage.onclick = function () { openImage (objImage.src, height, width) };
		//objImage.width = max_width;
		objImage.className = "image_link";
	}
}

function resizeImageWithoutLink(max_width, objImage) {
	if (objImage.width > max_width)	{
		objImage.width = max_width;
	}
}

function openImage(vLink, vHeight, vWidth)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	if (sLink == '')
	{
		return false;
	}

	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<title>VTV.NET</title><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', 'Dong lai', '" border=0></a>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}
