/*

                                                  
                          `.---.                  
                       `-/::::+++.                
                     `:////++ooooo`               
                    :++++oooooosss-               
                  `++oooooosssssss:               
                 `+ooooossssssyyyy.               
                 /oossssssyyyyyyyo                
                /sssssyyyyyyyhhh+                 
               /sssyyyyyyhhhhs/`                  
             .oyyyyyyyhhyo/-    `..`              
            `osssso+/:.```.--::///++/             
               `.-:///++++++++++++ooo             
             .+++oooooooosssssssssys.             
             `+sssssssyyyyyyyyyhhhs.              
               `:oyyhhhhhhhhhhhhs:                
                   .:/+ossoo+:.                   
                                                  
                                                  
Copyright 2007. Intacard
                                       


*/

window.addEvent('domready', function() {

new SlideList($E('ul#pnav', $('head')), {transition: Fx.Transitions.Sine.easeInOut, duration: 500, onClick: function(ev, item) { ev.stop(); }});
new ToTop();
new Foot();
new SmoothScroll();
new Page();

//-->Create Small Tool Tips
this.icons= $ES('.smlTip');

var iconTips= new Tips(this.icons, { maxTitleChars: 50, className: 'small-tool', showDelay: 500, hideDelay: 0 });
var smlTip= $E('.small-tool-tip');
smlTip.adopt(new Element('div').addClass('lft')).adopt(new Element('div').addClass('rht'));

//-->Anything with a class of toolTip will display it's title tag in the large tool tip bubble
var myTips = new Tips($ES('.lrgTip'), {
maxTitleChars:50,
showDelay:500,
hideDelay:0
});

});


/*-------------------------------------------------------------------------------------------------
~Class» ToTop*
Version» 0.02*
*
Author» Kirk Bentley*
Email» kirk[at]intabill[dot]com*
*
Descripion» Scrolls current page to top*
*
--------------------------------------------------------------------------------------------------*/
var ToTop= new Class({

s:new Fx.Scroll( window, { duration: 300, transition: Fx.Transitions.sineInOut }),

initialize:function(){
var b= $ES('a.btnToTop');

b.forEach(function(el){
el.setAttribute('href','javascript:void(0);');
el.addEvent('click',function(){ this.ToTop()}.bind(this));
},this);
},

ToTop:function(){
this.s.toTop();
}

});

/*-------------------------------------------------------------------------------------------------
~Class» Corners*
Version» 0.01*
*
Author» Kirk Bentley*
Email» kirk[at]intabill[dot]com*
*
Descripion» Inject content corners*
*
--------------------------------------------------------------------------------------------------*/
var Corners= new Class({

initialize:function(){
this.c= $ES('.corners');
this.c ? this.AddCrorners():null;
},

AddCrorners:function(){

var crnrs= ['tl','tr','bl','br'];

this.c.forEach(function(el){

var i= new Element('div', { 'class':'inner' });
i.adopt(el.getChildren());
el.adopt(i);

crnrs.forEach(function(crnr){
if(el.className.test(crnr)){
nc= new Element('div', { 'class':'crnr' }).setHTML('<!-- -->').addClass(crnr).injectBefore(el.getFirst());
nc.setStyle('height', el.offsetHeight);
}
}.bind(this));

},this);
}

});

/*-------------------------------------------------------------------------------------------------
~Class» Page*
Version» 0.01*
*
Author» Kirk Bentley*
Email» kirk[at]intabill[dot]com*
*
Descripion» - Injects cover png*
  - Stretches Content*
*
--------------------------------------------------------------------------------------------------*/
var Page= new Class({

cover:new Element('div', { 'class':'cover' }),
conInner:new Element('div', { 'class':'inner' }),

pageHdr:null,
lft:null,
rht:null,
btns:null,


initialize:function(){

//this.EvenContent();
this.Buttons();
//-->Corners is called here, because we must perform content height matching first...
new Corners();

},

EvenContent:function(){

this.lft= $('lft');
this.rht= $('rht');

if(this.lft && this.rht){
if(this.lft.scrollHeight > this.rht.scrollHeight && !this.rht.className.test('nostretch')){
this.rht.setStyle('height', this.lft.getParent().scrollHeight);
}else if(!this.lft.className.test('nostretch')){
this.lft.setStyle('height', this.lft.getParent().scrollHeight);
}
}

},

Buttons:function(){
if(window.ie6){
this.buttons= $ES('button');

this.buttons.forEach(function(btn){
btn.addEvent('mouseover', function(){
//alert(btn);
this.addClass('btnOver');
});
btn.addEvent('mouseout', function(){
this.removeClass('btnOver');
});
});
}
}

});

