// Givon JS file

var floatOnly = /^[0-9.]+$/;
var retVal = true;


function checkFloatOnly(theField, disp) 
{
	var theRetValue;

   theRetValue = true;
//   alert (theField.value)
   if (theField.value && floatOnly.test(theField.value))
   {
//	   alert("reach here")
   } else {
//	   alert("reach here")
	   if (theField.value) {  // we allow blanks
	     if (disp == 1) {
	         alert("Please enter a number")
	         theField.focus();
             theField.select();
		 } // disp = 1
          errCode = 2;
          theRetValue = false;
	   }
   }
   retVal = theRetValue;
//   alert("called " + retVal);
   return theRetValue
} // checkFloatOnly



function checkIfOK()
{
	toSend = true;
    if (toSend) {
       return true
    } else {
       alert ("All fields must be filled, with legal Values")
 	  return false
    }
}


   function loadImages()

   {
       var docu = document;
       var arraySz = 11;
   if (docu.images)
    {
       if (!docu.PW_img) {
 	     docu.PW_img = new Array(arraySz);
 		 for(j=1; j<arraySz; j++) {
            docu.PW_img[j] = new Image;
         } // for
		 for (j=1; j<arraySz; j++)
		 {
	        docu.PW_img[j].src = "Images/topBanner/btn_" + (j) + "n.jpg";
     	 }  // for loading
       } // !docu.PW_img

   } // if docu.images

   hidePop();

  } // loadImages

  function hidePop() {
  }

  function hidePopOld()
  {
	  if (document.getElementById)
	  {
//	  alert("hide")
//     alert(document.getElementById("expPop"))
		  document.getElementById("expPop").style.visibility = 'hidden';
		  document.getElementById("expPop").style.display = 'none';
		  document.getElementById("expHide").style.visibility = 'visible';
		  document.getElementById("expHide").style.display = 'block';

	  } else {
		  if (document.layers)
		  {
			  document.expPop.visibility = 'hidden';
			  document.expHide.visibility = 'visible';
		  } else {
			  document.expPop.visibility = 'hidden';
			  document.expHide.visibility = 'visible';
		  }
	  }
  }

  function showPop() {
  }

  function showPopOld()
  {
	  if (document.getElementById)
	  {
//	  alert("hide")
//     alert(document.getElementById("expPop"))
		  document.getElementById("expHide").style.visibility = 'hidden';
		  document.getElementById("expHide").style.display = 'none';
		  document.getElementById("expPop").style.visibility = 'visible';
		  document.getElementById("expPop").style.display = 'block';
//		  alert(document.getElementById("expPop").style.visibility)

	  } else {
		  if (document.layers)
		  {
			  document.expPop.visibility = 'visible';
			  document.expHide.visibility = 'hidden';
		  }  else {
			  document.all.expPop.visibility = 'visible';
			  document.all.expHide.visibility = 'hidden';
		  }
	  }
  }



  function ImgOn (picNum)
{
//	alert(eval(this));
//	alert(theField.name)
   fImage = eval("document.btn_" + picNum);
//   fImage.src = theImg + "_o.jpg";
//   fImage = eval("Image" + picNum);
   fImage.src = "Images/topBanner/btn_" + picNum + "n.jpg";

}

function ImgOff (picNum)
{
   fImage = eval("document.btn_" + picNum);
   fImage.src = "Images/topBanner/btn_" + picNum  + ".jpg";
}

function doSelectSearch() 
{
//   document.makeSForm.subMethod.value = "SubmitBest"
//   if (document.makeSForm.recName.value) {
      document.searchForm.submit()
//   } else {
//      alert ("Please fill the Mixmate Name")
//   }
}


 function givonOpenWin (theURL,winName,features) { //v2.0
   if (features == "width=450,height=460")
   {
//	   features = "width=450,height=526";
	   features = "width=450,height=551";
   }
   features = features+",resizable=yes,status=yes"

   glosWindow = window.open(theURL,winName,features);
 //  glosWindow.focus();
 } //   infoOpenWin

// popup menus
menuTimeoutVar = null;
var menuTime = 400;
var numOfMenus = 2;
var timeOutVar;

function showSub(theID, theBtn, menuNum) {
//		alert(theID);
		var obj = $(theID);
		hideOtherMenus(menuNum);
		clearTimeOut();
//		alert(obj);
		if (!obj) {
//			return false;
		}
		else if (obj.style) {
			if (obj.style.display == "none") {
				 obj.style.display="";
				 obj.visibility = "show";
				 btnHeight = Element.getDimensions($(theBtn)).height;
//				alert("here1");
				 btnWidth = Element.getDimensions($(theBtn)).width;
				 menuWidth = Element.getDimensions($(theID)).width;
				 widthOffset = menuWidth - btnWidth
//					 alert("btnWidth: " + btnWidth + " menuWidth: " + menuWidth + " widthOffset: " + widthOffset);
//				 alert(menuWidth);
				 absButton = absPosLocal($(theBtn));
                 obj.style.top = absButton.y + btnHeight;
//                 obj.style.left = absButton.x - widthOffset;
                 obj.style.left = absButton.x;
//				 obj.onMouseOut=timeout1(theID);
//				 obj.onMouseOver=clearTimeOut();
			} else {
//				obj.style.display="none";
			}
		}
}

function hideOtherMenus(curId) 
{
	for (idx=1; idx <= numOfMenus; idx++)
	{
		if (idx != curId)
		{
             hideSub("sub" + idx)
		}
	}
	// also also a special case for 7
//	if (curId != 6)
//	{
//             hideSub("sub6")
//	}
}

function clearTimeOut() {
//	alert("clear");
   if (menuTimeoutVar) {
	   clearTimeout(menuTimeoutVar);
	   menuTimeoutVar = null;
   }
}

function timeout1(theID)
{
		var obj = $(theID);
//		alert(theID);
		menuTimeoutVar = setTimeout(function() {hideSub(theID)},menuTime);
//				obj.style.display="none";
}

function hideSub(theID) {
		var obj = $(theID);
		obj.style.display="none";
}

function absPosLocal(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}  // if
	return {x:curleft, y:curtop};
}

