/* Email a friend */

function WindowPrint(){
	window.print();
}

function loadLogin(myform,nm){

	for (var i = 0, logins=myform.elements; i < logins.length; i++)
	{
		if(logins[i].name == nm && logins[i].checked)
		myform.action=logins[i].value;
	}
}

function getActionPanelHref(buttonName) {
	var href = jQuery("input[name="+buttonName+"]:checked").val();
	if (href !== undefined) {
		window.open(href,'_blank');
	}
}

/* Helpful hints in feedback form */
jQuery(document).ready(function() {
	jQuery("table#forms tr td").hover(function() {
		jQuery(this).find("div").stop().animate({left: "0", opacity:1}, "fast").css("display","block")
	}, function() {
		jQuery(this).find("div").stop().animate({left: "0", opacity: 0}, "fast")
	});
});

/* Increase / Decrease font size */
jQuery(document).ready(function(){
  // Reset Font Size
  var originalFontSize = jQuery('html').css('font-size');
  jQuery(".resetFont").click(function(){
  jQuery('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  jQuery(".increaseFont").click(function(){
  	var currentFontSize = jQuery('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 9);
    var newFontSize = currentFontSizeNum*1.2;
	jQuery('html').css('font-size', newFontSize);
	return false;
  });
  // Decrease Font Size
  jQuery(".decreaseFont").click(function(){
  	var currentFontSize = jQuery('html').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 9);
    var newFontSize = currentFontSizeNum*0.8;
	jQuery('html').css('font-size', newFontSize);
	return false;
  });
});

/* Generic CLICK links panel */
jQuery(document).ready(function() {
	var hash = window.location.hash;

	var list = jQuery("div[id^='clicktoggleThis']");
    var idCounter = 0;
    jQuery.each(list, function() {
    	(!hash) ? hideAllExcept('#' + jQuery(this).children('div:first').attr('id')) : hideAllExcept(window.location.hash);
    });

    jQuery('a.clicktoggle').click(function() {
        var href = jQuery(this).attr('href');
        hideAllExcept(href);
        decorateLink(jQuery(this));
        return false; // prevents the window from scrolling to the anchor
    });

    function decorateLink(dl) {
    	deactivateLinks(jQuery(dl).parents("ul").siblings().children('li')); // in case list in two columns
    	deactivateLinks(jQuery(dl).parents("ul").children('li'));
    	jQuery(dl).addClass('active');
	}

	function deactivateLinks(arr) {
		jQuery.each(arr, function() {
			jQuery(this).children('a:first').removeClass('active');
		});
	}

	function hideAllExcept(el) {
		jQuery(el).removeClass('hide').siblings().addClass('hide');
		jQuery('a[href="' + el + '"]').addClass('active');
	}
});

/* Change phone numbers footer */
jQuery(document).ready(function() {
	var hash = window.location.hash;
    
    (!hash) ?  
        hideAllExcept('#' + jQuery('#pntoggleThis > div:first').attr('id')) 
            : hideAllExcept(window.location.hash);

    jQuery('a.pntoggle').click(function() {
        var href = jQuery(this).attr('href');
        hideAllExcept(href);
        return false; // prevents the window from scrolling to the anchor
    });
	
	function hideAllExcept(el) {
		jQuery(el).removeClass('hide').siblings().addClass('hide');    
		jQuery('a.pntoggle').removeClass('active');
		jQuery('a[href="' + el + '"]').addClass('active');
		
	}
});

/* Change phone numbers - side box */
jQuery(document).ready(function() {
    var hash = window.location.hash;
    
    (!hash) ?  
        sphideAllExcept('#' + jQuery('#sptoggleThis > div:first').attr('id')) 
            : sphideAllExcept(window.location.hash);

    jQuery('a.sptoggle').click(function() {
        var href = jQuery(this).attr('href');
        sphideAllExcept(href);
        return false; // prevents the window from scrolling to the anchor
    });
	
	function sphideAllExcept(el) {
		jQuery(el).removeClass('hide').siblings().addClass('hide');    
		jQuery('a.sptoggle').removeClass('active');
		jQuery('a[href="' + el + '"]').addClass('active');
		
	}
});

/* Change claim numbers */
jQuery(document).ready(function() {
    var hash = window.location.hash;
    
    (!hash) ?  
        ClaimhideAllExcept('#' + jQuery('#claimToggleThis > div:first').attr('id')) 
            : ClaimhideAllExcept(window.location.hash);

    jQuery('a.claimToggle').click(function() {
        var productInfo = "#claim-" + jQuery(this).attr('id');
        
        ClaimhideAllExcept(productInfo);
        return false; 
    });
	
	function ClaimhideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	    jQuery('a.claimToggle').removeClass('active');
	    jQuery('a[href="' + el + '"]').addClass('active');
	}
});