/*-------------------------------------------------------------------------------------------------
~Class» Foot*
Version» 0.01*
*
Author» Kirk Bentley*
Email» kirk[at]intabill[dot]com*
*
Descripion» Scrolls current page to top*
*
--------------------------------------------------------------------------------------------------*/
var Foot= new Class({

initialize:function(){

window.ie6 ? this.IE6():null;
},

IE6:function(){
var icos= $ES('#foot dl dd.ico a');
icos.forEach(function(i){
i.addEvent('mouseover', function(){
$E('span', this).addClass('over');
});

i.addEvent('mouseout', function(){
$E('span', this).removeClass('over');
});
});
}

});

/*-----------------------------------------------------------------------------
Original script available @
http://devthought.com/cssjavascript-true-power-fancy-menu

This script has been slightly barstardized
-----------------------------------------------------------------------------*/

var SlideList = new Class({
initialize: function(menu, options) {
this.setOptions(this.getOptions(), options);

this.menu = $(menu), this.current = this.menu.getElement('li.current');

this.menu.getElements('li').each(function(item){
item.addEvent('mouseover', function(){ $clear(this.delay); this.moveBg(item); }.bind(this));
item.addEvent('mouseout', function(){ this.delay = (function(){ this.moveBg(this.current); }.bind(this)).delay(200) }.bind(this));
item.addEvent('mouseup', function(event){ this.clickItem(event, item); }.bind(this));

item.adopt(new Element('span').adopt(item.getChildren()));

}.bind(this));

this.back = new Element('div').addClass('bg').adopt(new Element('div').addClass('lft')).adopt(new Element('div').addClass('rht')).injectInside(this.menu);
this.back.fx = this.back.effects(this.options);

!$('head').hasClass('nocover') ? $E('body').adopt(new Element('div', { 'id':'pnavCover' })):null;

if(this.current) this.setCurrent(this.current);
},

setCurrent: function(el, effect){
this.back.setStyles({left: (el.offsetLeft), width: (el.offsetWidth)});
(effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
this.current = el;
},

getOptions: function(){
return {
transition: Fx.Transitions.sineInOut,
duration: 500, wait: false,
onClick: Class.empty
};
},

clickItem: function(event, item) {
if(!this.current) this.setCurrent(item, true);
this.current = item;
this.options.onClick(new Event(event), item);
},

moveBg: function(to) {
if(!this.current) return;
this.back.fx.custom({
left: [this.back.offsetLeft, to.offsetLeft],
width: [this.back.offsetWidth, to.offsetWidth]
});
}
});

SlideList.implement(new Options);







var SmoothScroll = Fx.Scroll.extend({

initialize: function(options){
this.parent(window, options);
this.links = (this.options.links) ? $$(this.options.links) : $$(document.links);
var location = window.location.href.match(/^[^#]*/)[0] + '#';
this.links.each(function(link){
if (link.href.indexOf(location) != 0) return;
var anchor = link.href.substr(location.length);
if (anchor && $(anchor)) this.useLink(link, anchor);
}, this);
},

useLink: function(link, anchor){
link.addEvent('click', function(event){
this.anchor = anchor;
this.toElement(anchor);
event.stop();
}.bindWithEvent(this));
}

});


/*
        .-.  
       (0.0)  
     '=.|m|.='
     .='`"`'=.

*/
window.addEvent('domready', function() {

new Faqs();

});

/*-------------------------------------------------------------------------------------------------
~Class» Faqs*
Version» 0.01*
*
Descripion» - Injects question icons*
  - *
*
--------------------------------------------------------------------------------------------------*/
var Faqs= new Class({

Questions:null,
qIcon:new Element('span', { 'class':'iconQuestion' }),
aIcon:new Element('span', { 'class':'iconAnswer' }),

initialize:function(){

this.InjectIcons();

},

InjectIcons:function(){

this.Questions= $ES('dl dd ol li a', $('questions'));
this.Answers= $ES('dl dd ol li', $('answers'));

this.Questions.forEach(function(q){
q.adopt(this.qIcon.clone());
}, this);

this.Answers.forEach(function(a){
if(a.getFirst().getTag() !== 'a'){
a.adopt(this.aIcon.clone());
}
}, this);

}

});