// get Map Functions, make request and get image back

var flightHeight = "";
var gTimes ;
var gFilePref ;
var gExt ;
var gbCross ;
var imageWidth =0;
var imageHeight=0 ;
var frameNo=-1 ;
var widthRatio=590 ;
var heightRatio=500 ;
var turnBack=false;
var reSet=true;
var widthOrig;
var heightOrig;

function closeWindow()
{
	window.close();
}
function openPBWxFolder(pdfid)
{
	var strURL = getServer() + "/view/foster_pb_wxfolder.cfm?pdfid="+pdfid;
	var sW= screen.width - 10;
	var sH=screen.height - 50;
 	newwin=window.open(strURL,'briefing_pb_wxfolder','left=10000,top=0,width='+sW +',height='+sH);
}
function openPB()
{
	var strURL = getServer() + "/view/foster_pb.cfm";
	var sW= screen.width - 10;
	var sH=screen.height - 50;
 	newwin=window.open(strURL,'briefing_pb','left=0,top=0,width='+sW +',height='+sH);
}
function changeServiceIFrame(url , h, w, x,y) {
//    document.myIframe.src =url;
  document.myServiceIframe.location =url;
  document.getElementById("myServiceIframe").height=Number(h) - Number(19);
  document.getElementById("myServiceIframe").width=w;
//    document.getElementById("myServiceIframe").left=x;
//	alert("XX:"+x+":"+h+":"+w+":"+y);
	var xPos=getAbsLeft(document.getElementById("movie") );
	var yPos=getAbsTop(document.getElementById("movie"));
	var yyPos= parseInt(yPos) + parseInt(y) + Number(16);
	//alert("XX:"+xPos+":"+y+":"+yPos+":"+yyPos);
  document.getElementById("myServiceIframe").style.left=xPos+"px";
  document.getElementById("myServiceIframe").style.top=yyPos+"px";
}

function changeIFrame(url , h, w, x,y) {
//	alert("XX:"+x);
//    document.myIframe.src =url;
  document.myIframe.location =url;
  document.getElementById("myIframe").height=h;
  document.getElementById("myIframe").width=w;
//    document.getElementById("myIframe").left=x;
	var xPos=getAbsLeft(document.getElementById("movie") );
	var yPos=getAbsTop(document.getElementById("movie"));
	var yyPos= parseInt(yPos) + parseInt(y);
// alert("XX:"+yyPos+":"+xPos);
   yyPos=  parseInt(y)+13;
  xPos -= 14;
// alert("1XX:"+yyPos+":"+xPos);
//	alert("XX:"+xPos+":"+y+":"+yPos+":"+yyPos);
  document.getElementById("myIframe").style.left=xPos+"px";
  document.getElementById("myIframe").style.top=yyPos+"px";
}
function getAbsLeft(el){
var l=el.offsetLeft;
  while((el=el.parentNode) && el!=document)
    l+=el.offsetLeft;
  return l;
}
function getAbsTop(el){
var t=el.offsetTop;
  while((el=el.parentNode) && el!=document)
    t+=el.offsetTop;
  return t;
}

function setServiceURLVisible(args) {
    document.getElementById("myServiceIframe").style.visibility = args ;
}
function changeServiceURL(args)
{
  var tmpStr = args.split(",");
//	alert("LENGTH:"+tmpStr.length);
  if(tmpStr.length == 5) {
    var url = tmpStr[0];
    var height = tmpStr[2];
    var width = tmpStr[1];
    var x = tmpStr[3];
    var y = tmpStr[4];
    changeServiceIFrame(url,height,width,x,y);
  }
}

function setURLVisible(args) {
    document.getElementById("myIframe").style.visibility = args ;
}
function changeURL(args)
{
  var tmpStr = args.split(",");
  if(tmpStr.length == 5) {
    var url = tmpStr[0];
    var height = tmpStr[2];
    var width = tmpStr[1];
    var x = tmpStr[3];
    var y = tmpStr[4];
    changeIFrame(url,height,width,x,y);
  }
}

function getMenuDisplayType() {
	var value = getCookie('menu_type');
	var list = value.split(':');
	if(list.length <= 1) {
		return "";
	}
	else {
		return value.replace(list[0]+':','');
	}
}

function clearCookie(key) {
	document.cookie = key + "=" + "deleted; expires=Tue, 1-Jan-1980 00:00:00;";
}

function getCookieAfterClear(key) {
	var value = getCookie(key);
	clearCookie(key);
	return value;
}

function getCookie(key) {
	//alert("getTmpCookie start");
	var name = key + "=";
	var cookieValue = document.cookie + ";";
	var start = cookieValue.indexOf(name);
	if(start != -1){
		var end = cookieValue.indexOf(";", start);
		var value = unescape(cookieValue.substring(start + name.length, end));
		//document.cookie = key + "=" + "del; expires=Tue, 1-Jan-1980 00:00:00;";
		//alert(key+" : "+value);
		return value;
	}
	return "";
}

function setCookie(key, value) {
	//alert("setTmpCookie start");
	//alert("setCookie "+key+" : "+value);
	var tmp = key + "=" + escape(value) + "; ";
	tmp += "expires=Tue, 31-Dec-2030 23:59:59; ";

	//alert("tmp : "+tmp)
	clearCookie(key);
	document.cookie = tmp;
	//alert("document.cookie : "+document.cookie)
}

function movie_DoFSCommand(command, args) {
	//alert("movie_DoFSCommand start\n"+args);
  if (command == "changeURL")
  {
    changeURL(args);
  }else if( command == "closeWindow")
  {
    closeWindow(args);
  }else if( command == "openPBWxFolder")
  {
    openPBWxFolder(args);
  }else if( command == "openPB")
  {
    openPB(args);
  }else if( command == "setURLVisible")
  {
    setURLVisible(args);
  }else if( command == "setServiceURLVisible")
  {
    setServiceURLVisible(args);
  }else if( command == "changeServiceURL")
  {
    changeServiceURL(args);
  }
	if(command.indexOf("cookie&") >= 0) {
		var tmpStr = command.split("&");
		if(tmpStr.length == 2) {
			var key = tmpStr[1];
			setCookie(key, args);
		}
	}
}

function getCheckedValue(name,def_value) {
	for(var t=0;t<document.getElementsByName(name).length;t++) {
		if(document.getElementsByName(name)[t].checked) {
			return document.getElementsByName(name)[t].value;
		}
	}
	return def_value;
}

function showhide(id){
	if(document.getElementById){
		if(document.getElementById(id).style.display == "block")
			document.getElementById(id).style.display = "none";
		else
			document.getElementById(id).style.display = "block";
	}
}

function getHttpHead() {
	var url = window.location.href;
	url = url.split('/');
	
	var httpHead = url[0] + url[1]  ;
	return httpHead;
}

function getServer() {
	var url = window.location.href;
	url = url.split('/');
	var server = url[0] + url[1] + '//' + url[2];
	return server;
}
function viewfunction(viewWidth){
	if(viewWidth==1024)
	{
		widthRatio = 800;
		heightRatio = 620;
	}
	if(viewWidth==1280)
	{
		widthRatio = 1030;
		heightRatio = 670;
	}
}
// check to see if the user is an admin user
function checkLogin(argUsername,argPassword, b800, b1024, b1280){
	doLoading();
		var argWidth = 800;
	if( b1024 )
		 argWidth = 1024;
	if( b1280 )
		 argWidth = 1280;
//	alert('ggg');
    var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.checkLogin&username=' + argUsername + '&password=' + argPassword + '&width=' + argWidth,'updateAdminMessage','text');
//	alert(getServer() + '/c/action.cfm?evt=' + urlEvt);
    xmlhttp.doXmlhttp();

//window.location=getServer() + '/index.cfm?iaX=admin.checkLogin';
//	doLoading();
}

function getLayers(){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.loadLayers','displaylayers','text');
	xmlhttp.doXmlhttp();
}

function getLayerForEdit(){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.loadLayersEditor','displaylayerseditor','text');
	xmlhttp.doXmlhttp();
}

function getLayerForDelete(){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.loadLayersDelete','displaylayers','text');
	xmlhttp.doXmlhttp();
}

function populateEditor(argId){
	document.getElementById('layerName').value = document.getElementById(argId).childNodes[3].innerHTML;
	document.getElementById('displayName').value = document.getElementById(argId).childNodes[5].innerHTML;
	document.getElementById('id').value = argId;
	document.getElementById('layerRequest').value = document.getElementById(argId).childNodes[17].childNodes[0].value;
	for(var i=0;i < document.getElementById('layerType').length;i++){
		//alert(document.getElementById('layerType')[i].innerHTML);
		//alert(document.getElementById(argId).childNodes[9].innerHTML);
		if(document.getElementById(argId).childNodes[9].innerHTML == document.getElementById('layerType')[i].innerHTML){
			document.getElementById('layerType')[i].selected = true;
		}
	}
	for(var iz=0;iz < document.getElementById('deleted').length;iz++){
		//alert(document.getElementById('layerType')[i].innerHTML);
		if(document.getElementById(argId).childNodes[11].innerHTML == document.getElementById('deleted')[iz].innerHTML){
			//alert(document.getElementById('deleted')[iz].innerHTML);
			//alert(document.getElementById(argId).childNodes[11].innerHTML);
			document.getElementById('deleted')[iz].selected = true;
		}
	}
	for(var iz=0;iz < document.getElementById('fosterType').length;iz++){
		//alert(document.getElementById('layerType')[i].innerHTML);
		if(document.getElementById(argId).childNodes[13].innerHTML == document.getElementById('fosterType')[iz].innerHTML){
			//alert(document.getElementById('deleted')[iz].innerHTML);
			//alert(document.getElementById(argId).childNodes[11].innerHTML);
			document.getElementById('fosterType')[iz].selected = true;
		}
	}
	for(var iz=0;iz < document.getElementById('layerSource').length;iz++){
		//alert(document.getElementById('layerType')[i].innerHTML);
		if(document.getElementById(argId).childNodes[15].innerHTML == document.getElementById('layerSource')[iz].innerHTML){
			//alert(document.getElementById('deleted')[iz].innerHTML);
			//alert(document.getElementById(argId).childNodes[11].innerHTML);
			document.getElementById('layerSource')[iz].selected = true;
		}
	}
}

