/// Vars ////////
var ms = 10000;
var fade_ms = 400;
var i = 0;
/////////////////
function isChar(cCode) {
	return /[a-z\A-Z\s]/.test(String.fromCharCode(cCode));
}
function isNum(cCode) {
	return /[\d\+\-\.\(\)\s]/.test(String.fromCharCode(cCode));
}
function loadNews(first) {
	$('#news .news-inner>div').fadeOut((first ? 0 : fade_ms), function(){
		$(this).load('content.txt #news .item:eq('+i+')');
		if ( ++i > 1) i=0;
		$(this).fadeIn((first ? 0 : fade_ms));
	})
}
$(document).ready(function(){
	/*if ($('.content').length > 0) {
		var c_id = $('.content').eq(0).attr('id');
		$('.content').removeAttr('id').eq(0).load('content.txt #'+c_id);
	}*/
	if ($('#news').length > 0) {
		loadNews(true);
		setInterval('loadNews()',ms);
	}
	$('input[name=contact_us\[phone\]]').keypress(function(e){
		if($.browser.msie){
      return isNum(e.keyCode);
		}else{
      return (e.keyCode) ? true : isNum(e.charCode);
		}
	})
	$('input[name=contact_us\[name\]]').keypress(function(e){
		if($.browser.msie){
      return isChar(e.keyCode);
		}else{
      return (e.keyCode) ? true : isChar(e.charCode);
		}
	})
})

/* Main page popup */
$(document).ready(function () {
    $("a.[rel]").overlay({        
        fixed: false,
        left: 0,
        top: 	0,
//        mask: {
//            color: '#000',
//            loadSpeed: 200,
//            opacity: 0.3
//        },
        closeOnClick: false
    });
});
