//onKeyPress
function numberCheck()
{
	if(event.keyCode < 47 || event.keyCode > 58) { 
		return false;
	}
}
//onBlur
function numberCheck2(obj)
{
	var intRegex = /^\d+$/;
	var value = obj.value;
	if(!intRegex.test(value)) {
		obj.value = '';
	}
}
function textCheck(fieldId, fieldName)
{
	var value = $('#'+fieldId).val();
	if(value == '' ) {
		alert('Input ' + fieldName + '.', $('#'+fieldId).focus());
		return false;
	}
	return true;
}

function selectCheck(fieldId, fieldName)
{
	var value = $('#'+fieldId).val();
	if(value == '') {
		alert('Choose ' + fieldName + '.', $('#'+fieldId).focus());
		return false;
	}
	return true;
}
function radioCheck(fieldId, fieldName)
{
	var value = $(':input:radio[name='+fieldId+']:checked').val();
	if(value == undefined) {
		alert('Choose ' + fieldName + '.');
		return false;
	}
	return true;
}
function lengthCheck(fieldId, maxSize, fieldName)
{
	var value = $("#"+fieldId).val();
    var byteLength = 0;
    for(var i=0; i<value.length; i++)
    {
    	var oneChar = escape(value.charAt(i));
    	if(oneChar.length == 1)	{
    		byteLength += 1;
    	} else if(oneChar.indexOf("%u") != -1) {
    		byteLength += 2;
    	} else if (oneChar.indexOf("%") != -1) {
    		byteLength += oneChar.length / 3;
    	}
    }

    if(byteLength > maxSize) {
    	alert('Enter below '+ maxSize +' bytes in ' + fieldName + '.', $('#'+fieldId).select());
    	return false;
    } else {
    	return true;
    }
}

function trim(s)
{
	return s.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
function keyCode(e)
{
	return (!e.which&&((e.charCode||e.charCode===0)?e.charCode:e.keyCode))?(e.charCode||e.keyCode):e.which;
}
function entered(e)
{
	return (keyCode(e)==13)? true:false;
}
function slideMenu2() 
{ 
	var currentPosition = parseInt($('#slidemenu2').css('top')); 
	$(window).scroll(function() { 
		var position = $(window).scrollTop(); 
		if (position < 700) { 
			$('#slidemenu2').stop().animate({'top':currentPosition+'px'},800); 
		}else { 
			$('#slidemenu2').stop().animate({'top':position+currentPosition-715+'px'},800); 
		} 
	}); 
} 
