/*

Handy functions for selecting stuff.

*/

function jumpTo(URL_List)
{
    var URL = URL_List.options[URL_List.selectedIndex].value;
    var txt = URL_List.options[URL_List.selectedIndex].text;

    if (URL != '' && URL != txt) {
	window.location.href = URL;
    }
}



MaxOptionLength = 30 ;

function CutOptionsValue(){
  // alert( document.location );
  tmp = document.getElementsByTagName('OPTION');
  for (i=0; i<tmp.length; i++) {
		// firefox doesn't define innerText
     if (tmp[i].innerText != undefined && tmp[i].innerText.length > MaxOptionLength) {
      tmp[i].innerText = tmp[i].innerText.substring(0, MaxOptionLength) + '...' ;
     }
  } // for
} // CutOptionsValue

onload = CutOptionsValue ;

// top.frame[1].
if( document.location.href.indexOf('id=101', 0) != -1 ) {
 MaxOptionLength = 60 ;
  // for Parthner page
}

//FLASH <-> HTML interaction
var flashwin;
var flashPeriodRequest;
function contentLink(url)
{
	top.focus();
	top.frames.content.location.href = url;
}

function showFlashTool(period_id)
{
	flashPeriodRequest = period_id;
	s = top.document.location.href;
	//path = s.substr(0, s.lastIndexOf("/")+1)+"timelines.html";
	path = "http://"+document.location.host+"/timelines.html";
	if (!flashwin || flashwin.closed)  {
		flashwin = top.open(path, "Flash",  getParamsString(796, 549, 0, 0) + ",menubar=0,resizable=1,location=0,scrollbars=0,toolbar=0,status=0");
		
	} else {
		flashwin.focus();
		flashwin.selectPeriod(period_id);
		
	}
	
}


function resetFlashWin()
{
	flashwin = 0;
}

function getParamsString(in_width, in_height, in_xOffset, in_yOffset)
{	
	return "width=" + in_width + ",height=" + in_height + ",left=" + ((screen.width-16-in_width)/2 + in_xOffset) + ",top=" + ((screen.height-60-in_height)/2 + in_yOffset);
}