/* Change claim numbers */
jQuery(document).ready(function() {
    var hash = window.location.hash;
    
    (!hash) ?  
        ClaimhideAllExcept('#' + jQuery('#videoToggleThis > div:first').attr('id')) 
            : ClaimhideAllExcept(window.location.hash);

    jQuery('li.videoToggle').click(function() {
        var productInfo = "#video-" + jQuery(this).attr('id');
        
        ClaimhideAllExcept(productInfo);
        return false; 
    });
	
	function ClaimhideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	    jQuery('a.claimToggle').removeClass('active');
	    jQuery('a[href="' + el + '"]').addClass('active');
	}
});

/* Change numbers on contact form */
jQuery(document).ready(function() {
    var hash = window.location.hash;

    (!hash) ?  
        hideAllExcept('#' + jQuery('#ipntoggleThis > div:first').attr('id')) 
            : hideAllExcept(window.location.hash);

    jQuery('a.ipntoggle').click(function() {
        var href = jQuery(this).attr('href');
        hideAllExcept(href);
        return false; // prevents the window from scrolling to the anchor
    });
	
	function hideAllExcept(el) {
		jQuery(el).removeClass('hide').siblings().addClass('hide');    
		jQuery('a.ipntoggle').removeClass('active');
		jQuery('a[href="' + el + '"]').addClass('active');
		
	}
});

/* Generic HOVER links panel */
jQuery(document).ready(function() {
    var hash = window.location.hash;

	var list = jQuery("div[id^='hoverToggleThis']");
	var idCounter = 0;
	jQuery.each(list, function() {
		(!hash) ? ProducthideAllExcept('#' + jQuery(this).children('div:first').attr('id')) : ProducthideAllExcept(window.location.hash);
	});

    jQuery('a.hoverToggle').mouseover(function() {
        var productInfo = "#hv-" + jQuery(this).attr('id');
        ProducthideAllExcept(productInfo);
        return false; 
    });

	function ProducthideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	    jQuery('a.hoverToggle').removeClass('active');
	    jQuery('a[href="' + el + '"]').addClass('active');
	}
});

/* Homepage products */
jQuery(document).ready(function() {
    var hash = window.location.hash;
    
    (!hash) ?  
        ProducthideAllExcept('#' + jQuery('#productToggleThis > div:first').attr('id')) 
            : ProducthideAllExcept(window.location.hash);

    jQuery('a.prodToggle').mouseover(function() {
        var productInfo = "#prod-" + jQuery(this).attr('id');
        
        ProducthideAllExcept(productInfo);
        return false; 
    });
	
	function ProducthideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	    jQuery('a.prodToggle').removeClass('active');
	    jQuery('a[href="' + el + '"]').addClass('active');
	}
});

/* Logins/Setup/Claim */
jQuery(document).ready(function(){
	jQuery('#tabs div').hide();
	jQuery('#tabs div:first').show();
	jQuery('#tabs ul li:first').addClass('active');

	jQuery('#tabs ul li a').click(function(){
		jQuery('#tabs ul li').removeClass('active');
		jQuery(this).parent().addClass('active');
		var currentTab = jQuery(this).attr('href');
		jQuery('#tabs div').hide();
		jQuery(currentTab).show();
		return false;
	});
});

jQuery(document).ready(function() { // HIDE AND SHOW COUNTRY INFORMATION
	var hash = window.location.hash;
    (!hash) ?  
        CountryhideAllExcept('#' + jQuery('#countryToggleThis > div:first').attr('id')) 
            : CountryhideAllExcept(window.location.hash);
    jQuery('a.countryToggle').click(function() {	   
		var countryInfo = "#country-" + jQuery(this).attr('id');
		CountryhideAllExcept(countryInfo);
        return false; 
    });
    jQuery('a.countryToggleLink').click(function() {	
		var countryInfo = "#country-" + jQuery(this).attr('href');
		CountryhideAllExcept(countryInfo);
        return false; 
    });
    jQuery('area.countryToggleMap').click(function() {							  
        var countryInfo = "#country-" + jQuery(this).attr('href');   
        CountryhideAllExcept(countryInfo);
        return false; 
    });
	function CountryhideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	}
});

jQuery(document).ready(function() {  // ROLL OVER EFFECT TABLE ON MANAGEMENT PAGE
	jQuery('#photos div').mouseover(function() {
		jQuery(this).addClass("overCell");
	});
	jQuery('#photos div').mouseout(function() {
		jQuery(this).removeClass("overCell");
		jQuery('#photos div img').show();
	});
	jQuery('#photos div').click(function() {
		jQuery(this).addClass("activeCell");
		jQuery(this).siblings().removeClass("activeCell");
	});
});

jQuery(document).ready(function() { // SHOW - HIDE BIOGRAPHIES
	var hash = window.location.hash;

	(!hash) ? 
		hideAllExcept('#' + jQuery('#bioToggleThis > div:first').attr('id')) 
			: hideAllExcept(window.location.hash);
	jQuery('#photos div').click(function() {
		var bioInfo = "#bio-" + jQuery(this).attr('id');
		hideAllExcept(bioInfo);
		return false;
	});

	function hideAllExcept(el) {
		jQuery(el).removeClass('hide').siblings().addClass('hide');
	}
});

