 ////////////////////////////////////////////////////////////////////////////////////////////
function showLoadMsg(msg, divLocation)
{
	hidden = document.getElementById(divLocation);
	hidden.innerHTML = '<img src="http://www.thearete.com/js/indicator.gif" alt="" /> ' + msg;
}
function interestShort(interestForm)
{
	with(interestForm)
	{
		if(firstName.value == "")
		{
			alert("Please enter a valid First Name");
			firstName.focus();
			return false;
		}
		if(lastName.value == "")
		{
			alert("Please enter a valid Last Name");
			lastName.focus();
			return false;
		}
		if(validate_email(email, "Please enter a valid email") == false)
		{
			email.focus();
			return false;
		}
		var responseDiv = document.getElementById("interestShortResponse");
		responseDiv.style.visibility = "hidden";
		showLoadMsg("Processing...", "interestShortMessage");
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request");
		 return;
		 }
		var url="interest.inc.short.php";
		url=url+"?firstName="+firstName.value+"&lastName="+lastName.value+ "&email="+email.value;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=interestStateChanged ;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
			return false;
	}
}
function interestStateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 
 	var response = xmlHttp.responseText ;
	var statusBarMessage = document.getElementById("interestShortMessage");
	var responseDiv = document.getElementById("interestShortResponse");
	if(response == "duplicate")
	{
		alert("Please enter a valid email");
		statusBarMessage.innerHTML  = "";
		responseDiv.style.visibility = "visible";
	
	}
	else
	{
	
		statusBarMessage.innerHTML = "";
		document.getElementById("interestShortResponse").innerHTML = response;
		responseDiv.style.visibility = "visible";
	}
	
 } 
}
function validate_email(field,alerttxt)
{
	with (field)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	if (apos<1||dotpos-apos<2) 
  	{alert(alerttxt);return false;}
	else {return true;}
	}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

// accessible short forms
function initOverLabels () {
  if (!document.getElementById) return;      

  var labels, id, field;

  // Set focus and blur handlers to hide and show 
  // labels with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {

    if (labels[i].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      } 

      // Change the applied class to hover the label 
      // over the form field.
      labels[i].className = 'overlabel-apply';

      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      };
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      };

      // Handle clicks to label elements (for Safari).
      labels[i].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      };

    }
  }
};

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    field_for = labels[i].htmlFor || labels[i].getAttribute('for');
    if (field_for == field_id) {
      labels[i].style.textIndent = (hide) ? '-90000px' :'0px';
      return true;
    }
  }
}
// trucate news section
$(function() {

    $(".newsContainer p").truncate( 200, {
        chars: /\s/,
        trail: [ " <a href='#' class='truncate_show moreBtn'>more</a>", "<a href='#' class='truncate_hide moreBtn'>less</a>" ]
    });


});

window.onload = function () {
	$(".levelGroup area").fancybox({ 'zoomSpeedIn': 0, 'zoomSpeedOut': 0, 'overlayShow': false }); 
	$(".subpgLeft a").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 0, 'overlayShow': false });
  setTimeout(initOverLabels, 50); 
	
};
/*
window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#be7736');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#be7736');
		}
	});

	//add click event to the "add section" link
	$('add_section').addEvent('click', function(event) {
		event.stop();
		
		// create toggler
		var toggler = new Element('h3', {
			'class': 'toggler',
			'html': 'Common descent'
		});
		
		// create content
		var content = new Element('div', {
			'class': 'element',
			'html': '<p>A group of organisms is said to have common descent if they have a common ancestor. In biology, the theory of universal common descent proposes that all organisms on Earth are descended from a common ancestor or ancestral gene pool.</p><p>A theory of universal common descent based on evolutionary principles was proposed by Charles Darwin in his book The Origin of Species (1859), and later in The Descent of Man (1871). This theory is now generally accepted by biologists, and the last universal common ancestor (LUCA or LUA), that is, the most recent common ancestor of all currently living organisms, is believed to have appeared about 3.9 billion years ago. The theory of a common ancestor between all organisms is one of the principles of evolution, although for single cell organisms and viruses, single phylogeny is disputed</p>'
		});
		
		// position for the new section
		var position = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion.addSection(toggler, content, position);
	});
});*/