$(document).ready(
	function(){
		attachNavRollovers();
		nextPrevProjectLinks();
		leftColImageSizeControl();
		alternateColors();
		deactivateSelected3rdTierRightCol();
	}
)

function leftColImageSizeControl(){
	$(".picgroupcell img","#leftcol").each(function(){
		//if(window.console){ console.log("w:",$(this).attr("width")); }
		var thisImgWidth = parseInt($(this).attr("width"));
		if(thisImgWidth > 337){
			$(this).attr("width","337");
			if(window.console){ console.log("the image:",$(this).attr("src")," had to be resized"); }
		}		
	});
}

function nextPrevProjectLinks(){
	//<div class="gallerynavlinks"><!-- InstanceBeginEditable name="NextPrevLink" --><a class="prevlink" href="notyetset">&#171; Previous</a>&nbsp;<a class="nextlink" href="residential-newhomes-de.html">Next &#187;</a><!-- InstanceEndEditable --></div>
	//<div class="gallerynavlinks"><a class="duplicateprev" href="notyetset">&#171; Previous</a>&nbsp;<a class="duplicatenext" href="notyetset">Next &#187;</a></div>
	$(".nextlink,.prevlink").each(function(){
		//if(window.console){console.log("this:",this)}
		//if(window.console){console.log("this.href:",this.href)}
		if(this.href.indexOf("notyetset")!=-1){
			$(this).css("visibility","hidden");
				if($(this).hasClass("nextlink")){
					$(".duplicatenext").hide();
				} else {
					$(".duplicateprev").hide();
				}
		} else {
			var thisHrefValue = $(this).attr("href");
			if($(this).hasClass("nextlink")){
				$(".duplicatenext").attr("href",thisHrefValue);
			} else {
				$(".duplicateprev").attr("href",thisHrefValue);
			}
		}
	});
}

function deactivateSelected3rdTierRightCol(){
	var $thrdTierSubs = $("a.selected","#rightcol .subsectionlinksNaturalH");
	$thrdTierSubs.bind("click",function(){return false});
	//if(window.console)console.log("$thrdTierSubs:",$thrdTierSubs);
}

function attachNavRollovers(){
	$("img","#nav").hover(
		function(){
			if($(this).attr("src").indexOf("-off.gif") != -1) {
				var newSrc = $(this).attr("src").replace("-off.gif","-on.gif");
				$(this).attr("src",newSrc);
			}
		},
		function(){
			if($(this).attr("src").indexOf("-on.gif") != -1  && $(this).attr("class").indexOf("selected") == -1) {
				var oldSrc = $(this).attr("src").replace("-on.gif","-off.gif");
				$(this).attr("src",oldSrc);
			}
		}
	);	
}
function alternateColors(){
	$("a:odd",".alternatelinks").addClass("alternate-odd");
	$("a:even",".alternatelinks").addClass("alternate-even");
}

function generalOpenWin(winurl,winname,winfeatures){
	if(winname=='recipeWin' && (!winfeatures || winfeatures=="" || winfeatures==null)) winfeatures="width=400,height=600,resizable=1,scrollbars=1,menubar=1";
	//alert('winfeatures='+winfeatures);
	var winname = window.open(winurl,winname,winfeatures);
	if(window.focus) winname.focus();
}

//form val
var whitespace = " \t\n\r";
var digits = "0123456789";

function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}

function isEmptyOrWhitespace (s) {   
	var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function isValidEmailAddress(s) {
	var temp = s.replace(/\s/g, "")
	return (temp.match(/^[\w\.\-]+\x40[\w\.\-]+\.\w{2,3}$/)) && 
			temp.charAt(0) != "." && !(temp.match(/\.\./))
}

function isValidSelectBox(o) {
	return (o.options[o.selectedIndex].value != "_none_" && 
			o.options[o.selectedIndex].value.trim() != "")
}
// as convenient a place as any to store this...
var STD_ERROR_PREFIX = "There were one or more problems with the form values "
STD_ERROR_PREFIX += "you entered.\nPlease check the following and try submitting "
STD_ERROR_PREFIX += "the form again:\n\n"


