function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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 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
		window.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.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.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="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);
}