/*
*  Effect Controls v1 : Last revesion 06/06/06 AM
							Last revesion 08/05/06 AB
*    - load and configure effects used on site //requires scriptaculous//
*  for timorous beasties
*    - by 2Fluid : http://www.2fluid.co.uk
*/

/* 
*  Add scrollTo actions to anchor links.
*/
function addAnchorScroll(class_name) {
	class_name = class_name || 'addScroll';
	if(typeof Scriptaculous != "object") {
		throw("Scrolling anchor links require the Scriptaculous library");
		return false;
	} else {
		var l = document.getElementsByTagName("a");
		for(var i = 0; i < l.length; i++) {
			if(hasClassName(l[i],class_name)) {
				l[i].onclick = function() { startScroll(this.getAttribute("href")); return false; }
			}
		}
	}

}

// The scroll function itself
function startScroll(target) {
	if(!target) return false;
	var segments = target.split('#');
	new Effect.ScrollTo(segments[segments.length -1], {duration:0.5});
}
//YAHOO.util.Event.addListener(window,'load', addAnchorScroll);

/* 
*  Main Navigation menu functions
*  navMenu.addLink() : Attach event handler to subMenu header links
*/
/*
var navMenu = {
	addLink: function(){
		var a = document.getElementsByClassName('subNavLink');
		YAHOO.util.Event.addListener(a,'click',navMenu.toggle);
	},
	toggle: function(e){
		YAHOO.util.Event.stopEvent(e);
		if(hasClassName(this.parentNode,'active')) {
			removeClass(this.parentNode, 'active');
		} else {
			addClass(this.parentNode, 'active');
		}
		new Effect.toggle(this.getAttribute('rel'), 'blind');
	},
	hideSub: function(class_name) {
		var ul = document.getElementsByClassName('subMenu');
		for(var i = 0; i < ul.length; i++) {
			Element.hide(ul[i]);
			removeClass(ul[i], 'subMenuHidden');
		}
	}
}
YAHOO.util.Event.addListener(window,'load',navMenu.hideSub);
YAHOO.util.Event.addListener(window,'load',navMenu.addLink);
*/

tabToggle = function(element) {

  // This gives the active tab its look
  var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  
  //Hide all content containers
  contents = document.getElementsByClassName('tabset_content');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  
  //Magic Happens
  new Effect.Appear(ele);
}

teaserToggle = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('tabset_content');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  
  //Magic Happens
  new Effect.Appear(ele);
}

showSolution1 = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('solutionContent1');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  ele2 = $('solutionLink1');
  //Magic Happens
  new Effect.Appear(ele);
  //new Effect.Fade(ele2);
}

showSolution2 = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('solutionContent2');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  ele2 = $('solutionLink2');
  //Magic Happens
  new Effect.Appear(ele);
  //new Effect.Fade(ele2);
}
showSolution3 = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('solutionContent3');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  ele2 = $('solutionLink3');
  //Magic Happens
  new Effect.Appear(ele);
  //new Effect.Fade(ele2);
}
showSolution4 = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('solutionContent4');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  ele2 = $('solutionLink4');
  //Magic Happens
  new Effect.Appear(ele);
  //new Effect.Fade(ele2);
}
showSolution5 = function(element) {

  // This gives the active tab its look
  /*var tabs = $('tabs').getElementsByTagName('li');
  for(j = 0; j < tabs.length; j++) {
    link = tabs[j].getElementsByTagName('a')[0];
    link.id = "";
    tabs[j].id = "";
  }
  element.id = "current"
  element.parentNode.id = "active"
  */
  //Hide all content containers
  contents = document.getElementsByClassName('solutionContent5');
  for(var i = 0; i < contents.length; i++) {
    contents[i].style.display = 'none';
  }

  //Extract content container id from href

  tabname = element.getAttribute('rel').replace(/^.*\#/,'');
  ele = $(tabname);
  ele2 = $('solutionLink5');
  //Magic Happens
  new Effect.Appear(ele);
  //new Effect.Fade(ele2);
}

function swapAtt(node_id, att, value, node_id2, att2, value2) {
	if(document.getElementById) {

		var node = document.getElementById(node_id);
    if(typeof att == "string") {
			node.setAttribute(att, value);
		} else {
			for(var i = 0; i < att.length; i++) {
				node.setAttribute(att[i], value[i]);
			}
		}
		var node2 = document.getElementById(node_id2);
    if(typeof att2 == "string") {
			node2.setAttribute(att2, value2);
		} else {
			for(var i = 0; i < att2.length; i++) {
				node2.setAttribute(att2[i], value2[i]);
			}
		}

	}
}


/*
function tabFormSubmit() {
    var isSubmit = getQueryVariable("submit");
    if(isSubmit) {
        var tabs = document.getElementById("tabs");
        var tabLinks = tabs.getElementsByTagName("a");
        for(var i = 0; i < tabLinks.length; i++) {
            if(tabLinks[i].getAttribute("rel") != "#option4") continue;
            new tabToggle(tabLinks[i]);
            break;
        }
    }
}
*/