$(function(){
	$('#lmUser').focus(function(){
		$('#lmUser').css('color','#000');
		if($('#lmUser').val()=='Username') {$('#lmUser').val('')};
	});	
	$("#lmUser").blur(function(){
		if($('#lmUser').val()=='') {
			$('#lmUser').val('Username');
			$('#lmUser').css('color','#4d4f53');
		};
	});
	
	$('#lmPassMASK').focus(function() {
		$('#lmPassMASK').hide();
		$('#lmPass').show();
		$('#lmPass').focus();
	});
	
	$('#lmPass').blur(function() {
		if($('#lmPass').val() == '') {
			$('#lmPassMASK').show();
			$('#lmPass').hide();
		}
	});
	
	$("#mmSearchBar").focus(function(){
		$("#mmSearchBar").css("color","#000");
		if($("#mmSearchBar").val()=="Search NN4D.com") {$("#mmSearchBar").val("")};
	});
	
	$("#mmSearchBar").blur(function(){
		if($("#mmSearchBar").val()=="") {
			$("#mmSearchBar").val("Search NN4D.com");
			$("#mmSearchBar").css("color","#6d6d6d");
		};
	});
	$('.readOn').hover(function(){
			$active = $(this);
			$('.readOnIcon',$active).addClass("hover");	
		}
		,function() {
			$active = $(this);
			$('.readOnIcon',$active).removeClass("hover");
    });
	
	$('.level00 li').hover(function(){
			$active = $(this);
			$('ul',$active).css('display', 'inline-block');
			$('img',$active).addClass("hover");
		}
		,function() {
			$active = $(this);
			$('ul',$active).css('display', 'none');
			$('img',$active).removeClass("hover");
    });	
	$('.level01 li').hover(function(){
			$active = $(this);
			$('.actIcon',$active).addClass("roll");			
		}
		,function() {
			$active = $(this);
			$('.actIcon',$active).removeClass("roll");			
    });	
	$('.tout a').hover(function(){
			$active = $(this);
			$('.btnDL',$active).addClass("hover");	
			$active.css( 'cursor', 'pointer' );
		}
		,function() {
			$active = $(this);
			$('.btnDL',$active).removeClass("hover");
			$active.css( 'cursor', 'auto' );
    });


	checkAll = function(container){
			$(container).find('input[type=checkbox]').each(function(){
				$('label[for="'+$(this).attr('id')+'"]').addClass('checked');
				$(this).attr('checked', true);
			});
	};
	uncheckAll = function(container){
			$(container).find('input[type=checkbox]').each(function(){
				$('label[for="'+$(this).attr('id')+'"]').removeClass('checked');
				$(this).attr('checked',false);
				/*if($.browser.msie){
					$(this).attr('checked',false);
				}else{
					$(this).trigger('click');
				};*/
			});
			
	};
	
	
	$('.downloadNow').hover(function(){
			$active = $(this);
			$('.readOnIcon',$active).addClass("hover");	
		}
		,function() {
			$active = $(this);
			$('.readOnIcon',$active).removeClass("hover");
    });	
	
	$('.moreRM').hover(function(){
			$active = $(this);
			$('.readOnIcon',$active).addClass("hover");	
		}
		,function() {
			$active = $(this);
			$('.readOnIcon',$active).removeClass("hover");
    });	
	
	$('.morePartner').hover(function(){
			$active = $(this);
			$('.readOnIcon',$active).addClass("hover");	
		}
		,function() {
			$active = $(this);
			$('.readOnIcon',$active).removeClass("hover");
    });
	
	$('.learnMore').hover(function(){
			$active = $(this);
			$('.readOnIcon',$active).addClass("hover");	
		}
		,function() {
			$active = $(this);
			$('.readOnIcon',$active).removeClass("hover");
    });	
	
	if(document.getElementById('menuLeft')) {
		$("#menuLeft").find("li").each(function(){
			if($('a',this).height()<=18) {
				//$(this).css('background','none');
				$("a",this).css('height','26');
			} else{
				//$(this).css('background','none');
				$(this).addClass("double");
				$("a",this).css('height','42');
			}
			/*if($('span',this).height()<=18) {
				//$(this).css('background','none');
				//$("span",this).css('height','26');
			}else{
				//$(this).css('background','none');
				$(this).addClass("double");
			}*/
		});

		$("#menuLeft li").click(function(){
			//alert($("a",this).height() + " : " + $(this).innerHeight() + " : " + $(this).outerHeight());
		});
	}
});

function submitViaEnter(evt) {
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13) {
        if (validateForm(form)) {
            form.submit();
            return false;
        }
    }
    return true;
}
