function localizedString(key) {
	if (innovaMessages[key]) {
		return innovaMessages[key];
	} else {
		return key;
	}
}

function showPrintDialog() {
	window.print();
}

function toggleSettingsPopup() {
	if ($("#settingsPopup").hasClass("visible")) {
			$("#settingsPopup").slideUp();	
			$("#settingsPopup").removeClass("visible");
		}
	else	
		{
			$("#settingsPopup").slideDown();	
			$("#settingsPopup").addClass("visible");		
		}

}

function showProductRecommendation() {
	var productLine = $("input[name=product]:checked").val();
	var lifePhase = $("input[name=age]:checked").val();
	var coverage = $("input[name=coverage]:checked").val();
//	alert("productLine: "+productLine + "\nlifePhase: "+lifePhase + "\ncoverage: "+coverage);
	if (productLine && lifePhase && coverage) {
		// reset error message (if there was any)
		$("#settingsFeedback").html("");
		// reset all highlighted products (if there were any)
		$(".product").removeClass("selected_product");
		// highlight the products
		if (productLine == "sanvita") {
			$("#sanvita").addClass("selected_product");
		} else if (productLine == "activa") {
			$("#activa").addClass("selected_product");
		} else if (productLine == "complementa") {
			$("#complementa").addClass("selected_product");
			$("#casaComplementa").addClass("selected_product");
		}
		if (productLine == "sanvita" || productLine == "activa") {
			if (coverage == "maximal" || lifePhase == "kids" || lifePhase == "bestAgers") {
				$("#casaNova").addClass("selected_product");
			} else {
				if (coverage == "standard") {
					$("#telCare").addClass("selected_product");
				} else {
					$("#telGate").addClass("selected_product");
				}
			}
		}
/*		if (lifePhase == "singles") {
			$("#telCare").addClass("selected_product");
		} else {
			$("#casaNova").addClass("selected_product");
		}*/
		if (coverage == "maximal") {
			$("#switch").addClass("selected_product");
			if (productLine == "sanvita" || productLine == "activa") {
				$("#plusZwei").addClass("selected_product");
			} else {
				$("#plusEins").addClass("selected_product");
			}
			if (lifePhase == "kids" || lifePhase == "teens") {
				$("#denta").addClass("selected_product");
				$("#primau").addClass("selected_product");
				$("#primak").addClass("selected_product");
			} else if (lifePhase == "singles" || lifePhase == "families") {
				$("#primau").addClass("selected_product");
				$("#primak").addClass("selected_product");
				$("#justizia").addClass("selected_product");
			} else if (lifePhase = "bestAgers") {
				$("#justizia").addClass("selected_product");
			}
		} else if (coverage == "standard") {
			$("#switch").addClass("selected_product");
			if (productLine == "sanvita" || productLine == "activa") {
				if (lifePhase == "kids" || lifePhase == "teens") {
					$("#plusEins").addClass("selected_product");
				} else {
					$("#plusZwei").addClass("selected_product");
				}
			} else {
				$("#plusEins").addClass("selected_product");
			}
			if (lifePhase == "kids" || lifePhase == "teens") {
				$("#primau").addClass("selected_product");
			} else {
				$("#justizia").addClass("selected_product");
			}
		} else {
			$("#allgemein").addClass("selected_product");
			$("#plusEins").addClass("selected_product");
			if (lifePhase == "kids" || lifePhase == "teens") {
				$("#primau").addClass("selected_product");
			} else {
				$("#justizia").addClass("selected_product");
			}
		}
		// set the settings and recommendation
		$("#settingProductLine").text(productLine);
		$("#settingLifePhase").text(localizedString('age_' + lifePhase));
		$("#settingCoverage").text(localizedString('coverage_' + coverage));
		$("div.searchParameters div.settings").show();
		var recommendation1 = "";
		$("#productTypeRow1 a.selected_product").each(function() {
			recommendation1 += $(this).text() + ", ";
		});
		recommendation1 = recommendation1.substring(0, recommendation1.length-2);
		$("#recommendation1").html(recommendation1);		
		var recommendation2 = "";
		$("#productTypeRow2 a.selected_product").each(function() {
			recommendation2 += $(this).text() + ", ";
		});
		recommendation2 = recommendation2.substring(0, recommendation2.length-2);
		$("#recommendation2").html(recommendation2);		
		var recommendation3 = "";
		$("#productTypeRow3 a.selected_product").each(function() {
			recommendation3 += $(this).text() + ", ";
		});
		recommendation3 = recommendation3.substring(0, recommendation3.length-2);
		$("#recommendation3").html(recommendation3);		
		$("div.searchParameters div.recommendation").show();
		// hide settings slider
		toggleSettingsPopup();
	} else {
		// show error message
		$("#settingsFeedback").html("<div class=\"error\">Auswahl unvollständig. Bitte füllen Sie alle 3 Kriterien aus.</div>");		
//		alert("productLine: "+productLine+"\nlifePhase: "+lifePhase+"\ncoverage: "+coverage);
	}
}

