﻿GlobalLanding_class = function() {
	this.init();
}

GlobalLanding_class.prototype.init = function() {
	this.events();
	this.reduceHeadline();
}

GlobalLanding_class.prototype.events = function() {
	var siteOptions = $(".site-menu ul.third-level li");
	siteOptions.bind('click', $.setContext(this.setRegionSiteCookie, this));
}

GlobalLanding_class.prototype.setRegionSiteCookie = function(e, el) {

	var siteEl = el;
	var region = $(siteEl).attr("region");
	var site = $(siteEl).attr("site");

	$.cookie("regionCookie", region, { expires: 90, path:"/" } );
	$.cookie("siteCookie", site, { expires: 90, path: "/" });
}

GlobalLanding_class.prototype.reduceHeadline = function() {
	var headline = $(".introduction h2");

	var pageWidth = 560; //hard coded for ie6
	var textWidth = $('span', headline).width();
	var headlineSize = headline.css("font-size");
	headlineSize = parseFloat(headlineSize);
	var minFontSize = 10;

	while (textWidth > pageWidth && headlineSize >= minFontSize) {
		headline.css("font-size", headlineSize);

		headlineSize--;
		textWidth = $('span', headline).width();
	}

	// if length is still larger than the page width then wrap
	if (textWidth > pageWidth) {
		headline.css("white-space", "normal")
	}
	headline.removeClass("almost-transparent");
	headline.css("position", "relative");

}

$(document).ready(function() {
	var globalLanding= new GlobalLanding_class();
});

