﻿// Carousel pagination functions

if (jQuery(".left_arrow1").hasClass("inactive") == true) {
	jQuery(".left_arrow1").css("backgroundPosition","0 0");
}

if (jQuery(".right_arrow1").hasClass("inactive") == true) {
	jQuery(".right_arrow1").css("backgroundPosition","-168px 0");
}

if (jQuery(".left_arrow2").hasClass("inactive") == true) {
	jQuery(".left_arrow2").css("backgroundPosition","0 0");
}

if (jQuery(".right_arrow2").hasClass("inactive") == true) {
	jQuery(".right_arrow2").css("backgroundPosition","-168px 0");
}

var countObject1 = jQuery(".cc1 > div.cc_div > div.cc_visible > div.cc_clone > div.cc_item");
var count1 = countObject1.size();
var marginAmount1 = 0;
var position1 = 0;
var maxPosition1 = count1 - 1;


var countObject2 = jQuery(".cc2 > div.cc_div > div.cc_visible > div.cc_clone > div.cc_item");
var count2 = countObject2.size();
var marginAmount2 = 0;
var position2 = 0;
var maxPosition2 = count2 - 1;



function checkMaxPos(ccnumber, direction, ccinav) {
	ccnumber_full = ".cc" + ccnumber;
	direction = "." + direction;
	var affectThis = jQuery(ccnumber_full).children(direction);
	jQuery(affectThis).removeClass("inactive");
	if (ccnumber == 1) {
		jQuery('.cci_navlinks_next').removeClass("inactive");
	} else if (ccnumber == 2) {
		jQuery('.cci_navlinks_next2').removeClass("inactive");
	}
	if (direction == ".left_arrow" + ccnumber) {
		jQuery(affectThis).css("backgroundPosition","-34px 0");
	} else if (direction == ".right_arrow" + ccnumber)  {
		jQuery(affectThis).css("backgroundPosition","-134px 0");
	}
}


	jQuery(".left_arrow1, .cci_navlinks_prev").live("click", function() {
		if (position1 != 0) {
			position1--;
			if (marginAmount1 < 0) {
				marginAmount1 = marginAmount1 + 609;
			}
			marginAmount1 = marginAmount1;		
		
			jQuery(".cc1").children(".cc_div").children('.cc_visible').animate({
				marginLeft: marginAmount1 + "px"
			}, 500, function() {
				// Animation complete.	
				
				if (position1 == 0) {
					jQuery('.left_arrow1').css("backgroundPosition","0 0");
					jQuery('.left_arrow1, .cci_navlinks_prev').addClass("inactive");
				} else {
					jQuery('.left_arrow1').css("backgroundPosition","-34px 0");
					
				}
				return position1;			
			});
			if (position1 > 0) {
				checkMaxPos('1','right_arrow1','cci_navlinks_next');
			}
		}
	});		

	
	jQuery(".right_arrow1, .cci_navlinks_next").live("click", function() {
		if ((position1 != maxPosition1) && (maxPosition1 > 0)) {
			position1++;
			jQuery(".left_arrow1").css("backgroundPosition","-68px 0");
			jQuery(".left_arrow1, .cci_navlinks_prev").removeClass("inactive");
			if (marginAmount1 <= 0) {
				marginAmount1 = marginAmount1 - 609;
			}
			marginAmount1 = marginAmount1;		
			jQuery(".cc1").children(".cc_div").children('.cc_visible').animate({
				marginLeft: marginAmount1 + "px"
			}, 500, function() {
				// Animation complete.	
				
				if (position1 == maxPosition1) {
					jQuery('.right_arrow1').css("backgroundPosition","-168px 0");
					jQuery('.right_arrow1, .cci_navlinks_next').addClass("inactive");
				} else {
					jQuery('.right_arrow1').css("backgroundPosition","-134px 0");
				}
				return position1;			
			});	
			if (position1 < maxPosition1) {
				checkMaxPos('1','left_arrow1','cci_navlinks_prev');						
			}			
			
		}
	});	
	
	jQuery(".left_arrow1, .cci_navlinks_prev").mouseenter(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-68px 0");	
		}
	});
	
	jQuery(".left_arrow1, .cci_navlinks_prev").mouseleave(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-34px 0");	
		}
	});
	
	jQuery(".right_arrow1, .cci_navlinks_next").mouseenter(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-100px 0");	
		}
	});
	
	jQuery(".right_arrow1, .cci_navlinks_next").mouseleave(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-134px 0");	
		}
	});	
	
	
	
	jQuery(".left_arrow2, .cci_navlinks_prev2").live("click", function() {
		if (position2 != 0) {
			position2--;
			if (marginAmount2 < 0) {
				marginAmount2 = marginAmount2 + 609;
			}
			marginAmount2 = marginAmount2;		
		
			jQuery(".cc2").children(".cc_div").children('.cc_visible').animate({
				marginLeft: marginAmount2 + "px"
			}, 500, function() {
				// Animation complete.	
				
				if (position2 == 0) {
					jQuery('.left_arrow2').css("backgroundPosition","0 0");
					jQuery('.left_arrow2,.cci_navlinks_prev2').addClass("inactive");
				} else {
					jQuery('.left_arrow2').css("backgroundPosition","-34px 0");
				}
				return position2;			
			});
			if (position2 > 0) {
				checkMaxPos('2','right_arrow2','cci_navlinks_prev2');						
			}
		}
	});		

	
	jQuery(".right_arrow2, .cci_navlinks_next2").live("click", function() {
		if ((position2 != maxPosition2) && (maxPosition2 > 0)) {
			position2++;
			jQuery(".left_arrow2").css("backgroundPosition","-68px 0");
			jQuery(".left_arrow2, .cci_navlinks_prev2").removeClass("inactive");
			if (marginAmount2 <= 0) {
				marginAmount2 = marginAmount2 - 609;
			}
			marginAmount2 = marginAmount2;		
			jQuery(".cc2").children(".cc_div").children('.cc_visible').animate({
				marginLeft: marginAmount2 + "px"
			}, 500, function() {
				// Animation complete.	
				
				if (position2 == maxPosition2) {
					jQuery('.right_arrow2').css("backgroundPosition","-168px 0");
					jQuery('.right_arrow2, .cci_navlinks_next2').addClass("inactive");
				} else {
					jQuery('.right_arrow2').css("backgroundPosition","-134px 0");
				}
				return position2;			
			});	
			if (position2 < maxPosition2) {
				checkMaxPos('2','left_arrow2','.cci_navlinks_prev2');						
			}			
		}
	});	
	
	jQuery(".left_arrow2").mouseenter(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-68px 0");	
		}
	});
	
	jQuery(".left_arrow2").mouseleave(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-34px 0");	
		}
	});
	
	jQuery(".right_arrow2").mouseenter(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-100px 0");	
		}
	});
	
	jQuery(".right_arrow2").mouseleave(function() {
		if(jQuery(this).hasClass("inactive") == false) {		
			jQuery(this).css("backgroundPosition","-134px 0");	
		}
	});		

	
