/* Remove IE6 image flickering */
try {
document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


/* Initializes spcfh_setHdrSearchBox with a delay */
function spcfh_hdrSearchInit() {
	var delay = setTimeout(spcfh_setHdrSearch, 1);
}

/* Sets the active/disabled text colors for the search labels and erases text on focus */

function spcfh_setHdrSearch() {
				var hdrForm = document.getElementById("hdrsearch");
				var hdrFormTxtField = document.getElementById("hdrsearchbox");
if (hdrFormTxtField) {	
//hdrFormTxtField.defaultValue = 'Search Recipes and More';

//alert(unescape(tiiGetQueryParamValue('Ntt')));
if ( unescape(tiiGetQueryParamValue('Ntt')) != "null" ) {
	//hdrFormTxtField.value = unescape(tiiGetQueryParamValue('Ntt'));
	hdrFormTxtField.style.color= "#000";
} else {
	hdrFormTxtField.value = "Search Recipes and More";
	hdrFormTxtField.style.color= "#a8a8a8";
}        
        hdrFormTxtField.onfocus = function() {
					 if (this.value == 'Search Recipes and More') {
						this.value = "";
						this.style.color= "#000";
					  }
                };
				
               hdrFormTxtField.onblur = function() {
                    if(this.value == "") {
                        this.value = "Search Recipes and More";
						this.style.color= "#a8a8a8";
                    }
                };
}
            };
            
/* Initialization Calls */
tii_callFunctionOnElementLoad ('hdrsearchbox', spcfh_hdrSearchInit);
/* for serach box focus on error pages */
tii_callFunctionOnElementLoad ('searchbox2', function ()
{
	var field = document.getElementById ('searchbox2');
	field.value ="";
	field.focus ();
	
});

tii_callFunctionOnWindowLoad (function () {
	// for newsletter signup in footer
	var newsltr_email = document.getElementById('newsltr_email');
	if (newsltr_email) {
		var newsltr_default = newsltr_email.value;
		tii_addEventHandler(newsltr_email, 'focus', function(event) {
			if (newsltr_email.value == newsltr_default) {
				newsltr_email.value = "";
				newsltr_email.className = "active";
			}
		}, false);
		tii_addEventHandler(newsltr_email, 'blur', function(event) {
			if (newsltr_email.value == "") {
				newsltr_email.value = newsltr_default;
				newsltr_email.className = "";
			}
		}, false);
	}
});


tii_callFunctionOnWindowLoad (function () {
	/* Get the links to have underlines when hovered upon */
	setGalleryPaginationHover ();
	
	// for Easy Ways to Find Recipes search on Home Page
	var srch = document.getElementById('srch');
	if (srch) {
		var srch_default = srch.value;
		tii_addEventHandler(srch, 'focus', function(event) {
			if (srch.value == srch_default) {
				srch.value = "";
				srch.className = "active";
			}
		}, false);
		tii_addEventHandler(srch, 'blur', function(event) {
			if (srch.value == "") {
				srch.value = srch_default;
				srch.className = "";
			}
		}, false);
	}
});
/* Show Hide Functions */
            function is_all_ws( nod )
            {
              // Use ECMA-262 Edition 3 String and RegExp features
              return !(/[^\t\n\r ]/.test(nod.data));
            }

            function is_ignorable( nod )
            {
              return ( nod.nodeType == 8) || // A comment node
                     ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
            }
            
            function node_before( sib )
            {
              while ((sib = sib.previousSibling)) {
                if (!is_ignorable(sib)) return sib;
              }
              return null;
            }
              
            function node_after( sib )
            {
              while ((sib = sib.nextSibling)) {
                if (!is_ignorable(sib)) return sib;
              }
              return null;
            }
              
            function last_child( par )
            {
              var res=par.lastChild;
              while (res) {
                if (!is_ignorable(res)) return res;
                res = res.previousSibling;
              }
              return null;
            }
            
            function first_child( par )
            {
              var res=par.firstChild;
              while (res) {
                if (!is_ignorable(res)) return res;
                res = res.nextSibling;
              }
              return null;
            }
              
            function data_of( txt )
            {
              var data = txt.data;
              // Use ECMA-262 Edition 3 String and RegExp features
              data = data.replace(/[\t\n\r ]+/g, " ");
              if (data.charAt(0) == " ")
                data = data.substring(1, data.length);
              if (data.charAt(data.length - 1) == " ")
                data = data.substring(0, data.length - 1);
              return data;
            }
            
            function showHideLeftNav() {
				if (!document.getElementsByTagName) return false;
				if (!document.getElementById) return false;
				if (!document.getElementById("refineSearch")) return false;
				var listMods = document.getElementById( "refineSearch" ).getElementsByTagName( "dl" );
				var listModsLength = listMods.length;
                for( var i = 0; i < listModsLength; i++ ) {
                    showHide( listMods[ i ] );
                }
            }
            
			function showHide( listMod ) {
			//window.alert( listMod );
				var allAs = listMod.getElementsByTagName( "span" );
				var allAsLen = allAs.length;
				for( var i = 0; i < allAsLen; i++ ) {
					if( allAs[ i ].className.toUpperCase() == "SHOWMORE") {
						allAs[ i ].onclick = function() {
							
							if( node_after( this.parentNode ).style.display == "none" ||  node_after( this.parentNode ).style.display == "" ) {
								node_after( this.parentNode ).style.display = "block";
								this.innerHTML = "Show Less";
								this.className = "showLess";
							} else {
								node_after( this.parentNode ).style.display = "none";
								this.innerHTML = "Show More";
								this.className = "showMore";
							}
						};             
					}
				}
			}       
         tii_callFunctionOnWindowLoad( showHideLeftNav);
/* Show Hide Functions */
