﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function removeHint(fld) { //removes field hint on focus
  fld.value="";
}

function resetHint(fld,fldTxt) { //rest field hint on focus
  fld.value=fldTxt;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function IsNumeric(sText)
{
   var ValidChars = ".0123456789";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myfield.form.submit();
   return false;
   }
else
   return true;
}

function setMenuHeader(tx){
 document.getElementById("htextDiv").innerHTML="";	
 document.getElementById("htextDiv").innerHTML=tx;
}

function getFeatureInfo(url){
    document.getElementById('iframeDiv').src = url;
}

function setFocus(tabid,url){
 for(var id =1;id<=4;id++){
  var fnid="tab"+id;
  if(id==tabid){
	try{
		document.getElementById(fnid).className="featureLoading";
		getFeatureInfo(url);
		}catch(e){
		
		};
  }else{
	try{document.getElementById(fnid).className=""}catch(e){};
  }
 }  
}

var verticalpos="fromtop";
function JSFX_FloatTopDiv()
{
	document.getElementById('backToTop').style.visibility = "hidden";
	var startX = 155,
	startY = 340;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id){
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		el.y = startY;
		return el;
	}
	window.stayTopRight=function(){
		if (document.documentElement && document.documentElement.scrollTop){
			var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			//alert(pY);
		}else{
			var pY = ns ? pageYOffset : document.body.scrollTop;
		}
		
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		//alert(ftlObj.y);
		if(ftlObj.y > 800){
			document.getElementById('backToTop').style.visibility = "visible";
			//document.getElementById('backToTop').innerHTML(ftlObj.y);
			//alert("ftlObj.y=" + document.getElementById('backToTop').style.top);
		}else{
			document.getElementById('backToTop').style.visibility = "hidden";
		}

		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopRight()", 20);
	}
	ftlObj = ml("backToTop");
	stayTopRight();
	//alert(ftlObj.y);
}

function removeFSHint(fldid, rfldid) { //removes flower search file hint on focus
  document.getElementById(fldid).value ="";
  document.getElementById(rfldid).value = " Your email address"
}

function removeRegisterHint(rfldid, fldid) { //removes register field hint on focus
  document.getElementById(rfldid).value ="";
  document.getElementById(fldid).value = " Enter flower name";
}


function removeHintByID(fldid) { //removes field hint on focus
   document.getElementById(fldid).value ="";
}
function calcHeight(){
	var the_height=document.getElementById('iframeDiv').contentWindow.document.body.scrollHeight;
	document.getElementById('iframeDiv').height=the_height + 100;
}

function calcFlowerInfoHeight(){
	var the_height=document.getElementById('iframeDiv').contentWindow.document.body.scrollHeight;
	document.getElementById('iframeDiv').height=the_height + 20 + 'px';
	removeLoader();
}

function removeLoader() {
	for(var id =1;id<=4;id++){
	  var fnid="tab"+id;
	  var obj = document.getElementById(fnid);
	  if(obj.className=="featureLoading"){
		try{
			obj.className="featureLoaded";
			}catch(e){
			
			};
	  }else{
		try{obj.className=""}catch(e){};
	  }
	 }  
}

function noenter(e) {
 	 var key;      
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox      

     return (key != 13);
}

function DoSearch(evt, val) {
	if(evt.keyCode=='13'){
		evt.preventDefault();  
		var searchurl = "/search/?k=" + val;
		//theform.action = searchurl;
		//alert(theform.action);
        window.location = searchurl;
	}
}

function popup(mylink, windowname)
{
	if (! window.focus)return true;
		var href;
		if (typeof(mylink) == 'string')
		   href=mylink;
		else
		   href=mylink.href;

	window.open(href, windowname, 'width=500,height=300,scrollbars=yes');
	return false;
}

function GP_popupConfirmMsg(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}