// Superfooter Height equalization script
c1height = jQuery("#super_footer > #column1").height();
c2height = jQuery("#super_footer > #column2").height();
c3height = jQuery("#super_footer > #column3").height();
	
c1height = c1height + 15;
c2height = c2height + 15;
c3height = c3height + 15;
if ((c1height > c2height) && (c1height > c3height)) {
	jQuery("#super_footer > #column2").height(c1height);
	jQuery("#super_footer > #column3").height(c1height);	
}

if ((c2height > c1height) && (c2height > c3height)) {
	jQuery("#super_footer > #column1").height(c2height);
	jQuery("#super_footer > #column3").height(c2height);	
}

if ((c3height > c2height) && (c3height > c1height)) {
	jQuery("#super_footer > #column1").height(c3height);
	jQuery("#super_footer > #column2").height(c3height);	
}



// Progressive disclosure scripts
jQuery(".progressive_disclosure").children(".pd_item:first").addClass("tbo");
jQuery(".pd_item").each(function() {
	jQuery(this).children(".pd_content").children(".pd_item:first").addClass("tbo");
	jQuery(this).children(".pd_content").children(".pd_item:last").addClass("nbb");	
});

jQuery(".pd_text").each(function() {
	if (jQuery(this).children("h3").val() != false && jQuery(this).children(".left_col").val() != false) {
		jQuery(this).children("p:first").css("paddingTop","0px");	
	} 
});

