$.fn.trimval = function() {
	return $(this).val().toString().replace(/^\s+|\s+$/g,"");
};

function isValidEmail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	return (filter.test(str));
}

function isValidPhone(str){
	//var patt1 = new RegExp(/^(ext|x)*[0-9 \(\)\+\-]{8,20}$/i);
	var patt1 = new RegExp(/^(ext|x)*[0-9 \(\)\+\-]{1,50}$/i);
	return patt1.test(str);
}

function isValidNumber(str){
	var patt1 = new RegExp(/^[0-9]+$/i);
	return patt1.test(str);
}

function onBefore(){
//console.log("calling "+$(arguments[1]).attr("src"));
	//$('.banner_img[src='+$(arguments[1]).attr("src")+']').show();
	$('.banner_img:hidden').css({"position":"absolute", "top":"0px"});
	//$('.banner_img:visible').hide();
	//$('.banner_img:visible').animate({"top": "-195px"}, 4000);
}
function onAfter(){
//console.log(arguments);
	$('.banner_img').css({"position":"absolute", "top":"0px"});
	$('.banner_img:visible').animate({"top": "-195px"}, {"duration":5400, "queue":false});
}
$(document).ready(function() {
	$('.btn_over').mouseover(function(){
		$(this).attr('src', $(this).attr('src').toString().replace('.g','_over.g'));
		$(this).attr('src', $(this).attr('src').toString().replace('.j','_over.j'));
		$(this).attr('src', $(this).attr('src').toString().replace('.p','_over.p'));
    }).mouseout(function(){
		$(this).attr('src', $(this).attr('src').toString().replace('_over.g','.g'));
		$(this).attr('src', $(this).attr('src').toString().replace('_over.j','.j'));
		$(this).attr('src', $(this).attr('src').toString().replace('_over.p','.p'));
    });
	
	if($('#index_banner').length>0){
			$('#index_banner').css("position","relative").cycle({
				fx:     'fade',
				speed:  'slow',
				timeout: 4600,
				pager:  '#nav',
				slideExpr: 'img',
				before: onBefore,
				after: onAfter
			});	
	}
 // $('a[rel*=facebox]').facebox();

});