function deleteEntry(argId){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.deleteSelectedLayer&layerID=' + argId,'displaylayersdelete','text');
	xmlhttp.doXmlhttp();
}

function updateLayerGroup(nameValue,groupID,deleted){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.updateLayerGroup&nameValue=' + nameValue + '&groupID=' + groupID + '&deleted=' + deleted,'updatelayergroup','text');
	xmlhttp.doXmlhttp();
}

function deleteLayerGroup(groupID){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.deleteLayerGroup&groupID=' + groupID,'showdeletedgroups','text');
	xmlhttp.doXmlhttp();
}

function assignLayers(groupid,layerlist){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.updateLayerGroupsLayers&groupid=' + groupid + '&layerlist=' + layerlist,'updatelayergroupview','text');
	xmlhttp.doXmlhttp();
}

function removeLayer(layerid){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.removeLayerGroupJunction&layerid=' + layerid,'redrawlayerStuff','text');
	xmlhttp.doXmlhttp();
}

function setHir(parentGroup,childGroup,plevel){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.saveHierarchy&parentGroup=' + parentGroup + '&childGroup=' + childGroup + '&plevel=' + plevel,'showHeirarchyInformation','text');
	xmlhttp.doXmlhttp();
}

function updateHir(parentGroup,childGroup,plevel,id) {
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.updateHierarchy&parentGroup=' + parentGroup + '&childGroup=' + childGroup + '&plevel=' + plevel + '&id=' + id,'showUpdatedHeirarchyInformation','text');
	xmlhttp.doXmlhttp();
}

function assignGroup(groupName,serviceMenu,id){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.reassignGroupToServiceMenu&groupName=' + groupName + '&serviceMenu=' + serviceMenu + '&id=' + id,'updateUIforAssignServiceMenu','text');
	xmlhttp.doXmlhttp();
}

function updateUser(firstName,lastName,userGreeting,userEmail,companyName,companyID,admin,username,password,id,userActive,shortCode,boundingBox,chatInfo){
	doLoading();
	var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.updateSaveUser&firstName=' + firstName + '&lastName=' + lastName + '&userEmail=' + userEmail + '&companyName=' + companyName + '&companyID=' + companyID + '&admin=' + admin + '&username=' + username + '&password=' + password + '&id=' + id + '&userGreeting=' + userGreeting + '&userActive=' + userActive + '&shortcode=' + shortCode + '&boundingbox=' + boundingBox + '&chatInfo=' + chatInfo,'showUserUpdate','text');
	xmlhttp.doXmlhttp();
}

/* Functions for text section */

function icaolistFocus(){
	var sub = document.textSearchForm.submenuvalues;
	if(sub[0].checked == false){
		 sub[0].checked = true;
	}
}

function getTimeStringOfFaxChart(nowTime){
	var year = nowTime.getUTCFullYear();
	var month = nowTime.getUTCMonth() + 1;
	var date = nowTime.getUTCDate();
	var hour = nowTime.getUTCHours();
	var minutes = nowTime.getUTCMinutes();
	var seconds = nowTime.getUTCSeconds();

	hour = Math.floor((hour > 0 ? hour-1 : hour)/3) * 3;
	var ret = year+(month/10 >= 1 ? "" : "0")+month+(date/10 >= 1 ? "" : "0")+date+(hour/10 >= 1 ? "" : "0")+hour+"0000";
	return ret;
}