function resizeImage(image, width, height, isMax, center) {
	if (image) {
		var origWidth = image.width;
		var origHeight = image.height;
		var scaleFactor = 1;
		if (width && width > 0 && height && height > 0) {
			// Bild-Seitenverhältnis
			var ratioImage = origWidth / origHeight;
			// Box-Seitenverhältnis
			var ratioBox = width / height;			
			if (isMax) {
				if (ratioBox > ratioImage) {
					// Wenn das Box-Seiten-Verhältnis > Bild-Seitenverhältnis muss die Höhe übereinstimmen
					scaleFactor = height / origHeight;
				} else {
					// Wenn das Box-Seiten-Verhältnis < Bild-Seitenverhältnis muss die Breite übereinstimmen
					scaleFactor = width / origWidth;
				}
			} else {
				if (ratioBox < ratioImage) {
					// Wenn das Box-Seiten-Verhältnis < Bild-Seitenverhältnis muss die Höhe übereinstimmen
					scaleFactor = height / origHeight;
				} else {
					// Wenn das Box-Seiten-Verhältnis > Bild-Seitenverhältnis muss die Breite übereinstimmen
					scaleFactor = width / origWidth;
				}
			}
			var newWidth = Math.ceil(origWidth * scaleFactor);
			var newHeight = Math.ceil(origHeight * scaleFactor);
			$(image).css("width", "" + newWidth + "px");
			$(image).css("height", "" + newHeight + "px");
			$(image).css("position", "relative");
			if (isMax && center) {
				if (newWidth < width) {
					$(image).css("left", Math.round((width - newWidth) / 2) + "px");
				}
				if (newHeight < height) {
					$(image).css("top", Math.round((height - newHeight) / 2) + "px");
				}
			}
			if (!isMax && center) {
				if (newWidth > width) {
					$(image).css("left", "-" + Math.round((newWidth - width) / 2) + "px");
				}
				if (newHeight > height) {
					$(image).css("top", "-" + Math.round((newHeight - height) / 2) + "px");
				}
			}
		}
/*		} else if (width && width > 0) {
			ratio = width / origWidth;
		} else if (height && height > 0) {
			ratio = height / origHeight;
		}*/
//		percentage = ratio*100;
	}
}

/* collapsible paragraph stuff ********************************************************************/
// add the toggle functionality to the collapsible_item a.switch links 
$(document).ready(function() {
	$(".collapsible_item a.switch").click(function() {
		var collapsibleItem = $(this).closest(".collapsible_item");
		if ($(collapsibleItem).hasClass("collapsible_closed")) {
			$(".body", collapsibleItem).slideDown(200, function() {
				$(collapsibleItem).addClass("collapsible_open");
				$(collapsibleItem).removeClass("collapsible_closed");
			});
		} else {
			$(".body", collapsibleItem).slideUp(200, function() {
				$(collapsibleItem).addClass("collapsible_closed");
				$(collapsibleItem).removeClass("collapsible_open");
			});
		}
		$(this).blur();
	});
//	$(".accordion").accordion();
//	$(".TabbedPanels").tabs();
});
/*function toggleCollapsibleParagraph(id) {
	var paragraph = document.getElementById(id);
	if (paragraph) {
		var currentClass = paragraph.getAttribute("class");
		if (!currentClass) {
			currentClass = paragraph.getAttribute("className");
		}
		if (currentClass == "closed") {
			paragraph.setAttribute("class", "open"); 
			paragraph.setAttribute("className", "open");
		} else {
			paragraph.setAttribute("class", "closed"); 
			paragraph.setAttribute("className", "closed");
		}
	}
}

function openCollapsibleParagraph(id) {
	var paragraph = document.getElementById(id);
	if (paragraph) {
		var currentClass = paragraph.getAttribute("class");
		if (!currentClass) {
			currentClass = paragraph.getAttribute("className");
		}
		if (currentClass == "closed") {
			paragraph.setAttribute("class", "open"); 
			paragraph.setAttribute("className", "open");
		}
		window.location.hash=id;
	}
}*/
/* calculator form ********************************************************************************/
/*function validateAndSubmitCalculatorForm() {
	// validate
	var sex = $("#calculatorForm input[name=sex]:checked").val();
	var year = $("#calculatorForm input[name=year]").val();
	var zip = $("#calculatorForm input[name=zip]").val();

	// because the regex pattern needs to be reset after each use we cannot use if ... else if ...
	if (!year) {
		alert(localizedString['code1']);
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	if (year.length != 4) {
		alert(localizedString['code2']);
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	// reset regex pattern
	posIntCheckRegExp.lastIndex = 0;
	if (!posIntCheckRegExp.test(year)) {
		alert(localizedString['code3']);
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	if (!sex) {
		alert(localizedString['code4']);
		return false;
	}
	if (!zip) {
		alert(localizedString['code5']);
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}
	if (zip.length != 4) {
		alert(localizedString['code6']);
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}
	// reset regex pattern
	posIntCheckRegExp.lastIndex = 0;
	if (!posIntCheckRegExp.test(zip)) {
		alert(localizedString['code7']);
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}

		var myXML = calculatorXML;
		$(myXML).find('PLZ').text(zip);
		$(myXML).find('Birthdate').text(year + "-01-01");
		$(myXML).find('Sex').text(sex);
		var xmlString = (new XMLSerializer()).serializeToString(myXML);
		$("#calculatorForm input[name=CPW_STARTUP_XML]").val(xmlString);
//		alert($("#hiddenCalculatorForm textarea[name=CPW_STARTUP_XML]").val());
//		$("#hiddenCalculatorForm").submit();
		return true;
}*/

