

var iv_scriptletIncluded_search = 1;



iv_searchIVUrl = "http://search.ivillage.com/search/ivillage";
iv_searchHealthUrl = "http://search.ivillage.com/search/health";
iv_searchWebUrl = "http://search.ivillage.com/search/web";
iv_searchMBUrl = "http://search.ivillage.com/search/mb";


function iv_handleGoogleSearch(inputForm, frmIDBase) {
    var skin = inputForm.sk;
    var restrictValue = inputForm.restrict;
    var mt = inputForm.q.value;

    if (mt.length == 0) {
        alert('Your search could not be completed because no search words were entered.');
        inputForm.q.focus();
        inputForm.q.select();
        return false;
    }

    if (document.getElementById) {
        var r1 = document.getElementById(frmIDBase + '_ivradio');
		var r2 = inputForm;
        if (r1.src.indexOf("off.") > -1) {
            inputForm.action = "http://search.ivillage.com/search/web";
            restrictValue.value = "web";
        } else {
			if (r2.name.indexOf("health") > -1) {
				inputForm.action = "http://search.ivillage.com/search/health";
            	restrictValue.value = "health";
			} else {
				inputForm.action = "http://search.ivillage.com/search/ivillage";
            	restrictValue.value = "ivillage";
			} 
	    }
        return true;
    }
}


function iv_handleGoogleSimpleSubmit(inputForm) {
    var skin = inputForm.sk;
    var mt = inputForm.q.value;

    var restrictValue = "";
    for (var i = 0; i < inputForm.restrict.length; i++) {
        if (inputForm.restrict[i].checked) { var restrictValue = inputForm.restrict[i].value; break; }
    }

    if (mt.length == 0) {
        alert('Your search could not be completed because no search words were entered.');
        inputForm.q.focus();
        inputForm.q.select();
        return false;
    }

    if (restrictValue == "ivillage") {
        inputForm.action = "http://search.ivillage.com/search/ivillage";
    } else {
        inputForm.action = "http://search.ivillage.com/search/web";
    }
}


function iv_toggleSearch(selectedRadio, frmIDBase) {
    if (document.getElementById) {
        r1 = document.getElementById(frmIDBase + '_ivradio');
        r2 = document.getElementById(frmIDBase + '_webradio');

        var current = (r1.src.indexOf("off.") > -1) ? "web" : "ivillage";

        if (current != selectedRadio) {
            var src1 = r1.src;
            r1.src = r2.src;
            r2.src = src1;
        }
    }
}


function iv_submitCSSearch(frm) {
	if (frm.q.value == "") { 
		alert("Your search could not be completed because no search words were entered.");
		return false; 
	}
}


function cs_handleSearch(inputForm) {
	iv_searchIVUrl = "http://search.ivillage.com/search/ivillage";
	iv_searchHealthUrl = "http://search.ivillage.com/search/health";
	iv_searchWebUrl = "http://search.ivillage.com/search/web";
	iv_searchMBUrl = "http://search.ivillage.com/search/mb";
    iv_searchMomtourageUrl = "http://search.momtourage.com/search/momtourage";
	iv_searchWebMomtourageUrl = "http://search.momtourage.com/search/webmomtourage";
    var skin = inputForm.sk;
	var theaction;
    var restrictValue;

	if (inputForm.name != 'ivSearchForm' && inputForm.name != 'MomtourageSearchForm' && inputForm.name != 'ivSearchFormBot') {
		restrictValue = inputForm.restrictValue.options[inputForm.restrictValue.selectedIndex].value;
	} else {
		restrictValue = inputForm.restrict.value;
	}
			   
	switch (restrictValue)
	{
		case "ivillage":
			theaction = iv_searchIVUrl;
			break
		
		case "health":
			theaction = iv_searchHealthUrl;
			break
			
		case "mb":
			theaction = iv_searchMBUrl;
			break	
				
		case "momtourage":
			theaction = iv_searchMomtourageUrl;
			break
		
		case "webmomtourage":
			theaction = iv_searchWebMomtourageUrl;
			break
				
		
		default:
			theaction = iv_searchWebUrl;
			break
	}
	inputForm.action = theaction;
    inputForm.submit(); 
}