function textSearch(startrow,sortrow,argUsername){
// Loop through the search option section and find the checked value
    var nowtime = new Date().getTime();
    var searchOption = document.textSearchForm.textoption;
    //alert('test sear user = '+argUsername);
       
    for(var l=0;l < searchOption.length;l++){
        if(searchOption[l].checked){
            mainSearchOption = searchOption[l].value;
            //alert(mainSearchOption);
        }
    }
    if(mainSearchOption == null){
        alert('Please make a selection from the main menu');
        return;
    }
    switch (mainSearchOption) {
        case 'metars_tafs_notams':
            if(document.getElementById('metar').checked){
                var productString = document.getElementById('metar').value;
            }
            if(document.getElementById('taf').checked){
                productString = document.getElementById('taf').value + "," + productString;
            }
            if(document.getElementById('notam').checked){
                productString = document.getElementById('notam').value + "," + productString;
            }
            var sub = document.textSearchForm.submenuvalues;
            for(var m=0;m < sub.length;m++){
                //alert(sub[m].value);
                if(sub[m].checked){
                    submenuOptions = sub[m].value;
                }
            }
            if(submenuOptions == null){
                alert('Please make a selection from the submenu.');
                return;
            }
            var timeFrom = document.getElementById('time_from').value;
            var timeTo = document.getElementById('time_to').value;
            // set icao up to pass in a station list
            if(submenuOptions == 'icao'){
                var icaolist = document.getElementById('icaolist').value;
								n = 0;
                var icaoListTmp = icaolist;
								do {
                 n = icaoListTmp.indexOf(",");
								if( n>-1){
                 var icaoTmp = icaoListTmp.replace(",","&");
                 icaoListTmp = icaoTmp;
								}
								} while (n >-1 );

								n = 0;
								do {
                 n = icaoListTmp.indexOf("&");
								if( n>-1){
                 var icaoTmp = icaoListTmp.replace("&","','");
                 icaoListTmp = icaoTmp;
								}
								} while (n >-1 );

                var icaolist = "'" + icaoListTmp;
                var icaolist = icaolist + "'";
                //var icaolist = icaolist.replace(",","','");
                //alert(icaolist);
            }else{
                var icaolist = "";
            }
            //alert(submenuOptions);
            //switch (submenuOptions) {
             //   case 'north_east':
              //      var icaolist = "'KACK','KACY','KALB','KBGR','KBOS','KBTV','KBUF','KBWI','KCLE','KCMH','KCVG','KDCA','KDTW','KEAU','KEWR','KFWA','KGRB','KGRR','KHPN','KHYA','KIAD','KIND','KISP','KJFK','KLGA','KMDW','KMKE','KMQT','KMSN','KMYV','KORD','KORF','KPHL','KPIA','KPIT','KPSM','KPVD','KPWM','KRIC','KROA'";
               //     break;
            //    case 'central':
             //       var icaolist = "'KAMA','KAUS','KBIS','KDFW','KDLH','KDSM','KELP','KFAR','KFYV','KHOU','KIAH','KICT','KLIT','KLNK','KMCI','KMSP','KMSY','KOKC','KOMA','KPIR','KSAT','KSHV','KSTL','KTOP','KTUL'";
              //      break;
             //   case 'west':
              //      var icaolist = "'KABQ','KBIL','KBOI','KCOS','KCPR','KCYS','KDEN','KFAT','KFLG','KGEG','KGTF','KLAS','KLAX','KLGB','KONT','KPDX','KPHX','KPSP','KRDD','KRNO','KSAC','KSAN','KSEA','KSFO','KSJC','KSLC','KTUS'";
              //      break;
            //     var icaolist = "'KATL','KBHM','KBNA','KCAE','KCHS','KCLT','KEYW','KFLL','KGSO','KJAN','KJAX','KMCO','KMEM','KMIA','KMOB','KMYR','KPAH','KPBI','KRDU','KSAV','KSDF','KTLH','KTPA','KTYS'";
            //        break;
            //    case 'canada':
            //        var icaolist = "'CYEG','CYOW','CYUL','CYWG','CYYC','CYYZ','CYVR'";
            //        break;
           //     case 'caribbean':
            //        var icaolist = "'TAPA','TNCA','TXKF','TBPB','TNCC','TFFF','TGPY','MUHA','MUHG','MKJP','MKJS','TJNR','SVMG','MDPP','TTPP','TFFR','MDSD','TJSJ','MDST','TIST','TISX','TNCM','TTCP'";
           //         break;
           //     case 'central_america':
            //        var icaolist = "'MMAA','MMLO','MZBZ','MMUN','MMGL','MGGT','MMBT','MMLP','MMMX','MNMG','MMMD','MMMY','MMMZ','MPTO','MMPR','MSLP','MHLM','MROC','MHTG'";
          //          break;
          //      case 'south_america':
          //          var icaolist = "'SCFA','SCAR','SGAS','SKBQ','SBBE','SKBO','SBBR','SBBV','SCIE','SVMI','SKCL','SBCF','SKCG','SPZO','SAEZ','SBGL','SBGR','SEGU','SPQT','SPIM','SLLP','SBEG','SVMC','KMDZ','SUMU','SPSO','SBPA','SBPV','SBRB','SARE','SACO','SCEL','SBSN','SEQU','SLVR'";
          //          break;
          //      case 'europe':
           //         var icaolist = "'EBBR','EHAM','LEBB','LEBL','LEIB','LEMD','LEMG','LEMH','LEPA','LEST','LEVC','LEZL','LFPG','LFPO','LIMC','LIPZ','LIRF','LPPT'";
          //          break;
          //      case 'north_atlantic':
          //          var icaolist = "'BGBW','BGSF','BIKF','BIRK','CYFB','CYHZ','CYJT','CYQM','CYYR','CYYT','EGPH','EGPK','EIDN','EINN','LPAZ','LPLA'";
          //          break;
          //      case 'pacific':
          //          var icaolist = "'PANC','RJCC','RJTT','PHNL','PHTO','RJBB','RJAA','PHOG'";
         //           break;
           //     case 'china':
        //        	var icaolist = '';//"'ZBAA','ZBCF','ZBCZ','ZBDT','ZBHD','ZBHH','ZBLA','ZBMZ','ZBOW','ZBSJ','ZBTJ','ZBTL','ZBUH','ZBUL','ZBXH','ZBYC','ZBYN','ZGBH','ZGCD','ZGCJ','ZGDY','ZGGG','ZGHA','ZGKL','ZGLG','ZGMX','ZGNN','ZGOW','ZGSD','ZGSZ','ZGZH','ZGZJ','ZHCC','ZHCY','ZHES','ZHHH','ZHLY','ZHNY','ZHXF','ZHYC','ZJHK','ZJSY','ZLAK','ZLDH','ZLGM','ZLHZ','ZLIC','ZLJQ','ZLLL','ZLQY','ZLXN','ZLXY','ZLYA','ZLYL','ZMUB','ZPBS','ZPDL','ZPDQ','ZPJH','ZPLC','ZPLJ','ZPMS','ZPPP','ZPSM','ZPWS','ZPZT','ZSAM','ZSCG','ZSCN','ZSDY','ZSFZ','ZSGS','ZSGZ','ZSHC','ZSJD','ZSJJ','ZSJN','ZSJU','ZSLG','ZSLQ','ZSLY','ZSNB','ZSNJ','ZSNT','ZSOF','ZSPD','ZSQD','ZSQZ','ZSSS','ZSTX','ZSWF','ZSWH','ZSWX','ZSWY','ZSWZ','ZSXZ','ZSYN','ZSYT','ZSYW','ZSZS','ZUBD','ZUCK','ZUDX','ZUGH','ZUGY','ZUJZ','ZULS','ZULZ','ZUMY','ZUNC','ZUNP','ZUNZ','ZUTR','ZUUU','ZUWX','ZUXC','ZUYB','ZUYI','ZUZH','ZWAT','ZWCM','ZWKL','ZWKM','ZWSH','ZWTN','ZWWW','ZWYN','ZYCC','ZYCY','ZYDD','ZYHB','ZYHE','ZYJM','ZYJZ','ZYMD','ZYQQ','ZYTL','ZYTX','ZYYJ','VHHH','VMMC'";  
            //    	var icaolist = "'RCKH','RCSS','RCTP','RPLB','RPLI','RPLL','RPMD','RPMZ','RPVM','VHHH','VMMC','ZBAA','ZBCF','ZBCZ','ZBDT','ZBHD','ZBHH','ZBLA','ZBMZ','ZBOW','ZBSJ','ZBTJ','ZBTL','ZBUH','ZBUL','ZBXH','ZBYC','ZBYN','ZGBH','ZGCD','ZGCJ','ZGDY','ZGGG','ZGHA','ZGKL','ZGLG','ZGMX','ZGNN','ZGOW','ZGSD','ZGSZ','ZGZH','ZGZJ','ZHCC','ZHCY','ZHES','ZHHH','ZHLY','ZHNY','ZHXF','ZHYC','ZJHK','ZJSY','ZLAK','ZLDH','ZLGM','ZLHZ','ZLIC','ZLJQ','ZLLL','ZLQY','ZLXN','ZLXY','ZLYA','ZLYL','ZMUB','ZPBS','ZPDL','ZPDQ','ZPJH','ZPLC','ZPLJ','ZPMS','ZPPP','ZPSM','ZPWS','ZPZT','ZSAM','ZSCG','ZSCN','ZSDY','ZSFZ','ZSGS','ZSGZ','ZSHC','ZSJD','ZSJJ','ZSJN','ZSJU','ZSLG','ZSLQ','ZSLY','ZSNB','ZSNJ','ZSNT','ZSOF','ZSPD','ZSQD','ZSQZ','ZSSS','ZSTX','ZSWF','ZSWH','ZSWX','ZSWY','ZSWZ','ZSXZ','ZSYN','ZSYT','ZSYW','ZSZS','ZUBD','ZUCK','ZUDX','ZUGH','ZUGY','ZUJZ','ZULS','ZULZ','ZUMY','ZUNC','ZUNP','ZUNZ','ZUTR','ZUUU','ZUWX','ZUXC','ZUYB','ZUYI','ZUZH','ZWAT','ZWCM','ZWKL','ZWKM','ZWSH','ZWTN','ZWWW','ZWYN','ZYCC','ZYCY','ZYDD','ZYHB','ZYHE','ZYJM','ZYJZ','ZYMD','ZYQQ','ZYTL','ZYTX','ZYYJ'";  
        //    		break;
       //     }
            if(productString.length <= 2) {
                alert('You Haven\'t Selected a Product.  Please select METARs, TAFs, or NOTAMs to complete your search');
            } else {
                doLoading();
						var httpstr = getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues='+ submenuOptions + '&startrow=' + startrow + '&sortrow=' + sortrow + "&times=" + timeFrom+ ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime + '&argUsername=' + argUsername;
                var xmlhttp = new Request(httpstr,'showTextResults','text');
       //         var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + submenuOptions + '&startrow=' + startrow + '&sortrow=' + sortrow + "&times=" + timeFrom + ',' + timeTo + '&icaolist=' + icaolist,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            }
        break;
        case 'sigmets':
        // get main menu stuff
            if(document.getElementById('icing').checked){
                var productString = document.getElementById('icing').value;
            }
            if(document.getElementById('turb').checked){
                productString = document.getElementById('turb').value + "," + productString;
            }
            if(document.getElementById('conv').checked){
                productString = document.getElementById('conv').value + "," + productString;
            }
            if(document.getElementById('volcanic').checked){
                productString = document.getElementById('volcanic').value + "," + productString;
            }
            if(document.getElementById('sand').checked){
                productString = document.getElementById('sand').value + "," + productString;
            }
            if(document.getElementById('tropical').checked){
                productString = document.getElementById('tropical').value + "," + productString;
            }
            if(productString.length <= 2){
                alert('You Haven\'t Selected a Product.  Please select from the submenu below your main text choice to continue');
                return;
            }
        // get time stuff
            var timeFrom = document.getElementById('time_from').value;
            var timeTo = document.getElementById('time_to').value;
       // get massive amount of submenu stuff
            if(document.getElementById('susa').checked){
                var subProductString = document.getElementById('susa').value;
            }
            if(document.getElementById('snorth_east').checked){
                subProductString = document.getElementById('snorth_east').value + "," + subProductString;
            }
            if(document.getElementById('scentral').checked){
                subProductString = document.getElementById('scentral').value + "," + subProductString;
            }
            if(document.getElementById('swest').checked){
                subProductString = document.getElementById('swest').value + "," + subProductString;
            }
            if(document.getElementById('ssouth_east').checked){
                subProductString = document.getElementById('ssouth_east').value + "," + subProductString;
            }
            if(document.getElementById('salaska').checked){
                subProductString = document.getElementById('salaska').value + "," + subProductString;
            }
            if(document.getElementById('seastern_canada').checked){
                subProductString = document.getElementById('seastern_canada').value + "," + subProductString;
            }
            if(document.getElementById('swestern_canada').checked){
                subProductString = document.getElementById('swestern_canada').value + "," + subProductString;
            }
            if(document.getElementById('scarribbean').checked){
                subProductString = document.getElementById('scarribbean').value + "," + subProductString;
            }
            if(document.getElementById('scentral_america').checked){
                subProductString = document.getElementById('scentral_america').value + "," + subProductString;
            }
            if(document.getElementById('ssouth_america').checked){
                subProductString = document.getElementById('ssouth_america').value + "," + subProductString;
            }
            if(document.getElementById('swestern_europe').checked){
                subProductString = document.getElementById('swestern_europe').value + "," + subProductString;
            }
            if(document.getElementById('seastern_europe').checked){
                subProductString = document.getElementById('seastern_europe').value + "," + subProductString;
            }
            if(document.getElementById('smiddle_east').checked){
                subProductString = document.getElementById('smiddle_east').value + "," + subProductString;
            }
            if(document.getElementById('scentral_asia').checked){
                subProductString = document.getElementById('scentral_asia').value + "," + subProductString;
            }
            if(document.getElementById('srussia_kazakhstan').checked){
                subProductString = document.getElementById('srussia_kazakhstan').value + "," + subProductString;
            }
            if(document.getElementById('seastern_asia').checked){
                subProductString = document.getElementById('seastern_asia').value + "," + subProductString;
            }
            if(document.getElementById('ssoutheast_asia').checked){
                subProductString = document.getElementById('ssoutheast_asia').value + "," + subProductString;
            }
            if(document.getElementById('saustralia').checked){
                subProductString = document.getElementById('saustralia').value + "," + subProductString;
            }
            if(document.getElementById('safrica').checked){
                subProductString = document.getElementById('safrica').value + "," + subProductString;
            }
            if(document.getElementById('snorth_atlantic').checked){
                subProductString = document.getElementById('snorth_atlantic').value + "," + subProductString;
            }
            if(document.getElementById('swest_atlantic').checked){
                subProductString = document.getElementById('swest_atlantic').value + "," + subProductString;
            }
            if(document.getElementById('scentral_atlantic').checked){
                subProductString = document.getElementById('scentral_atlantic').value + "," + subProductString;
            }
            if(document.getElementById('ssouth_atlantic').checked){
                subProductString = document.getElementById('ssouth_atlantic').value + "," + subProductString;
            }
            if(document.getElementById('snorth_pacific').checked){
                subProductString = document.getElementById('snorth_pacific').value + "," + subProductString;
            }
            if(document.getElementById('scentral_pacific').checked){
                subProductString = document.getElementById('scentral_pacific').value + "," + subProductString;
            }
            if(document.getElementById('ssouth_pacific').checked){
                subProductString = document.getElementById('ssouth_pacific').value + "," + subProductString;
            }
            if(document.getElementById('sindian_ocean').checked){
                subProductString = document.getElementById('sindian_ocean').value + "," + subProductString;
            }
            if(document.getElementById('schina').checked){
                subProductString = document.getElementById('schina').value + "," + subProductString;
            }
            if(subProductString.length <= 2){
                alert('You Haven\'t Selected a Sub-Product.  Please select from the submenu to the right to continue');
                return;
            }
            var icaolist = "";
             doLoading();
             //alert("productString:"+productString);
             var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
             xmlhttp.doXmlhttp();
             setAutoUpdate(startrow);
        break;
        case 'watches':
        // get the main menu stuff
            if(document.getElementById('ts').checked){
                var productString = document.getElementById('ts').value;
            }
            if(document.getElementById('tn').checked){
                productString = document.getElementById('tn').value + "," + productString;
            }
            if(productString.length <= 2){
                alert('You Haven\'t Selected a Product.  Please select from the submenu below your main text choice to continue');
                return;
            }
        // get the submenu stuff
        // get time stuff
            var timeFrom = document.getElementById('time_from').value;
            var timeTo = document.getElementById('time_to').value;
        // do request
            var icaolist = "";
            var subProductString = "";
             doLoading();
             var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
             xmlhttp.doXmlhttp();
             setAutoUpdate(startrow);
        break;
        case 'airmets':
        // get the main menu stuff
            if(document.getElementById('aicing').checked){
                var productString = document.getElementById('aicing').value;
            }
            if(document.getElementById('aturb').checked){
                productString = document.getElementById('aturb').value + "," + productString;
            }
            if(productString.length <= 2 || productString == null){
                alert('You Haven\'t Selected a Product.  Please select from the submenu below your main text choice to continue');
                return;
            } 
        // get the sub stuff
            if(document.getElementById('ausa').checked){
                var subProductString = document.getElementById('ausa').value;
            }
            if(document.getElementById('anorth_east').checked){
                subProductString = document.getElementById('anorth_east').value + "," + subProductString;
            }
            if(document.getElementById('asouth_east').checked){
                subProductString = document.getElementById('asouth_east').value + "," + subProductString;
            }
            if(document.getElementById('anorth_central').checked){
                subProductString = document.getElementById('asouth_central').value + "," + subProductString;
            }
            if(document.getElementById('anorth_west').checked){
                subProductString = document.getElementById('asouth_west').value + "," + subProductString;
            }
            if(document.getElementById('aalaska').checked){
                subProductString = document.getElementById('aalaska').value + "," + subProductString;
            } 
            if(document.getElementById('hhawaii').checked){
                subProductString = document.getElementById('hhawaii').value + "," + subProductString;
            }
            if(subProductString.length <= 2){
                alert('You Haven\'t Selected a Sub-Product.  Please select from the submenu to the right to continue');
                return;
            }
         // get time stuff
            var timeFrom = document.getElementById('time_from').value;
            var timeTo = document.getElementById('time_to').value;
        // do request
            var icaolist = "";
             doLoading();
             var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
             xmlhttp.doXmlhttp();
             setAutoUpdate(startrow);
        break;
        case 'pireps':
            //get the submenu stuff
            var sub1 = document.textSearchForm.pirep_type_values;
            for(var m=0;m < sub1.length;m++){
                //alert(sub1[m].value);
                if(sub1[m].checked){
                    submenuOptions1 = sub1[m].value;
                }
            }
            var sub2 = document.textSearchForm.pirep_intensity_values;
            for(var m=0;m < sub2.length;m++){
                //alert(sub2[m].value);
                if(sub2[m].checked){
                    submenuOptions2 = sub2[m].value;
                }
            }
            var sub3 = document.textSearchForm.pirep_region_values;
            for(var m=0;m < sub3.length;m++){
                //alert(sub3[m].value);
                if(sub3[m].checked){
                    submenuOptions3 = sub3[m].value;
                }
            }
            if(submenuOptions1 != "" && submenuOptions1 != "other"){
                submenuOptions = submenuOptions1;
            }else{
                submenuOptions = " ";
            }
            if(submenuOptions2 != ""){
                submenuOptions = submenuOptions2 + "|" + submenuOptions;
            }else{
                submenuOptions = " " + "|" + submenuOptions;
            }
            if(submenuOptions3 != ""){
                submenuOptions = submenuOptions3 + "|" + submenuOptions;
            }else{
                submenuOptions = " " + "|" + submenuOptions;
            }  
            if(submenuOptions == null){
                alert('Please make a selection from the submenu to the right.');
                return;
            }
            var timeFrom = document.getElementById('time_from').value;
            var timeTo = document.getElementById('time_to').value;
            // set icao up to pass in a station list
            if(submenuOptions1 == 'other'){
                var icaolist = document.getElementById('pirep_free_text').value;
                submenuOptions = "other" + "|" + submenuOptions;
                //alert(icaolist);
            }else{
                var icaolist = "";
                submenuOptions = " " + "|" + submenuOptions;
            }
            //alert(submenuOptions);
            var productString = "";
            if(submenuOptions.length <= 2) {
                alert('You Haven\'t Selected a Product.  Please select PIREPs to complete your search');
            } else {
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + submenuOptions + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            }
            break;
            case 'volcanic_ash':
                if(document.getElementById('eastern_asia').checked){
                    var subProductString = document.getElementById('eastern_asia').value;
                }
                if(document.getElementById('southeast_asia').checked){
                    subProductString = document.getElementById('southeast_asia').value + "," + subProductString;
                }
                if(document.getElementById('southcentral_pacific').checked){
                    subProductString = document.getElementById('southcentral_pacific').value + "," + subProductString;
                }
                if(document.getElementById('north_pacific').checked){
                    subProductString = document.getElementById('north_pacific').value + "," + subProductString;
                }
                if(document.getElementById('canada_northwestern').checked){
                    subProductString = document.getElementById('canada_northwestern').value + "," + subProductString;
                } 
                if(document.getElementById('central_america').checked){
                    subProductString = document.getElementById('central_america').value + "," + subProductString;
                }
                if(document.getElementById('southern_south_america').checked){
                    subProductString = document.getElementById('southern_south_america').value + "," + subProductString;
                }
                if(document.getElementById('north_atlantic').checked){
                    subProductString = document.getElementById('north_atlantic').value + "," + subProductString;
                }
                if(document.getElementById('europe_africa').checked){
                    subProductString = document.getElementById('europe_africa').value + "," + subProductString;
                }
                if(subProductString.length <= 2){
                    alert('You Haven\'t Selected a Sub-Product.  Please select from the submenu to the right to continue');
                    return;
                }
                var timeFrom = document.getElementById('time_from').value;
                var timeTo = document.getElementById('time_to').value;
                //alert(submenuOptions);
                var productString = "";
                var icaolist = "";
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            break;
            case 'airport_status':
                var productString = "";
                var icaolist = "";
                var timeFrom = "";
                var timeTo = "";
                var subProductString = "";
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            break;
			case 'convective_outlook':
                var productString = "";
                var icaolist = "";
               	var timeFrom = document.getElementById('time_from').value;
                var timeTo = document.getElementById('time_to').value;
                var day = document.getElementById('day_from_frm').value;
                var subProductString = "";
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + ',' + day + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            break;
            case 'winds_aloft':
                var productString = "";
                var icaolist = "";
               	var timeFrom = document.getElementById('time_from').value;
                var timeTo = document.getElementById('time_to').value;
                // get the sub stuff
	            if(document.getElementById('winds_alaska').checked){
	                var subProductString = document.getElementById('winds_alaska').value;
	            }
	            if(document.getElementById('winds_canada').checked){
	                subProductString = document.getElementById('winds_canada').value + "," + subProductString;
	            }
	            if(document.getElementById('winds_hawaii').checked){
	                subProductString = document.getElementById('winds_hawaii').value + "," + subProductString;
	            }
	            if(document.getElementById('winds_norway').checked){
	                subProductString = document.getElementById('winds_norway').value + "," + subProductString;
	            }
	            if(document.getElementById('winds_oceania').checked){
	                subProductString = document.getElementById('winds_oceania').value + "," + subProductString;
	            }
	            if(document.getElementById('winds_usa').checked){
	                subProductString = document.getElementById('winds_usa').value + "," + subProductString;
	            }
	            if(subProductString.length <= 1){
	                alert('You Haven\'t Selected a Sub-Product.  Please select from the submenu to the right to continue');
	                return;
	            }
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            break;
            case 'tropical':
                var productString = "";
                var icaolist = "";
               	var timeFrom = document.getElementById('time_from').value;
                var timeTo = document.getElementById('time_to').value;
                var subProductString = "";
                doLoading();
                var xmlhttp = new Request(getServer() + '/index.cfm?iaX=foster.text.ajaxInterface&bigproduct=' + mainSearchOption + '&product=' + productString + '&submenuvalues=' + subProductString + '&startrow=' + startrow + '&sortrow=' + sortrow + '&times=' + timeFrom + ',' + timeTo + '&icaolist=' + icaolist + '&now=' + nowtime,'showTextResults','text');
                xmlhttp.doXmlhttp();
                setAutoUpdate(startrow);
            break;
    }
}

function setAutoUpdate(start){
 if(typeof(intV) == "undefined"){
	    intV = setInterval('textSearch(' + start + ',1)', 180000);
	}
}
function printText(){

	//alert("text print:");
	var textResult = document.getElementById('text_body_display_results').innerHTML;
	//alert(textResult.length);
	if(textResult.length==0) return;
  	newwin=window.open('','printwin','left=10,top=10,width=660,height=720')
  	newwin.document.open();
	newwin.document.write('<HTML>\n<HEAD>\n')
 	newwin.document.write('<title>Weathernews FOSTER</title>\n')
  	newwin.document.write('</HEAD>\n')
  	newwin.document.write('<BODY >\n')
	newwin.document.write('<link rel="stylesheet" href="view/styles/textstyle.css" type="text/css" />\n')
	//alert(textResult);
newwin.document.write(textResult);
  	newwin.document.write('</BODY>\n')
  	newwin.document.write('</HTML>\n')
  	newwin.document.close();
  	newwin.print();
	newwin.close();
}

function clearAutoUpdate(startrow){
    if(typeof(intV) != "undefined"){
        clearInterval(intV);
        intV = null;
        intV = setInterval('textSearch(' + startrow + ',1)',180000);
    }
}

/* Charts Scripts */

function makeSelection(optArg){
    // change image
    clearFrame();
		gbCross = false;
    var idarr = optArg.split("_");
    var images = document.getElementsByTagName('img');
    for(var i=0;i < images.length;i++){
        if(images[i].src.indexOf("_on.png") != -1 && images[i].src.indexOf("btn_charts01_on.png") == -1){
        newSrc = images[i].src.replace('_on.png',".png");
        images[i].src = newSrc;
        }
    }
    if(idarr.length == '2'){
        var origSrc = document.getElementById(idarr[1]).src;
        newSrc = origSrc.replace('.png',"_on.png");
        document.getElementById(idarr[1]).src = newSrc;
    } else {
        var origSrc = document.getElementById(optArg).src;
        newSrc = origSrc.replace('.png',"_on.png");
        document.getElementById(idarr[0]).src = newSrc;
    }
    switch(optArg){
        case 'stabilityindices':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/EXTERNAL/stability",".png");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
			break;
		case 'ASAS':
		case 'BOM-SIGWX':
		case 'CH-SIGWX-SOUTH':
		case 'CH-SIGWX100-250':
		case 'CH-SIGWX250-450':
   		case 'CH-SIGWX250-100':
   		case 'CH-WINTEM200':
		case 'CH-WINTEM300':
		case 'CH-WINTEM500':
   		case 'CH-WINTEM250':
		case 'CH-WINTEM400':
		case 'FBJP':
		case 'FSAS':
		case 'KMA-SIGWX':
		case 'PGAE05':
		case 'PGBE05':
		case 'PGBE99':
		case 'PGCE05':
		case 'PGCE14':
		case 'PGDE14':
		case 'PGDE29':
		case 'PGEE05':
		case 'PGGE05':
		case 'PGIE05':
		case 'PGJE05':
		case 'PGKE05':
		case 'PGNE14':
		case 'PGRE05':
		case 'PGSE05':
		case 'PGZE05':
		case 'PGZE14':
		case 'PWSD20':
		case 'PWSD25':
		case 'PWSD30':
		case 'PWSD40':
		case 'PWSD50':
		case 'PWSE20':
		case 'PWSE25':
		case 'PWSE30':
		case 'PWSE40':
		case 'PWSE50':
		case 'QHQA17':
		case 'QPAA99':
		case 'QUNA00':
		case 'QWAA00':
			var typeName =optArg.replace(/-/g, "_");
	//		alert(optArg+" : " +typeName );
			var nowTime = new Date();
			gTimes = new Array();
			gTimes[0] = getTimeStringOfFaxChart(nowTime);
			imageWidth =0;
			imageHeight=0 ;
//alert( gTimes[0]);
			createLoadingInit(gTimes[0]);
			var xmlhttp = new Request(getServer() + 
				'/index.cfm?iaX=foster.charts.t4chart&typeName='+typeName+'&idtime='+gTimes[0]+'','changeDivsForT4Chart','text');
			xmlhttp.doXmlhttp();
		break;
	//----------------------------------------------------	

	  case 'europesurface':
	   	 	 var typeName="MSLP_EURO_";
     
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'00\',\'MSLP_EURO_00\');">00</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'MSLP_EURO_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'MSLP_EURO_12\');">12</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'18\',\'MSLP_EURO_18\');">18</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'24\',\'MSLP_EURO_24\');">24</a> | <a class="jlink"  onMouseOver="createDivsForImgWidthData(\'36\',\'MSLP_EURO_36\');">36</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'48\',\'MSLP_EURO_48\');">48</a>';
            
            createDivsForImgWidthData('00',typeName+"00");
		break;
		case 'northatlanticsurface':
			 var typeName="MSLP_TATL_";
			 document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'00\',\'MSLP_TATL_00\');">00</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'MSLP_TATL_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'MSLP_TATL_12\');">12</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'18\',\'MSLP_TATL_18\');">18</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'24\',\'MSLP_TATL_24\');">24</a> | <a class="jlink"  onMouseOver="createDivsForImgWidthData(\'36\',\'MSLP_TATL_36\');">36</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'48\',\'MSLP_TATL_48\');">48</a>';
            
            createDivsForImgWidthData('00',typeName+"00");
		break;
			
	  case 'ussurface':	
	  	   var typeName="MSLP_NAMER_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'00\',\'MSLP_NAMER_00\');">00</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'MSLP_NAMER_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'MSLP_NAMER_12\');">12</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'18\',\'MSLP_NAMER_18\');">18</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'24\',\'MSLP_NAMER_24\');">24</a> | <a class="jlink"  onMouseOver="createDivsForImgWidthData(\'36\',\'MSLP_NAMER_36\');">36</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'48\',\'MSLP_NAMER_48\');">48</a>';
            
            createDivsForImgWidthData('00',typeName+"00");
		break;
		
//--------------------		
		case 'fpg_usa':	
	  	   var typeName="FPG_US_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'03\',\'FPG_US_03\');">03</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_US_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'09\',\'FPG_US_09\');">09</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_US_12\');">12</a>';
            
            createDivsForImgWidthData('03',typeName+"03");
		break;
		
		
		case 'fpg_caribbean':	
	  	   var typeName="FPG_CARIB_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'03\',\'FPG_CARIB_03\');">03</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_CARIB_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'09\',\'FPG_CARIB_09\');">09</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_CARIB_12\');">12</a>';
            
            createDivsForImgWidthData('03',typeName+"03");
           
		break;
		
		case 'fpg_northatlantic':	
	  	   var typeName="FPG_NATL_";
	  	   	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_NATL_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_NATL_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
   
		break;
		
		case 'fpg_northpacific':	
	  	   var typeName="FPG_NPAC_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_NPAC_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_NPAC_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
		break;
		
		
		
		case 'fpg_southamerica':	
	  	   var typeName="FPG_SAMER_";
	  	  document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_SAMER_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_SAMER_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
		break;
		
		
		
		case 'fpg_asia':	
	  	   var typeName="FPG_ASIA_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_ASIA_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_ASIA_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
		break;
		
		
		case 'fpg_europe':	
	  	   var typeName="FPG_EURO_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_EURO_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_EURO_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
		break;
	
		case 'fpg_korea':	
	  	   var typeName="FPG_KOREA_";
	  	   document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="createDivsForImgWidthData(\'06\',\'FPG_KOREA_06\');">06</a> | <a class="jlink" onMouseOver="createDivsForImgWidthData(\'12\',\'FPG_KOREA_12\');">12</a>';
            
            createDivsForImgWidthData('06',typeName+"06");
		break;
//----------------------------------------------------		
	
		
		
        case 'typhoonAA':
        case 'typhoonSI':
        case 'typhoonAS':
        case 'typhoonWP':
        case 'typhoonEP':
        case 'typhoonCP':
        case 'typhoonSP':
        case 'typhoonBB':
					gbCross = true;
			var typeName =optArg.replace(/-/g, "_");
		//	alert(optArg+" : " +typeName );
			var nowTime = new Date();
			gTimes = new Array();
			gTimes[0] = getTimeStringOfFaxChart(nowTime);
			imageWidth =0;
			imageHeight=0 ;
//alert( gTimes[0]);
			createLoadingInit(gTimes[0]);
			var xmlhttp = new Request(getServer() + 
				'/index.cfm?iaX=foster.charts.typhoon&typeName='+typeName+'&idtime='+gTimes[0]+'','changeDivsForTyphoon','text');
			xmlhttp.doXmlhttp();
		break;
       /* case 'fpg_usa':
            times = new Array();
            times[0] = "03";
            times[1] = "06";
            times[2] = "09";
            times[3] = "12";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_US_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'03\',\'03|06|09|12\');">03</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'03|06|09|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'09\',\'03|06|09|12\');">09</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'03|06|09|12\');">12</a>';
        	showFrame('03','03|06|09|12');
		break;
        case 'fpg_asia':
            times = new Array();
            times[0] = "06";
            times[1] = "12";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_ASIA_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
       		showFrame('06','06|12');
	   break;
       case 'fpg_caribbean':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
//           times[2] = "09";
//           times[3] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_CARIB_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> |  <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
           showFrame('06','06|12');
		break;
        case 'fpg_europe':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_EURO_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
       	   showFrame('06','06|12');
	    break;
        case 'fpg_northatlantic':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_NATL_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
           showFrame('06','06|12');
		break;
       case 'fpg_korea':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_KOREA_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
           showFrame('06','06|12');
		break;
        case 'fpg_northpacific':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_NPAC_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
           showFrame('06','06|12');
		break;
        case 'fpg_southamerica':
           times = new Array();
           times[0] = "06";
           times[1] = "12";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FPG_SAMER_",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'06\',\'06|12\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'06|12\');">12</a>';
           showFrame('06','06|12');
		break;*/
        case 'centralpacific':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_CPAC",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'easternpacific':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_EPAC",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'gulfofmexico':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_GULF",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'tropicalatlantic':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_TATL",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'westernatlantic':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_WATL",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'westernpacific':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROP_WPAC",".jpg");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'driftdownip':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            document.getElementById('fleveltimes').innerHTML = 'Flight Levels: <span id="flight_radio"><input id="flevel" onClick="setFlightLevel(100);makeSelection(\'driftdownip\');" name="flevel" type="radio" value="100" /> 100 </span><br /><div id="timeX"></div>';
            if(getFlightLevel() == ""){
				setFlightLevel(100);
			}
			var flightLevel = getFlightLevel();
            var sub3 = document.getElementsByTagName('input');
            for(var m=0;m < sub3.length;m++){
                //alert(sub3[m].value);
                if(sub3[m].value == flightLevel){
                       sub3[m].checked = true;
                }
            }
            if(flightLevel.length == 0){
                return;
            }
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/DD_ICING_TATL_" + flightLevel + "_",".jpg");
            document.getElementById('timeX').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24\');">24</a>';
            showFrame('00','00|06|12|18|24');
		break;
       /* case 'ussurface':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            times[5] = "36";
            times[6] = "48";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/MSLP_NAMER_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24|36|48\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24|36|48\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24|36|48\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24|36|48\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24|36|48\');">24</a> | <a class="jlink" onMouseOver="showFrame(\'36\',\'00|06|12|18|24|36|48\');">36</a> | <a class="jlink" onMouseOver="showFrame(\'48\',\'00|06|12|18|24|36|48\');">48</a>';
            showFrame('00','00|06|12|18|24|36|48');
		break;
        case 'northatlanticsurface':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            times[5] = "36";
            times[6] = "48";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/MSLP_TATL_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24|36|48\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24|36|48\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24|36|48\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24|36|48\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24|36|48\');">24</a> | <a class="jlink" onMouseOver="showFrame(\'36\',\'00|06|12|18|24|36|48\');">36</a> | <a class="jlink" onMouseOver="showFrame(\'48\',\'00|06|12|18|24|36|48\');">48</a>';
            showFrame('00','00|06|12|18|24|36|48');
		break;
        case 'europesurface':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            times[5] = "36";
            times[6] = "48";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/MSLP_EURO_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24|36|48\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24|36|48\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24|36|48\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24|36|48\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24|36|48\');">24</a> | <a class="jlink" onMouseOver="showFrame(\'36\',\'00|06|12|18|24|36|48\');">36</a> | <a class="jlink" onMouseOver="showFrame(\'48\',\'00|06|12|18|24|36|48\');">48</a>';
            showFrame('00','00|06|12|18|24|36|48');
		break;*/
        case 'freezinglevel':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FRZLV_TATL_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24\');">24</a>';
            showFrame('00','00|06|12|18|24');
		break;
        case 'fuelfreeze':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            times[4] = "24";
            document.getElementById('fleveltimes').innerHTML = 'Flight Levels: <span id="flight_radio"><input id="flevel" onClick="setFlightLevel(200);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="200" checked /> 200 | <input id="flevel" onClick="setFlightLevel(250);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="250" /> 250 | <input id="flevel" onClick="setFlightLevel(300);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="300" /> 300 | <input id="flevel" onClick="setFlightLevel(340);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="340" /> 340 | <input id="flevel" onClick="setFlightLevel(390);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="390" /> 390 | <input id="flevel" onClick="setFlightLevel(420);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="420" /> 420 | <input id="flevel" onClick="setFlightLevel(440);makeSelection(\'fuelfreeze\');" name="flevel" type="radio" value="440" /> 440</span><br /><div id="timeX"></div>';
			if(getFlightLevel() == ""){
				setFlightLevel(200);
			}
            var flightLevel = getFlightLevel();
            var sub3 = document.getElementsByTagName('input');
            for(var m=0;m < sub3.length;m++){
                //alert(sub3[m].value);
                if(sub3[m].value == flightLevel){
                       sub3[m].checked = true;
                }
            }
            if(flightLevel.length == 0){
                return;
            }
            createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/FUEL_FRZ_TATL_" + flightLevel + "_",".jpg");
            document.getElementById('timeX').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24\');">24</a>';
            
			showFrame('00','00|06|12|18|24');
		break;
        case 'sigwxhigh':
            times = new Array();
            times[0] = "00";
            times[1] = "06";
            times[2] = "12";
            times[3] = "18";
            createDivsForImgWidth(times,"https://aviationweather.gov/data/products/swh/PGIE07_","_CL_new.gif");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18\');">18</a>';
            showFrame('00','00|06|12|18');
		break;
        case 'sigwxlow':
            times = new Array();
            times[0] = "12";
            times[1] = "18";
            times[2] = "00";
            times[3] = "06";
            createDivsForImgWidth(times,"https://aviationweather.gov/data/products/swl/ll_","_4_cl_new.gif");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18\');">18</a>';
            showFrame('00','00|06|12|18');
		break;

        case 'tropopause':
           times = new Array();
           times[0] = "00";
           times[1] = "06";
           times[2] = "12";
           times[3] = "18";
           times[4] = "24";
           createDivsForImgWidth(times,"https://beacon.wni.com/INTERNAL/TROPO_TATL_",".jpg");
            document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00|06|12|18|24\');">00</a> | <a class="jlink" onMouseOver="showFrame(\'06\',\'00|06|12|18|24\');">06</a> | <a class="jlink" onMouseOver="showFrame(\'12\',\'00|06|12|18|24\');">12</a> | <a class="jlink" onMouseOver="showFrame(\'18\',\'00|06|12|18|24\');">18</a> | <a class="jlink" onMouseOver="showFrame(\'24\',\'00|06|12|18|24\');">24</a>';
           showFrame('00','00');
		break;
        case 'wxdepiction':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/EXTERNAL/depiction",".png");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'weatherwatches':
           times = new Array();
           times[0] = "00";
           createDivsForImgWidth(times,"https://beacon.wni.com/MCIDAS/charts/WATCH_WARN_NA",".GIF");
           document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\'00\',\'00\');">Current</a>';
           showFrame('00','00');
		break;
        case 'tfrs':
           var tfWin = CreateWindow('http://tfr.faa.gov/tfr2/list.html','800','800','tfrlist');
           var tfrWin = CreateWindow('http://tfr.faa.gov/tfr_map_ims/html','800','800','tfrdisplay');
        break;
		case 'arrivaldemand':
			var adWin = CreateWindow('http://www.fly.faa.gov/Products/AADC/aadc.html','800','800');
		break;
    }
}

