//add to Favourites
function bookmarksite(title, url)
{
	if (document.all)
		window.external.AddFavorite(url, title);
	else 
		if (window.sidebar)
			window.sidebar.addPanel(title, url, "");
}

//validateSearch
function validateSearch()
{
	fv =  new formValidator();
		
	if (fv.isEmpty("searchterm"))
		fv.raiseError("Please enter your search term.");
		
	if (fv.numErrors() > 0)
	{
		fv.displayErrors();
		return false;
	}
	else
	  return true;
}

//jquery Left Menu
jQuery(document).ready(function() {
	var options = { path: '/', expires: 10 };

	jQuery("#menu > li > a.expanded").find("ul").slideToggle("medium");
	jQuery("#menu > li > a.collapsed").click(function() {
		var currentId = jQuery(this).attr("id"); 
		jQuery.cookie('mbs'+currentId, currentId, options);
		jQuery(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
	});
	jQuery("#menu > li > a.expanded").click(function() {
		var currentId = jQuery(this).attr("id"); 
		jQuery.cookie('mbs'+currentId, null, options);
		jQuery(this).toggleClass("collapsed").toggleClass("expanded").find("+ ul").slideToggle("medium");
	});
});

//jquery Tabs
jQuery(document).ready(function() {
    var tabContainers = jQuery('#overview, #gallery, #videos, #products, #branches, #stockists, #mapper');
    jQuery('div.partner_tabs ul.tabnav a').click(function () {
        tabContainers.hide().stop().filter(this.hash).show();
        jQuery('div.partner_tabs ul.tabnav a').removeClass('selected');
        jQuery(this).addClass('selected');
        return false;
    }).filter(':first').click();
});

//jquery Submenu
jQuery(function(){
	jQuery(".sub_nav li").mouseenter(function() {
		jQuery(this).find('ul').css({'display' : 'block'});
    });
	jQuery(".sub_nav li").mouseleave(function() {
		jQuery(this).find('ul').css({'display' : 'none'});
    });
});

//jquery Contact List select
jQuery(function(){
	jQuery('.contactlist table tr').click(function() {
		jQuery(this).toggleClass('highlight').toggleClass('highlight_off');
    });
});

//jquery Contact List click fades + hover
jQuery(function(){
	jQuery('ul.ph_nav > li.contactlist > a, .sp_item > ul > li.add a, p.sublinks a').click(function() {
		jQuery("ul.mh_nav > li.list > p.contact_list_pop").fadeIn(1000).fadeOut(1000);
    });
	jQuery("ul.mh_nav li.list").mouseenter(function() {
		jQuery(this).find("p.contact_list_pop").show();
    });
	jQuery("ul.mh_nav li.list").mouseleave(function() {
		jQuery(this).find("p.contact_list_pop").hide();
    });
});

//jquery Home Tabs (Featured+Latest)
jQuery(function(){
	jQuery("div#controller").jFlow({
		slides: "#slides",
		width: "460px",
		height: "250px"
	});
});

//jquery Home Tabs (Featured+Latest)
jQuery(function(){
	jQuery(".tab_content").css({'margin-top':'-10000px'});
	jQuery("div.featured_latest ul.featurenav a:first").addClass("selected").show(); //Activate first tab
	jQuery(".tab_content:first").css({'margin-top':'0px'}); //Show first tab content
	
	//On Click Event
	jQuery("div.featured_latest ul.featurenav a").click(function() {
		jQuery("div.featured_latest ul.featurenav a").removeClass("selected"); //Remove any "active" class
		jQuery(this).addClass("selected"); //Add "active" class to selected tab
		jQuery(".tab_content").css({'margin-top':'-10000px'});
		var activeTab = jQuery(this).attr("href"); //Find the rel attribute value to identify the active tab + content
		jQuery(activeTab).css({'margin-top':'0px'}); //Fade in the active content
		return false;
	});
});
//jquery Home Tabs (Popular+Choice)
jQuery(function(){
	jQuery(".tab2_content").css({'margin-top':'-10000px'});
	jQuery("div.popular_choice ul.popnav a:first").addClass("selected").show(); //Activate first tab
	jQuery(".tab2_content:first").css({'margin-top':'0px'}); //Show first tab content
	
	//On Click Event
	jQuery("div.popular_choice ul.popnav a").click(function() {
		jQuery("div.popular_choice ul.popnav a").removeClass("selected"); //Remove any "active" class
		jQuery(this).addClass("selected"); //Add "active" class to selected tab
		jQuery(".tab2_content").css({'margin-top':'-10000px'});
		var activeTab = jQuery(this).attr("href"); //Find the rel attribute value to identify the active tab + content
		jQuery(activeTab).css({'margin-top':'0px'}); //Fade in the active content
		return false;
	});
});

//jquery Carousels
jQuery(function(){
	jQuery(".join_carousel").jCarouselLite({
        btnNext: ".join_next",
        btnPrev: ".join_prev",
		auto: 3000,
    	speed: 500,
		visible: 1
    });
	jQuery(".babygifts_carousel").jCarouselLite({
        btnNext: ".bg_next",
        btnPrev: ".bg_prev",
		auto: 3000,
    	speed: 500,
		visible: 3
    });
	jQuery(".featured_carousel").jCarouselLite({
        btnNext: ".featured_next",
        btnPrev: ".featured_prev",
		//auto: 3000,
    	speed: 500,
		visible: 4
    });
	jQuery(".latest_carousel").jCarouselLite({
        btnNext: ".latest_next",
        btnPrev: ".latest_prev",
		//auto: 3000,
    	speed: 500,
		visible: 4
    });

/*
	jQuery(".popular_carousel").jCarouselLite({
        btnNext: ".popular_next",
        btnPrev: ".popular_prev",
		//auto: 3000,
    	speed: 500,
		visible: 4
    });
	jQuery(".choice_carousel").jCarouselLite({
        btnNext: ".choice_next",
        btnPrev: ".choice_prev",
		//auto: 3000,
    	speed: 500,
		visible: 4
    });
*/

	jQuery(".babies_of_the_week_carousel").jCarouselLite({
        btnNext: ".bgpics_prev",
        btnPrev: ".bgpics_next",
    	speed: 500,
		visible: 5
    });
});

function getSelectedContacts()
{
	var checkBoxCount = 0;
	var checkBoxes = "";
	for (var i=0;i<document.frmContactList.elements.length;i++)
	{
 		if (document.frmContactList.elements[i].type == "checkbox")
		{
			checkBoxName = new String(document.frmContactList.elements[i].name);
			if (checkBoxName.substring(0, 3) == "chk")
			{
				if (document.frmContactList.elements[i].checked)
					checkBoxes = checkBoxName.slice(3,checkBoxName.length);
			}
		}
	}

	return checkBoxes;	
}

function validateContactList()
{
	checkBoxes = getSelectedContacts();
	if (checkBoxes == "")
	{
		alert('At least one vendor must be selected to in order to send an email.');
		return false;
	}
	else
	  return true;
}


