function trim ( string ) {
	var i, numFirstChar = -1, numLastChar = -1;
	
	for ( i = 0; i < string.length; i ++ ) {
		if ( string.substring ( i, i + 1 ) != ' ' ) {
			numFirstChar = i;
			break;
		}
	}
	
	if ( numFirstChar == -1 )
		return "";
	
	for ( i = string.length; i >= 0; i -- ) {
		if ( string.substring ( i - 1, i ) != ' ' ) {
			numLastChar = i;
			break;
		}
	}
	
	return string.substring ( numFirstChar, numLastChar );
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function isEmail (email) {
	var valid_email_address = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return valid_email_address.test(email)
}
function isPhoneNumber (phone) {
	var valid_phone_number=/^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$/;
	return valid_phone_number.test(phone)
}

var lastRecipeID = 0;
function showpic(recipeID, recipeTitle) {
	if (lastRecipeID != 0) {
		closepic(lastRecipeID);
	}

	var picdiv = document.getElementById('div_' + recipeID);
	var viewRecipeID = recipeID;
	if (recipeID < 10) {
		viewRecipeID = "000" + recipeID;
	} else if (recipeID < 100) {
		viewRecipeID = "00" + recipeID;
	} else if (recipeID < 1000) {
		viewRecipeID = "0" + recipeID;
	}
	picdiv.innerHTML = "<div style='background-color:#FFFFFF; border:2px #939f6c solid; padding:5px; position:relative; z-index:5;width:205px;'><div align='right'><a href='javascript:;' onclick='closepic(" + recipeID + ");'>close</a></div><div style='width:200px; text-align:center; font-weight:bold;'><a href='/recipes/recipe-view.aspx?recipeID=" + recipeID + "'>" + recipeTitle + "</a></div><a href='/recipes/recipe-view.aspx?recipeID=" + recipeID + "'><img src='/images/dbrecipes/" + viewRecipeID + ".jpg' border=0></a></div>";
	
	lastRecipeID = recipeID;
}
function closepic(recipeID) {
	var picdiv = document.getElementById('div_' + recipeID);
	picdiv.innerHTML = '';
}
