/***
 * Demos 			JoomShaper demos
 *
 * version			1.0
 * 
 * author			JoomShaper.com
 * copyright		JoomShaper.com
 *
 */
window.addEvent("domready",function(){
	$('menu-items').set('tween',{
        onComplete:function(){
        if ($('menu-items').getStyle('opacity') == 0) {
                $('menu-items').setStyle('display','none');
            }
        },
        onStart: function() {
            if ($('menu-items').getStyle('opacity') == 0) {
                $('menu-items').setStyle('display','block');
            }
        }
    }).setStyle('opacity',0);
    $('ddbox').addEvent('click', function(){
        $('menu-items').fade('toggle');
    });
	
	$('wrap').addEvents({
	'mouseleave': function(){	
		 $('menu-items').fade('out');
	}
	
	});
	
	var hasTip = new Tips($$('.hasTip'), {
        initialize: function() { this.tip.fade('hide'); },
        onShow: function(tip) { tip.fade('in');tip.setStyle('z-index','99999');},
        onHide: function(tip) { tip.fade('out'); }
    });
	
	var anchors = $('menu-items').getElements('a');
	var itemText;
	anchors.each(function(item,index){
		item.addEvents({
			'click':function(){
				itemText = item.get('html').stripTags("span", "span");
				$('ddbox').set('html', itemText);
				$('menu-items').fade('out');
			}
		});
	})	
});
function resizer() {
	var theWidth, theHeight;
	// Window dimensions:
	if (window.innerWidth) {
	theWidth=window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
	theWidth=document.documentElement.clientWidth;
	}
	else if (document.body) {
	theWidth=document.body.clientWidth;
	}
	if (window.innerHeight) {
	theHeight=window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) {
	theHeight=document.documentElement.clientHeight;
	}
	else if (document.body) {
	theHeight=document.body.clientHeight;
	}
	var ifrm=document.getElementById('demoframe');
	ifrm.style.height= (theHeight -70) + 'px';
	ifrm.style.width= theWidth + 'px';
}
window.addEvent("resize",resizer);
window.addEvent("load",resizer);
