/**************  GLOBAL JS  ****************  */
	
// FAQ PAGE
$(document).ready(function() {
var content = $('#faq-block dd, #portal-data dd, #portal-data div.expand'),
	target = $('#faq-block dt, #portal-data dt, #portal-data .sns-prod'),
	btnClose = $('#faq-block dd span, #portal-data dd p');
content.hide();

target.click(function () {
		$(this).toggleClass('open').next().animate({
		"height": "toggle",
		"opacity": "1.0"
		}, 700);
	}); 
	btnClose.click(function () {
	if ( target.hasClass('open') ) {
	target.removeClass('open');
	}
	$(this).parent().slideUp();

	 });
 });
 
$(document).ready(function() {
	var location = $("#primary-content ul.ind-list li");
	//move the image in pixel
	var move = -15;	
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;

	//On mouse over those thumbnail
	$('.caption').hover(function() {

		width = $('.caption').width() * zoom;
		height = $('.caption').height() * zoom;
		
		//Move and zoom the image
		$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('.txt-cap').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$(this).find('img').stop(false,true).animate({'width':$('.caption').width(), 'height':$('.caption').height(), 'top':'0', 'left':'0'}, {duration:100});	
		//Hide the caption
		$(this).find('.txt-cap').stop(false,true).fadeOut(200);
	});
	// Make block a link
	location.click(function () {
	var url = $(this).find("a").attr('href');
	window.location = url;
	});

}); 

$(document).ready(function(){
	var parentLi = $('ul#nav_sub.product-group li:first ul li:first');
		parentLi.addClass('first');
		
		if ( parentLi.children().size() > 1 ) { 
			parentLi.addClass('has-children');
		} else {
			parentLi.removeClass('has-children');
		}
	}); 

$(document).ready(function() {

$('.window').colorbox();
$("#rep").colorbox({inline:true, href:"#rep-container"});
$("#search").colorbox({inline:true, href:"#zip-container"});
$("#window").colorbox({width:"80%", height:"100%", scrolling: "false", iframe:true});
$(".outside").colorbox({width:"70%", height:"100%", scrolling: "false", iframe:true});
$("a[rel='gallery'], a.blowup").colorbox({
						transition:"elastic",
						speed: 1000,													
						scrolling: "false"
						});

					});
					
$(document).ready(function() {
	$('ul#callout').cycle({ 
    fx:     'fade', 
	speed:   2000, 
    timeout: 8000,
	pause: 1
	});	
}); 

$(document).ready(function() {
	$('ul#callout2').cycle({ 
    fx:     'fade', 
	speed:   2000, 
    timeout: 9000,
	pause: 1
	});	
}); 


$(document).ready(function(){
       $(".scroll").click(function(event){
               //prevent the default action for the click event
               event.preventDefault();

               //get the full url - like mysitecom/index.htm#home
               var full_url = this.href;

               //split the url by # and get the anchor target name - home in mysitecom/index.htm#home
               var parts = full_url.split("#");
               var trgt = parts[1];

               //get the top offset of the target anchor
               var target_offset = $("#"+trgt).offset();
               var target_top = target_offset.top;

               //goto that anchor by setting the body scroll top to anchor top
               $('html, body').animate({scrollTop:target_top}, 1200);
       });
});

$(document).ready(function() {

// temporary link to google traslate - remember to get this idiot thing out of here when fr fields go live
	$('a#frlg').click(function () {
	window.open('http://www.google.com/translate_p?u='+encodeURIComponent(location.href)+'&langpair=en%7Cfr&hl=en&ie=UTF8'); 
	return false;
	});
	
	 $("a[href*='http://']:not([href*='"+location.hostname+"'])")
    .attr("target","_blank")
    .addClass("external");
	$("a[href$='.pdf']").addClass("pdf").attr("target","_blank");
	$("a[href$='.doc'], a[href$='.DOC']").addClass("ms-word").attr("target","_blank");
	
 });

