
function event_load(obj_event) {
	var obj_body = document.getElementsByTagName("body")[0];
	if (obj_body) {
		switch (obj_body.id.replace("page-","")) {
			case "marketing-solutions":
				init_topic();
				break;
		} // end switch
	} // end if
	
	if (document.getElementById("gallery-2")) {		// if there's a second item in the gallery then we need to turn on the slideshow	
		gallery_start();
	} // end if
	
	js_external_links();
} // end function
window.onload = event_load;


// google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18403062-1']);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


/* external links */
function js_external_links() { 
	if (!document.getElementsByTagName) return; 
	var arr_anchors = document.getElementsByTagName("a"); 
	for (var int_i=0; int_i < arr_anchors.length; int_i ++) { 
		var obj_anchor = arr_anchors[int_i]; 
		if (obj_anchor.getAttribute("href")) {
			if (obj_anchor.getAttribute("href").indexOf("http")>=0 || obj_anchor.getAttribute("href").indexOf(".pdf")>=0){
				obj_anchor.target = "_blank"; 
			} // end if
		} //end if 
	} // end for
} // end function 

/* gallery */
var int_gallery_index = 1;
function gallery_start() {
	window.setTimeout("gallery_update()", 8000);
} // end function
function gallery_update() {
	var obj_image;
	obj_image = document.getElementById("gallery-" + int_gallery_index);
	if (obj_image) {
		obj_image.style.display = "none";
	} // end if
	int_gallery_index ++;
	obj_image = document.getElementById("gallery-" + int_gallery_index);
	if (obj_image) {
		obj_image.style.display = "block";
	} else {
		int_gallery_index = 1;
		obj_image = document.getElementById("gallery-" + int_gallery_index);
		if (obj_image) {
			obj_image.style.display = "block";
		} // end if
	} // end if
	gallery_start();	
} // end function



/* marketing topics */
var str_current_topic = "";
function init_topic() {
	// set up links (adds javascript events to ensure topic changes happen)
	var obj_links = document.getElementById("block-navigation");
	if (obj_links) {
		var arr_links = obj_links.getElementsByTagName("a");
		for (var int_i = 0; int_i < arr_links.length; int_i++) {
			var obj_link = arr_links[int_i]; 
			if (obj_link.getAttribute("href")) {
				var str_topic = obj_link.getAttribute("href");
				if (str_topic.indexOf("#") >=0){
					str_topic = str_topic.substring(str_topic.indexOf("#")+1, str_topic.length);
					obj_link.id = "link-" + str_topic;
 					obj_link.onclick = function () { set_topic(this.id.replace("link-","")); }
 				} // end if
			} //end if 			
		} // end for
	} // end if
	
	// check for and set current topic (passed in via address #)
	var str_location = document.location.href;
	if (str_location.indexOf("#") > 0) {
		str_location = str_location.substring(str_location.indexOf("#")+1, str_location.length);
	} else {
		str_location = "";
	} // end if	
	if (str_location != "") {
		set_topic(str_location);
	} // end if
} // end function
function set_topic(str_topic) {
	var obj_element;
	// reset current topic
	if (str_current_topic != "") {
		obj_element = document.getElementById("link-" + str_current_topic);
		if (obj_element) {
			obj_element.className = "";
		} // end if
		obj_element = document.getElementById(str_current_topic);
		if (obj_element) {
			obj_element.className = "";
		} // end if
	} // end if
			
	// set new topic link (id="link-str_topic")
	obj_element = document.getElementById("link-" + str_topic);
	if (obj_element) {
		obj_element.className = "on";
	} // end if
	// set new topic text (id=str_topic)
	obj_element = document.getElementById(str_topic);
	if (obj_element) {
		obj_element.className = "on";
	} // end if
			
	// remember current topic
	str_current_topic = str_topic;
} // end function
		

