function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
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 RollOverWhite(oTd,stockstatus) 
{
	oTd.style.backgroundColor="#F7F7F7";
}
function RollOutGrey(oTd,stockstatus) 
{
	oTd.style.backgroundColor="#F7F7F7";
}
function RollOver(oTd,stockstatus) 
{
	oTd.style.backgroundColor="#F2F2F2";
}
function RollOut(oTd,stockstatus) 
{
	oTd.style.backgroundColor="#FFFFFF";
}

function openConverter()
{
	var winConverter = window.open("/currency_converter.htm", "", "width=180,height=280,location=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no");
	winConverter.moveTo(20,20);
}

function openConverterDe()
{
	var winConverter = window.open("/currency_converter_de.htm", "", "width=180,height=280,location=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no");
	winConverter.moveTo(20,20);
}

function popMap(vUrl)
{
	var width  = 580;
	var height = 515;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;

	var mapWin = window.open("http://www.findingafrica.com/map.aspx?mapUrl=" + vUrl, "", "height=515,width=580,directories=no,location=no0,status=0,menubar=0,toolbar=0,resizable=0,");
	mapWin.moveTo(left, 10);
}

function popSizedMap(vUrl, w, h)
{
	var width  = w;
	var height = h;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;

	var mapWin = window.open("http://www.findingafrica.com/map.aspx?mapUrl=" + vUrl, "", "height=" + h + ",width=" + w + ",directories=no,location=no0,status=0,menubar=0,toolbar=0,resizable=0,");
	mapWin.moveTo(left, 10);
}

function disableReturnKeyText()
{
	if (document.all){
	
		if (event.keyCode == 13) 
		{ 
			event.returnValue=false; 
			event.cancel = true;
		}
	}
}

function hitEnter()
{
	if (document.all){
	
		if (event.keyCode == 13) 
		{
			event.returnValue=false; 
			event.cancel = true;
			return true;
		}
		else
			return false;
	}
}

//onkeypress = "return numbersOnly(event);"
function numbersOnly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode;
	//if (unicode!=8 && unicode!=32){ //if the key isn't the backspace key (which we should allow)
	if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
	if (unicode<48||unicode>57) //if not a number
	return false; //disable key press
	}
	return true;
}

function digitsOnly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode!=8 && unicode!=32){ //if the key isn't the backspace key (which we should allow)
	if (unicode<48||unicode>57) //if not a number
	return false; //disable key press
	}
	return true;
}

function fnTrapKD(btn)
{
	if (document.all){
		if (event.keyCode == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
}

function checkDatePartOfDate(ctrl,monthCtrl,yearCtrl){
	var allowed= "0123456789";
	
	for(i=0;i<ctrl.value.length;i++)
		if(allowed.indexOf(ctrl.value.substring(i,i+1))==-1)
		{
			alert('Day part of date can only accepts numeric values.');
			ctrl.value=ctrl.value.substring(0,ctrl.value.length-1);
			break;
		}
		
	if(!checkDate(ctrl.value,monthCtrl.options[monthCtrl.selectedIndex].value,yearCtrl.options[yearCtrl.selectedIndex].value))
	{
		ctrl.value='';
		ctrl.focus();
	}
}


function getMonthNumber(month){
	
	switch(month.toLowerCase()){
		case "jan": return 0;
		case "feb": return 1;
		case "mar": return 2;
		case "apr": return 3;
		case "may": return 4;
		case "jun": return 5;
		case "jul": return 6;
		case "aug": return 7;
		case "sep": return 8;
		case "oct": return 9;
		case "nov": return 10;
		case "dec": return 11;
	}
}


function checkDate(day,month,year){
	
	if(day!=""){
	
		var d = new Date();
		d.setFullYear(year, month - 1, day);
												
		var autoFail = !((day==d.getDate()) && ((month-1)==d.getMonth()) && (year==d.getFullYear()));
		
		if(autoFail || isNaN(d))
		{
			alert('Please supply a valid date.');
			return false;
		}
	
		return true;
	}
}


function formatAmt(num)
{
	//formats 1000 as 1,000
	
	var tmpNumStr = new String(num);
	var retVal = "0";
	if (isNaN(parseInt(num))) retVal="0";
	
	if(num >= 1000)
		retVal = tmpNumStr.substring(0, tmpNumStr.length-3) + "," + tmpNumStr.substring(tmpNumStr.length-3);
	else
		retVal = tmpNumStr;
		
	return retVal;
}



//Google search
function doSearch() 
{
    var keyword = document.getElementById("q").value;
    document.forms["Form1"].action = "/SearchResults.aspx?cx=010214945641490285599:1h9adgczkko&cof=FORID:9&ie=UTF-8&q=" + keyword;
    document.forms["Form1"].submit();
}
