		/*
		Author: Kimball Le
	
		Uses: 
			  1. text shadow
			  2. open anchors in new tab
			  3. email && phone placement
			  4. div bkr img changer
			  5. expand portfolio divs
			  6. gallery switch
			  7. preload images
			  8. form validaiton
		
		*/
		
		$(function(){
			// 				Over port gall
			
			$('#wip_ul_port > li > img').hover(icon_over,icon_out);
			
		 	function icon_over(){
				$(this).parent().css({background:'url(img/wip_li_port2.png) top center'});
			}
			function icon_out(){
				$(this).parent().css({background:'url(img/wip_li_port.png) top center'});
			}
		
					
			//				1.Text Shadow
			$("p,h1,h2,h3,h4,h5,h6").css("textShadow", "2px 2px 2px black");
			
			//				2.OPEN ANCHORS IN NEW TAB
			
			$("#ie7Fix2 a, p a").attr("target","new");
		
			//				3.EMAIL
			
			var phone = " (530)-902-7658";
			var email = " kimball@kimballle.com";
			$(".email").text(email);
			$(".phone").text(phone);
			
			// 				4.DIV Background Image Changer
			$(".slice").click(
				function()	{
					var iconSrc = $(this).attr("src");
					$("#print_logo_slice > div").css("background","url("+iconSrc+") 0px 0px").animate({height:"500px"},700).css({opacity:opacOver,filter:alphaOver});
				
			});
			$(".pro").click(
				function()	{
					var iconSrc2 = $(this).attr("src");
					$("#print_pro_bottle > div").css("background","url("+iconSrc2+") 0px 0px").animate({height:"500px"},700).css({opacity:opacOver,filter:alphaOver});
			});
			
			
			// 				5.EXPAND PORTFOLIO DIVS
							
				//opacity will not validate, use js to change em!
				var opacOut = "0.4";
				var alphaOut = "alpha(opacity=40)";
				var opacOver = "1.0";
				var alphaOver = "alpha(opacity=100)";
				
				$("div[title]").css({opacity:opacOut,filter:alphaOut});					
				$("div[title]").click(expand);
				
				function expand (){
					if ($(this).hasClass("over")){
						$(this).removeClass("over").animate({height:"200px"},700);
					}
					else {
						var id = $(this).attr("title");
						$("#.grid_7 div").removeClass("over").animate({height:"200px"},700).addClass("opac");
						$(this).addClass("over");
						$(this).animate({height:id},900).css({opacity:opacOver,filter:alphaOver,border:'5px solid white'});
					}
				}
			//						6.GALLERY SWITCH
				
				$(".web_port_cont, .icon_port_cont").hide();
				$(".web_port_cont_img").click(slide1);
					function slide1(){
						$("#.grid_7 div").removeClass("over").animate({height:"200px"},700);
						$(".icon_port_cont").slideUp(1000);
						$(".print_port_cont").slideUp(1000);
						$(".web_port_cont").slideDown(2000);
					}
				
				$(".print_port_cont_img").click(slide2);
					function slide2(){
						$("#.grid_7 div").removeClass("over").animate({height:"200px"},700);
						$(".web_port_cont").slideUp(1000);
						$(".icon_port_cont").slideUp(1000);
						$(".print_port_cont").slideDown(2000);
					}
				$(".icon_port_cont_img").click(slide3);
					function slide3(){
						$("#.grid_7 div").removeClass("over").animate({height:"200px"},700);
						$(".web_port_cont").slideUp(1000);
						$(".print_port_cont").slideUp(1000);
						$(".icon_port_cont").slideDown(2000);
					}
				// 					7.PRELOAD IMAGES
				preLoadImages();
					function preLoadImages(){
						$("img").each(function(){
							//preload all images
							var imgs = $(this).attr("src");
							var imgs_preload = $("<img />").attr('src',imgs);
						});
					}
					
				// animate social networks --- fix when you know whats wrong with ie7 dom
				/*$("#copyrt li img,").hover(big,small);
					function big(){$(this).animate({top:'-4px'},100);}
					function small(){$(this).animate({top:'0px'},200);}*/
					

				//					8.FORM VALIDATION
				// form id's
				required = ["name", "email", "message"];
				// phone email containers
				email = $("#email");
				errornotice = $("#error");
				// error msg's
				emptyerror = "Please fill out this field.";
				emailerror = "Please enter a valid e-mail.";
		
				$("#request").submit(function(){	
					//Validate required fields
					for (i=0;i<required.length;i++) {
						var input = $('#'+required[i]);
						if ((input.val() == "") || (input.val() == emptyerror)) {
							input.addClass("needsfilled");
							input.val(emptyerror);
							errornotice.fadeIn(750);
						} else {
							input.removeClass("needsfilled");
						}
					}
					// Validate the e-mail.
					if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
						email.addClass("needsfilled");
						email.val(emailerror);
					}
					
					//if any inputs on the page have the class 'needsfilled' the form will not submit
					if ($(":input").hasClass("needsfilled")) {
						return false;
					} else {
						errornotice.hide();
						alert("message sent!");
						return true;
					}
				});
					// Clears any fields in the form when the user clicks on them
					$(":input").add($(":textarea")).focus(function(){		
					   if ($(this).hasClass("needsfilled") ) {
							$(this).val("");
							$(this).removeClass("needsfilled");
					   }
					});				
			});