$(document).ready(function() {
	//DROPDOWN MENUS
	$('li').mouseenter(function(){
		var ID = $(this).attr("id").replace("expand_", "");
		$("#expand_"+ID+" .menu_panel").show();
		$("#expand_"+ID).addClass("selected");
	});
	$('li').mouseleave(function(){
		var ID = $(this).attr("id").replace("expand_", "");
		$("#expand_"+ID+" .menu_panel").hide();
		$("#expand_"+ID).removeClass("selected");
	});
});

function accordian(tab) {
	//CONTENT BOX ACCORDIAN
	$('.content_box ul').hide();
	if (tab == 1) {
		$('.content_box ul:first').next().next().delay(300).slideDown(); //LINK FROM HOME -> GOTO 2ND TAB
	} else {
		$('.content_box ul:first').delay(300).slideDown(); //NORMAL
	}
	$('.content_box h4').click( function() {
		//KEEPS LAST H4 ROUNDED							 
		if ($(this).hasClass("last")) {
			$('.content_box h4:last').removeClass("round_bottom");
		} else {
			$('.content_box h4:last').addClass("round_bottom");
		}
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;g
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('.content_box ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			return false;
		 }
	});
}
//TITLE TOOLTIPS
$(function(){
	$(".title").tipTip();
});
//FRONT PAGE CAROUSEL
function scrollBox() {
	$(".auto .carousel").jCarouselLite({
		auto: 800,
		speed: 1000
	});
}
//TAB CONTROLS
function tabs(tab) {
	$('.tabs li:last-child').css('margin-right', '0');
	$('ul.tabs').tabs('div.panes > div', {
		initialIndex : tab
	});
}

$(function() {
	$('.feature_expand').click(function(){
		if ($(this).hasClass("expanded")) {
			$(this).next('.product_list').slideUp(500);
			$(this).next('.product_list').removeClass('expanded_list');
			$(this).removeClass('expanded');
		} else {
			$(this).addClass('expanded');
			$(this).next('.product_list').addClass('expanded_list');
			$(this).next('.product_list').slideDown(500);
		}
	});
});

//LIGHTBOX
$(function() {
	$('a.lightbox').fancybox({
		'titleShow' : true, 
		'overlayColor' : '#000',
		'overlayOpacity' : 0.6,
		'transitionIn' : 'elastic',
		'transitionOut' : 'fade'
	});

});

//SLIDING FORM LABELS
$(function(){
	$('form#sendEmail .slider label').each(function(){
		var labelColor = '#999';
		var restingPosition = '5px';
		// style the label with JS for progressive enhancement
		$(this).css({
			'color' : labelColor,
				'position' : 'absolute',
				'top' : '6px',
				'left' : restingPosition,
				'display' : 'inline',
						'z-index' : '99'
		});
		var inputval = $(this).next().val();
		var labelwidth = $(this).width();
		var labelmove = labelwidth + 5 +'px';
		// onload, check if a field is filled out, if so, move the label out of the way
		if(inputval !== ''){
			$(this).stop().animate({ 'left':'-'+labelmove }, 1);
		}    	
		// if the input is empty on focus move the label to the left
		$('input, textarea').focus(function(){
			var label = $(this).prev('label');
			var width = $(label).width();
			var adjust = width + 5 + 'px';
			var value = $(this).val();
			if(value == ''){
				label.stop().animate({ 'left':'-'+adjust }, 'fast');
			} else {
				label.css({ 'left':'-'+adjust });
			}
		}).blur(function(){
			var label = $(this).prev('label');
			var value = $(this).val();
			if(value == ''){
				label.stop().animate({ 'left':restingPosition }, 'fast');
			}	
	
		});
	});
});

function initialize() {
	var myLatlng = new google.maps.LatLng(37.811172,-122.267481);
	var myOptions = {
		zoom: 17,
		center: myLatlng,
		mapTypeControl: true,
		mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
		navigationControl: true,
		navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
		mapTypeId: google.maps.MapTypeId.ROADMAP  
	}
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var contentString = '<div id="map_info">'+
	'<h4>ReadyTech</h4>'+
	'2201 Broadway Suite 202<br>'+
	'Oakland, CA 94612<br>'+
	'+1.800.707.1009'+
	'</div>';
	
	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});
	
	var marker = new google.maps.Marker({
		position: myLatlng,
		map: map,
		title:"ReadyTech"
	});
	
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map,marker);
	});
}

