var nav = "<ul id=\"nav\"> <li id=\"link_home\" class=\"first\"><a href=\"http://celebrity-babies.com/\">Home</a></li> <li id=\"link_photos\"><a href=\"http://celebrity-babies.com/photos/\">Photos</a></li> <li id=\"link_fashionandgear\"><a href=\"http://celebrity-babies.com/category/fashion-gear/\">Fashion &amp; Gear</a></li> <li id=\"link_shopping\"><a href=\"http://celebrity-babies.com/category/shopping-guide/\">Shopping Guide</a></li> <li id=\"link_calendar\"><a href=\"http://www.people.com/people/celebritybabies/calendar/\">Calendar</a></li> <li id=\"link_contactus\"><a href=\"mailto:cbbtips@gmail.com\">Contact Us</a></li> <li id=\"link_mostpopular\"> <a href=\"javascript:void(0)\"><span class=\"parent\">Most Popular</span></a> <ul> <li><a href=\"http://celebritybabies.com/category/expecting/\"><span class=\"child\">Expecting News</span></a></li> <li><a href=\"http://celebrity-babies.com/category/moms-to-be/\"><span class=\"child\">Moms-to-Be</span></a></li> <li><a href=\"http://celebritybabies.com/category/babies/\"><span class=\"child\">Babies</span></a></li> <li><a href=\"http://celebritybabies.com/category/kids/\"><span class=\"child\">Kids</span></a></li> <li><a href=\"http://celebritybabies.com/category/dads/\"><span class=\"child\">Dads</span></a></li> <li><a href=\"http://celebritybabies.com/category/births/\"><span class=\"child\">Births</span></a></li> <li><a href=\"http://celebritybabies.com/category/parenting/\"><span class=\"child\">Parenting</span></a></li> <li><a href=\"http://celebritybabies.com/category/celeb-style/\"><span class=\"child\">Celeb Style</span></a></li> <li><a href=\"http://celebritybabies.com/category/health/\"><span class=\"child\">Health</span></a></li> <li><a href=\"http://celebritybabies.com/category/cbb-giveaways/\"><span class=\"child\">Giveaways</span></a></li> </ul></li></ul><form action=\"http://www.google.com/custom\" method=\"get\" id=\"search\" target=\"google_window\"> <input type=\"text\" name=\"q\" id=\"q\" size=\"15\" value=\" Search\" /> <input type=\"submit\" value=\"GO\" name=\"sa\" class=\"submit\" /> <input type=\"hidden\" name=\"domains\" value=\"celebrity-babies.com\"></input> <input type=\"hidden\" id=\"site1\" name=\"sitesearch\" value=\"celebrity-babies.com\" value=\"1\"></input> <input type=\"hidden\" name=\"client\" value=\"pub-\"></input> <input type=\"hidden\" name=\"forid\" value=\"1\"></input> <input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\"></input> <input type=\"hidden\" name=\"oe\" value=\"ISO-8859-1\"></input> <input type=\"hidden\" name=\"safe\" value=\"active\"></input> <input type=\"hidden\" name=\"cof\" value=\"GALT:#;GL:1;DIV:#;VLC:;AH:center;BGC:FFFFFF;LBGC:;ALC:0000FF;LC:0000FF;T:;GFNT:0000FF;GIMP:0000FF;FORID:1;\"></input> </form>";
/**** globals  ****/
var PEOPLE=window.PEOPLE||{};

/**** functions  ****/
var __eventListeners = [];//eventlistener functions, http://ajaxcookbook.org/

function addEventListener(instance, eventName, listener) {
    var listenerFn = listener;
    if (instance.addEventListener) {
        instance.addEventListener(eventName, listenerFn, false);
    } else if (instance.attachEvent) {
        listenerFn = function() {
            listener(window.event);
        };
        instance.attachEvent("on" + eventName, listenerFn);
    } else {
        //throw new Error("Event registration not supported");
    }
    var event = {
        instance: instance,
        name: eventName,
        listener: listenerFn
    };
    __eventListeners.push(event);
    return event;
}

function removeEventListener(event) {
    var instance = event.instance;
    if (instance.removeEventListener) {
        instance.removeEventListener(event.name, event.listener, false);
    } else if (instance.detachEvent) {
        instance.detachEvent("on" + event.name, event.listener);
    }
    for (var i = 0; i < __eventListeners.length; i++) {
        if (__eventListeners[i] == event) {
            __eventListeners.splice(i, 1);
            break;
        }
    }
}

function unregisterAllEvents() {
    while (__eventListeners.length > 0) {
        removeEventListener(__eventListeners[0]);
    }
}

var qVal;
function windowOnload(){ //use cross browser onload call to resolve cross-browser conflict, http://cross-browser.com/talk/onload_conflict.html
	
	//search input box listener: empty default value on click, reload if unchanged on blur, else leave as what user input
	qVal = window.document.getElementById('q').value;
	PEOPLE.listener = addEventListener(window.document.getElementById('q'), "click", function() {
		if(window.document.getElementById('q').value == qVal){ window.document.getElementById('q').value = ''; }
	});
	PEOPLE.listener = addEventListener(window.document.getElementById('q'), "blur", function() {
		if(window.document.getElementById('q').value === ''){ window.document.getElementById('q').value = qVal; }
	});
}

//son of suckerfish hover state for IE, http://htmldog.com/articles/suckerfish/dropdowns/
PEOPLE.sfHover = function() {
	var sfEls = window.document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		};
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		};
	}
}; if (window.attachEvent) { window.attachEvent("onload", PEOPLE.sfHover); }

/****  window listeners  ****/
window.onload = windowOnload;