/* BEGIN: SUCKERFISH :hover for IE6 (used on drop-downs)
 * 
 * The suckerfish hover method mimics the :hover pseudo-class
 * for IE6 on any element by dynamically adding the sfHover class.
 * More info: http://www.htmldog.com/articles/suckerfish/hover/
 * 
 * This is globally applied for navigation, footer, and rss hovers.
 * Application is per element.  Add more here as necessary.
 * And don't forget, this is for IE6 only.
 */
/*sfHover = function() {
	
		var sfEls = document.getElementById("country_container");
		
	    var sfSelector = document.getElementById("country_selector");
	    
		sfEls.onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls.onmouseout=function() {
		    //sfSelector.style.display = "none";
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

*/
sfHover = function() {
	var sfEls = document.getElementById("country_container").getElementsByTagName("li");
	
	var sfEls2 = document.getElementById("dentalProf_container").getElementsByTagName("li");
	
	if (document.getElementById("navigation_container"))
	{
	    var sfEls3 = document.getElementById("navigation_container").getElementsByTagName("li");
	    
	    for (var i=0; i<sfEls3.length; i++) {
		    sfEls3[i].onmouseover=function() {
			    this.className+=" sfhover";
		    }
		    sfEls3[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		    }
	    }
	}
	
	if (document.getElementById("ph_navigation_container"))
	{
	    var sfEls4 = document.getElementById("ph_navigation_container").getElementsByTagName("li");
	    
	    for (var i=0; i<sfEls4.length; i++) {
		    sfEls4[i].onmouseover=function() {
			    this.className+=" sfhover";
		    }
		    sfEls4[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		    }
	    }
	}
	
	if (document.getElementById("leftnav_container"))
	{
	    var sfEls5 = document.getElementById("leftnav_container").getElementsByTagName("li");
	    
	    for (var i=0; i<sfEls5.length; i++) {
		    sfEls5[i].onmouseover=function() {
			    this.className+=" sfhover";
		    }
		    sfEls5[i].onmouseout=function() {
			    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		    }
	    }
	}
	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			//sfSelector.style.margin="auto";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	
	for (var i=0; i<sfEls2.length; i++) {
		sfEls2[i].onmouseover=function() {
			this.className+=" sfhover";
			//sfSelector.style.margin="auto";
		}
		sfEls2[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}

	
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/* END: SUCKERFISH :hover */

//product page enlarge image function

 function showLargeImg() {

	        $("#products-large-image-pop").fadeIn();
	        $("#products-large-image-pop img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg1() {

	        $("#board-large-image-pop1").fadeIn();
	        $("#board-large-image-pop1 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg2() {

	        $("#board-large-image-pop2").fadeIn();
	        $("#board-large-image-pop2 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg3() {

	        $("#board-large-image-pop3").fadeIn();
	        $("#board-large-image-pop3 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg4() {

	        $("#board-large-image-pop4").fadeIn();
	        $("#board-large-image-pop4 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg5() {

	        $("#board-large-image-pop5").fadeIn();
	        $("#board-large-image-pop5 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

 function showLargeImg6() {

	        $("#board-large-image-pop6").fadeIn();
	        $("#board-large-image-pop6 img.large-image").hide();
	        if (typeof(itemIndex)=="undefined")
	            itemIndex = "0";
}

/* TO MAKE A SPECIFIC TAB ON PRODUCTS PAGE ACTIVE */

function activeTab(param)
{ 
    //When any link is clicked
    //test to stop any playing videos
    try {
        if (flashMovie)
	        flashMovie.videoURL("");
    }
        catch(err)
    {
        //do nothing	
    }
    $('#tabs ul li').removeClass('active'); // Remove active class from all links
    var currentListItem = "#tabs ul li:eq(" + (parseInt(param) - 1) + ")";
    $(currentListItem).addClass('active'); //Set clicked link class to active
    var currentTab = "#tab-" + param; // Set variable currentTab to value of href attribute of clicked link
    $('#tabs > div').hide(); // Hide all divs
    //$('#tabs div div').show(); //Override for divs within parent div
    $(currentTab).show(); // Show div with id equal to variable currentTab
    return false;
}

function checkActiveTabs()
{
    //get querystring.  if dtab exists, then process activetab to show.
    
    tabValue = "";
    
    if (queryString("dTab"))
        activeTab(queryString("dTab"));
        
}


function queryString(theString) {
	qString = window.location.search.substring(1);
	qStringArray = qString.split("&");
	for (i=0;i<qStringArray.length;i++) {
		getString = qStringArray[i].split("=");
		if (getString[0] == theString) {
			return getString[1];
		}
	}
}


/* GLOBAL STICKY NAV */

$(document).ready(function() {
	
	var rootPath = location.pathname.split("/");
	
    if (rootPath[1] == "crest-products")
        document.getElementById("nav1").className = "liNavActive";
    if (rootPath[1] == "dental-hygiene-topics")
        document.getElementById("nav2").className = "liNavActive";
    if (rootPath[1] == "crest-advisory-board")
        document.getElementById("nav3").className = "liNavActive";
    if (rootPath[1] == "crest-coupons")
        document.getElementById("nav4").className = "liNavActive";
       
});