


function refresh(){

	var myForm = document.AnimationForm;
	var	 index = myForm.Product.selectedIndex;
	var	 typeid  = myForm.Product[index].value;

	var	 index = myForm.Region.selectedIndex;
	var	 regionid = myForm.Region[index].value;

	var	 index = myForm.Year.selectedIndex;
	var	 year  = myForm.Year[index].value;
	
	if(typeid == 0)		{alert(" Please select Data type"); return;};
	if(regionid == 0)	{alert(" Please select Region"); return;};
	if(year == 0)		{alert(" Please select Year"); return;};
	
	var regionnames = ["World","NorthAmerica","SouthAmerica","Africa","Europe","Asia","Australia", "USA", "Mexico",
			 "Argentina","Brazil","SouthAfrica","Rusia","China","India","Ukraine"];

	var imagetypes =["SMN","SMT","VCI","TCI","VHI","FireRisk","VHchangeWeekly","VHchangeYearly"];
  
	var rname= regionnames[regionid-1];
	var imagetype= imagetypes[typeid-1];
	
	var baseurl = getVHrootURL();
	  
	var colorbar= getColorBarURL(imagetype);
	
	var fname1= baseurl +"/" + year +"/" + rname + "_"+ imagetype +"_"+ year ;
	
	// the following variables are for animation; should be "global" variables.
	animation_name1 = fname1;	//the base "path/name" of the image set without the numbers
	animation_name2 = ".png";	//the base "path/name" of the image set without the numbers

	animation_first_image = 1;                    //first image number
	animation_last_image  = 52;                    //last image number

// 	animation_height = height;              //height of the images in the animation
// 	animation_width  = width;               //width of the images in the animation
	animation_colorbar = colorbar;


	var cur_week = getCurrentWeek();
	var cur_year = getCurrentYear() ;
	

	href = "vh_imageloop_showpage.php";
	if( year == cur_year ) animation_last_image = cur_week;

	if(imagetype == "DIFF_VTI_YEARLY" ){
		if( year == 1981) href="vh_imageloop_no_data.php";
		if( year == 1982) animation_first_image =35;
	}else 	if(imagetype == "DIFF_VTI_WEEKLY" && (year == 1981)){
		animation_first_image =36;
	}else if(imagetype == "DVT" && (year <= 1981) ) {
		animation_first_image =40;
	}else{
		if( year == 1981 ) animation_first_image =35;
	}
	 
	parent.ImageloopFrame.document.location.href = href;
}


function animation_createForm(rname,imagetype,year){
	var list_names =["Product","Region","Year"];
	var list_titles =["Select a data product","Select a region","Select a year"];
	var len= list_names.length;
	var s="" ;
	for (var i=0; i< len; i++){
		s =  s + "<select title='" + list_titles[i] + "' name='" + list_names[i] +"'>"
		if(i == 0)	s =  s + AnimationImageTypeList_ALL(imagetype);
		if(i == 1)  s =  s + AnimationRegionList(rname);
		if(i == 2)	s =  s + CalendarY(year);
		s = s +"</select>&nbsp;";
	}
	s =  s +"<input onclick='refresh();return true;' type='button' title='Load selected animation' value='Load animation'>";
	 
	document.writeln(s);
	return(s);
}

function imageloop_option(rname,imagetype,year){

	var baseurl=getVHrootURL();
    var cssfn = baseurl +"/images/vh_style.css";
  
	if(year == "CURRENT_YEAR") {
		var today	=new Date();
		var current_year	=today.getYear();
		if( current_year < 1000 )	  current_year += 1900 ;
		year= current_year;
	}
	
	document.writeln("<form name='AnimationForm'><div style='padding: 6px; background-color: #efefef; width: 60em; border: 1px solid #666666;'>");
	var s = animation_createForm(rname,imagetype, year);
	document.writeln("</div></form>");
	
}

