// Top Navigation Controllers
	var menuTimer = 0;
	
	// set rollover state of top nav
	function activateNav(div, img){
		document.getElementById('birthday').src='images/custom/nav/birthday.jpg';
		document.getElementById('love_and_marriage').src='images/custom/nav/love_and_marriage.jpg';
		document.getElementById('new_baby').src='images/custom/nav/new_baby.jpg';
		document.getElementById('holidays_and_celebrations').src='images/custom/nav/holidays_and_celebrations.jpg';
		document.getElementById('graduation').src='images/custom/nav/graduation.jpg';
		document.getElementById('other_occasions').src='images/custom/nav/other_occasions.jpg';
		document.getElementById('just_because').src='images/custom/nav/just_because.jpg';
		
		document.getElementById(div).src=img;
	}
	
	function displaySubNavigation(node_id, cid){
		clearTimeout(menuTimer);
		// turn off navigation that should not be visible
		var div = "";
		var nodes = new Array(11, 12, 3, 5, 26, 27, 34);
		
        //document.getElementById('div_categoty_9').style.visibility='hidden';
		//document.getElementById('div_categoty_7').style.visibility='hidden';
		//document.getElementById('div_categoty_6').style.visibility='hidden';
		//document.getElementById('div_categoty_80').style.visibility='hidden';
        //document.getElementById('div_categoty_2').style.visibility='hidden';
		
/*		var arrows = new Array(9, 7, 6, 80, 2);
		for (var i=0; i<5; i++){
			arrow = "arrow_"+arrows[i];
			document.getElementById(arrow).src='images/custom/arrow_down.gif';
		}
*/		
		for (var i=0; i<7; i++){
			if(nodes[i] != cid){
				div = "div_categoty_"+nodes[i]; 
				document.getElementById(div).style.visibility='hidden';
			}
		}
		
		// turn on active subnavigation
		document.getElementById(node_id).style.visibility='visible';
		
		// set timer to automatically close sub navigation
		menuTimer = setTimeout("offSubNavigation()", 8000);
	}
	function offSubNavigation(){
		// deactivate topnav
		document.getElementById('birthday').src='images/custom/nav/birthday.jpg';
		document.getElementById('love_and_marriage').src='images/custom/nav/love_and_marriage.jpg';
		document.getElementById('new_baby').src='images/custom/nav/new_baby.jpg';
		document.getElementById('holidays_and_celebrations').src='images/custom/nav/holidays_and_celebrations.jpg';
		document.getElementById('graduation').src='images/custom/nav/graduation.jpg';
		document.getElementById('other_occasions').src='images/custom/nav/other_occasions.jpg';
		document.getElementById('just_because').src='images/custom/nav/just_because.jpg';
		
		// deactivate subnav
        document.getElementById('div_categoty_11').style.visibility='hidden';
		document.getElementById('div_categoty_12').style.visibility='hidden';
		document.getElementById('div_categoty_3').style.visibility='hidden';
		document.getElementById('div_categoty_5').style.visibility='hidden';
		document.getElementById('div_categoty_26').style.visibility='hidden';
		document.getElementById('div_categoty_27').style.visibility='hidden';
		document.getElementById('div_categoty_34').style.visibility='hidden';
		//document.getElementById('div_categoty_9').style.visibility='hidden';
		//document.getElementById('div_categoty_7').style.visibility='hidden';
		//document.getElementById('div_categoty_6').style.visibility='hidden';
		document.getElementById('div_categoty_80').style.visibility='hidden';
        document.getElementById('div_categoty_2').style.visibility='hidden';  
		
		var arrows = new Array(9, 7, 6, 80, 2);
		for (var i=0; i<5; i++){
			arrow = "arrow_"+arrows[i];
			document.getElementById(arrow).src='images/custom/arrow_down.gif';
		}
	}
	function resetMenuTimer(){
		clearTimeout(menuTimer);
		menuTimer = setTimeout("offSubNavigation()", 8000);	
	}


