//General functions used thoughtout the site.
//These functions can be loaded when the footer page gets loaded so it reduces the load time of the other pages
//CHECKED for Netscape 4.x, 6.x IE 4.x 5.x
//note object which browser must be created before the launch it also must be named bInfo
//*************************************************
//****create a pop-up window
//*************************************************
function newWin(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}
//*************************************************
//****Check any date boxes - ALL versions
//*************************************************
function checkDate(item)
{
	if (item.value!="")
	{
		if (isNaN(parseInt(item.value)))
		{
			item.value="";
			alert("invalid date: only use digits");
			item.focus();
		}
		else if ((parseInt(item.value)<1000)||(parseInt(item.value)>2003))
		{
			item.value="";	
			alert("invalid date: must be a year between the range 1000 - 2002");
			item.focus();
		}
		else
		{
			item.value=parseInt(item.value);
		}
	}
}
///*************************************************
//****Checks to see if the fastfind form is blank then organizes the fastfind ALL VERSIONS
//*************************************************
function checkFastFind(item)
{
	var input_empty       =true;
	var total_count       =0;
	var ff_temp           ="";
	var check_count       =0;
	fast_array= new Array(
								item.ff0.value,
								item.ff1.value,
								item.ff2.value,
								item.ff3.value,
								item.ff4.value,
								item.ff5.value
							);
	
	//count the number of items
	for(var count=0;count<(fast_array.length);count++)
	{
		if (fast_array[count]!="")
		{
			input_empty=false;
			total_count++;
		}
	}

	//Tell user if fast find is empty
	if (input_empty==true)
	{
		alert("You did not fill a field!");
	}
	else
	{
		//put total back into TotalCount variable
		item.totalcount.value=total_count;

		//shuffle the input to the very left box
		for(var out_count=0;out_count<(fast_array.length);out_count++)
		{
			if (fast_array[out_count]=="")
			{
                        
				for(var in_count=out_count;in_count<(fast_array.length);in_count++)
				{
					if ((in_count+1)<(fast_array.length))
						fast_array[in_count]=fast_array[in_count+1];
					else
						fast_array[in_count]="";
				}
				if (check_count<fast_array.length)
				{
					out_count--;
					check_count++;
				}
				else
					check_count=0;
			}
		}
		//put in new values into the fast find
		item.ff0.value=fast_array[0]
		item.ff1.value=fast_array[1]
		item.ff2.value=fast_array[2]
		item.ff3.value=fast_array[3]
		item.ff4.value=fast_array[4]
		item.ff5.value=fast_array[5]

		return true;
	}
	return false;
}
///*************************************************
//****Swap Images swaps images on mouseOver and mouseOut events => NE4 => IE 4
//*************************************************
function hiLite(imgDocID,imgObjName,Frame)
{
	if (bInfo.pass) 
	{
		if (Frame==null)
			document.images[imgDocID].src = eval(imgObjName + ".src");
		else
			parent.frames[Frame].document.images[imgDocID].src = eval(imgObjName + ".src");
	}
}
// CSS Function
function createCSS(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") 
		return '<STYLE TYPE="text/css">\n'
	else if (id=="END") 
		return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'; top:'+top+';' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += ' layer-background-color:'+color+'; background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
//write the CSS
function writeCSS(test,innerStr) {
	if (test) alert(createCSS('START')+innerStr+createCSS('END'));
	document.write(createCSS('START')+innerStr+createCSS('END'));
}
var winW = (bInfo.browser=='ie') ? document.body.offsetWidth-20 : window.innerWidth-16;
var winH = (bInfo.browser=='ie') ? document.body.offsetHeight : window.innerHeight;
//selects the drop down
function selectIt(indexVal,item)
{
   for (var i=0; i<item.length; i++)
   {
      if (item.options[i].value == indexVal || item.options[i].text == indexVal)
      {
         item.options[i].selected = true;
         return;
      }
   }
}
//clears a form
function resetForm(itm)
{
   for(var i=0;i<itm.elements.length;i++)
   {
      if (itm.elements[i].type=="text")
         itm.elements[i].value = "";
      else if (itm.elements[i].type == "select-one")
         itm.elements[i].selectedIndex=0;
   }

}
//--------------------
//	FADE OPACITY
//--------------------
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	var object = document.getElementById(id);
	//-- make sure the object is visible
	object.style.display = '';
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	//-- make sure we colapse item after it disappears
	if (opacity <= 0)
		object.display = 'none';	    
}

function getCurrentYear()
{
    mydate = new Date();
    currentyear = mydate.getYear(); 
    currentyear = (currentyear < 1000) ? currentyear + 1900 : currentyear; 
    
    return currentyear;
}

