// JavaScript Document

var Event = YAHOO.util.Event;
var Dom = YAHOO.util.Dom;

function is_all_ws( nod )
{
  // Use ECMA-262 Edition 3 String and RegExp features
  return !(/[^\t\n\r ]/.test(nod.data));
}


function is_ignorable( nod )

{

  return ( nod.nodeType == 8) || // A comment node

         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws

}

 
function first_child( par )
{
  var res=par.firstChild;
  while (res) {
    if (!is_ignorable(res)) return res;
    res = res.nextSibling;
  }
  return null;
}

var slater = {

	initialize: function() {
		slater.menus = GSSI.DOM.getElementsByClassName('topmenu');
		var m;
		for ( var i=0; i<slater.menus.length; i++ ) {
			m = slater.menus[i];
			if (m.className.indexOf('active') != -1) {
				m._jpcurrent = true;
			}
		}
		GSSI.Events.Add(slater.menus,'mouseover', slater.showMenu);
		GSSI.Events.Add(slater.menus,'mouseout', slater.hideMenu);
	},
	
	showMenu: function () {
		mainmenu.show(this.id, this);
	},
	
	hideMenu: function () {
		mainmenu.hide();
	}
	
};

Event.onDOMReady(function() {

		slater.initialize();

        var tabs = Dom.getElementsByClassName('tab','a');
 
        if(tabs) {
               for(var i=0; i<tabs.length; i++) {
                       if (first_child(tabs[i].parentNode) == tabs[i]) {
                               Dom.addClass(tabs[i],'active');
                               Dom.addClass(Dom.getElementsByClassName(tabs[i].id)[0],'open');
                       }
                       else {
                               Dom.removeClass(tabs[i],'active');
                               Dom.addClass(Dom.getElementsByClassName(tabs[i].id)[0],'closed');
                       }
               }
               Event.on(tabs,'mouseover', function() {
                       if (!Dom.hasClass(this,'active')) {
                               var currentTab = Dom.getElementsByClassName('active','a',this.parentNode)[0];
                               Dom.removeClass(currentTab,'active');
                               Dom.replaceClass(Dom.getElementsByClassName(currentTab.id)[0],'open','closed');
                               
                               Dom.addClass(this,'active');
                               Dom.replaceClass(Dom.getElementsByClassName(this.id)[0],'closed','open');
                       }
           });
        }
});

function validate(){
	missinginfo = "";
	if (document.forms[0].recipientname.value == "") {
		missinginfo += "\n   -  Recipient Name";
	}
	if (document.forms[0].sendername .value == "") {
		missinginfo += "\n   -  Sender Name";
	}
	if ((document.forms[0].senderemail .value == "") ||
		(document.forms[0].senderemail .value.indexOf('@') == -1) ||
		(document.forms[0].senderemail .value.indexOf('.') == -1)) {
			missinginfo += "\n   -  Senders Email Address";
	}
	if ((document.forms[0].recipientemail.value == "") ||
		(document.forms[0].recipientemail.value.indexOf('@') == -1) ||
		(document.forms[0].recipientemail.value.indexOf('.') == -1)) {
			missinginfo += "\n   -  Recipients Email Address";
	}
	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"You failed to correctly fill in your:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease re-enter and submit again!";
		alert(missinginfo);
		return false;
	}
	else return true;
}