// Gift Finder Navigation Controllers
	var GiftMenuTimer = 0;
	function displaySubGiftNavigation(node_id, cid){
        document.getElementById('birthday').src='images/custom/nav/birthday.jpg';
        document.getElementById('love_and_marriage').src='images/custom/nav/love_and_marriage.jpg';
        document.getElementById('new_baby').src='images/custom/nav/new_baby.jpg';
        document.getElementById('holidays_and_celebrations').src='images/custom/nav/holidays_and_celebrations.jpg';
        document.getElementById('graduation').src='images/custom/nav/graduation.jpg';
        document.getElementById('other_occasions').src='images/custom/nav/other_occasions.jpg';
        document.getElementById('just_because').src='images/custom/nav/just_because.jpg';
        
		clearTimeout(GiftMenuTimer);
		// turn off navigation that should not be visible
		var div = "";
		var arrow = "";
		var nodes = new Array(9, 7, 6, 80, 2);
		
		document.getElementById('div_categoty_11').style.visibility='hidden';
		document.getElementById('div_categoty_12').style.visibility='hidden';
		document.getElementById('div_categoty_3').style.visibility='hidden';
		document.getElementById('div_categoty_5').style.visibility='hidden';
		document.getElementById('div_categoty_26').style.visibility='hidden';
		document.getElementById('div_categoty_27').style.visibility='hidden';
		document.getElementById('div_categoty_34').style.visibility='hidden';
		
		// close arrows
		for (var i=0; i<5; i++){
			if(nodes[i] != cid){
				div = "div_categoty_"+nodes[i]; 
				document.getElementById(div).style.visibility='hidden';
				// change arrow to the down position
				arrow = "arrow_"+nodes[i];
				document.getElementById(arrow).src='images/custom/arrow_down.gif';
			}else{
				arrow = "arrow_"+nodes[i];
				document.getElementById(arrow).src='images/custom/arrow_rt.gif';
			}
		}
		
		// turn on active subnavigation
		document.getElementById(node_id).style.visibility='visible';
		
		// set timer to automatically close sub navigation
		GiftMenuTimer = setTimeout("offSubNavigation()", 8000);
	}
	function offSubGiftNavigation(){    
    //document.getElementById('div_categoty_9').style.visibility='hidden';
		//document.getElementById('div_categoty_7').style.visibility='hidden';
		//document.getElementById('div_categoty_6').style.visibility='hidden';
		document.getElementById('div_categoty_80').style.visibility='hidden';
        document.getElementById('div_categoty_2').style.visibility='hidden'; 
		document.getElementById('div_categoty_11').style.visibility='hidden';
		document.getElementById('div_categoty_12').style.visibility='hidden';
		document.getElementById('div_categoty_3').style.visibility='hidden';
		document.getElementById('div_categoty_5').style.visibility='hidden';
		document.getElementById('div_categoty_26').style.visibility='hidden';
		document.getElementById('div_categoty_27').style.visibility='hidden';
		document.getElementById('div_categoty_34').style.visibility='hidden';
		document.getElementById('price').style.visibility='hidden';
		
		var arrows = new Array(9, 7, 6, 80, 2);
		for (var i=0; i<5; i++){
			arrow = "arrow_"+arrows[i];
			document.getElementById(arrow).src='images/custom/arrow_down.gif';
		}
	}
	function resetGiftMenuTimer(){
		clearTimeout(GiftMenuTimer);
		GiftMenuTimer = setTimeout("offSubNavigation()", 8000);
	}
	

	// more wishes attribute drop down box
	function moreWishes(){
		frm_wish = document.getElementById("wish_value").value;
		if(frm_wish == "more"){
			xajax_processAjaxAction("attributes_wish", "");
		}
	}
	

	// more occasions attribute drop down box
	function moreOccasions(){
		frm_occasion = document.getElementById("occasion_value").value;
		if(frm_occasion == "more"){
			xajax_processAjaxAction("attributes_occasions", "");
		}
	}
    
    // show New Address Form on Step 1
    function selectShippingAddress(recipient_key, occasion_key, field){
        if(field.value == "new"){
            document.getElementById('new_address_hide_1'+recipient_key+'_'+occasion_key).style.display='block';
            document.getElementById('new_address_hide_2'+recipient_key+'_'+occasion_key).style.display='block'; 
        }else{
            document.getElementById('new_address_hide_1'+recipient_key+'_'+occasion_key).style.display='none';
            document.getElementById('new_address_hide_2'+recipient_key+'_'+occasion_key).style.display='none'; 
        }
    }
    
    // toggel display of a div tag
    function toggleSignupDisplay(div){
        current_display = document.getElementById(div).style.display;
        
        if(current_display == "none"){
            billing_email_address = document.getElementById('billing_address_email').value;
            
            if(billing_email_address != ""){
                document.getElementById(div).style.display = "block";
                document.getElementById('signup_login').value = billing_email_address;
                document.getElementById('signup_login_display').value = billing_email_address;
            }else{
                document.getElementById('signup_checkbox').checked = false;
                alert("Please fill in your billing information first.");
            }
        }else{
            document.getElementById(div).style.display = "none";
        }
    }
    
    // toggel display of gift message div tag
    function toggleGiftMessage(div){
        current_display = document.getElementById(div).style.display;
        
        if(current_display == "none"){
            document.getElementById(div).style.display = "block";
            document.getElementById('signup_login').value = billing_email_address;
            document.getElementById('signup_login_display').value = billing_email_address;
        }else{
            document.getElementById(div).style.display = "none";
        }
    }
    
    
    // CONCIERGE AJAX EVENTS DURING THE CHECKOUT PROCESS
    // add a concierge event
    function addNewConciergeEvent(){
    
        concierge_date          = document.getElementById("date").value;
        concierge_name          = document.getElementById("concierge_name").value;
        concierge_notes         = document.getElementById("concierge_notes").value;
        
        if(concierge_name != ""){
            xajax_processAjaxAction("add_concierge_event", concierge_date, concierge_name, concierge_notes);
        }else{
            alert("Please enter a Name for this concierge event.");
            document.forms["frmBillingShippingMethod"].elements["concierge_name"].focus();
        }
    }
    
    // delete a concierge event
    function deleteConciergeEvent(conid){
        if(confirm("Do you really want to delete this event?")){
            xajax_processAjaxAction("delete_concierge_event", conid);
        } 
    }
    
    // change concierge status
    function changeConciergeStatus(status){
        if(status == "No"){
            if(confirm("Do you really want to turn off your Concierge reminders?")){
                xajax_processAjaxAction("change_concierge_status", status);
            }
        }else{
            xajax_processAjaxAction("change_concierge_status", status);
        } 
    }
    
    // change concierge status
    function editConciergeEvent(conid){
    
        concierge_date          = document.getElementById("date").value;
        concierge_name          = document.getElementById("concierge_name").value;
        concierge_notes         = document.getElementById("concierge_notes").value;
    
        if(concierge_name != ""){
            xajax_processAjaxAction("edit_concierge_event", conid, concierge_date, concierge_name, concierge_notes);
        }else{
            alert("Please enter a Name for this concierge event.");
            document.forms["frmBillingShippingMethod"].elements["concierge_name"].focus();
        } 
    }
		
		
		function ShowPopup2(src){
	var bWin = null;
//***
	bWin = window.open(
		src, 
		"PopupWind", 
		"titlebar=no, toolbar=no, menubar=no, status=no, resizable=yes, directories=no, scrollbars=yes, top=20, left=20, width=1100, height=1100"
	);
//***
	while(bWin==null);
	bWin.focus();
}