jQuery(".left_col").each(function() {
	if (jQuery(this).children("h3").val() != false) {
		jQuery(this).children("p:first").css("paddingTop","0px");	
	} 			
});

jQuery(".right_col").each(function() {
	if (jQuery(this).children("h3").val() != false) {
		jQuery(this).children("p:first").css("paddingTop","0px");	
	} 			
});		

jQuery(".pd_header").each(function() {
	var tmptmp = jQuery(this).children(".pd_title").html();
	var tmptmp2 = tmptmp.length;
	if (tmptmp2 > 120) {
		if (jQuery.browser.msie) {
			jQuery(this).css("paddingBottom", "40px");							
		} else {
			jQuery(this).css("paddingBottom", "55px");			
		}				
	} else {
		if (jQuery.browser.msie) {
			jQuery(this).css("paddingBottom", "20px");							
		} else {
			jQuery(this).css("paddingBottom", "35px");			
		}
	}
});

jQuery(".pd_header").mouseenter(function(){
	jQuery(this).css("backgroundColor","#FFFFFF");
});

jQuery(".pd_header").mouseleave(function(){
	jQuery(this).css("backgroundColor","#f3f3f3");										 
});	

jQuery(".pd_header").live("click",function() {
	jQuery(this).siblings(".pd_content").slideToggle(250, function() {
		var tmp = jQuery(this).siblings(".pd_header").children(".pd_icon").children("img");
		if (tmp.attr("src") == "/certification/images/icon_expand.png") {
			tmp.attr("src","/certification/images/icon_collapse.png");	
		} else {
			tmp.attr("src","/certification/images/icon_expand.png");					
		}
	});
	
});	
		
jQuery("#expand_all").live("click",function() {
	jQuery(".pd_content").each(function() {
		jQuery(this).slideDown(250, function() {
			jQuery(this).siblings(".pd_header").children(".pd_icon").children("img").attr("src","/certification/images/icon_collapse.png");
		});	
	});
	
});	

jQuery("#collapse_all").live("click",function() {
	jQuery(".pd_content").each(function() {
		jQuery(this).slideUp(250, function() {
			jQuery(".pd_content").siblings(".pd_header").children(".pd_icon").children("img").attr("src","/certification/images/icon_expand.png");
		});	
	});
	
});



var tempOS = window.navigator.platform;
if (jQuery.browser.mozilla && tempOS.indexOf("Mac") >= 0) {
	jQuery(".sort_arrow").css("marginLeft","0px");
}

if(jQuery.browser.msie && jQuery.browser.version=="6.0") {
	jQuery("th").each(function() {
		var temp = jQuery(this).children("strong").html().length;
		if (temp > 15) {
			jQuery(this).children(".sort_arrow").css("marginTop","-15px");	
		}
	});				
}
	

// Dropdown menu re-skin script	
jQuery(".everything").click(function(){
	jQuery(".dropdown").children("dd").children("ul").hide();
});

jQuery(".dropdown dt").live("click", function(e) {
	e.stopPropagation();
	if (!jQuery(this).hasClass("clicked")) {
		jQuery(this).siblings("dd").children("ul").toggle();
	}
});

jQuery(".dropdown dd ul li a").live("click", function(e) {
	e.preventDefault();
	e.stopPropagation();
	var value = jQuery(this).attr("href");
	var text = jQuery(this).html();
	jQuery(this).parent("li").parent("ul").parent("dd").siblings("dt").children("span.value").html(value);
	jQuery(this).parent("li").parent("ul").parent("dd").siblings("dt").children("span.display").html(text);
	jQuery(this).parent("li").parent("ul").hide();
	var pathname = window.location.pathname;
	if (pathname.indexOf("view_certifications") != -1) {
		if (value == "#") {
			jQuery("#cert_tables_filter_path").attr("value","");
		} else {
			jQuery("#cert_tables_filter_path").attr("value",value);
		}
	}
});

