<!--
/* <documentation about="ABOUT javascript/default.js" type="GENERAL">
	<summary>This file is the default javascript file for Bonpack: it contains methods, calls and variables for all Bonpack pages
		Structure of this file:         
		1. Implementation of namespace Amersfoortse 
		2. Query.noConflict(): to avoid conflicts in jQuery library
		3. Definition global variables
		4. Bonpack.init(): start javascript app
		5. Specific functions
		6. Call Bonpack.init
	</summary>
	<namespace>Amersfoortse</namespace>
</documentation> */
var Bonpack = {};

 /* <documentation about="jQuery.noConflict()" type="Function call">
	<summary>Function is called to avoid conflicts among jQuery and other javascript used</summary>
</documentation> */
jQuery.noConflict();

/* global variables go here */


/* <documentation about="Bonpack.init" type="init function">
	<summary>This function containes all calls made to functions used on every page of Bonpack.
		It is initialized on document ready
	</summary>
	<namespace>Bonpack</namespace>
</documentation> */
Bonpack.init = function() {
	Bonpack.addOpenInLinksNewWindow();
	Bonpack.adjustKeywordsHeight();
	Bonpack.addProductGroupClick();
}

/* <documentation about="Bonpack.addOpenInLinksNewWindow" type="specific function">
	<summary>Adds functionality that all links with type='new-window' will be opened in a new window</summary>
	<namespace>Bonpack</namespace>
	<param type="string" descr="Id of parent element; defaults to document if not supplied">parentElementId</param>
</documentation> */
Bonpack.addOpenInLinksNewWindow = function (parentElementId) {
	var container = "";
	if(parentElementId && parentElementId.length != 0) { container = "#" + parentElementId + " "; }
	var hyperlinks = jQuery(container + "a");
	
	for (var i=0; i < hyperlinks.length; i++) {
		if (hyperlinks[i].getAttribute("type") != "new-window") { continue; }
		
		jQuery(hyperlinks[i]).click(function () { window.open(this.href); return false; });		
	}
}

//function called from selectedindexchanged op language dropdown: set cookie so right language is loaded
//afer that reload page so right xml content (translation) can be loaded
Bonpack.setCulture = function(dropDown)
{
    Bonpack.setCookie("UserCulture", dropDown.options[dropDown.selectedIndex].value, true);
    location.href=location.href;
}

//sets cookkie
Bonpack.setCookie = function(name, value, expires ) 
{
    var today = new Date();
    today.setTime( today.getTime() );
    if ( expires ) { expires = expires * 1000 * 60 * 60 * 31;  }
    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie = name+"="+escape( value ) + ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) 
}



/* <documentation about="Bonpack.adjustKeywordsHeight" type="specific function">
	<summary>Adjust height of keywords in ProductGroups</summary>
	<namespace>Bonpack</namespace>
</documentation> */
Bonpack.adjustKeywordsHeight = function () {
	if(jQuery("body.productgroups").length==0) return; 
	
	var types = jQuery(".types");	
	var maxHeight = 0; 
	for (var i=0; i < types.length; i++) {
		if(maxHeight < jQuery(types[i]).height()) { maxHeight = jQuery(types[i]).height(); }
	}
	//jQuery(".group-tab .types ").attr("style", "min-height:" + maxHeight + "px");
	
	var keywords = jQuery(".keywords");	
	maxHeight = 0; 
	for (var i=0; i < keywords.length; i++) {
		if(maxHeight < jQuery(keywords[i]).height()) { maxHeight = jQuery(keywords[i]).height(); }
	}
	jQuery(".group-tab .keywords ").attr("style", "height:" + maxHeight + "px");
}

Bonpack.addProductGroupClick = function () {
    if(jQuery("body.productgroups").length==0) return; 
	
	jQuery(".group-tab a").click(function () {  window.open(this.href); return false; }).mouseover(function () { jQuery(this).parent().parent().parent().parent().removeClass("hover"); return false; });		
	
	var redirect = function(groupTabId) {
	    window.open(jQuery("#" + groupTabId + " h2 a").attr("href"));
	}
	
	jQuery(".group-tab h2 a").mouseover(function () { jQuery(this).parent().parent().addClass("hover");  }).mouseout(function () { jQuery(this).parent().parent().removeClass("hover"); });	
	jQuery(".group-tab .types").click(function () { redirect(jQuery(this).parent().attr("id")); return false; }).mouseover(function () { jQuery(this).parent().addClass("hover");  }).mouseout(function () { jQuery(this).parent().removeClass("hover"); });		
	jQuery(".group-tab .keywords").click(function () { redirect(jQuery(this).parent().attr("id")); return false; }).mouseover(function () { jQuery(this).parent().addClass("hover");  }).mouseout(function () { jQuery(this).parent().removeClass("hover"); });		
	
	
	
	
}
 
jQuery(document).ready(function(){ Bonpack.init(); });     	
//-->

