$(document).ready(function(){
						   
	reseth()
$("#2gigaward").mouseover(function(){
	$("#2gigaward").animate({
   		 height: '241px',
		 width:'230px',
		 top:'-65px',
		 left:'423px'
  }, 500, function() { });
	});	

$("#2gigaward").mouseout(function(){
	$("#2gigaward").animate({
   		 height: '121px',
		 width:'115px',
		 top:'-10px',
		 left:'445px'
  }, 500, function() { });
	});	

$(".equipment-title").click(function(){
		a=$(this).parent();
	if($(this).parent().height()<100){
		fadeout=a.children("div:eq(1)")
		fadein=a.children("div:eq(2)")
	}else{
		fadeout=a.children("div:eq(2)")
		fadein=a.children("div:eq(1)")		
	}
		change=a.children("div:eq(0)").children("img")
	equipmentOC(fadeout,fadein,change);
});	

$(".equipment-tn").dblclick(function(){
		a=$(this).parent();
		fadeout=a.children("div:eq(1)")
		fadein=a.children("div:eq(2)")
		change=a.children("div:eq(0)").children("img")
	equipmentOC(fadeout,fadein,change);
});	

$(".equipment-info").dblclick(function(){
		a=$(this).parent();
		fadeout=a.children("div:eq(2)")
		fadein=a.children("div:eq(1)")
		change=a.children("div:eq(0)").children("img")
	equipmentOC(fadeout,fadein,change);
});	

$(".closeEQ").mouseup(function(){
	a=$(this).parent().parent();
	  a.animate({
   		 height: '18px'
  }, 200, function() {
	a.children(".equipment-tn").fadeOut("500")
	a.children(".equipment-info").fadeOut("500")	
	c=a.children(".equipment-title").children("img")
	iSrc=change.attr("src").split("-")
	change.attr("src",iSrc[0]+"-"+iSrc[1]+"-"+"open.jpg") 
	a.children(".equipment-title").children(".closeEQ").css("display","none")
	a.children(".equipment-title").children(".closeEQa").css("display","block")
  });
});	

$("#hor").change(function() {
			$("input[name=i-am-the").val($(this).children("select option:selected").attr("value"))
									});

$("#quote-contact").change(function() {
  a=$(this).children("select option:selected").attr("value")
  if(a=="phone"){
	  $("#email").removeClass("red")
	  $("#phone1").addClass("red")

  }else{
	  $("#email").addClass("red")
	  $("#phone1").removeClass("red")	

	  }
});

$("#sendemailsend").click(function() {

for(i=0;i<$("#sendemail").find(".red").length-1;i++){
	j="eq("+i+")"
	
	a=$("#sendemail").find(".red:"+j).attr('id')
	b=$("input[name="+a+"]").val()
	if(b==""){
		a=a.replace(/-/gi," ")
		alert(a + " can not be empty")
		return false
		}
		
	if(a=="email"){
		AtPos = $("input[name="+a+"]").val().indexOf("@")
		StopPos = $("input[name="+a+"]").val().lastIndexOf(".")
				
		if (AtPos == -1 || StopPos == -1 || StopPos < AtPos || StopPos - AtPos == 1) {
			alert("Not a valid email address")
			return false
		}
	}
	
	if(a=="phone" ||a=="phone1" || a=="phone2" ){
		pNum = $("input[name="+a+"]").val()
			pNum=pNum.replace(/-/g,"")
			pNum=pNum.replace("(","")
			pNum=pNum.replace(")","")
			pNum=pNum.replace(" ","")
			
			if(pNum.length != 7 && pNum.length != 10 || isNaN(pNum)){
			alert("Invalid Phone Number")	
			return false
				}
	}
	if(a=="zip"){
		zip1 = $("input[name="+a+"]").val()			
			if(zip1.length != 5 || isNaN(zip1)){
			alert("Invalid Zip Code")	
			return false
				}
	}	
}

})

	$(".btn").click(function(){
		iName=$(this).attr("name")						 
		iValue=$(this).prev("select").children("select option:selected").attr("value");
									 
		if($(this).val()=="Send to Quote"){
			$(this).val("Change")
		}else{
			$(this).val("Change Again")	
			}
		if($(this).css("background-color")=="#0c3"){
			$(this).css("background-color","#c03")
		}else{
			$(this).css("background-color","#0c3")	
			}
		$("#" + iName).val(iValue)
	})

$("#headershrink").click(function(){
	headerShrink(300)
});					 

$("#headergrow").click(function(){
	headerGrow(300)				
});	


	//Remove outline from links
	$("a").click(function(){
		$(this).blur();
	});
	
	//When mouse rolls over
	$(".link").mouseover(function(){
		var len = $(this).children("ul").children("li").length 
		$(this).children(".submenu").animate({height:len*22+5},{queue:false, duration:len*150, easing: 'easeOutBounce'})
		$(this).children(".m_title").css("background-color","#4276b7");
		$(this).children("ul").css("border-width","3px");
		$(this).children("ul").css("border-top-width","0px");
		$(this).children("ul").css("border-left-width","0px");
	});
	
	//When mouse is removed
	$(".link").mouseout(function(){
		var len = $(this).children("ul").children("li").length *150
		$(this).children(".submenu").animate({height:'0px'},{queue:false, duration:len, easing: 'easeOutBounce'})
		$(this).children(".m_title").css("background-color","");
		$(this).children("ul").css("border-width","0px");
	});
	
	$("#header").children("a").children("img").mouseover(function(){
		$(this).fadeTo('fast', 0.5, function() {
		});
	});	
	
	$("#header").children("a").children("img").mouseout(function(){
		$(this).fadeTo('slow', 1, function() {
		});
	});	
		
//info click
$(".info").click(function(){

$(this).children(".infoclose")
		if($(this).children(".infoclose").css("display")=="none"){
		infoOC($(this).children(".infoclose"),$(this).children(".infoclose").siblings(".infoinside").height()+24,"#cef1f1",".infoopen",".infoclose",500)	
			}else{
		infoOC($(this).children(".infoopen"),"125px","#4276b7",".infoclose",".infoopen",500)
				}
		
});	

// Modular Functions

// Equipment Open Close
function equipmentOC(fadeout,fadein,change){
	fadeout.fadeOut("200")
	fadein.fadeIn("400")
	fadein.parent().height(fadein.height()+18)
	iSrc=change.attr("src").split("-")
	if(iSrc[2]=="open.jpg"){
		iSrc[2]="closea.jpg"
		}else{
			iSrc[2]="open.jpg";
		}
		change.attr("src",iSrc[0]+"-"+iSrc[1]+"-"+iSrc[2])
		fadein.siblings(".equipment-title").children(".closeEQ").css("display","block")
		fadein.siblings(".equipment-title").children(".closeEQa").css("display","none")
}


// open close  info boxes
function infoOC(t,h,c,none,block,speed){
	$(t).parent(".info").animate({
	height: h,
  }, speed, function() {
		$(this).css("border-color",c);
		$(this).children(none).css("display","none"); 
		$(this).children(block).css("display","block");
		reseth()
  });
}
  });	


function headerOC(move,none,block,mbody,speed){
	$("#header").animate({"top": move
	  }, speed, function() {
	  });
	
	$("#body").animate({"top": mbody
	  }, speed, function() {
					$(none).css("display","none");  
					$(block).css("display","block");	  
					reseth()
	  });	
}

function headerShrink(speed){
	headerOC("-20px","#headershrink","#headergrow","160px",speed)
}					 

function headerGrow(speed){
	headerOC("119px","#headergrow","#headershrink","299px",speed)					
}	

function reseth(){
		$(".hbar").height(0)
    	$(".hbar").height($("#body").height()-24)
		$("#footer").css("top",$("#body").height()+$("#body").position().top+10 );
}