function CreateWindow(url,width,height,winname){
	var myWin = window.open(url,winname,'width=' + width + ',height=' + height + ',scrollbars=yes,resize=yes');
	return myWin;
}

function setFlightLevel(fl){
    flightHeight = fl;
}

function getFlightLevel(){
    return flightHeight;
}

function printImageOnly(){
	if( gbCross)
	{
		printImageCrossOnly();
		return;
	}
	var widthP = 650;
	var heightP = 700;
	var imageW = imageWidth;
	var imageH = imageHeight;

	if( frameNo < 0)
		return;

  newwin=window.open('','printwin','left=10,top=10,width=660,height=720')
  newwin.document.open();
  newwin.document.write('<HTML>\n<HEAD>\n')
  newwin.document.write('<title>Weathernews FOSTER</title>\n')
  newwin.document.write('</HEAD>\n')
  newwin.document.write('<BODY>\n')
  for(var t=0;t<gTimes.length;t++){
		if( gTimes[t] != frameNo)
			continue;
		var	obj = document.getElementById( "chart_" + gTimes[t] );
		if( obj.width > widthP || obj.height > heightP)
		{
			imageWidth = obj.width;
			imageHeight = obj.height;
			if( imageWidth * heightP/ widthP > imageHeight)
			{
				imageW = widthP;
				imageH = widthP*imageHeight/imageWidth;
			}else
			{
				imageH = heightP ;
        imageW = heightP* imageWidth/imageHeight;
			}
		}else
		{
			imageH = obj.height;
			imageW = obj.width;
		}
    if(gFilePref.charAt(gFilePref.length - 1) == '_'){
			if( gFilePref.indexOf('http') == -1){
       chart="<img id='chart_'" + gTimes[t] + "' src='view/images/chart_images/" + gFilePref + gTimes[t] + gExt + "' ";
     	}else {
      	chart="<img id='chart_'" + gTimes[t] + "' src='" + gFilePref + gTimes[t] + gExt + "' ";
    	}
		}else {
      if(gFilePref.indexOf('http') == -1 && gExt.length > 0){
          chart = "<img id='chart_'" + gTimes[t] + "' src='view/images/chart_images/" + gFilePref + gExt + "' ";
      } else {
        chart = "<img id='chart_'" + gTimes[t] + "' src='" + gFilePref + gExt + "' ";
       // chart.setAttribute("width",gFilePref + gExt);
    	} 
  	}
		break;
  }
	newwin.document.write(chart + " width=" + imageW + " height=" + imageH + " />");
  newwin.document.write('</BODY>\n')
  newwin.document.write('</HTML>\n')
  newwin.document.close();
  newwin.print();
	newwin.close();
}
function printImageCrossOnly(){
	var widthP = 1000;
	var heightP = 690;
	var imageW = imageWidth;
	var imageH = imageHeight;

	if( frameNo < 0)
		return;

  newwin=window.open('','printwin','left=10,top=10,width=1020,height=700')
  newwin.document.open();
  newwin.document.write('<HTML>\n<HEAD>\n')
  newwin.document.write('<title>Weathernews FOSTER</title>\n')
  newwin.document.write('</HEAD>\n')
  newwin.document.write('<BODY>\n')
  for(var t=0;t<gTimes.length;t++){
		if( gTimes[t] != frameNo)
			continue;
		var	obj = document.getElementById( "chart_" + gTimes[t] );
		if( obj.width > widthP || obj.height > heightP)
		{
			imageWidth = obj.width;
			imageHeight = obj.height;
			if( imageWidth * heightP/ widthP > imageHeight)
			{
				imageW = widthP;
				imageH = widthP*imageHeight/imageWidth;
			}else
			{
				imageH = heightP ;
        imageW = heightP* imageWidth/imageHeight;
			}
		}else
		{
			imageH = obj.height;
			imageW = obj.width;
		}
    if(gFilePref.charAt(gFilePref.length - 1) == '_'){
			if( gFilePref.indexOf('http') == -1){
       chart="<img id='chart_'" + gTimes[t] + "' src='view/images/chart_images/" + gFilePref + gTimes[t] + gExt + "' ";
     	}else {
      	chart="<img id='chart_'" + gTimes[t] + "' src='" + gFilePref + gTimes[t] + gExt + "' ";
    	}
		}else {
      if(gFilePref.indexOf('http') == -1 && gExt.length > 0){
          chart = "<img id='chart_'" + gTimes[t] + "' src='view/images/chart_images/" + gFilePref + gExt + "' ";
      } else {
        chart = "<img id='chart_'" + gTimes[t] + "' src='" + gFilePref + gExt + "' ";
       // chart.setAttribute("width",gFilePref + gExt);
    	} 
  	}
		break;
  }
	newwin.document.write(chart + " width=" + imageW + " height=" + imageH + " />");
  newwin.document.write('</BODY>\n')
  newwin.document.write('</HTML>\n')
  newwin.document.close();
  newwin.print();
	newwin.close();
}