jQuery(document).ready(function(){ // IMAGE LIBRARY
	jQuery('#tabs div').hide();
	jQuery('#tabs div:first').show();
	jQuery('#tabs ul li:first').addClass('active');
	jQuery('#tabs ul li a').click(function(){ 
	jQuery('#tabs ul li').removeClass('active');
	jQuery(this).parent().addClass('active'); 
	var currentTab = $(this).attr('href'); 
	jQuery('#tabs div').hide();
	jQuery(currentTab).show();
	return false;
	});
});

/* FAQs - show/hide */
SSS_faq = {
	init : function() {
		jQuery('div.faq-on .answer').show();
		jQuery('div.faq-on .question').addClass('active');
		jQuery('div.faq-on .question').click(function() { SSS_faq.toggle(this) });		
		jQuery('div.faq-off .answer').slideToggle('fast');
		jQuery('div.faq-off .question').click(function() { SSS_faq.toggle(this) });
		jQuery('div.benefit .answer').slideToggle('fast');
		jQuery('div.benefit .question').click(function() { SSS_faq.toggle(this) });
	},
	
	toggle : function(el) {
		jQuery(el).toggleClass('active');
		jQuery(el).siblings('.answer').slideToggle('fast');
	}
}

jQuery(function() { 
	SSS_faq.init();
});

/* Page FAQs - show/hide */
jQuery(document).ready(function() { 	
	jQuery('#closeallpagefaq').click(function() { SSS_page_faq_closeall() });
	jQuery('#openallpagefaq').click(function() { SSS_page_faq_openall() });
	jQuery('div.page-faq .question').click(function() { SSS_page_faq_toggle(this) });
});
	
function SSS_page_faq_closeall() {
	jQuery('div.page-faq .question.active').each(function() {
		jQuery(this).siblings('.answer').slideUp('fast');
		jQuery(this).find("div.openfaq").css("display", "none");
		jQuery(this).find("div.closedfaq").css("display", "block");
		jQuery(this).removeClass('active');
	});
	jQuery("#closeallpagefaq").css("display", "none");
	jQuery("#openallpagefaq").css("display", "block");
	
}
function SSS_page_faq_openall() {
	jQuery('div.page-faq .question').each(function() {
		if (!jQuery(this).hasClass('active')) {
			jQuery(this).siblings('.answer').slideDown('fast');
			jQuery(this).find("div.closedfaq").css("display", "none");
			jQuery(this).find("div.openfaq").css("display", "block");
			jQuery(this).addClass('active');
		}
	});
	jQuery("#openallpagefaq").css("display", "none");
	jQuery("#closeallpagefaq").css("display", "block");

}
function SSS_page_faq_toggle(el) {
	jQuery(el).toggleClass('active');
	jQuery(el).siblings('.answer').slideToggle('fast');
	if (jQuery(el).hasClass("active")) {
		jQuery(el).find("div.closedfaq").css("display", "none");
		jQuery(el).find("div.openfaq").css("display", "block");
		
	}
	else {
		jQuery(el).find("div.openfaq").css("display", "none");
		jQuery(el).find("div.closedfaq").css("display", "block");
	}
	
	if (jQuery('div.page-faq .question.active').length > 0) {
		jQuery("#openallpagefaq").css("display", "none");
		jQuery("#closeallpagefaq").css("display", "block");
	}
	else {
		jQuery("#closeallpagefaq").css("display", "none");
		jQuery("#openallpagefaq").css("display", "block");
	}
}

jQuery(document).ready(function() { // HIDE AND SHOW VIDEOS
    var hash = window.location.hash;
    
    (!hash) ?  
        hideAllExcept('#' + jQuery('#videoToggleThis > div:first').attr('id')) 
            : hideAllExcept(window.location.hash);
    jQuery('#interviews div').click(function() {
        var videoInfo = "#video-" + jQuery(this).attr('id');
        
        hideAllExcept(videoInfo);
        return false; 
    });
	
	function hideAllExcept(el) {
	    jQuery(el).removeClass('hide').siblings().addClass('hide');  
	}
});

/* INTERVIEWS */
jQuery(document).ready(function() {  // ROLL OVER EFFECT TABLE
	jQuery('#interviews div').mouseover(function() {
		 jQuery(this).addClass("overCell");
    });
	jQuery('#interviews div').mouseout(function() {
		 jQuery(this).removeClass("overCell");
    });
	jQuery('#interviews div').click(function() {
		 jQuery(this).addClass("activeCell");
		 jQuery(this).siblings().removeClass("activeCell"); 
    });
});

jQuery(document).ready(function() {
	jQuery('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
});
