
//  this is my tab-menu class
var slideMenu = new Class({
	tabs : [],
	initialize: function(selector) {
		// the selector is assumed to be the mouse over menu element li, 
		// with the submenu in a nested ul
		this.tabs = $$(selector);
		this.tabs.each( function(tab) {
			var dropdown = tab.getElement('ul');
			if (null != dropdown) {
				var size = dropdown.getSize();
				tab.addEvent('mouseenter', this.unRoll.pass([dropdown,size.y], this) );
				tab.addEvent('mouseleave', this.rollUp.pass(dropdown, this) );
			}
		  },   this );
	},

	unRoll: function(e,height) {
				
				e.setStyle( 'opacity', 0);
				e.set('morph', {
					duration: 200,
					transition: Fx.Transitions.Sine.easeOut
					}).morph({ 
						height : (height-1) + 'px',
						opacity : 1,
						visibility : 'visible'
						});
	},

	rollUp: function(e) {
				
				e.set('morph', {
					duration: 200,
					transition: Fx.Transitions.Sine.easeIn
					}).morph({
						height : '0px',
						opacity : 0
						});
	}

});

// now process all the page items
window.addEvent('domready', function() {

// set up the tab menu
menu = new slideMenu('#horiz-menu li.tab');

// the "starlist" UL style
var star = new Element('span',{'class':'star'}); // create the span
star.innerHTML = '*&nbsp;'; // put in the contents
var listItems = $$('ul.starlist li');
listItems.each( function(listItem){
	if (null != listItem ) {
			listItem.grab(star.clone(),'top');
			s = listItem.getElement('.star').getSize();
			listItem.setStyles({
				'text-indent': '-' + s.x + 'px',
				'margin-left': s.x + 'px'
				});
		}
	},this);
	
star.innerHTML = '&bull;&thinsp;'; // put in the contents
var listItems = $$('ul.artlist li');
listItems.each( function(listItem){
	if (null != listItem ) {
			listItem.grab(star.clone(),'top');
			s = listItem.getElement('.star').getSize();
			listItem.setStyles({
				'text-indent': '-' + s.x + 'px',
				'margin-left': s.x + 'px'
				});
		}
	},this);

var carat = new Element('span',{'class':'carat'}); // create the span
carat.innerHTML = ''; // put in the contents
var listItems = $$('ul.section-menu h3');
listItems.each( function(listItem){
	if (null != listItem ) {
			listItem.grab(carat.clone(),'top');
			s = listItem.getElement('.carat').getSize();
			listItem.setStyles({
				'text-indent': '-' + s.x + 'px',
				'margin-left': s.x + 'px'
				});
		}
	},this);
});


//  set iframe heights
function iFrameHeight() {
	var pad = 30;  //  pad space at bottom of iframe
	if(document.getElementById && !(document.all)) {
		h = document.getElementById('cheight').contentDocument.body.scrollHeight;
		document.getElementById('cheight').style.height = h + pad + "px";
	}
	else if(document.all) {
		h = document.frames('cheight').document.body.scrollHeight;
		document.all.cheight.style.height = h + pad + "px";
	}
}

/*  EMAIL OBFUSCATION  */

// global variables to form MY addresses
var pref = ""; // subdomain, or ""
var at1 = "@";
var dot = ".";
var typ = "com";
var baseurl = "index.php?page=";  // for real link
var page = "complete-order";  // CMS alias of the return page
var domain = "brilliantbreakthroughs";
var id = "mm";    // real id1 for email
var url = "brilliantbreakthroughs";       // real email URL
var fid1 = "sa";      // fake id1
var fid2 = "les"    // fake id2
var furl = "brilliantbreakthroughs";    // fake URL

function FixBusi (obj1) {  // PayPal FORM business value
var tmp;
  if (obj1.business) {     // see what is in this form 
    tmp = obj1.business.value;
    obj1.business.value = id + at1 + url + dot + typ;
  }
  return true;             // make it work...
}

function FixLink (obj1) {  // fix any PayPal link in calling FORM
var tmp,org,ary=new Array();
  for (i=0; i<obj1.length; i++) {  // run whole FORM
    obj = obj1.elements[i];        // address an element
    org = obj.value;
    tmp = org;  // place holder
    ary = tmp.split (furl);  // do we have a fake
    if (ary.length > 1) {    // still a fake
      tmp = ary.join (pref + domain);  // put in the real url
      obj.value = tmp;
    }
    org = tmp;  // any more stuff to fix?
    ary = tmp.split (fid1 + fid2);  // have a fake ID here?
    if (ary.length > 1) {    // still a fake
      tmp = ary.join (baseurl + page);   // asemble our real url
      obj.value = tmp;
    }
  }
}


// JavaScript Document  link is made up of  pref + url + id1 + id2
// We call this with onclick="FixMail(this,'name');" in the a tag

function FixMail (obj1,name,dom) {  // fix a hyperlink mail addr

	var tmp;
  tmp = obj1.href;
  if (tmp.indexOf('?') > -1) {  // look for parameters to pass along
	  params = tmp.split('?');
	  obj1.href = "mailto:" + name + at1 + dom + '?' + params[1];
	  }
	  else {
	  obj1.href = "mailto:" + name + at1 + dom;
	  }
  return true;             // make it work...
}


//
// Mouseover code for IE
//
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/
var i=0;
var ie=(document.all)?1:0;
var ns=(document.layers)?1:0;
function initStyleElements()
{var a = document.pad;
if (ie)
{
a.submit.style.backgroundColor="#F0F0F0";
a.submit.style.cursor="hand";
}
else return;
}
function LightOn(what)
{
if (ie) what.style.backgroundColor = '#D0C5E1';
else return;
}
function LightOff(what)
{if (ie) what.style.backgroundColor = '#F0F0F0';
else return;
}