function doChartError(pcode){
   document.getElementById( 'chart_' + pcode).src="/view/images/chart_error.png";
   var load = document.getElementById( 'loading');
//alert( load);
   document.getElementById( pcode).removeChild( load);
}

var gnameList="";

function changeDivsForTyphoon(text){
	var times = text.split(",");
	var name1="";
	var filename1=text;
	var iLen = times.length / 2;
	var nameList = "";
	var nameFirst = "";
	var bFirst = true;
		
	//newstr=text.replace(/^\s+|\s+$/g, "");

//	alert("changeDivsForTaphoon:"+filename1+":"+text+":"+name1);
		for(var t=0;t < iLen;t++){
			var iPos = t*2;
			var iFilePos = iPos + 1;
			var filenameT = "";
			var nameT = "";
			if( iFilePos >= times.length)
			{
				nameList = filename1;
				nameT = filename1;
				filenameT = filename1;
				nameFirst = filename1;
			
			}else
			{
				filenameT = times[iFilePos];
				nameT = times[iPos];
				nameT = nameT.replace(/^\s+|\s+$/g, "");
				if(bFirst)
				{
					nameList = nameT;
					nameFirst = nameT;
					gFilePref = filenameT;
					gExt = "";
					bFirst = false;
				}else 
				{
					nameList=nameList + "|"+ nameT;
				}
			}
      createLoadingInit(nameT);

	try{
		var imgStr = "<img name='my_chart'"+nameT+" id='chart_" + nameT + 
			"' src='" + filenameT + 
		"' onClick='imageClick(event);' onError='doChartError("+nameT+");' />";
		chart = document.createElement(imgStr);
		document.getElementById(nameT).appendChild(chart);
	} catch (e) {
	//alert("changeDivsForTaphoon:"+filenameT+":"+text+":"+nameT);
		//chart = document.createElement("img"+ nameT);
		chart = document.createElement("img");
		chart.setAttribute("id", "chart_"+nameT);
		chart.setAttribute("src","" + filenameT+"");
		chart.setAttribute("onClick", ("imageClick(event);"));
		document.getElementById(nameT).appendChild(chart);
	}
		}

	gTimes = nameList.split("|");
	var strHTML = '';

	if( times.length > 1)
	{
		for(var i=0;i< iLen;i++){
			var iPos = i*2;
			var iFilePos = iPos + 1;
			if( iPos >= times.length || iFilePos >= times.length)
				continue;
			var nameTD = times[iPos];
			nameTD = nameTD.replace(/^\s+|\s+$/g, "");
			var filenameTD = times[iFilePos];
			if( i==0){
				strHTML = ' <a class="jlink" style="color:#FFFFFF" onMouseOver="testMouseOver(\''+nameTD+'\');">'+nameTD+'</a>';
			}else
			{
				strHTML = strHTML + ' <a> | </a>  <a class="jlink" style="color:#FFFFFF" onMouseOver="testMouseOver(\''+nameTD+'\');">'+nameTD+'</a>';
			}
		}
	}else
	{
		strHTML = ' <a class="jlink" onMouseOver="showFrame(\''+nameT+'\',\''+nameList+'\');">'+name1+'</a>';
	}
	document.getElementById('fleveltimes').innerHTML = '<a> Tropical Weather: </a> '+strHTML ;
//	showFrame(gTimes[0],gTimes[0]);
	showFrame(nameFirst,nameList);
	gnameList = nameList;

}
function testMouseOver(nameT)
{
	showFrame(nameT,gnameList);
}
//----------------
function changeDivsForT4ChartData(text){
//alert('changeDivsForT4ChartData='+text);	
	newstr=text.replace(/^\s+|\s+$/g, "");
	//cur_tm=newstr.substring(newstr.length-6,newstr.length-4);
	try{
		gFilePref = newstr;
			//alert("changeDivsForT4Chart text  :  "+newstr);
		gExt = "";
		var imgStr = "<img name='my_chart' id='chart_" + gTimes[0] + 
			"' src='" + newstr + "' onClick='imageClick(event);' onError='doChartError(gTimes[0]);' />";
//alert(imgStr);		
chart = document.createElement(imgStr);
//alert("chart="+chart);
		document.getElementById(gTimes[0]).appendChild(chart);
	} catch (e) {
//alert(e);

		chart = document.createElement("img");
    chart.setAttribute("name","my_chart");		
    chart.setAttribute("id","chart_" + gTimes[0]);
		//chart.setAttribute("src","" + gTimes[0]);
   chart.setAttribute("src",text);
		chart.setAttribute("onClick", ("imageClick(event);"));
    chart.setAttribute("onError",("doChartError(gTime[0]);"));
		document.getElementById(gTimes[0]).appendChild(chart);
	}
	showFrame(gTimes[0],gTimes[0]);
}
//---------------------
function changeDivsForT4Chart(text){
//alert(text);	
newstr=text.replace(/^\s+|\s+$/g, "");

	//alert("changeDivsForT4Chart text:"+newstr);
	try{
		gFilePref = newstr;
		gExt = "";
//alert( gTimes[0]);
		var imgStr = "<img name='my_chart' id='chart_" + gTimes[0] + 
			"' src='" + newstr + "' onClick='imageClick(event);' onError='doChartError(gTimes[0]);' />";
		chart = document.createElement(imgStr);
		document.getElementById(gTimes[0]).appendChild(chart);
	} catch (e) {
		chart = document.createElement("img");
		chart.setAttribute("name","my_chart");
    chart.setAttribute("id","chart_" + gTimes[0]);
	//	chart.setAttribute("src","" + gTimes[0]);
    chart.setAttribute("src",text);
		chart.setAttribute("onClick", ("imageClick(event);"));
	chart.setAttribute("onError",("doChartError(gTime[0]);"));	
document.getElementById(gTimes[0]).appendChild(chart);
	}
	document.getElementById('fleveltimes').innerHTML = 'Valid Times: <a class="jlink" onMouseOver="showFrame(\''+gTimes[0]+'\',\''+gTimes[0]+'\');">Current</a>';
	showFrame(gTimes[0],gTimes[0]);

}
	
