/* 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";
}


/* GLOBAL STICKY NAV */

$(document).ready(function() {
	
	var rootPath = location.pathname.split("/");
    if (rootPath[2] == "crest-products")
        document.getElementById("nav1").className = "liNavActive";
    if (rootPath[2] == "dental-hygiene-topics")
        document.getElementById("nav2").className = "liNavActive";
    if (rootPath[2] == "crest-advisory-board")
        document.getElementById("nav3").className = "liNavActive";
    if (rootPath[2] == "crest-coupons")
        document.getElementById("nav4").className = "liNavActive";
      
    //for interstitial close button
    $("#closeInt").click(function() {
        $("#leaveSite").hide();
    }); 
});

function launchInterstitial(Url, TopPx, bottomTop)
{
    //alert(findPos(document.getElementById("footer")));
     $("#leaveSite").show();
     document.getElementById("dialogHref").href = Url;
     if (typeof(itemIndex)=="undefined")
        itemIndex = "0";
     
     if (bottomTop == "top")
     {
        document.getElementById("leaveSite").style.marginTop = (parseInt(findPos(document.getElementById("main"))) + parseInt(TopPx) + 'px');
        //alert((parseInt(findPos(document.getElementById("main"))) + parseInt(TopPx) + 'px'));
     }
     else
     {
        document.getElementById("leaveSite").style.marginTop = (parseInt(findPos(document.getElementById("footer"))) - parseInt(TopPx) + 'px');
        //alert(parseInt(findPos(document.getElementById("footer"))) + " " + parseInt(TopPx));
     }
}

function launchAltInterstitial(Url, myObj, bottomTop)
{
    //alert(findPos(document.getElementById('buyNowButton')));
    //alert(findPos(document.getElementById("footer")));
     $("#leaveSite").show();
     document.getElementById("dialogHref").href = Url;
     if (typeof(itemIndex)=="undefined")
        itemIndex = "0";
     
     if (bottomTop == "top")
     {
        document.getElementById("leaveSite").style.marginTop = (parseInt(findPos(myObj) - 300) + 'px');
        //alert((parseInt(findPos(document.getElementById("main"))) + parseInt(TopPx) + 'px'));
     }
     else
     {
        document.getElementById("leaveSite").style.marginTop = (parseInt(findPos(myObj)) - parseInt(350)) + 'px';
        //alert(parseInt(findPos(document.getElementById("footer"))) + " " + parseInt(TopPx));
     }
}

function closeInterstitial()
{
    $("#leaveSite").hide();
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curtop];
}