function cs_toggleSearch(selectedTab) {	
    if (document.getElementById) {
        r1 = document.getElementById('top_ivtab');
        r2 = document.getElementById('top_webtab');   
		
        if (selectedTab == 'ivillage') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/search/ivillage_new_on1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/search/web_new_off1.gif';
        } else {
			r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/search/ivillage_new_off1.gif';
	        r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/search/web_new_on1.gif';
		}
    }
	document.ivSearchForm.restrict.value = selectedTab;	
}
//function for Momtourage search
function cs_toggleSearchMom(selectedTab) {	
    if (document.getElementById) {
        r1 = document.getElementById('top_momtab');
        r2 = document.getElementById('top_momwebtab');        

        if (selectedTab == 'momtourage') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/mom_searchresults_on.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/web_searchresults_off.gif';
        } else {
			r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/mom_searchresults_off.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/web_searchresults_on.gif';
		}
    }
	document.MomtourageSearchForm.restrict.value = selectedTab;	
}



// Change for new header
function cs_toggleUnifiedSearch(selectedTab) {	
     if (document.getElementById) {
        r1 = document.getElementById('top_ivtab');
        r2 = document.getElementById('top_webtab');   
		r3 = document.getElementById('top_mbtab');      
		
        if (selectedTab == 'ivillage') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_on1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_off1.gif';
			r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_off1.gif';
			document.ivSearchForm.forum.value = '';
			document.ivSearchForm.partner_tag.value = '';				
        } else {
			 if (selectedTab == 'mb') {			
	            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_off1.gif';
	            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_off1.gif';
				r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_on1.gif';
				document.ivSearchForm.forum.value = 'yes';
				document.ivSearchForm.partner_tag.value = 'ivillage_us_web-search';					
	        } else {
				r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_off1.gif';
	            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_on1.gif';
				r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_off1.gif';
				document.ivSearchForm.forum.value = '';
				document.ivSearchForm.partner_tag.value = '';				
				}
		}
    }
	document.ivSearchForm.restrict.value = selectedTab;	
}

// function for Momtourage search
function cs_toggleUnifiedSearchMom(selectedTab) {	
    if (document.getElementById) {
        r1 = document.getElementById('top_momtab');
        r2 = document.getElementById('top_momwebtab');        

        if (selectedTab == 'momtourage') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/mom_searchresults_on.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/web_searchresults_off.gif';
        } else {
			r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/mom_searchresults_off.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/momtourage_vertical/mom_moments/web_searchresults_on.gif';
		}
    }
	document.MomtourageSearchForm.restrict.value = selectedTab;	
}





function cs_toggleUniSearch(selectedTab) {	
    if (document.getElementById) {
        r1 = document.getElementById('top_ivtab');
        r2 = document.getElementById('top_webtab');
		r3 = document.getElementById('top_msgtab');
		r4 = document.getElementById('top_shoptab');        

        if (selectedTab == 'ivillage') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_on1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_off1.gif';
			r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_off1.gif';
			r4.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/shopping_off.gif';
        } else if (selectedTab == 'messageboards') {			
		    r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_off1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_off1.gif';
			r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_on1.gif';
			r4.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/shopping_off.gif';
        } else if (selectedTab == 'shopping') {			
            r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_off1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_off1.gif';
			r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_off1.gif';
			r4.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/shopping_on2.gif';
        } else {
			r1.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/ivillage_new_off1.gif';
            r2.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/web_new_on1.gif';
			r3.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/mb_new_off1.gif';
			r4.src = 'http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/shared/iv/refresh/channels/shopping_off.gif';
		}
    }
	
}

function cs_focusSearch(inputForm) {	
	//inputForm.q.focus();
}
		