function imageClick()
{
	var init=true;	
	for(var t=0;t < gTimes.length;t++){
		var	obj = document.getElementById( "chart_" + gTimes[t] );
		//alert("index:" + t + " obj:"+obj.style.display);
		//alert("index:" + t + " obj:"+obj.width);
	       if(!turnBack)
		{
                    if( obj.width >0 )
	     		{
				if(imageWidth!=0&&imageWidth!=obj.width&&t>0) init=false;
				imageWidth = obj.width;
				imageHeight = obj.height;
				reSet = false;
			}
			if( imageHeight * widthRatio/ heightRatio < imageWidth)
				{					

				obj.width = widthRatio;
				obj.height = widthRatio*imageHeight/imageWidth;				
				}else
				{
				obj.height = heightRatio ;
				obj.width = heightRatio* imageWidth/imageHeight;
				}
		}else
		{
			obj.width = widthOrig;
            		obj.height = heightOrig;
//alert("widthOrig :" + widthOrig+"heightOrig ="+heightOrig);
			reSet=true;
		}
	}
	if(!reSet){
		if(init)
		{
		  widthOrig = imageWidth;
	  	  heightOrig = imageHeight;}
		//alert("widthOrig :" + widthOrig+"heightOrig ="+heightOrig); 
		 turnBack = true;
		  }else{
			turnBack=false;
		}
}

