function doSubscribe() {
	var regEmail = /^[A-Za-z0-9\-_]+(\.[A-Za-z0-9\-_]+)*@([A-Za-z0-9\-_\.]+\.)+[A-Za-z]{2,8}$/i;
	
    if (document.getElementById('mailing').FirmEmail.value < 1) {
			alert("Please enter e-mail address!");
            document.getElementById('mailing').FirmEmail.focus();
            return false;
    } else {
        if (document.getElementById('mailing').FirmEmail.value.search(regEmail) == -1) {
            alert("Please enter valid e-mail address!");
            document.getElementById('mailing').FirmEmail.focus();
            return false;
        }
    }
}

var alertTimerId = 0;
var featureNum = 2;

$(document).ready(function(){
	$("#index-content .quarter div").hover(function(){
		$(this).css('border-color', '#010065');
	},function(){		
		$(this).css('border-color', '#fff');
	});

	$(".mainnav").hover(function(){
		$(".mainnav").removeClass('current');
		$(".subnav").hide();
		$("#navBox").hide();

		navID = $(this).get(0).id.replace(/\D*/, '');
		if($("#sub" + navID).size() > 0) {
			$("#main" + navID).addClass('current');
			$("#sub" + navID).show();

			var position = $("#main" + navID).position();

			$("#sub" + navID).css('left', position['left']);
			
			var maxWidth = 0;
			$("#sub" + navID + " li").each( function() {
				var curWidth = $(this).width();

				if(curWidth > maxWidth)
					maxWidth = curWidth;
			});

			//$("#navBox").css('width', (maxWidth + 6) + 'px');
			//$("#navBox").css('height', ($("#sub" + navID).height() + 2) + 'px');
			//$("#navBox").css('left', (position['left'] + 7) + 'px');
			//$("#navBox").show();

			$("#sub" + navID + " li").css('width', maxWidth);
			$("#sub" + navID).css('width', maxWidth);
		}
	},function(){	
		navID = $(this).get(0).id.replace(/\D*/, '');	

		if($("#sub" + navID).size() > 0) {
			// Do nothing ;)
		} else {
			$("#main" + navID).removeClass('current');
		}
	});
	
	$(".subnav").hover(function(){
		// Do nothing ;)
	},function(){		
		$(this).hide();
		$("#navBox").hide();
		$("#main" + $(this).get(0).id.replace(/\D*/, '')).removeClass('current');
	});

	$(".subnav li").hover(function(){
		$(this).css('background', '#0033FF');
	},function(){		
		$(this).css('background', '#0260C4');
	});
	
	var havePortfolio = $("#portfolio").size();
	if(havePortfolio > 0) {
		var position = $("#portfolio .top").position();
		$(".client-info").css('top', position['top']);

		
		$("#portfolio").ready(function(){
			$(".category-id:eq(0)").show();

			var h4max = 0;
			var h4i = 0;
			var h4j = 0;
			$(".category-id:eq(0) h4").each(function (i) {
				var h4current = $(this).height();

				if(h4current > h4max) {
					h4max = h4current;
				}

				if(h4i>2 || ($(".category-id:eq(0) h4:eq("+(i+1)+")").size() < 1)) {
					for(j = h4j; j < (h4j + 3); j++) {
						$(".category-id:eq(0) h4:eq("+j+")").css('height', h4max);
					}

					h4max = 0;
					h4i = 0;
					h4j = h4j + 3;
				}

				h4i++;

			});
			
			$(".categories a:eq(0)").addClass("current");
		});

		$("#portfolio .categories a").click( function() {
			var catShowID = $(this).get(0).name;

			$(".category-id").hide();
			$("#"+catShowID).show();

			var h4max = 0;
			var h4i = 0;
			var h4j = 0;
			$("#"+catShowID+" h4").each(function (i) {
				var h4current = $(this).height();

				if(h4current > h4max) {
					h4max = h4current;
				}

				if(h4i>2 || ($("#"+catShowID+" h4:eq("+(i+1)+")").size() < 1)) {
					for(j = h4j; j < (h4j + 3); j++) {
						$("#"+catShowID+" h4:eq("+j+")").css('height', h4max);
					}

					h4max = 0;
					h4i = 0;
					h4j = h4j + 3;
				}

				h4i++;

			});

			$(".categories a").removeClass("current");
			$(this).addClass("current");

			return false;
		});

		$("#portfolio .clients .client a").click( function() {
			var clientShowID = $(this).get(0).name;

			$(".client-info").hide();
			$("."+clientShowID).show();

			return false;
		});
		
		$(".client-info").click( function() {
			return false;
		});

		$("body").click( function() {
			$(".client-info").hide();
		});

		$(".portfolio-close").click( function() {
			$(".client-info").hide();

			return false;
		});

		$(".client-info a").click( function() {
			var hrefToGo = $(this).get(0).href;

			if(!hrefToGo.match(/\/close/)) {

				window.open(hrefToGo);
			}

			return true;
		});

		document.onkeydown = function(e){ 	
			if (e == null) { // ie
				keycode = event.keyCode;
			} else { // mozilla
				keycode = e.which;
			}
			if(keycode == 27){ // close
				$(".client-info").hide();
			}	
		};

		$(".scroll").jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
		$(".client-info").hide();
		$(".client-info").removeClass("goLeft");
	}
	
	var imageRotate = $(".image-rotate").size();
	if(imageRotate > 0) {
		alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);
	}
});

nextFeature = {

	show : function(number) {
		var totalFeatureNum = $(".image-rotate img").size();

		$(".image-rotate img").fadeOut();
		$(".image-rotate img:eq("+(number - 1)+")").fadeIn();

		if(featureNum < totalFeatureNum)
			featureNum++;
		else
			featureNum = 1;

		alertTimerId = setTimeout("nextFeature.show(featureNum)", 7000);
	}
}