// Radio and Checkbox scripts

jQuery("label").live("click", function() {
	if (jQuery(this).siblings("input").attr("type") == "radio") {
		var tmpNAME = jQuery(this).siblings("input").attr("name");
		jQuery("input").each(function(){
			if (jQuery(this).attr("name") == tmpNAME) {
				jQuery(this).siblings("label").removeClass("on");
				jQuery(this).siblings("label").children(".radio_replace").removeClass("radio_on");
			}
		});
		tmpNAME = "";
	}
	
	if (jQuery(this).children("span.radio_replace").size() > 0) {
		if (jQuery(this).hasClass("on")) {
			jQuery(this).children(".radio_replace").removeClass("radio_on");
			jQuery(this).removeClass("on");
		} else {
			jQuery(this).children(".radio_replace").addClass("radio_on");
			jQuery(this).addClass("on");						
		}
	} else if (jQuery(this).children(".checkbox_replace")) {
		if (jQuery(this).hasClass("on")) {
			jQuery(this).children(".checkbox_replace").removeClass("checkbox_on");		
			jQuery(this).removeClass("on");			
		} else {
			jQuery(this).children(".checkbox_replace").addClass("checkbox_on");	
			jQuery(this).addClass("on");
		}
	}
	
});

//Tooltip code
	var intId = "";
	jQuery(".help_link").mouseenter(function() {
		var thisID = jQuery(this);
		intId = setTimeout(function() { jQuery(thisID).children(".help_tt").css("display","block"); }, 1000);											 
	});				
	
	jQuery(".help_link").mouseleave(function() {
		jQuery(this).children(".help_tt").css("display","none");
		clearTimeout(intId);
	});	


//Menus code

jQuery('document').ready(function() {

	
	
	var urlArr = location.pathname.split('/');
	if (urlArr.length > 1) {
		urlArr = urlArr.slice(urlArr.length - 2, urlArr.length);
	}
	var url = urlArr.join("/");

	// collapse all nested lists
	collapseList('ul.rightnavlist ul');

	// recurse through list elements, looking for link matching current page filename
	searchLink('ul.rightnavlist', url, function(e) {

		var linkText = jQuery(e).html(); // text content of hyperlink
		var listElement = jQuery(e).parent('li');
		
		// remove hyperlink and reconstruct the list item and contained sublist
		jQuery(listElement).children('a:first').remove();
		var liContent = jQuery(listElement).html();
		liContent = linkText + liContent;
		jQuery(listElement).html(liContent); // insert reconstructed list item and contained sublist

		// show parent and child lists
		jQuery(listElement).children('ul').show();
		jQuery(listElement).parents('ul').show();
		jQuery(listElement).parents('ul li').addClass('open');
		if (jQuery(listElement).parents('ul').size() < 3) {
			if (jQuery(listElement).children('ul').size() != 0) {
				jQuery(listElement).addClass('active');
			} else {
				jQuery(listElement).addClass('active_nochild');
			}
		}
	});
	
	function collapseList(list)	{
		jQuery(list).each(function() {
			jQuery(this).hide();
		});
	}

	function searchLink(list, link, callback) {
		var hasHtml = true;
		if (link.split('.').pop() != 'html') {
			hasHtml = false;
		}
		
		var links = jQuery(list).find('li a');
		jQuery(links).each(function() {
			var linkUrl = jQuery(this).attr('href');
			var linkUrlArr = linkUrl.split('/');
			if (linkUrlArr.length > 1) {
				linkUrlArr = linkUrlArr.slice(linkUrlArr.length - 2, linkUrlArr.length);
			}
			var linkForSearch = hasHtml ? linkUrlArr.join("/") : linkUrlArr[0].concat('/');

			if (link === linkForSearch) {
				callback(this);
			}
		});
	}
	
	jQuery("#noFilter").siblings("label").children(".radio_replace").addClass("radio_on");
	
});




	