function createLoadingInit(name) {
	try {
//alert('createLoadingInit');
		element = document.createElement("<div id='" + name + "' class='chart'></div>");
		document.getElementById('charts').appendChild(element);
		element2 = document.createElement("<img id='loading' class='loading' src='view/images/loading_movie.gif' />");
		document.getElementById(name).appendChild(element2);

	} catch (e) {
		element = document.createElement("div");
		element.setAttribute("id", name);
		element.setAttribute("class","chart");
		imgelement = document.createElement("img");
		imgelement.setAttribute("class","loading");
		imgelement.setAttribute("id","img_" + name);
		imgelement.setAttribute("src","view/images/loading_movie.gif");
		document.getElementById('charts').appendChild(element);
		document.getElementById(name).appendChild(imgelement);
	}
}

//mskz delete
function initImageClickParam(name)
{
	gTimes = new Array();
	gTimes[0] = name;
	imageWidth =0;
	imageHeight=0 ;
}

//------------------------- 		 
function createDivsForImgWidthData(times,filePref){
//alert('createDivsForImgWidthData=='+filePref);
  	reSet = true;
	turnBack = false;
	init = true;
	imageWidth =0;
	imageHeight=0; 
	document.getElementById('charts').innerHTML = '';
    gTimes = new Array();
    gTimes[0] = times;
    createLoadingInit(gTimes[0]);
//alert("gTimes=="+gTimes[0]);
//alert(getServer());	
var xmlhttp = new Request(getServer() + 
			'/index.cfm?iaX=foster.charts.t4chart&typeName='+filePref+'&idtime='+ gTimes[0] +'','changeDivsForT4ChartData','text');
//alert(xmlhttp);
	xmlhttp.doXmlhttp();
	
}
//-------------------------------