function validateAndSubmitCalculatorForm() {
	// validate
	var sex = $("#calculatorForm input[name=sex]:checked").val();
	var year = $("#calculatorForm input[name=year]").val();
	var zip = $("#calculatorForm input[name=zip]").val();

	// because the regex pattern needs to be reset after each use we cannot use if ... else if ...
	if (!year) {
		alert("Bitte geben Sie den Jahrgang ein");
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	if (year.length != 4) {
		alert("Bitte geben Sie den Jahrgang als 4-stellige Zahl ein");
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	// reset regex pattern
	posIntCheckRegExp.lastIndex = 0;
	if (!posIntCheckRegExp.test(year)) {
		alert("Ungültige Jahrzahle \"" + year + "\"!\nBitte geben Sie nur Zahlen ein im Jahrzahl-Feld");
		$("#calculatorForm input[name=year]").focus();
		return false;
	}
	if (!sex) {
		alert("Bitte geben Sie das Geschlecht an");
		return false;
	}
	if (!zip) {
		alert("Bitte geben Sie die PLZ ein");
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}
	if (zip.length != 4) {
		alert("Bitte geben Sie die PLZ als 4-stellige Zahl ein");
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}
	// reset regex pattern
	posIntCheckRegExp.lastIndex = 0;
	if (!posIntCheckRegExp.test(zip)) {
		alert("Bitte geben Sie nur Zahlen ein im PLZ-Feld");
		$("#calculatorForm input[name=zip]").focus();
		return false;
	}

	var myXML = calculatorXML;
	var xmlString;
	$(myXML).find('PLZ').text(zip);
	$(myXML).find('Birthdate').text(year + "-01-01");
	$(myXML).find('Sex').text(sex);
	//then convert it back to a string
	//for IE 
	if (window.ActiveXObject) {
		xmlString = myXML.xml;
	 }
	// code for Mozilla, Firefox, Opera, etc.
	else {
	   xmlString = (new XMLSerializer()).serializeToString(myXML);
	}
	$("#calculatorForm input[name=CPW_STARTUP_XML]").val(xmlString);
	return true;
}


//var calculatorXML = '<?xml version="1.0" encoding="utf-8"?><Offerte><Ort><LandIso>ch</LandIso><PLZ>__PLZ__</PLZ></Ort><PersonenArray><Person><Id>1</Id><Sex>__GESCHLECHT__</Sex><Birthdate>__JAHRGANG__-01-01</Birthdate><Arbeitnehmer>true</Arbeitnehmer></Person></PersonenArray></Offerte>';
var calculatorXML;
var posIntCheckRegExp = /^[0-9]+$/g

function initCalculator(url) {
	$.ajax({
		type: "GET",
		url: url,
		dataType: "xml",
		success: function(xml) {
			calculatorXML = xml;
			$("#calculatorForm").slideDown();
		}
	});
}

/* noyb stuff *************************************************************************************/
function dcmadr(nnnn) {
	var a = "";
	for(i=0,m=nnnn.length;i < m;i++){
		if(i%3==0){
			a += String.fromCharCode(nnnn.substr(i, 3)-37);
		}
	}
	return a;
}

function dcmt(nnnn) {
	var a = dcmadr(nnnn);
	location.href=('m'+'ail'+'t'+'o:'+a);
}

/* tell a friend **********************************************************************************/
function checkLength( o, n, min, max ) {
	if ( o.length > max || o.length < min ) {
		alert( "Length of " + n + " must be between " +
			min + " and " + max + "." );
		return false;
	} else {
		return true;
	}
}

function checkRegexp( o ) {
	return true;
	var regexp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
	
	if ( !( regexp.test( o ) ) ) {
		alert( "Please fill in a real e-Mail Adress!");
		return false;
	} else {
		return true;
	}
}

function validateTellAFriendForm() {
	// validate
	var fromName = $("#tell_a_friend_dialog input[name=fromName]").val();
	var from = $("#tell_a_friend_dialog input[name=from]").val();
	var toName = $("#tell_a_friend_dialog input[name=toName]").val();
	var to = $("#tell_a_friend_dialog input[name=to]").val();
	var message = $("#tell_a_friend_dialog textarea[name=message]").val();
	var url = $("#tell_a_friend_dialog input[name=url]").val();
	var title = $("#tell_a_friend_dialog input[name=title]").val();
	var subject = $("#tell_a_friend_dialog input[name=subject]").val();
	var mailTemplate = localizedString("mailTemplate");	
	var isValid = true;
	
//	alert ("URL: " + url + " title: " +title );

	$('#tell_a_friend_dialog label').removeClass('error');
	
	
	if (!to || !checkRegexp( to )) {
		$("#tell_a_friend_dialog input[name=to]").focus();
		$("#tell_a_friend_dialog label[for=to]").addClass('error');		
		isValid = false;
	}
	if (!toName) {
		$("#tell_a_friend_dialog input[name=toName]").focus();	
		$("#tell_a_friend_dialog label[for=toName]").addClass('error');		
		isValid = false;
	}			
	if (!from || !checkRegexp( from )) {
		$("#tell_a_friend_dialog input[name=from]").focus();
		$("#tell_a_friend_dialog label[for=from]").addClass('error');		
		isValid = false;
	}		
	if (!fromName) {
		$("#tell_a_friend_dialog input[name=fromName]").focus();
		$("#tell_a_friend_dialog label[for=fromName]").addClass('error');		
		isValid = false;
	}	

	//var dataString = 'name='+ name + '&email=' + email;
  //alert (dataString);return false; 
  paramData = new Object();
  paramData.fromName = fromName;
  paramData.toName = toName;
  paramData.from = from;
  paramData.to = to;
  paramData.url = url;
  paramData.title = title;
  paramData.message = message;
  paramData.subject = subject;
//  paramData.mailTemplate = "innovaTellFriend_de";
  paramData.mailTemplate = mailTemplate;
  
  var labelSend =  localizedString("Send");
  var labelCancel =  localizedString("Cancel");
  var labelClose =  localizedString("Close");
  
  if (isValid) {
	  $("div.error_message").html("").hide();	
	  tafButtons[sendButtonKey] = function() {
	  	if (validateTellAFriendForm()) {
	  		$(this).dialog(""); 
	  	}
	  }
	  tafButtons[cancelButtonKey] = function() {
//	  	$(this).dialog(""); 
		$(this).dialog("close"); 
	  } 
	  $('#tell_a_friend_dialog').dialog({buttons: tafButtons});
/*	  $('#tell_a_friend_dialog').dialog({
		buttons: {
			"${labelSend}": function() {
				if (validateTellAFriendForm()) {
					$(this).dialog(""); 
				}
			},
			"${labelCancel}": function() { 
				$(this).dialog(""); 
			} 
		}
		});	*/	
		
	 $('.ui-dialog-buttonset button').addClass('senden');

	  $.ajax({
		url: contextPath + '/.magnolia/pages/tellAFriend.html?command=validateAndSendMail',
		data: paramData,
		type: 'POST',
		dataType: 'json',
		success: function(data) {
			if (data.errors) {
				var errorString = "";
				for (errorKey in data.errors) {
					errorString += errorKey + ": " + data.errors[errorKey] + "\n";
					if (errorKey == 'to') { 
						$("#tell_a_friend_dialog input[name=to]").focus();	
						$("#tell_a_friend_dialog label[for=to]").addClass('error');
						}					
					if (errorKey == 'toName') {
						$("#tell_a_friend_dialog input[name=toName]").focus();	
						$("#tell_a_friend_dialog label[for=toName]").addClass('error');
						}
					if (errorKey == 'from') { 
						$("#tell_a_friend_dialog input[name=from]").focus();
						$("#tell_a_friend_dialog label[for=from]").addClass('error');
						}
					if (errorKey == 'fromName') { 
						$("#tell_a_friend_dialog input[name=fromName]").focus();
						$("#tell_a_friend_dialog label[for=fromName]").addClass('error');
						}
					if (errorKey == 'mail') {
						$("div.error_message").html("<div>" + localizedString("email.not.sent") + "</div>").show();
					}	
				}
				alert("an error occured!:\n" + errorString);
			} else if (data.message) {
				$("div.tell_a_friend_form").hide();
				$("div.tell_a_friend_confirmation").html( localizedString("email.sent") ).show();
				confirmationButtons[closeButtonKey] = function() {
					  tafButtons[sendButtonKey] = function() {
								if (validateTellAFriendForm()) {
									$("#tell_a_friend_form form").submit();
									$(this).dialog("close"); 
								}
					  }
					  tafButtons[cancelButtonKey] = function() {
								$(this).dialog("close"); 
					  } 
					  $('#tell_a_friend_dialog').dialog({buttons: tafButtons});

					$(this).dialog("close");
				}
/*				$('#tell_a_friend_dialog').dialog({
					buttons	: {
						labelClose: function() {
							$(this).dialog("close");
						}
					}
				});*/
				$('#tell_a_friend_dialog').dialog({buttons: confirmationButtons});
			}else {
				var hmString = "";
				for (key in data) {
					hmString += key + ": " + data[key] + "\n";
				}
				alert("Neither error nor message?!:\n" + hmString);
			 }
		}
	  });
  } else {
	$("div.error_message").html(localizedString("fill.out.form") ).show();
  }
  return false;	
}

function initProductBoxes() {
				$('a.product').each(function() {
					var href = $(this).attr("href");
					$(this).attr("rel", href);
					$(this).attr("href", "javascript:;");
				});
//				$('div.product a.more_link').bt({
				$('a.product').bt({
					trigger:         'click',          
					contentSelector: "$(this).siblings('.more_link_content').html();", /*get text of inner content of hidden div*/
//					contentSelector: "$($(this).attr('id') + '_more').html();",
					clickAnywhereToClose: true,              // clicking anywhere outside of the tip will close it 
					closeWhenOthersOpen: true,              // tip will be closed before another opens - stop >= 2 tips being on
												 
					shrinkToFit:      false,                 // should short single-line content get a narrower balloon?
					width:            '250px',               // width of tooltip box 
					
					padding:          '15px',                // padding for content (get more fine grained with cssStyles)
					spikeGirth:       50,                    // width of spike
					spikeLength:      70,                    // length of spike
					overlap:          20,                     // spike overlap (px) onto target (can cause problems with 'hover' trigger)
					overlay:          false,                 // display overlay on target (use CSS to style) -- BUGGY!
					killTitle:        true,                  // kill title tags to avoid double tooltips
				  
					textzIndex:       9999,                  // z-index for the text
					boxzIndex:        9998,                  // z-index for the "talk" box (should always be less than textzIndex)
					wrapperzIndex:    9997,
					offsetParent:     null,                  // DOM node to append the tooltip into.
															 // Must be positioned relative or absolute. Can be selector or object
					positions:        ['most'],              // preference of positions for tip (will use first with available space)
															 // possible values 'top', 'bottom', 'left', 'right' as an array in order of
															 // preference. Last value will be used if others don't have enough space.
															 // or use 'most' to use the area with the most space
					fill:             "white",  // fill color for the tooltip box, you can use any CSS-style color definition method
															 // http://www.w3.org/TR/css3-color/#numerical - not all methods have been tested
					
					windowMargin:     10,                    // space (px) to leave between text box and browser edge
				  
					strokeWidth:      1,                     // width of stroke around box, **set to 0 for no stroke**
					strokeStyle:      "#000",                // color/alpha of stroke
				  
					cornerRadius:     0,                     // radius of corners (px), set to 0 for square corners
					
									  // following values are on a scale of 0 to 1 with .5 being centered
					
					centerPointX:     1,                    // the spike extends from center of the target edge to this point
					centerPointY:     -1,                    // defined by percentage horizontal (x) and vertical (y)
					  
					shadow:           true,                 // use drop shadow? (only displays in Safari and FF 3.1) - experimental
					shadowOffsetX:    2,                     // shadow offset x (px)
					shadowOffsetY:    2,                     // shadow offset y (px)
					shadowBlur:       2,                     // shadow blur (px)
					shadowColor:      "#000",                // shadow color/alpha
					shadowOverlap:   false,                  // when shadows overlap the target element it can cause problem with hovering
															 // set this to true to overlap or set to a numeric value to define the amount of overlap
					noShadowOpts:     {strokeStyle: '#999'},  // use this to define 'fall-back' options for browsers which don't support drop shadows
					
					cssClass:         '',                    // CSS class to add to the box wrapper div (of the TIP)
					cssStyles:        {},                    // styles to add the text box
															 //   example: {fontFamily: 'Georgia, Times, serif', fontWeight: 'bold'}
																 
					activeClass:      'bt-active'           // class added to TARGET element when its BeautyTip is active
				});
}

function initDownloadInfoBoxes() {
	$('span.moreInfo').hide();
	$('div.moreInfo a.box').each(function() {
		var moreInfoID = $(this).parent().attr("id");
		$(this).bt({
			trigger: 'click',
			contentSelector: "$('#" + moreInfoID + " span.downloadInfo').html()", /*get text of inner content of hidden div*/
			clickAnywhereToClose: true,              // clicking anywhere outside of the tip will close it 
			closeWhenOthersOpen: true,              // tip will be closed before another opens - stop >= 2 tips being on
										 
			shrinkToFit:      false,                 // should short single-line content get a narrower balloon?
			width:            '250px',               // width of tooltip box 
			
			padding:          '15px',                // padding for content (get more fine grained with cssStyles)
			spikeGirth:       50,                    // width of spike
			spikeLength:      70,                    // length of spike
			overlap:          0,                     // spike overlap (px) onto target (can cause problems with 'hover' trigger)
			overlay:          false,                 // display overlay on target (use CSS to style) -- BUGGY!
			killTitle:        true,                  // kill title tags to avoid double tooltips
		  
			textzIndex:       9999,                  // z-index for the text
			boxzIndex:        9998,                  // z-index for the "talk" box (should always be less than textzIndex)
			wrapperzIndex:    9997,
			offsetParent:     null,                  // DOM node to append the tooltip into.
													 // Must be positioned relative or absolute. Can be selector or object
			positions:        ['most'],              // preference of positions for tip (will use first with available space)
													 // possible values 'top', 'bottom', 'left', 'right' as an array in order of
													 // preference. Last value will be used if others don't have enough space.
													 // or use 'most' to use the area with the most space
			fill:             "white",  // fill color for the tooltip box, you can use any CSS-style color definition method
													 // http://www.w3.org/TR/css3-color/#numerical - not all methods have been tested
			
			windowMargin:     10,                    // space (px) to leave between text box and browser edge
		  
			strokeWidth:      1,                     // width of stroke around box, **set to 0 for no stroke**
			strokeStyle:      "#000",                // color/alpha of stroke
		  
			cornerRadius:     0,                     // radius of corners (px), set to 0 for square corners
			
							  // following values are on a scale of 0 to 1 with .5 being centered
			
			centerPointX:     1,                    // the spike extends from center of the target edge to this point
			centerPointY:     -1,                    // defined by percentage horizontal (x) and vertical (y)
			  
			shadow:           true,                 // use drop shadow? (only displays in Safari and FF 3.1) - experimental
			shadowOffsetX:    2,                     // shadow offset x (px)
			shadowOffsetY:    2,                     // shadow offset y (px)
			shadowBlur:       2,                     // shadow blur (px)
			shadowColor:      "#000",                // shadow color/alpha
			shadowOverlap:   false,                  // when shadows overlap the target element it can cause problem with hovering
													 // set this to true to overlap or set to a numeric value to define the amount of overlap
			noShadowOpts:     {strokeStyle: '#999'},  // use this to define 'fall-back' options for browsers which don't support drop shadows
			
			cssClass:         '',                    // CSS class to add to the box wrapper div (of the TIP)
			cssStyles:        {},                    // styles to add the text box
													 //   example: {fontFamily: 'Georgia, Times, serif', fontWeight: 'bold'}
														 
			activeClass:      'bt-active'           // class added to TARGET element when its BeautyTip is active
		});
	});
}
