// JavaScript Document

var TouchDevice = 'ontouchstart' in document.documentElement;
	var megaMenuClear;
	var mmTimeout =300;
$(document).ready(function(){	

    //if (!$.browser.opera) {

        $('select.select').each(function(){
			$(this).wrap('<div class="wrapSelect" />');
            var title = $(this).attr('title');
            if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();
            $(this)
                .css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
                .after('<span class="select">' + title + '</span>')
                .change(function(){
                    val = $('option:selected',this).text();
                    $(this).next().text(val);
                    })
        });
		
		$('#Print').click(function(){ window.print(); return false});
		$('#Close').click(function(){ 
			$('#ResutsBox').animate({height:0},600);
			$('#afterConv').hide();
			$('#beforeConv').show();
		 	return false
		 });
		 $('#Convert').click(function(){ 
				// GET YOUR RESULTS AND THEN:
			var h = $('#ResutsBox .inner').height();
			h+=40;
			$('#ResutsBox').animate({height:h},600);
			$('#afterConv').show();
			$('#beforeConv').hide();
		 	return false
		 });
		 $('#Reset').click(function(){ 
			$('#amount').val('');
			$('#ChooseCurrency').val('Choose a currency');
			$('span.select').text('Choose a currency');
			$('#ResutsBox').animate({height:0},600);
			$('#afterConv').hide();
			$('#beforeConv').show();
		 	return false
		 });
		 

	$('.mainNavLink').mouseover(function(){
		window.clearTimeout(megaMenuClear);
		megaMenuClear= null;
		$('.list-nav').css('left','30px').hide();
		$(this).next().show();
	});
	if(TouchDevice){
	$('.mainNavLink').click(function(){
		window.clearTimeout(megaMenuClear);
		megaMenuClear= null;
		$('.list-nav').hide();
		$(this).next().show();
	});
	}
	$('.mainNavLink, .list-nav').mouseleave(function(){

		megaMenuClear = window.setTimeout("$('.list-nav').hide(200)", mmTimeout);		
	});
	$('.list-nav').mouseenter(function(){

		window.clearTimeout(megaMenuClear);
		megaMenuClear= null;	
	});

	$('body').click(function(){
		window.clearTimeout(megaMenuClear);
		megaMenuClear= null;

		$('.list-nav').hide();
	});	
	$('.list-nav').click(function(e){
		e.stopPropagation();  //to stop closing on whitespace
	})

//    };
		
});