function createDivsForImgWidth(times,filePref,ext){
	gTimes = times;
	gFilePref = filePref;
	gExt = ext;
	reSet = true;
	turnBack = false;
	init = true;
	imageWidth =0;
	imageHeight=0;  



	for(var f=0;f < times.length;f++){
		createLoadingInit(times[f]);
	}

	for(var t=0;t < times.length;t++){

		if(filePref.charAt(filePref.length - 1) == '_' && filePref.indexOf('http') == -1){


			try{
				//chart = createElement("<img id='chart_'" + times[t] + "' src='view/images/chart_images/" + filePref + times[t] + ext + "' />");
				chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + times[t] + ext + "' />");
				document.getElementById(times[t]).appendChild(chart);
				//alert(filePref + times[t] + ext);
			} catch (e) {
				chart = document.createElement("img");
				chart.setAttribute("id","chart_" + times[t]);
				//chart.setAttribute("src","view/images/chart_images/" + filePref + times[t] + ext);
				chart.setAttribute("src","" + filePref + times[t] + ext);
				chart.setAttribute("onClick", ("imageClick(event);"));
				//alert(filePref + times[t] + ext);
				document.getElementById(times[t]).appendChild(chart);
			}
		}else if(filePref.charAt(filePref.length - 1)=='_'&&filePref.indexOf('http') != -1){

			try{
				chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + times[t] + ext + "'  />");
				document.getElementById(times[t]).appendChild(chart);
				//var n = document.getElementById( 'chart_' + times[t] ).width;
				//document.getElementById( 'chart_' + times[t] ).width = n - 100;
				//alert(n );
			} catch (e) {
				chart = document.createElement("img");
				chart.setAttribute("id","chart_" + times[t]);
				chart.setAttribute("src",filePref + times[t] + ext);
				chart.setAttribute("onClick", ("imageClick(event);"));

				// document.getElementById( "chart_" + times[t] ).width = n - 100;
				// alert(filePref + times[t] + ext);
				document.getElementById(times[t]).appendChild(chart);
				//  document.getElementById( "chart_" + times[t] ).width = 550;
				//  document.getElementById( "chart_" + times[t] ).height = 500;
				//alert(document.body.clientHeight);
				//alert(document.body.clientWidth);
				//alert(document.documentElement.clientHeight);
			}
		} else {

			if(filePref.indexOf('http') == -1){
				try{
					//chart = createElement("<img id='chart_'" + times[t] + "' src='view/images/chart_images/" + filePref + ext + "' />");
					chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + ext + "' />");
					document.getElementById(times[t]).appendChild(chart);
				} catch (e) {
					chart = document.createElement("img");
					chart.setAttribute("id","chart_" + times[t]);
					chart.setAttribute("src","view/images/chart_images/" + filePref + ext);
					chart.setAttribute("onClick", ("imageClick(event);"));
					//alert(filePref + ext);
					document.getElementById(times[t]).appendChild(chart);
				}
			} else {
				try{
					chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + ext + "' />");
					chart.setAttribute("width",filePref + ext);
					document.getElementById(times[t]).appendChild(chart);
				} catch (e) {
					chart = document.createElement("img");
					chart.setAttribute("id","chart_" + times[t]);
					chart.setAttribute("src",filePref + ext);
					chart.setAttribute("onClick", ("imageClick(event);"));
					document.getElementById(times[t]).appendChild(chart);
				}
			} 
		}
	}
	if(typeof(refreshCharts) == "undefined"){
		refreshCharts = setInterval('refreshChartDivs("' + times + '")',30000);
	}else{
		clearInterval(refreshCharts);
		refreshCharts = setInterval('refreshChartDivs("' + times + '")',30000);
	}
}

function createDivsForImg(times,filePref,ext){
    for(var f=0;f < times.length;f++){
		createLoadingInit(times[f]);
            }
            for(var t=0;t < times.length;t++){
                if(filePref.charAt(filePref.length - 1) == '_' && filePref.indexOf('http') == -1){
                    try{
                        chart = createElement("<img id='chart_'" + times[t] + "' src='view/images/chart_images/" + filePref + times[t] + ext + "' />");
                        document.getElementById(times[t]).appendChild(chart);
                    } catch (e) {
                        chart = document.createElement("img");
                        chart.setAttribute("id","chart_" + times[t]);
                        chart.setAttribute("src","view/images/chart_images/" + filePref + times[t] + ext);
                        //alert(filePref + times[t] + ext);
                        document.getElementById(times[t]).appendChild(chart);
                    }
                } else if (filePref.charAt(filePref.length - 1) == '_' && filePref.indexOf('http') != -1){
                    try{
                        chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + times[t] + ext + "' />");
                        document.getElementById(times[t]).appendChild(chart);
                    } catch (e) {
                        chart = document.createElement("img");
                        chart.setAttribute("id","chart_" + times[t]);
                        chart.setAttribute("src",filePref + times[t] + ext);
                        //alert(filePref + times[t] + ext);
                        document.getElementById(times[t]).appendChild(chart);
                    }
                } else {
                    if(filePref.indexOf('http') == -1){
                        try{
                            chart = createElement("<img id='chart_'" + times[t] + "' src='view/images/chart_images/" + filePref + ext + "' />");
                            document.getElementById(times[t]).appendChild(chart);
                        } catch (e) {
                            chart = document.createElement("img");
                            chart.setAttribute("id","chart_" + times[t]);
                            chart.setAttribute("src","view/images/chart_images/" + filePref + ext);
                            //alert(filePref + ext);
                            document.getElementById(times[t]).appendChild(chart);
                        }
                    } else {
                        try{
                            chart = createElement("<img id='chart_'" + times[t] + "' src='" + filePref + ext + "' />");
                            document.getElementById(times[t]).appendChild(chart);
                        } catch (e) {
                            chart = document.createElement("img");
                            chart.setAttribute("id","chart_" + times[t]);
                            chart.setAttribute("src",filePref + ext);
                            document.getElementById(times[t]).appendChild(chart);
                        }
                   } 
                }
            }
	if(typeof(refreshCharts) == "undefined"){
        refreshCharts = setInterval('refreshChartDivs("' + times + '")',30000);
    }else{
		clearInterval(refreshCharts);
		refreshCharts = setInterval('refreshChartDivs("' + times + '")',30000);
	}
}

function refreshChartDivs(timesArr){
	if (timesArr.charAt(0) == ","){  
		str = timesArr.substring(1,timesArr.length);
  	} else {
		str = timesArr;
	}
	var times = str.split(",");
	//alert('chart_' + times[1]);
	for(var i=0;i < times.length;i++){
		if(typeof(document.getElementById('chart_' + times[i]).src) != "undefined"){
			//alert('Replacing divs');
			var winSrc = document.getElementById('chart_' + times[i]).src;
			document.getElementById('chart_' + times[i]).src = winSrc;
		} else {
			//alert('that doesn\'t exist yet');
		}
	}
}

function clearFrame(){
    document.getElementById('charts').innerHTML = '';
	document.getElementById('fleveltimes').innerHTML = "";
}

function showFrame(frameToShow,frames){
		frameNo = frameToShow;
		//alert("FRAME:"+frameToShow);
		//alert("FRAME:"+frames);
    arrframes = frames.split("|");
    for(var z=0;z < arrframes.length;z++){
        document.getElementById(arrframes[z]).style.display = 'none';
    }
    document.getElementById(frameToShow).style.display = 'block';
}

function sendLoginEmail(username,emailAddress){
	doLoading();
    var xmlhttp = new Request(getServer() + '/index.cfm?iaX=admin.sendUsernamePassword&username=' + username + '&emailAddress=' + emailAddress,'updateMessageText','text');
    xmlhttp.doXmlhttp();
}

function getMapImage(boundingbox){
	var demisstring = "http://demis.wni.com/wms/wms.asp?WMS=WorldMap4&VERSION=1.1.0&REQUEST=GetMap&SRS=EPSG:4326&BBOX=" + boundingbox + "&WIDTH=500&HEIGHT=500&FORMAT=PNG&BGCOLOR=0x0066FF&LAYERS=Countries,Borders,Coastlines,Counties,US%20State%20Borders,Cities,Airports,LatLon&EXCEPTIONS=INIMAGE&WRAPDATELINE=true";
	var demiswin = CreateWindow('','530','530','demiswin');
	demiswin.document.body.innerHTML = '<div id="clowin"><a style="font-family:Verdana;font-size:10px;" onClick="window.close();">Close</a><div id="imgwin"><span style="position:absolute;font-size:64px;left:235px;top:235px;color:#FF0000;font-weight:bold;">+</span><img src="' + demisstring + '" alt="Map Image of Storm Area" /></div>';
}



