/*function openCalendar(FormElement){
	var calendarwindow;
	url = "calendar.html?formname=resform&formelement=" + FormElement;
	calendarwindow = window.open(url,"thewindow","toolbar=no,LEFT=700,TOP=400,WIDTH=180,HEIGHT=150,status=no,scrollbars=no,resize=no,menubar=no");
	calendarwindow.focus();
}*/

function createRollovers() {
    var onText = "-on",
        offText = "-off";
 
    $('img.rollover' ).each( function() {

        var onImg = $(this).attr('src').replace(offText,onText),
            offImg = $(this).attr('src').replace(onText,offText);
        
        $(this).bind('mouseenter', function () {
            $(this).attr('src', onImg );
        });
        $(this).bind('mouseleave', function () {
            $(this).attr('src', offImg );
        });
    });
 
    return;
}

$(document).ready(function () {
    createRollovers();
});

//Clear fields
function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}

// show/hide subnavs
	var timeout    = 500;
	var closetimer = 0;
	var navitem = 0;

	function nav_open(){
		nav_canceltimer();
		   nav_close();
		   show_sub();
		   navitem = $(this).find('ul').css('visibility', 'visible');

	}

	function nav_close(){
		if(navitem) navitem.css('visibility', 'hidden');

	}

	function nav_timer(){
		closetimer = window.setTimeout(hide_sub, timeout);
	}

	function nav_canceltimer(){
		if(closetimer){
			window.clearTimeout(closetimer);
		        closetimer = null;
	}}
	
	function hide_sub(){
	$("#subStory,#subCapability,#subPortfolio,#subMedia,#subCareers,#subResponsibility").fadeOut("slow");
	}
	
	function show_sub(){
	$("#subStory,#subCapability,#subPortfolio,#subMedia,#subCareers,#subResponsibility").fadeIn("slow");
	}


	$(document).ready(function(){
		$('#nav > li').bind('mouseover', nav_open)
		$('#nav > li').bind('mouseout',  nav_timer)
	});


