$(function(){
	
	/*** standard ***/
	$("#link-req-a-quote").hover(
	  function () {
		  $("#request-a-quote-middle").stop().animate({height:"35px"}, {easing: "easeInOutQuad"});
	  },
	  function () {
		  $("#request-a-quote-middle").stop().animate({height:"19px"}, {easing: "easeInOutQuad"});
	  }
	);
	 
	/***  backtohome ***/	
	$(".site-logo").hover(		  
		  function () {
			  $("#back-to-top").fadeIn();
		  },
		  function () {
			  $("#back-to-top").fadeOut();
		  }
		);
		
	
	
	/*** modal request a quote ***/
	$.nmObj({
		 callbacks: {
            beforeShowCont: function(nm) {
               scrolltotop.scrollup();
            }
        },
		modal: false,	
		showCloseButton: false, 
		sizes: {	// Size information
		    initW: 983,	// Initial width
		    initH: 1367,	// Initial height
		    w: 983,		// width
		    h: 1367,		// height
		    minW: 983,	// minimum width
		    minH: 1367,	// minimum height
		    wMargin: undefined,	// Horizontal margin
		    hMargin: undefined	// Vertical margin,
		    
		  },
		  size: function() {}
		  
	});			
	//$(".link-req-a-quote").nyroModal();		
	
	$('form').jqTransform();
	
	$("#RequestAQuote form button").hover(		  
	  function () {
		  $(this).addClass("active");
	  },
	  function () {
		  $(this).removeClass("active");
	  }
	);
	
	$("#RequestAQuote form button").click(function(e){		
		//skip default values
		$('.clearMeFocus').skipDefaultValues();
		$("#RequestAQuoteForm").submit();		 		
		e.preventDefault();		
	});
	
	$("#RequestAQuote form input").blur( function(){
			if($(this).attr("id") != "marketing_budget"  && $(this).attr("id") != "website_budget"){
				if($(this).hasClass("required")){
					$(this).css({"background": 'url(img/bg-input-required.png) no-repeat'});
				}else{
					$(this).css({"background": 'url(img/bg-input.png) no-repeat'});
				}
			   
			}else{
				if ($(this).val() != ""){ 									
						$(this).css({"background": 'url(img/bg-input-dollar.png) no-repeat'});										
				}else{
					$(this).css({'paddingLeft': '40px', "width": "355px"});
					$(this).css({"background": 'url(img/bg-input.png) no-repeat'});
				}		
			}
			$(this).css({"color": '#1A5D87'});		 	
		}
	);	
	
	$("#RequestAQuote form input").focus(
		function(){
		  if($(this).attr("id") != "marketing_budget"  && $(this).attr("id") != "website_budget"){	
			  if($(this).hasClass("required")){			  
				  $(this).css({"background": 'url(img/bg-input-required-active.png) no-repeat'});
			  }else{
				  $(this).css({"background": 'url(img/bg-input-active.png) no-repeat'});
			  }
		  }else{			  
			  $(this).css({"background": 'url(img/bg-input-active-dollar.png) no-repeat', 'paddingLeft': '40px', "width": "355px"});			  			 
		  }
		  $(this).css({"color": '#ffffff'});
		}
	);
	
	//only numbers	
	jQuery('#marketing_budget, #website_budget').keyup(function () { 
	    this.value = this.value.replace(/[^0-9\.]/g,'');
	});
	
	$.fn.clearDefault = function(){
		return this.each(function(){			
			var default_value = $(this).val();
			
			$(this).focus(function(){ 
				if ($(this).val() == default_value ) $(this).val("");				
			});			
			$(this).blur(function(){				
				if ($(this).val() == ""){ 					
					$(this).val(default_value);
				}			
			});			
		});
	};			 			
	$.fn.skipDefaultValues = function(){				
		return this.each(function(){
			if($(this).hasClass("norequired") == false){				
				if ($(this).val() == $(this).attr("alt")) $(this).val("");		
			}
		});
	};
	
	$("#RequestAQuoteForm").validate({
		rules: {
	        first_name:   "required",
	        last_name:   "required",    			
			phone: "required",					
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			first_name: "Please enter your First Name",
			last_name: "Please enter your Last Name",			
			phone: "Please enter your phone",
			email: "Please enter a valid email"
		},
		errorPlacement: function (error, element) {						
			$(element).parent().css({paddingBottom: "10px"});	
			$(element).addClass("error");
			error.insertAfter(element);						
		},
		success: function(label) {
		   label.parent().css({paddingBottom: "26px"});
		   label.remove();
		   //
	   },	  
	   submitHandler: function(form) {
			/*$.post("mailform.php", $("#RequestAQuoteForm").serialize(), function() {
				
			});*/		   
		   /*
		   $.jGrowl("Thank you for your submission, we will contact you shortly.", {
				sticky:			false,
				life: 			5000				
			});		  
		   $.nmTop().close();*/
		   
		   form.submit();
		}
	});
	
	$('.clearMeFocus').clearDefault();
	
	/*** slider ***/
	
    jQuery('#seven-slider').jcarousel({        
        scroll: 5,
        animation: 1500,
        easing: "easeOutCubic",
    	wrap: "circular"
    });  
    
    $("#seo-marketing").parent().hover(
    	function () {    	
    		$("#submenu-wrapper").stop().animate({ height: "60px" }, 'slow');    		
   		},
   		function () {   
   			$("#submenu-wrapper").stop().animate({ height: "0px" }, 'slow');			
   		}
    ); 
    
    
    /*** main nav rollovers ***/
    
    $("#studio").hover(
    	function () {  
    		//alert(sSection);
    		$("#electric-line-studio").fadeIn();
   		},
   		function () {   
   			//alert(sSection);
   			if(sSection != "studio"){ 
   				$("#electric-line-studio").fadeOut();
   			}
   		}
    );     
    $("#examples").hover(
    	function () {    	
    		$("#electric-line-examples").fadeIn();
   		},
   		function () {   
   			if(sSection != "examples"){ 
   				$("#electric-line-examples").fadeOut();
   			}
   		}
    );     
    $("#design-development").hover(
    	function () {    	
    		$("#electric-line-dad").fadeIn();
   		},
   		function () {
   			if(sSection != "dad"){ 
   				$("#electric-line-dad").fadeOut();
   			}
   		}
    );     
    $("#seo-marketing").hover(
    	function () {    	
    		$("#electric-line-seo").fadeIn();
   		},
   		function () { 
   			if(sSection != "seo"){ 
   				$("#electric-line-seo").fadeOut();
   			}
   		}
    );     
    $("#contact-us").hover(
    	function () {    	
    		$("#electric-line-contact").fadeIn();
   		},
   		function () {   
   			if(sSection != "contact"){
   				$("#electric-line-contact").fadeOut();
   			}
   		}
    ); 
       
 
});
