var d = document;
var malp = function() {
	if(!d.getElementsByTagName('span')[0]) return;
    var sps = d.getElementsByTagName('span'), spn,
    	txt, mlt, anc,
    	i = sps.length;
    while (i--) {
        spn	= sps[i];
        if (spn.className.indexOf('malp') == -1 || !spn.childNodes[0]) continue;
        txt = spn.childNodes[0];
        mlt = txt.nodeValue.replace(RegExp('-at-','i'), '@');
        anc	= d.createElement('a');
        anc.setAttribute('href', 'mailto:' + mlt);
        anc.appendChild(d.createTextNode(mlt));
        spn.removeChild(txt);
        spn.appendChild(anc);
    };
};

(function($) {

    $.fn.cn_crossFade = function(options) {

        var defaults = {			
    		speed: 2000,
            pause: 3000
    	};
	
        var options = $.extend(defaults, options);
        
        this.each(function(){
            
            var obj = $(this);
                    
            function cn_crossSlide(x) { 
    
                $('li:animated', obj).stop();
    
                var iteLen = $('li', obj).length;
                var indLen = $('#indicators li').length;
    
                var toIndex = parseInt(x);
                var nextIndex = toIndex != (iteLen - 1) ? parseInt(toIndex + 1) : 0;
                var prevIndex = toIndex != 0 ? parseInt(toIndex - 1) : parseInt(iteLen - 1);
                
                $($('li', obj).get(toIndex)).fadeIn(options.speed); 

                $($('li', obj).get(prevIndex)).fadeOut(options.speed);
                
                crossSlideTimeout = setTimeout(function(){
    				cn_crossSlide(nextIndex);
    			}, options.pause);
    
            }
            
            var items = $('li', obj);
            items.hide();
            $('li:first-child', obj).show();
            
            crossSlideTimeout = setTimeout(function(){
    			cn_crossSlide(1);
    		}, options.pause);    
        });
    };
    
})(jQuery);

function changeBg() {          
    $('#second-frame').fadeIn();
    $('#first-frame').fadeOut();
    // backgroundTimeout = setTimeout('changeBg()', 5000);
    if (typeof(backgroundTimeout) != 'undefined') {
        clearTimeout(backgroundTimeout);
    };
}